1#include <xrpld/app/consensus/RCLConsensus.h>
3#include <xrpld/app/consensus/RCLCxLedger.h>
4#include <xrpld/app/consensus/RCLCxPeerPos.h>
5#include <xrpld/app/consensus/RCLCxTx.h>
6#include <xrpld/app/consensus/RCLValidations.h>
7#include <xrpld/app/ledger/BuildLedger.h>
8#include <xrpld/app/ledger/InboundLedger.h>
9#include <xrpld/app/ledger/InboundLedgers.h>
10#include <xrpld/app/ledger/InboundTransactions.h>
11#include <xrpld/app/ledger/LedgerMaster.h>
12#include <xrpld/app/ledger/LocalTxs.h>
13#include <xrpld/app/ledger/OpenLedger.h>
14#include <xrpld/app/misc/FeeVote.h>
15#include <xrpld/app/misc/NegativeUNLVote.h>
16#include <xrpld/app/misc/TxQ.h>
17#include <xrpld/app/misc/ValidatorKeys.h>
18#include <xrpld/app/misc/ValidatorList.h>
19#include <xrpld/overlay/Overlay.h>
20#include <xrpld/overlay/predicates.h>
22#include <xrpl/basics/Log.h>
23#include <xrpl/basics/Slice.h>
24#include <xrpl/basics/UnorderedContainers.h>
25#include <xrpl/basics/base_uint.h>
26#include <xrpl/basics/chrono.h>
27#include <xrpl/basics/contract.h>
28#include <xrpl/basics/random.h>
29#include <xrpl/beast/utility/Journal.h>
30#include <xrpl/beast/utility/Zero.h>
31#include <xrpl/beast/utility/instrumentation.h>
32#include <xrpl/consensus/CensorshipDetector.h>
33#include <xrpl/consensus/Consensus.h>
34#include <xrpl/consensus/ConsensusTypes.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;
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;
234 prop.set_currenttxhash(
proposal.position().begin(),
proposal.position().size());
235 prop.set_previousledger(
proposal.prevLedger().begin(),
proposal.prevLedger().size());
236 prop.set_proposeseq(
proposal.proposeSeq());
237 prop.set_closetime(
proposal.closeTime().time_since_epoch().count());
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 JLOG(
j_.info()) <<
"We closed at " << rawCloseTimes.self.time_since_epoch().count();
691 for (
auto const& [t, v] : rawCloseTimes.peers)
700 JLOG(
j_.info()) <<
"Our close offset is estimated at " << offset.count() <<
" ("
701 << closeCount <<
")";
703 app_.getTimeKeeper().adjustCloseTime(offset);
709 protocol::NodeEvent ne,
713 protocol::TMStatusChange s;
717 s.set_newevent(protocol::neLOST_SYNC);
724 s.set_ledgerseq(ledger.
seq());
725 s.set_networktime(
app_.getTimeKeeper().now().time_since_epoch().count());
726 s.set_ledgerhashprevious(
741 s.set_firstseq(uMin);
744 JLOG(
j_.trace()) <<
"send status change to peer";
752 bool closeTimeCorrect,
761 replayData->parent()->header().hash == previousLedger.
id(),
762 "xrpl::RCLConsensus::Adaptor::buildLCL : parent hash match");
777 using namespace std::chrono_literals;
778 app_.getTxQ().processClosedLedger(
app_, *built, roundTime > 5s);
783 JLOG(
j_.debug()) <<
"Consensus built ledger we already had";
785 else if (
app_.getInboundLedgers().find(built->header().hash))
787 JLOG(
j_.debug()) <<
"Consensus built ledger we were acquiring";
791 JLOG(
j_.debug()) <<
"Consensus built new ledger";
799 using namespace std::chrono_literals;
801 auto validationTime =
app_.getTimeKeeper().closeTime();
808 JLOG(
j_.warn()) <<
"RCLConsensus::Adaptor::validate: ValidatorKeys "
821 v.setFieldH256(sfLedgerHash, ledger.id());
822 v.setFieldH256(sfConsensusHash, txns.id());
824 v.setFieldU32(sfLedgerSequence, ledger.seq());
827 v.setFlag(kVfFullValidation);
832 if (auto const vl = ledgerMaster_.getValidatedLedger())
833 v.setFieldH256(sfValidatedHash, vl->header().hash);
835 v.setFieldU64(sfCookie, valCookie_);
838 if (ledger.ledger->isVotingLedger())
839 v.setFieldU64(sfServerVersion, build_info::getEncodedVersion());
843 auto const& ft = app_.getFeeTrack();
844 auto const fee = std::max(ft.getLocalFee(), ft.getClusterFee());
845 if (fee > ft.getLoadBase())
846 v.setFieldU32(sfLoadFee, fee);
851 if (ledger.
ledger->isVotingLedger())
854 feeVote_->doValidation(ledger.ledger->fees(), ledger.ledger->rules(), v);
859 auto const amendments =
860 app_.getAmendmentTable().doValidation(getEnabledAmendments(*ledger.ledger));
862 if (!amendments.empty())
863 v.setFieldV256(sfAmendments, STVector256(sfAmendments, amendments));
867 auto const serialized = v->getSerialized();
875 protocol::TMValidation val;
876 val.set_validation(serialized.data(), serialized.size());
877 app_.getOverlay().broadcast(val);
880 app_.getOPs().pubValidation(v);
886 JLOG(
j_.info()) <<
"Consensus mode change before=" <<
to_string(before)
906 ret[
"validating"] =
adaptor_.validating();
924 ss <<
"During consensus timerEntry: " << mn.
what();
925 JLOG(
j_.error()) << ss.
str();
926 CLOG(clog) << ss.
str();
942 JLOG(
j_.error()) <<
"During consensus gotTxSet: " << mn.
what();
964 return consensus_.peerProposal(now, newProposal);
973 !
app_.getOPs().isBlocked();
979 auto const when =
app_.getValidators().expires();
981 if (!when || *when <
app_.getTimeKeeper().now())
983 JLOG(
j_.error()) <<
"Voluntarily bowing out of consensus process "
984 "because of an expired validator list.";
993 JLOG(
j_.info()) <<
"Entering consensus process, validating, synced="
994 << (synced ?
"yes" :
"no");
999 JLOG(
j_.info()) <<
"Entering consensus process, watching, synced="
1000 << (synced ?
"yes" :
"no");
1007 if (!nowTrusted.
empty())
1008 nUnlVote_.newValidators(prevLgr.
seq() + 1, nowTrusted);
1029 return app_.getValidators().getQuorumKeys();
1037 return app_.getValidations().laggards(seq, trustedKeys);
1049 if ((positions == 0u) &&
app_.getOPs().isFull())
1064 now, prevLgrId, prevLgr, nowUntrusted,
adaptor_.preStartRound(prevLgr, nowTrusted), clog);
1070 if (!validating && !j.
info())
1086 outSs <<
header_ <<
"duration " << (duration.count() / 1000) <<
'.' <<
std::setw(3)
1087 <<
std::setfill(
'0') << (duration.count() % 1000) <<
"s. " <<
ss_->str();
A generic endpoint for log messages.
Decorator for streaming out compact json.
Holds transactions which were deferred to the next pass of consensus.
UInt256 const & key() const
void insert(std::shared_ptr< STTx const > txn)
std::vector< TxIDSeq > TxIDSeqVec
static std::uint32_t const kSeqJoin
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 > ClockType
Clock type for measuring time within the consensus code.
Manages the acquisition and lifetime of transaction sets.
Tracks the current ledger and any ledgers in the process of closing.
std::chrono::time_point< NetClock > time_point
std::chrono::duration< rep, period > duration
Slice slice() const noexcept
InboundTransactions & inboundTransactions_
CensorshipDetector< TxID, LedgerIndex > censorshipDetector_
NegativeUNLVote nUnlVote_
Result onClose(RCLCxLedger const &ledger, NetClock::time_point const &closeTime, ConsensusMode mode)
Close the open ledger and return initial consensus position.
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_
UInt256 getPrevLedger(UInt256 ledgerID, RCLCxLedger const &ledger, ConsensusMode mode)
Get the ID of the previous ledger/last closed ledger(LCL) on the network.
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::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.
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.
ConsensusResult< Adaptor > Result
std::pair< std::size_t, HashSet< NodeKeyT > > getQuorumKeys() const
bool preStartRound(RCLCxLedger const &prevLedger, HashSet< NodeID > const &nowTrusted)
Called before kicking off a new consensus round.
std::optional< RCLCxLedger > acquireLedger(LedgerHash const &hash)
Attempt to acquire a specific ledger.
bool hasOpenTransactions() const
Whether the open ledger has any transactions.
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_
std::size_t laggards(LedgerT::Seq const seq, HashSet< NodeKeyT > &trustedKeys) const
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={})
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_
void startRound(NetClock::time_point const &now, RCLCxLedger::ID const &prevLgrId, RCLCxLedger const &prevLgr, HashSet< NodeID > const &nowUntrusted, HashSet< NodeID > const &nowTrusted, std::unique_ptr< std::stringstream > const &clog)
Adjust the set of trusted validators and kick-off the next round of consensus.
ConsensusMode mode() const
RCLConsensus(Application &app, std::unique_ptr< FeeVote > &&feeVote, LedgerMaster &ledgerMaster, LocalTxs &localTxs, InboundTransactions &inboundTransactions, Consensus< Adaptor >::ClockType const &clock, ValidatorKeys const &validatorKeys, beast::Journal journal)
Constructor.
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.
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).
UInt256 const & suppressionID() const
Unique id used by hash router to suppress duplicates.
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.
std::uint32_t LedgerIndex
A ledger index.
Rules makeRulesGivenLedger(DigestAwareReadView const &ledger, Rules const ¤t)
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.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
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.
Slice makeSlice(std::array< T, N > const &a)
XRPL_NO_SANITIZE_ADDRESS void rethrow()
Rethrow the exception currently being handled.
boost::intrusive_ptr< SHAMapItem > makeShamapitem(UInt256 const &tag, Slice data)
std::chrono::seconds medianCloseOffset(ConsensusCloseTimes const ×)
Offset of the network's close time relative to ours, using a weighted median.
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.
Integral randInt(Engine &engine, Integral min, Integral max)
Return a uniformly distributed random integer.
Buffer signDigest(PublicKey const &pk, SecretKey const &sk, UInt256 const &digest)
Generate a signature for a message digest.
std::unordered_set< Value, Hash, Pred, Allocator > HashSet
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.
@ 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.
Sha512HalfHasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
Stores the set of initial close times.
ProposalT position
Our proposed position on transactions/close time.
TxSetT txns
The set of transactions consensus agrees go in the ledger.
Sends a message to all peers.