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/DatabaseCon.h>
32 #include <ripple/core/JobQueue.h>
33 #include <ripple/core/TimeKeeper.h>
48 : ledgerID_{ledger->info().hash}, ledgerSeq_{ledger->
seq()}, j_{j}
54 ancestors_ = hashIndex->getFieldV256(
sfHashes).value();
57 JLOG(j_.
warn()) <<
"Ledger " << ledgerSeq_ <<
":" << ledgerID_
58 <<
" missing recent ancestor hashes";
81 if (s >= minSeq() && s <= seq())
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_;
107 while (curr != Seq{0} && a[curr] != b[curr] && curr >= lower)
112 return (curr < lower) ? Seq{1} : (curr + Seq{1});
126 boost::optional<RCLValidatedLedger>
133 <<
"Need validated ledger for preferred ledger analysis " << hash;
145 assert(!ledger->open() && ledger->isImmutable());
146 assert(ledger->info().hash == hash);
178 s << (val->
isTrusted() ?
"trusted" :
"untrusted") <<
" "
179 << (val->
isFull() ?
"full" :
"partial") <<
" validation: " << hash
180 <<
" from " <<
id <<
" via " << source <<
": " << msg <<
"\n"
200 "conflicting validations issued for " +
to_string(seq) +
201 " (likely from a Byzantine validator)");
207 "multiple validations issued for " +
to_string(seq) +
208 " (multiple validators operating with the same key?)");
216 JLOG(j.
debug()) <<
"Val for " << hash <<
" from "
218 <<
" not added UNlisted";
boost::optional< PublicKey > getListedKey(PublicKey const &identity) const
Returns listed master public if public key is included on any lists.
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_
boost::optional< RCLValidatedLedger > acquire(LedgerHash const &id)
Attempt to acquire the ledger with given id from the network.
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
ValStatus
Status of newly received validation.
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.
beast::Journal journal() const
ID id() const
The ID (hash) of the ledger.
std::string to_string(ListDisposition disposition)
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.
virtual InboundLedgers & getInboundLedgers()=0
Seq seq() const
The sequence (index) of the ledger.
boost::optional< PublicKey > getTrustedKey(PublicKey const &identity) const
Returns master public key if public key is trusted.
RCLValidatedLedger(MakeGenesis)
ValStatus add(NodeID const &nodeID, Validation const &val)
Add a new validation.
virtual LedgerMaster & getLedgerMaster()=0
virtual JobQueue & getJobQueue()=0
Slice slice() const noexcept
Provide a light-weight way to check active() before string formatting.
ID operator[](Seq const &s) const
Lookup the ID of the ancestor ledger.
@ multiple
Multiple validations for the same ledger from multiple validators.
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 for different ledgers by a single validator.
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.
PublicKey getSignerPublic() const
std::uint32_t getFieldU32(SField const &field) const
const SF_UINT32 sfLastLedgerSequence
Adaptor const & adaptor() const
Return the adaptor instance.
void handleNewValidation(Application &app, std::shared_ptr< STValidation > const &val, std::string const &source)
Handle a new validation.