20 #include <ripple/app/consensus/RCLValidations.h>
21 #include <ripple/app/ledger/InboundLedger.h>
22 #include <ripple/app/ledger/InboundLedgers.h>
23 #include <ripple/app/ledger/LedgerMaster.h>
24 #include <ripple/app/main/Application.h>
25 #include <ripple/app/misc/NetworkOPs.h>
26 #include <ripple/app/misc/ValidatorList.h>
27 #include <ripple/basics/Log.h>
28 #include <ripple/basics/StringUtilities.h>
29 #include <ripple/basics/chrono.h>
30 #include <ripple/consensus/LedgerTiming.h>
31 #include <ripple/core/JobQueue.h>
32 #include <ripple/core/TimeKeeper.h>
47 : ledgerID_{ledger->info().hash}, ledgerSeq_{ledger->
seq()}, j_{j}
53 ancestors_ = hashIndex->getFieldV256(
sfHashes).value();
56 JLOG(j_.
warn()) <<
"Ledger " << ledgerSeq_ <<
":" << ledgerID_
57 <<
" missing recent ancestor hashes";
80 if (s >= minSeq() && s <= seq())
84 Seq const diff = seq() - s;
85 return ancestors_[ancestors_.size() - diff];
88 JLOG(j_.
warn()) <<
"Unable to determine hash of ancestor seq=" << s
89 <<
" from ledger hash=" << ledgerID_
90 <<
" seq=" << ledgerSeq_ <<
" (available: " << minSeq()
91 <<
"-" << seq() <<
")";
107 while (curr != Seq{0} && a[curr] != b[curr] && curr >= lower)
112 return (curr < lower) ? Seq{1} : (curr + Seq{1});
133 <<
"Need validated ledger for preferred ledger analysis " << hash;
138 jtADVANCE,
"getConsensusLedger", [pApp, hash]() {
145 assert(!ledger->open() && ledger->isImmutable());
146 assert(ledger->info().hash == hash);
175 validations.
add(
calcNodeID(masterKey.value_or(signingKey)), val);
193 ? validations.adaptor().journal().error()
194 : validations.adaptor().journal().info();
197 auto const id = [&masterKey, &signingKey]() {
200 if (masterKey && masterKey != signingKey)
207 ls <<
"Byzantine Behavior Detector: "
208 << (val->
isTrusted() ?
"trusted " :
"untrusted ") <<
id
209 <<
": Conflicting validation for " << seq <<
"!\n["
213 ls <<
"Byzantine Behavior Detector: "
214 << (val->
isTrusted() ?
"trusted " :
"untrusted ") <<
id
215 <<
": Multiple validations for " << seq <<
"/" << hash <<
"!\n["
RCLValidatedLedger::Seq mismatch(RCLValidatedLedger const &a, RCLValidatedLedger const &b)
NodeID calcNodeID(PublicKey const &pk)
Calculate the 160-bit node ID from a node public key.
const SF_UINT32 sfLedgerSequence
uint256 getLedgerHash() const
std::vector< uint256 > ancestors_
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Keylet const & skip() noexcept
The index of the "short" skip list.
Serializer getSerializer() const
std::shared_ptr< Ledger const > getLedgerByHash(uint256 const &hash)
NetClock::time_point now() const
Current time used to determine if validations are stale.
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
ID id() const
The ID (hash) of the ledger.
virtual TimeKeeper & timeKeeper()=0
RCLValidationsAdaptor(Application &app, beast::Journal j)
static Sink & getNullSink()
Returns a Sink which does nothing.
Wraps a ledger instance for use in generic Validations LedgerTrie.
bool isTrusted() const noexcept
virtual InboundLedgers & getInboundLedgers()=0
std::optional< PublicKey > getTrustedKey(PublicKey const &identity) const
Returns master public key if public key is trusted.
Seq seq() const
The sequence (index) of the ledger.
RCLValidatedLedger(MakeGenesis)
PublicKey const & getSignerPublic() const noexcept
ValStatus add(NodeID const &nodeID, Validation const &val)
Add a new validation.
virtual LedgerMaster & getLedgerMaster()=0
std::optional< PublicKey > getListedKey(PublicKey const &identity) const
Returns listed master public if public key is included on any lists.
std::optional< RCLValidatedLedger > acquire(LedgerHash const &id)
Attempt to acquire the ledger with given id from the network.
virtual JobQueue & getJobQueue()=0
Slice slice() const noexcept
ID operator[](Seq const &s) const
Lookup the ID of the ancestor ledger.
@ multiple
Multiple validations by a validator for the same ledger.
virtual time_point closeTime() const =0
Returns the close time, in network time.
@ current
This was a new validation and was added.
A generic endpoint for log messages.
virtual RCLValidations & getValidations()=0
void checkAccept(std::shared_ptr< Ledger const > const &ledger)
virtual ValidatorList & validators()=0
const SF_VECTOR256 sfHashes
@ conflicting
Multiple validations by a validator for different ledgers.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
LedgerIndex seq() const
Returns the sequence number of the base ledger.
std::uint32_t getFieldU32(SField const &field) const
const SF_UINT32 sfLastLedgerSequence
void handleNewValidation(Application &app, std::shared_ptr< STValidation > const &val, std::string const &source)
Handle a new validation.