1#include <xrpld/app/consensus/RCLConsensus.h>
3#include <xrpld/app/consensus/RCLCensorshipDetector.h>
4#include <xrpld/app/consensus/RCLCxLedger.h>
5#include <xrpld/app/consensus/RCLCxPeerPos.h>
6#include <xrpld/app/consensus/RCLCxTx.h>
7#include <xrpld/app/consensus/RCLValidations.h>
8#include <xrpld/app/ledger/BuildLedger.h>
9#include <xrpld/app/ledger/InboundLedger.h>
10#include <xrpld/app/ledger/InboundLedgers.h>
11#include <xrpld/app/ledger/InboundTransactions.h>
12#include <xrpld/app/ledger/LedgerMaster.h>
13#include <xrpld/app/ledger/LocalTxs.h>
14#include <xrpld/app/ledger/OpenLedger.h>
15#include <xrpld/app/misc/FeeVote.h>
16#include <xrpld/app/misc/NegativeUNLVote.h>
17#include <xrpld/app/misc/TxQ.h>
18#include <xrpld/app/misc/ValidatorKeys.h>
19#include <xrpld/app/misc/ValidatorList.h>
20#include <xrpld/consensus/Consensus.h>
21#include <xrpld/consensus/ConsensusTypes.h>
22#include <xrpld/overlay/Overlay.h>
23#include <xrpld/overlay/predicates.h>
25#include <xrpl/basics/Log.h>
26#include <xrpl/basics/Slice.h>
27#include <xrpl/basics/UnorderedContainers.h>
28#include <xrpl/basics/base_uint.h>
29#include <xrpl/basics/chrono.h>
30#include <xrpl/basics/contract.h>
31#include <xrpl/basics/random.h>
32#include <xrpl/beast/utility/Journal.h>
33#include <xrpl/beast/utility/Zero.h>
34#include <xrpl/beast/utility/instrumentation.h>
35#include <xrpl/core/HashRouter.h>
36#include <xrpl/core/Job.h>
37#include <xrpl/crypto/csprng.h>
38#include <xrpl/json/json_value.h>
39#include <xrpl/json/json_writer.h>
40#include <xrpl/ledger/AmendmentTable.h>
41#include <xrpl/ledger/ApplyView.h>
42#include <xrpl/ledger/Ledger.h>
43#include <xrpl/ledger/LedgerTiming.h>
44#include <xrpl/ledger/OpenView.h>
45#include <xrpl/ledger/ReadView.h>
46#include <xrpl/ledger/View.h>
47#include <xrpl/protocol/BuildInfo.h>
48#include <xrpl/protocol/Protocol.h>
49#include <xrpl/protocol/PublicKey.h>
50#include <xrpl/protocol/RippleLedgerHash.h>
51#include <xrpl/protocol/Rules.h>
52#include <xrpl/protocol/SField.h>
53#include <xrpl/protocol/STTx.h>
54#include <xrpl/protocol/STValidation.h>
55#include <xrpl/protocol/SecretKey.h>
56#include <xrpl/protocol/Serializer.h>
57#include <xrpl/protocol/UintTypes.h>
58#include <xrpl/protocol/digest.h>
59#include <xrpl/protocol/tokens.h>
60#include <xrpl/server/LoadFeeTrack.h>
61#include <xrpl/server/NetworkOPs.h>
62#include <xrpl/shamap/SHAMapItem.h>
63#include <xrpl/shamap/SHAMapMissingNode.h>
64#include <xrpl/shamap/SHAMapTreeNode.h>
66#include <boost/smart_ptr/intrusive_ptr.hpp>
129 XRPL_ASSERT(
valCookie_,
"xrpl::RCLConsensus::Adaptor::Adaptor : nonzero cookie");
135 JLOG(
j_.info()) <<
"Validator identity: "
140 JLOG(
j_.debug()) <<
"Validator ephemeral signing key: "
157 JLOG(
j_.warn()) <<
"Need consensus ledger " << hash;
162 app_.getJobQueue().addJob(
JtAdvance,
"GetConsL1", [
id = hash, &app =
app_,
this]() {
163 JLOG(
j_.debug()) <<
"JOB advanceLedger getConsensusLedger1 started";
171 !built->open() && built->isImmutable(),
172 "xrpl::RCLConsensus::Adaptor::acquireLedger : valid ledger state");
174 built->header().hash == hash,
175 "xrpl::RCLConsensus::Adaptor::acquireLedger : ledger hash match");
186 protocol::TMProposeSet prop;
188 auto const& proposal = peerPos.
proposal();
190 prop.set_proposeseq(proposal.proposeSeq());
191 prop.set_closetime(proposal.closeTime().time_since_epoch().count());
193 prop.set_currenttxhash(proposal.position().begin(), proposal.position().size());
194 prop.set_previousledger(proposal.prevLedger().begin(), proposal.prevLedger().size());
197 prop.set_nodepubkey(pk.data(), pk.size());
200 prop.set_signature(sig.data(), sig.size());
209 if (
app_.getHashRouter().shouldRelay(tx.
id()))
211 JLOG(
j_.debug()) <<
"Relaying disputed tx " << tx.
id();
212 auto const slice = tx.
tx->slice();
213 protocol::TMTransaction msg;
214 msg.set_rawtransaction(slice.data(), slice.size());
215 msg.set_status(protocol::tsNEW);
216 msg.set_receivetimestamp(
app_.getTimeKeeper().now().time_since_epoch().count());
218 app_.getOverlay().relay(tx.
id(), msg, kSkip);
222 JLOG(
j_.debug()) <<
"Not relaying disputed tx " << tx.
id();
228 JLOG(
j_.trace()) << (proposal.
isBowOut() ?
"We bow out: " :
"We propose: ")
232 protocol::TMProposeSet prop;
241 JLOG(
j_.warn()) <<
"RCLConsensus::Adaptor::propose: ValidatorKeys "
248 prop.set_nodepubkey(keys.publicKey.data(), keys.publicKey.size());
252 prop.set_signature(sig.data(), sig.size());
262 app_.getHashRouter().addSuppression(suppression);
264 app_.getOverlay().broadcast(prop);
286 return !
app_.getOpenLedger().empty();
292 return app_.getValidations().numTrustedForLedger(h);
313 if (netLgr != ledgerID)
316 app_.getOPs().consensusViewChange();
333 notify(protocol::neCLOSING_LEDGER, ledger, !wrongLCL);
335 auto const& prevLedger = ledger.ledger;
339 ledgerMaster_.setBuildingLedger(prevLedger->header().seq + 1);
341 auto initialLedger =
app_.getOpenLedger().current();
344 initialSet->setUnbacked();
347 for (
auto const& tx : initialLedger->txs)
349 JLOG(
j_.trace()) <<
"Adding open ledger TX " << tx.first->getTransactionID();
358 if (
app_.config().standalone() || (proposing && !wrongLCL))
360 if (prevLedger->isFlagLedger())
365 app_.getValidators().negativeUNLFilter(
app_.getValidations().getTrustedForLedger(
366 prevLedger->header().parentHash, prevLedger->seq() - 1));
367 if (validations.size() >=
app_.getValidators().quorum())
369 feeVote_->doVoting(prevLedger, validations, initialSet);
370 app_.getAmendmentTable().doVoting(prevLedger, validations, initialSet,
j_);
373 else if (prevLedger->isVotingLedger())
380 app_.getValidators().getTrustedMasterKeys(),
381 app_.getValidations(),
387 initialSet = initialSet->snapShot(
false);
391 LedgerIndex const seq = prevLedger->header().seq + 1;
394 initialSet->visitLeaves(
395 [&proposed, seq](boost::intrusive_ptr<SHAMapItem const>
const& item) {
403 auto const setHash = initialSet->getHash().asUInt256();
406 std::move(initialSet),
408 initialLedger->header().parentHash,
412 app_.getTimeKeeper().closeTime(),
425 doAccept(result, prevLedger, closeResolution, rawCloseTimes,
mode, std::move(consensusJson));
438 app_.getJobQueue().addJob(
442 [=,
this, cj = std::move(consensusJson)]()
mutable {
449 this->
doAccept(result, prevLedger, closeResolution, rawCloseTimes,
mode, std::move(cj));
450 this->
app_.getOPs().endConsensus(clog.
ss());
466 bool closeTimeCorrect =
false;
477 using namespace std::chrono_literals;
478 consensusCloseTime = prevLedger.
closeTime() + 1s;
479 closeTimeCorrect =
false;
486 closeTimeCorrect =
true;
489 JLOG(
j_.debug()) <<
"Report: Prop=" << (proposing ?
"yes" :
"no")
491 <<
" corLCL=" << (haveCorrectLCL ?
"yes" :
"no")
492 <<
" fail=" << (consensusFail ?
"yes" :
"no");
493 JLOG(
j_.debug()) <<
"Report: Prev = " << prevLedger.
id() <<
":" << prevLedger.
seq();
504 JLOG(
j_.debug()) <<
"Building canonical tx set: " << retriableTxs.
key();
506 for (
auto const& item : *result.
txns.map)
511 JLOG(
j_.debug()) <<
" Tx: " << item.key();
515 failed.
insert(item.key());
516 JLOG(
j_.warn()) <<
" Tx: " << item.key() <<
" throws: " << ex.
what();
529 auto const newLCLHash = built.id();
530 JLOG(
j_.debug()) <<
"Built ledger #" << built.seq() <<
": " << newLCLHash;
533 notify(protocol::neACCEPTED_LEDGER, built, haveCorrectLCL);
542 result.
txns.map->visitLeaves(
543 [&accepted](boost::intrusive_ptr<SHAMapItem const>
const& item) {
548 for (
auto const& r : retriableTxs)
549 failed.
insert(r.first.getTXID());
553 [curr = built.seq(), j =
app_.getJournal(
"CensorshipDetector"), &failed](
555 if (failed.contains(id))
558 auto const wait = curr - seq;
560 if (wait && (wait % kCensorshipWarnInternal == 0))
562 std::ostringstream ss;
563 ss <<
"Potential Censorship: Eligible tx " << id
564 <<
", which we are tracking since ledger " << seq
565 <<
" has not been included as of ledger " << curr <<
".";
567 JLOG(j.warn()) << ss.str();
575 validating_ = ledgerMaster_.isCompatible(*built.ledger,
j_.warn(),
"Not validating");
577 if (validating_ && !consensusFail && app_.getValidations().canValidateSeq(built.seq()))
579 validate(built, result.txns, proposing);
580 JLOG(
j_.info()) <<
"CNF Val " << newLCLHash;
584 JLOG(
j_.
info()) <<
"CNF buildLCL " << newLCLHash;
588 ledgerMaster_.consensusBuilt(built.ledger, result.txns.id(), std::move(consensusJson));
603 bool anyDisputes =
false;
604 for (
auto const& [_, dispute] : result.disputes)
607 if (!dispute.getOurVote())
612 JLOG(
j_.
debug()) <<
"Test applying disputed transaction that did"
613 <<
" not get in " << dispute.tx().id();
615 SerialIter sit(dispute.tx().tx->slice());
623 retriableTxs.insert(txn);
627 catch (std::exception
const& ex)
629 JLOG(
j_.debug()) <<
"Failed to apply transaction we voted "
637 std::unique_lock
lock{app_.getMasterMutex(), std::defer_lock};
638 std::unique_lock sl{ledgerMaster_.peekMutex(), std::defer_lock};
641 auto const lastVal = ledgerMaster_.getValidatedLedger();
642 std::optional<Rules> rules;
649 rules.
emplace(app_.config().features);
651 app_.getOpenLedger().accept(
655 localTxs_.getTxSet(),
660 [&](OpenView& view, beast::Journal j) {
662 return app_.getTxQ().accept(app_, view);
667 app_.getOPs().reportFeeChange();
672 ledgerMaster_.switchLCL(built.ledger);
676 ledgerMaster_.getClosedLedger()->header().hash == built.id(),
677 "xrpl::RCLConsensus::Adaptor::doAccept : ledger hash match");
679 app_.getOpenLedger().current()->header().parentHash == built.id(),
680 "xrpl::RCLConsensus::Adaptor::doAccept : parent hash match");
689 auto closeTime = rawCloseTimes.self;
691 JLOG(
j_.info()) <<
"We closed at " << closeTime.time_since_epoch().count();
692 using usec64_t = std::chrono::duration<std::uint64_t>;
696 for (
auto const& [t, v] : rawCloseTimes.peers)
704 closeTotal += usec64_t(closeCount / 2);
705 closeTotal /= closeCount;
708 using duration = std::chrono::duration<std::int32_t>;
709 using time_point = std::chrono::time_point<NetClock, duration>;
711 JLOG(
j_.info()) <<
"Our close offset is estimated at " << offset.count() <<
" ("
712 << closeCount <<
")";
714 app_.getTimeKeeper().adjustCloseTime(offset);
720 protocol::NodeEvent ne,
724 protocol::TMStatusChange s;
728 s.set_newevent(protocol::neLOST_SYNC);
735 s.set_ledgerseq(ledger.
seq());
736 s.set_networktime(
app_.getTimeKeeper().now().time_since_epoch().count());
737 s.set_ledgerhashprevious(
752 s.set_firstseq(uMin);
755 JLOG(
j_.trace()) <<
"send status change to peer";
763 bool closeTimeCorrect,
772 replayData->parent()->header().hash == previousLedger.
id(),
773 "xrpl::RCLConsensus::Adaptor::buildLCL : parent hash match");
788 using namespace std::chrono_literals;
789 app_.getTxQ().processClosedLedger(
app_, *built, roundTime > 5s);
794 JLOG(
j_.debug()) <<
"Consensus built ledger we already had";
796 else if (
app_.getInboundLedgers().find(built->header().hash))
798 JLOG(
j_.debug()) <<
"Consensus built ledger we were acquiring";
802 JLOG(
j_.debug()) <<
"Consensus built new ledger";
810 using namespace std::chrono_literals;
812 auto validationTime =
app_.getTimeKeeper().closeTime();
819 JLOG(
j_.warn()) <<
"RCLConsensus::Adaptor::validate: ValidatorKeys "
832 v.setFieldH256(sfLedgerHash, ledger.id());
833 v.setFieldH256(sfConsensusHash, txns.id());
835 v.setFieldU32(sfLedgerSequence, ledger.seq());
838 v.setFlag(kVfFullValidation);
843 if (auto const vl = ledgerMaster_.getValidatedLedger())
844 v.setFieldH256(sfValidatedHash, vl->header().hash);
846 v.setFieldU64(sfCookie, valCookie_);
849 if (ledger.ledger->isVotingLedger())
850 v.setFieldU64(sfServerVersion, BuildInfo::getEncodedVersion());
854 auto const& ft = app_.getFeeTrack();
855 auto const fee = std::max(ft.getLocalFee(), ft.getClusterFee());
856 if (fee > ft.getLoadBase())
857 v.setFieldU32(sfLoadFee, fee);
862 if (ledger.
ledger->isVotingLedger())
865 feeVote_->doValidation(ledger.ledger->fees(), ledger.ledger->rules(), v);
870 auto const amendments =
871 app_.getAmendmentTable().doValidation(getEnabledAmendments(*ledger.ledger));
873 if (!amendments.empty())
874 v.setFieldV256(sfAmendments, STVector256(sfAmendments, amendments));
878 auto const serialized = v->getSerialized();
886 protocol::TMValidation val;
887 val.set_validation(serialized.data(), serialized.size());
888 app_.getOverlay().broadcast(val);
891 app_.getOPs().pubValidation(v);
897 JLOG(
j_.info()) <<
"Consensus mode change before=" <<
to_string(before)
917 ret[
"validating"] =
adaptor_.validating();
935 ss <<
"During consensus timerEntry: " << mn.
what();
936 JLOG(
j_.error()) << ss.
str();
937 CLOG(clog) << ss.
str();
953 JLOG(
j_.error()) <<
"During consensus gotTxSet: " << mn.
what();
973 return consensus_.peerProposal(now, newProposal);
982 !
app_.getOPs().isBlocked();
988 auto const when =
app_.getValidators().expires();
990 if (!when || *when <
app_.getTimeKeeper().now())
992 JLOG(
j_.error()) <<
"Voluntarily bowing out of consensus process "
993 "because of an expired validator list.";
1002 JLOG(
j_.info()) <<
"Entering consensus process, validating, synced="
1003 << (synced ?
"yes" :
"no");
1008 JLOG(
j_.info()) <<
"Entering consensus process, watching, synced="
1009 << (synced ?
"yes" :
"no");
1016 if (!nowTrusted.
empty())
1017 nUnlVote_.newValidators(prevLgr.
seq() + 1, nowTrusted);
1038 return app_.getValidators().getQuorumKeys();
1046 return app_.getValidations().laggards(seq, trustedKeys);
1058 if ((positions == 0u) &&
app_.getOPs().isFull())
1073 now, prevLgrId, prevLgr, nowUntrusted,
adaptor_.preStartRound(prevLgr, nowTrusted), clog);
1079 if (!validating && !j.
info())
1095 outSs <<
header_ <<
"duration " << (duration.count() / 1000) <<
'.' <<
std::setw(3)
1096 <<
std::setfill(
'0') << (duration.count() % 1000) <<
"s. " <<
ss_->str();
A generic endpoint for log messages.
Decorator for streaming out compact json.
static constexpr std::size_t size()
Holds transactions which were deferred to the next pass of consensus.
void insert(std::shared_ptr< STTx const > txn)
uint256 const & key() const
uint256 const & signingHash() const
The digest for this proposal, used for signing purposes.
std::uint32_t proposeSeq() const
Get the sequence number of this proposal.
static std::uint32_t const kSeqJoin
Position const & position() const
Get the proposed position.
LedgerId const & prevLedger() const
Get the prior accepted ledger this position is based on.
bool isBowOut() const
Get whether this node left the consensus process.
NetClock::time_point const & closeTime() const
The current position on the consensus close time.
std::chrono::milliseconds read() const
beast::AbstractClock< std::chrono::steady_clock > clock_type
Clock type for measuring time within the consensus code.
Manages the acquisition and lifetime of transaction sets.
std::chrono::time_point< NetClock > time_point
std::chrono::duration< rep, period > duration
Slice slice() const noexcept
std::vector< TxIDSeq > TxIDSeqVec
InboundTransactions & inboundTransactions_
NegativeUNLVote nUnlVote_
Result onClose(RCLCxLedger const &ledger, NetClock::time_point const &closeTime, ConsensusMode mode)
Close the open ledger and return initial consensus position.
bool preStartRound(RCLCxLedger const &prevLedger, hash_set< NodeID > const &nowTrusted)
Called before kicking off a new consensus round.
bool validator() const
Whether I am a validator.
LedgerIndex getValidLedgerIndex() const
Adaptor(Application &app, std::unique_ptr< FeeVote > &&feeVote, LedgerMaster &ledgerMaster, LocalTxs &localTxs, InboundTransactions &inboundTransactions, ValidatorKeys const &validatorKeys, beast::Journal journal)
void updateOperatingMode(std::size_t const positions) const
Update operating mode based on current peer positions.
std::size_t proposersFinished(RCLCxLedger const &ledger, LedgerHash const &h) const
Number of proposers that have validated a ledger descended from requested ledger.
void onAccept(Result const &result, RCLCxLedger const &prevLedger, NetClock::duration const &closeResolution, ConsensusCloseTimes const &rawCloseTimes, ConsensusMode const &mode, json::Value &&consensusJson, bool const validating)
Process the accepted ledger.
void validate(RCLCxLedger const &ledger, RCLTxSet const &txns, bool proposing)
Validate the given ledger and share with peers as necessary.
std::unique_ptr< FeeVote > feeVote_
LedgerHash acquiringLedger_
std::atomic< bool > validating_
void propose(RCLCxPeerPos::Proposal const &proposal)
Propose the given position to my peers.
RCLCxLedger buildLCL(RCLCxLedger const &previousLedger, CanonicalTXSet &retriableTxs, NetClock::time_point closeTime, bool closeTimeCorrect, NetClock::duration closeResolution, std::chrono::milliseconds roundTime, std::set< TxID > &failedTxs)
Build the new last closed ledger.
ConsensusMode mode() const
NetClock::time_point lastValidationTime_
std::size_t proposersValidated(LedgerHash const &h) const
Number of proposers that have validated the given ledger.
void notify(protocol::NodeEvent ne, RCLCxLedger const &ledger, bool haveCorrectLCL)
Notify peers of a consensus state change.
std::atomic< ConsensusMode > mode_
std::pair< std::size_t, hash_set< NodeKey_t > > getQuorumKeys() const
std::optional< RCLTxSet > acquireTxSet(RCLTxSet::ID const &setId)
Acquire the transaction set associated with a proposal.
ValidatorKeys const & validatorKeys_
void doAccept(Result const &result, RCLCxLedger const &prevLedger, NetClock::duration closeResolution, ConsensusCloseTimes const &rawCloseTimes, ConsensusMode const &mode, json::Value &&consensusJson)
Accept a new ledger based on the given transactions.
uint256 getPrevLedger(uint256 ledgerID, RCLCxLedger const &ledger, ConsensusMode mode)
Get the ID of the previous ledger/last closed ledger(LCL) on the network.
LedgerMaster & ledgerMaster_
std::atomic< std::chrono::milliseconds > prevRoundTime_
void onForceAccept(Result const &result, RCLCxLedger const &prevLedger, NetClock::duration const &closeResolution, ConsensusCloseTimes const &rawCloseTimes, ConsensusMode const &mode, json::Value &&consensusJson)
Process the accepted ledger that was a result of simulation/force accept.
std::size_t laggards(Ledger_t::Seq const seq, hash_set< NodeKey_t > &trustedKeys) const
ConsensusResult< Adaptor > Result
std::optional< RCLCxLedger > acquireLedger(LedgerHash const &hash)
Attempt to acquire a specific ledger.
bool hasOpenTransactions() const
Whether the open ledger has any transactions.
RCLCensorshipDetector< TxID, LedgerIndex > censorshipDetector_
std::atomic< std::size_t > prevProposers_
bool haveValidated() const
void onModeChange(ConsensusMode before, ConsensusMode after)
Notified of change in consensus mode.
std::uint64_t const valCookie_
void share(RCLCxPeerPos const &peerPos)
Share the given proposal with all peers.
Consensus< Adaptor > consensus_
void timerEntry(NetClock::time_point const &now, std::unique_ptr< std::stringstream > const &clog={})
void startRound(NetClock::time_point const &now, RCLCxLedger::ID const &prevLgrId, RCLCxLedger const &prevLgr, hash_set< NodeID > const &nowUntrusted, hash_set< NodeID > const &nowTrusted, std::unique_ptr< std::stringstream > const &clog)
Adjust the set of trusted validators and kick-off the next round of consensus.
bool validating() const
Whether we are validating consensus ledgers.
json::Value getJson(bool full) const
bool peerProposal(NetClock::time_point const &now, RCLCxPeerPos const &newProposal)
void simulate(NetClock::time_point const &now, std::optional< std::chrono::milliseconds > consensusDelay)
std::recursive_mutex mutex_
RCLConsensus(Application &app, std::unique_ptr< FeeVote > &&feeVote, LedgerMaster &ledgerMaster, LocalTxs &localTxs, InboundTransactions &inboundTransactions, Consensus< Adaptor >::clock_type const &clock, ValidatorKeys const &validatorKeys, beast::Journal journal)
Constructor.
ConsensusMode mode() const
void gotTxSet(NetClock::time_point const &now, RCLTxSet const &txSet)
Represents a ledger in RCLConsensus.
LedgerHash ID
Unique identifier of a ledger.
LedgerIndex Seq
Sequence number of a ledger.
Seq const & seq() const
Sequence number of the ledger.
ID const & parentID() const
Unique identifier (hash) of this ledger's parent.
std::shared_ptr< Ledger const > ledger
The ledger instance.
ID const & id() const
Unique identifier (hash) of this ledger.
NetClock::time_point closeTime() const
The close time of this ledger.
A peer's signed, proposed position for use in RCLConsensus.
uint256 const & suppressionID() const
Unique id used by hash router to suppress duplicates.
PublicKey const & publicKey() const
Public key of peer that sent the proposal.
ConsensusProposal< NodeID, uint256, uint256 > Proposal
Slice signature() const
Signature of the proposal (not necessarily verified).
Proposal const & proposal() const
Represents a transaction in RCLConsensus.
boost::intrusive_ptr< SHAMapItem const > tx
The SHAMapItem that represents the transaction.
ID const & id() const
The unique identifier/hash of the transaction.
Represents a set of transactions in RCLConsensus.
uint256 ID
Unique identifier/hash of the set of transactions.
ID id() const
The unique ID/hash of the transaction set.
std::shared_ptr< SHAMap > map
The SHAMap representing the transactions.
Wraps a ledger instance for use in generic Validations LedgerTrie.
beast::Journal journal() const
Collects logging information.
std::unique_ptr< std::stringstream > const & ss()
std::chrono::steady_clock::time_point start_
RclConsensusLogger(char const *label, bool validating, beast::Journal j)
std::unique_ptr< std::stringstream > ss_
Slice slice() const noexcept
std::size_t getNodesAfter(Ledger const &ledger, ID const &ledgerID)
Count the number of current trusted validators working on a ledger after the specified one.
Adaptor const & adaptor() const
Return the adaptor instance.
std::optional< std::pair< Seq, ID > > getPreferred(Ledger const &curr)
Return the sequence number and ID of the preferred working ledger.
Validator keys and manifest as set in configuration file.
T duration_cast(T... args)
T emplace_back(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
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.
std::chrono::time_point< Clock, Duration > effCloseTime(std::chrono::time_point< Clock, Duration > closeTime, std::chrono::duration< Rep, Period > resolution, std::chrono::time_point< Clock, Duration > priorCloseTime)
Calculate the effective ledger close time.
ConsensusMode
Represents how a node currently participates in Consensus.
@ WrongLedger
We have the wrong ledger and are attempting to acquire it.
@ Proposing
We are normal participant in consensus and propose our position.
@ Observing
We are observing peer positions, but not proposing our position.
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
std::uint32_t LedgerIndex
A ledger index.
std::enable_if_t< std::is_integral_v< Integral > &&detail::is_engine< Engine >::value, Integral > randInt(Engine &engine, Integral min, Integral max)
Return a uniformly distributed random integer.
Rules makeRulesGivenLedger(DigestAwareReadView const &ledger, Rules const ¤t)
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::unordered_set< Value, Hash, Pred, Allocator > hash_set
CsprngEngine & cryptoPrng()
The default cryptographically secure PRNG.
std::string to_string(BaseUInt< Bits, Tag > const &a)
@ MovedOn
The network has consensus without us.
@ Yes
We have consensus along with the network.
XRPL_NO_SANITIZE_ADDRESS void rethrow()
Rethrow the exception currently being handled.
boost::intrusive_ptr< SHAMapItem > makeShamapitem(uint256 const &tag, Slice data)
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Validations< RCLValidationsAdaptor > RCLValidations
Alias for RCL-specific instantiation of generic Validations.
std::shared_ptr< Ledger > buildLedger(std::shared_ptr< Ledger const > const &parent, NetClock::time_point closeTime, bool const closeTimeCorrect, NetClock::duration closeResolution, Application &app, CanonicalTXSet &txns, std::set< TxID > &failedTxs, beast::Journal j)
Build a new ledger by applying consensus transactions.
Buffer signDigest(PublicKey const &pk, SecretKey const &sk, uint256 const &digest)
Generate a signature for a message digest.
uint256 proposalUniqueId(uint256 const &proposeHash, uint256 const &previousLedger, std::uint32_t proposeSeq, NetClock::time_point closeTime, Slice const &publicKey, Slice const &signature)
Calculate a unique identifier for a signed proposal.
@ CONNECTED
convinced we are talking to the network
@ FULL
we have the ledger and can even validate
bool isPseudoTx(STObject const &tx)
Check whether a transaction is a pseudo-transaction.
std::enable_if_t< std::is_same_v< T, char >||std::is_same_v< T, unsigned char >, Slice > makeSlice(std::array< T, N > const &a)
Stores the set of initial close times.
TxSet_t txns
The set of transactions consensus agrees go in the ledger.
Proposal_t position
Our proposed position on transactions/close time.
Sends a message to all peers.
T time_point_cast(T... args)
T time_since_epoch(T... args)