20#include <xrpld/app/consensus/RCLValidations.h> 
   21#include <xrpld/app/ledger/InboundLedger.h> 
   22#include <xrpld/app/ledger/InboundLedgers.h> 
   23#include <xrpld/app/ledger/LedgerMaster.h> 
   24#include <xrpld/app/main/Application.h> 
   25#include <xrpld/app/misc/ValidatorList.h> 
   26#include <xrpld/core/JobQueue.h> 
   27#include <xrpld/core/TimeKeeper.h> 
   28#include <xrpld/perflog/PerfLog.h> 
   30#include <xrpl/basics/Log.h> 
   31#include <xrpl/basics/chrono.h> 
   38    : ledgerID_{0}, ledgerSeq_{0}, j_{
beast::Journal::getNullSink()}
 
 
   45    : ledgerID_{ledger->info().hash}, ledgerSeq_{ledger->seq()}, j_{j}
 
   51            hashIndex->getFieldU32(sfLastLedgerSequence) == (
seq() - 1),
 
   52            "ripple::RCLValidatedLedger::RCLValidatedLedger(Ledger) : valid " 
   53            "last ledger sequence");
 
   54        ancestors_ = hashIndex->getFieldV256(sfHashes).value();
 
   58                        << 
" missing recent ancestor hashes";
 
 
   81    if (s >= minSeq() && s <= seq())
 
   85        Seq const diff = seq() - s;
 
   86        return ancestors_[ancestors_.size() - diff];
 
   89    JLOG(j_.
warn()) << 
"Unable to determine hash of ancestor seq=" << s
 
   90                    << 
" from ledger hash=" << ledgerID_
 
   91                    << 
" seq=" << ledgerSeq_ << 
" (available: " << minSeq()
 
   92                    << 
"-" << seq() << 
")";
 
 
  108    while (curr != 
Seq{0} && a[curr] != b[curr] && curr >= lower)
 
  113    return (curr < lower) ? 
Seq{1} : (curr + 
Seq{1});
 
 
  130    using namespace std::chrono_literals;
 
  140            << 
"Need validated ledger for preferred ledger analysis " << hash;
 
  145            jtADVANCE, 
"getConsensusLedger2", [pApp, hash, 
this]() {
 
  147                    << 
"JOB advanceLedger getConsensusLedger2 started";
 
  155        !ledger->open() && ledger->isImmutable(),
 
  156        "ripple::RCLValidationsAdaptor::acquire : valid ledger state");
 
  158        ledger->info().hash == hash,
 
  159        "ripple::RCLValidationsAdaptor::acquire : ledger hash match");
 
 
  172    auto const& signingKey = val->getSignerPublic();
 
  173    auto const& hash = val->getLedgerHash();
 
  174    auto const seq = val->getFieldU32(sfLedgerSequence);
 
  179    if (!val->isTrusted() && masterKey)
 
  190        validations.
add(
calcNodeID(masterKey.value_or(signingKey)), val);
 
  194        if (val->isTrusted())
 
  199                    j, 
"ripple::handleNewValidation : journal is available");
 
  202                    JLOG(j->trace()) << 
"Bypassing checkAccept for validation " 
  203                                     << val->getLedgerHash();
 
  222    if (
auto const ls = val->isTrusted()
 
  223            ? validations.adaptor().journal().error()
 
  224            : validations.adaptor().journal().info();
 
  227        auto const id = [&masterKey, &signingKey]() {
 
  230            if (masterKey && masterKey != signingKey)
 
  237            ls << 
"Byzantine Behavior Detector: " 
  238               << (val->isTrusted() ? 
"trusted " : 
"untrusted ") << 
id 
  239               << 
": Conflicting validation for " << seq << 
"!\n[" 
  240               << val->getSerializer().slice() << 
"]";
 
  243            ls << 
"Byzantine Behavior Detector: " 
  244               << (val->isTrusted() ? 
"trusted " : 
"untrusted ") << 
id 
  245               << 
": Multiple validations for " << seq << 
"/" << hash << 
"!\n[" 
  246               << val->getSerializer().slice() << 
"]";
 
 
A generic endpoint for log messages.
 
virtual RCLValidations & getValidations()=0
 
virtual TimeKeeper & timeKeeper()=0
 
virtual JobQueue & getJobQueue()=0
 
virtual InboundLedgers & getInboundLedgers()=0
 
virtual ValidatorList & validators()=0
 
virtual LedgerMaster & getLedgerMaster()=0
 
virtual void acquireAsync(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason reason)=0
 
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
 
void checkAccept(std::shared_ptr< Ledger const > const &ledger)
 
Wraps a ledger instance for use in generic Validations LedgerTrie.
 
ID id() const
The ID (hash) of the ledger.
 
ID operator[](Seq const &s) const
Lookup the ID of the ancestor ledger.
 
RCLValidatedLedger(MakeGenesis)
 
std::vector< uint256 > ancestors_
 
Seq seq() const
The sequence (index) of the ledger.
 
std::optional< RCLValidatedLedger > acquire(LedgerHash const &id)
Attempt to acquire the ledger with given id from the network.
 
RCLValidationsAdaptor(Application &app, beast::Journal j)
 
NetClock::time_point now() const
Current time used to determine if validations are stale.
 
time_point closeTime() const
Returns the predicted close time, in network time.
 
ValStatus add(NodeID const &nodeID, Validation const &val)
Add a new validation.
 
std::optional< PublicKey > getTrustedKey(PublicKey const &identity) const
Returns master public key if public key is trusted.
 
std::optional< PublicKey > getListedKey(PublicKey const &identity) const
Returns listed master public if public key is included on any lists.
 
Keylet const & skip() noexcept
The index of the "short" skip list.
 
auto measureDurationAndLog(Func &&func, std::string const &actionDescription, std::chrono::duration< Rep, Period > maxDelay, beast::Journal const &journal)
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
 
void handleNewValidation(Application &app, std::shared_ptr< STValidation > const &val, std::string const &source, BypassAccept const bypassAccept, std::optional< beast::Journal > j)
Handle a new validation.
 
RCLValidatedLedger::Seq mismatch(RCLValidatedLedger const &a, RCLValidatedLedger const &b)
 
@ current
This was a new validation and was added.
 
@ conflicting
Multiple validations by a validator for different ledgers.
 
@ multiple
Multiple validations by a validator for the same ledger.
 
NodeID calcNodeID(PublicKey const &)
Calculate the 160-bit node ID from a node public key.