20#include <xrpld/app/consensus/RCLConsensus.h>
21#include <xrpld/app/consensus/RCLValidations.h>
22#include <xrpld/app/ledger/BuildLedger.h>
23#include <xrpld/app/ledger/InboundLedgers.h>
24#include <xrpld/app/ledger/InboundTransactions.h>
25#include <xrpld/app/ledger/Ledger.h>
26#include <xrpld/app/ledger/LedgerMaster.h>
27#include <xrpld/app/ledger/LocalTxs.h>
28#include <xrpld/app/ledger/OpenLedger.h>
29#include <xrpld/app/misc/AmendmentTable.h>
30#include <xrpld/app/misc/HashRouter.h>
31#include <xrpld/app/misc/LoadFeeTrack.h>
32#include <xrpld/app/misc/NegativeUNLVote.h>
33#include <xrpld/app/misc/NetworkOPs.h>
34#include <xrpld/app/misc/TxQ.h>
35#include <xrpld/app/misc/ValidatorKeys.h>
36#include <xrpld/app/misc/ValidatorList.h>
37#include <xrpld/consensus/LedgerTiming.h>
38#include <xrpld/overlay/Overlay.h>
39#include <xrpld/overlay/predicates.h>
40#include <xrpl/basics/random.h>
41#include <xrpl/beast/core/LexicalCast.h>
42#include <xrpl/beast/utility/instrumentation.h>
43#include <xrpl/protocol/BuildInfo.h>
44#include <xrpl/protocol/Feature.h>
45#include <xrpl/protocol/digest.h>
70 , consensus_(clock, adaptor_, journal)
84 , feeVote_(
std::move(feeVote))
87 , inboundTransactions_{inboundTransactions}
89 , validatorKeys_(validatorKeys)
94 std::numeric_limits<
std::uint64_t>::max() - 1))
95 , nUnlVote_(validatorKeys_.nodeID, j_)
98 valCookie_,
"ripple::RCLConsensus::Adaptor::Adaptor : nonzero cookie");
100 JLOG(
j_.
info()) <<
"Consensus engine started (cookie: " +
107 JLOG(
j_.
info()) <<
"Validator identity: "
116 <<
"Validator ephemeral signing key: "
128 auto built = ledgerMaster_.getLedgerByHash(hash);
131 if (acquiringLedger_ != hash)
134 JLOG(
j_.
warn()) <<
"Need consensus ledger " << hash;
137 acquiringLedger_ = hash;
139 app_.getJobQueue().addJob(
141 "getConsensusLedger1",
142 [
id = hash, &app = app_,
this]() {
144 <<
"JOB advanceLedger getConsensusLedger1 started";
145 app.getInboundLedgers().acquireAsync(
153 !built->open() && built->isImmutable(),
154 "ripple::RCLConsensus::Adaptor::acquireLedger : valid ledger state");
156 built->info().hash == hash,
157 "ripple::RCLConsensus::Adaptor::acquireLedger : ledger hash match");
160 inboundTransactions_.newRound(built->info().seq);
168 protocol::TMProposeSet prop;
172 prop.set_proposeseq(
proposal.proposeSeq());
173 prop.set_closetime(
proposal.closeTime().time_since_epoch().count());
175 prop.set_currenttxhash(
177 prop.set_previousledger(
181 prop.set_nodepubkey(pk.data(), pk.size());
184 prop.set_signature(sig.data(), sig.size());
193 if (app_.getHashRouter().shouldRelay(tx.
id()))
195 JLOG(
j_.
debug()) <<
"Relaying disputed tx " << tx.
id();
196 auto const slice = tx.
tx_->slice();
197 protocol::TMTransaction msg;
198 msg.set_rawtransaction(slice.data(), slice.size());
199 msg.set_status(protocol::tsNEW);
200 msg.set_receivetimestamp(
201 app_.timeKeeper().now().time_since_epoch().count());
203 app_.overlay().relay(tx.
id(), msg, skip);
207 JLOG(
j_.
debug()) <<
"Not relaying disputed tx " << tx.
id();
213 JLOG(
j_.
trace()) << (
proposal.isBowOut() ?
"We bow out: " :
"We propose: ")
217 protocol::TMProposeSet prop;
219 prop.set_currenttxhash(
221 prop.set_previousledger(
223 prop.set_proposeseq(
proposal.proposeSeq());
224 prop.set_closetime(
proposal.closeTime().time_since_epoch().count());
226 if (!validatorKeys_.keys)
228 JLOG(
j_.
warn()) <<
"RCLConsensus::Adaptor::propose: ValidatorKeys "
233 auto const& keys = *validatorKeys_.keys;
235 prop.set_nodepubkey(keys.publicKey.data(), keys.publicKey.size());
240 prop.set_signature(sig.data(), sig.size());
250 app_.getHashRouter().addSuppression(suppression);
252 app_.overlay().broadcast(prop);
258 inboundTransactions_.giveSet(txns.
id(), txns.
map_,
false);
264 if (
auto txns = inboundTransactions_.getSet(setId,
true))
274 return !app_.openLedger().empty();
280 return app_.getValidations().numTrustedForLedger(h);
302 ledgerMaster_.getValidLedgerIndex());
304 if (netLgr != ledgerID)
307 app_.getOPs().consensusViewChange();
324 notify(protocol::neCLOSING_LEDGER, ledger, !wrongLCL);
326 auto const& prevLedger = ledger.ledger_;
328 ledgerMaster_.applyHeldTransactions();
330 ledgerMaster_.setBuildingLedger(prevLedger->info().seq + 1);
332 auto initialLedger = app_.openLedger().current();
336 initialSet->setUnbacked();
339 for (
auto const& tx : initialLedger->txs)
341 JLOG(
j_.
trace()) <<
"Adding open ledger TX "
342 << tx.first->getTransactionID();
351 if (app_.config().standalone() || (
proposing && !wrongLCL))
353 if (prevLedger->isFlagLedger())
357 auto validations = app_.validators().negativeUNLFilter(
358 app_.getValidations().getTrustedForLedger(
359 prevLedger->info().parentHash, prevLedger->seq() - 1));
360 if (validations.size() >= app_.validators().quorum())
362 feeVote_->doVoting(prevLedger, validations, initialSet);
363 app_.getAmendmentTable().doVoting(
364 prevLedger, validations, initialSet,
j_);
368 prevLedger->isVotingLedger() &&
369 prevLedger->rules().enabled(featureNegativeUNL))
376 app_.validators().getTrustedMasterKeys(),
377 app_.getValidations(),
383 initialSet = initialSet->snapShot(
false);
387 LedgerIndex const seq = prevLedger->info().seq + 1;
390 initialSet->visitLeaves(
392 seq](boost::intrusive_ptr<SHAMapItem const>
const& item) {
396 censorshipDetector_.propose(std::move(proposed));
400 auto const setHash = initialSet->getHash().as_uint256();
403 std::move(initialSet),
405 initialLedger->info().parentHash,
409 app_.timeKeeper().closeTime(),
410 validatorKeys_.nodeID}};
428 std::move(consensusJson));
441 app_.getJobQueue().addJob(
444 [=,
this, cj = std::move(consensusJson)]()
mutable {
458 this->app_.getOPs().endConsensus(clog.
ss());
474 bool closeTimeCorrect;
485 using namespace std::chrono_literals;
486 consensusCloseTime = prevLedger.
closeTime() + 1s;
487 closeTimeCorrect =
false;
493 consensusCloseTime, closeResolution, prevLedger.
closeTime());
494 closeTimeCorrect =
true;
498 <<
" val=" << (validating_ ?
"yes" :
"no")
499 <<
" corLCL=" << (haveCorrectLCL ?
"yes" :
"no")
500 <<
" fail=" << (consensusFail ?
"yes" :
"no");
501 JLOG(
j_.
debug()) <<
"Report: Prev = " << prevLedger.
id() <<
":"
513 JLOG(
j_.
debug()) <<
"Building canonical tx set: " << retriableTxs.key();
515 for (
auto const& item : *result.
txns.map_)
520 std::make_shared<STTx const>(
SerialIter{item.slice()}));
521 JLOG(
j_.
debug()) <<
" Tx: " << item.key();
525 failed.
insert(item.key());
527 <<
" Tx: " << item.key() <<
" throws: " << ex.
what();
531 auto built = buildLCL(
540 auto const newLCLHash = built.id();
541 JLOG(
j_.
debug()) <<
"Built ledger #" << built.seq() <<
": " << newLCLHash;
544 notify(protocol::neACCEPTED_LEDGER, built, haveCorrectLCL);
553 result.
txns.map_->visitLeaves(
554 [&
accepted](boost::intrusive_ptr<SHAMapItem const>
const& item) {
559 for (
auto const& r : retriableTxs)
560 failed.
insert(r.first.getTXID());
562 censorshipDetector_.check(
565 j = app_.journal(
"CensorshipDetector"),
567 if (failed.count(id))
570 auto const wait = curr - seq;
572 if (wait && (wait % censorshipWarnInternal == 0))
574 std::ostringstream ss;
575 ss <<
"Potential Censorship: Eligible tx " << id
576 <<
", which we are tracking since ledger " << seq
577 <<
" has not been included as of ledger " << curr <<
".";
579 JLOG(j.warn()) << ss.str();
587 validating_ = ledgerMaster_.isCompatible(
588 *built.ledger_,
j_.
warn(),
"Not validating");
590 if (validating_ && !consensusFail &&
591 app_.getValidations().canValidateSeq(built.seq()))
594 JLOG(
j_.
info()) <<
"CNF Val " << newLCLHash;
597 JLOG(
j_.
info()) <<
"CNF buildLCL " << newLCLHash;
600 ledgerMaster_.consensusBuilt(
601 built.ledger_, result.txns.id(), std::move(consensusJson));
616 bool anyDisputes =
false;
617 for (
auto const& [_, dispute] : result.disputes)
620 if (!dispute.getOurVote())
626 <<
"Test applying disputed transaction that did"
627 <<
" not get in " << dispute.tx().id();
630 auto txn = std::make_shared<STTx const>(sit);
637 retriableTxs.insert(txn);
643 JLOG(
j_.
debug()) <<
"Failed to apply transaction we voted "
655 auto const lastVal = ledgerMaster_.getValidatedLedger();
660 rules.
emplace(app_.config().features);
661 app_.openLedger().accept(
665 localTxs_.getTxSet(),
672 return app_.getTxQ().accept(app_, view);
677 app_.getOPs().reportFeeChange();
682 ledgerMaster_.switchLCL(built.ledger_);
686 ledgerMaster_.getClosedLedger()->info().hash == built.id(),
687 "ripple::RCLConsensus::Adaptor::doAccept : ledger hash match");
689 app_.openLedger().current()->info().parentHash == built.id(),
690 "ripple::RCLConsensus::Adaptor::doAccept : parent hash match");
701 auto closeTime = rawCloseTimes.self;
703 JLOG(
j_.
info()) <<
"We closed at "
704 << closeTime.time_since_epoch().count();
706 usec64_t closeTotal =
707 std::chrono::duration_cast<usec64_t>(closeTime.time_since_epoch());
710 for (
auto const& [t, v] : rawCloseTimes.peers)
716 std::chrono::duration_cast<usec64_t>(t.time_since_epoch()) * v;
719 closeTotal += usec64_t(closeCount / 2);
720 closeTotal /= closeCount;
725 auto offset = time_point{closeTotal} -
726 std::chrono::time_point_cast<duration>(closeTime);
727 JLOG(
j_.
info()) <<
"Our close offset is estimated at " << offset.count()
728 <<
" (" << closeCount <<
")";
730 app_.timeKeeper().adjustCloseTime(offset);
736 protocol::NodeEvent ne,
740 protocol::TMStatusChange s;
743 s.set_newevent(protocol::neLOST_SYNC);
747 s.set_ledgerseq(ledger.
seq());
749 s.set_ledgerhashprevious(
766 s.set_firstseq(uMin);
769 send_always(std::make_shared<Message>(s, protocol::mtSTATUS_CHANGE)));
770 JLOG(
j_.
trace()) <<
"send status change to peer";
778 bool closeTimeCorrect,
784 if (
auto const replayData = ledgerMaster_.releaseReplay())
787 replayData->parent()->info().hash == previousLedger.
id(),
788 "ripple::RCLConsensus::Adaptor::buildLCL : parent hash match");
803 using namespace std::chrono_literals;
804 app_.getTxQ().processClosedLedger(app_, *built, roundTime > 5s);
807 if (ledgerMaster_.storeLedger(built))
808 JLOG(
j_.
debug()) <<
"Consensus built ledger we already had";
809 else if (app_.getInboundLedgers().find(built->info().hash))
810 JLOG(
j_.
debug()) <<
"Consensus built ledger we were acquiring";
812 JLOG(
j_.
debug()) <<
"Consensus built new ledger";
822 using namespace std::chrono_literals;
824 auto validationTime = app_.timeKeeper().closeTime();
825 if (validationTime <= lastValidationTime_)
826 validationTime = lastValidationTime_ + 1s;
827 lastValidationTime_ = validationTime;
829 if (!validatorKeys_.keys)
831 JLOG(
j_.
warn()) <<
"RCLConsensus::Adaptor::validate: ValidatorKeys "
836 auto const& keys = *validatorKeys_.keys;
838 auto v = std::make_shared<STValidation>(
842 validatorKeys_.nodeID,
844 v.setFieldH256(sfLedgerHash, ledger.id());
845 v.setFieldH256(sfConsensusHash, txns.id());
847 v.setFieldU32(sfLedgerSequence, ledger.seq());
850 v.setFlag(vfFullValidation);
852 if (ledger.ledger_->rules().enabled(featureHardenedValidations))
857 if (auto const vl = ledgerMaster_.getValidatedLedger())
858 v.setFieldH256(sfValidatedHash, vl->info().hash);
860 v.setFieldU64(sfCookie, valCookie_);
863 if (ledger.ledger_->isVotingLedger())
865 sfServerVersion, BuildInfo::getEncodedVersion());
870 auto const& ft = app_.getFeeTrack();
871 auto const fee = std::max(ft.getLocalFee(), ft.getClusterFee());
872 if (fee > ft.getLoadBase())
873 v.setFieldU32(sfLoadFee, fee);
878 if (ledger.
ledger_->isVotingLedger())
881 feeVote_->doValidation(
882 ledger.ledger_->fees(), ledger.ledger_->rules(), v);
887 auto const amendments = app_.getAmendmentTable().doValidation(
888 getEnabledAmendments(*ledger.ledger_));
890 if (!amendments.empty())
892 sfAmendments, STVector256(sfAmendments, amendments));
896 auto const serialized = v->getSerialized();
904 protocol::TMValidation val;
905 val.set_validation(serialized.data(), serialized.size());
906 app_.overlay().broadcast(val);
909 app_.getOPs().pubValidation(v);
915 JLOG(
j_.
info()) <<
"Consensus mode change before=" <<
to_string(before)
923 censorshipDetector_.reset();
954 ss <<
"During consensus timerEntry: " << mn.
what();
956 CLOG(clog) << ss.
str();
972 JLOG(
j_.
error()) <<
"During consensus gotTxSet: " << mn.
what();
994 return consensus_.peerProposal(now, newProposal);
1004 validating_ = validatorKeys_.keys &&
1005 prevLgr.
seq() >= app_.getMaxDisallowedLedger() &&
1006 !app_.getOPs().isBlocked();
1010 if (validating_ && !app_.config().standalone() && app_.validators().count())
1012 auto const when = app_.validators().expires();
1014 if (!when || *when < app_.timeKeeper().now())
1016 JLOG(
j_.
error()) <<
"Voluntarily bowing out of consensus process "
1017 "because of an expired validator list.";
1018 validating_ =
false;
1026 JLOG(
j_.
info()) <<
"Entering consensus process, validating, synced="
1027 << (synced ?
"yes" :
"no");
1032 JLOG(
j_.
info()) <<
"Entering consensus process, watching, synced="
1033 << (synced ?
"yes" :
"no");
1037 inboundTransactions_.newRound(prevLgr.
seq());
1040 if (prevLgr.
ledger_->rules().enabled(featureNegativeUNL) &&
1041 !nowTrusted.
empty())
1042 nUnlVote_.newValidators(prevLgr.
seq() + 1, nowTrusted);
1045 return validating_ && synced;
1051 return ledgerMaster_.haveValidated();
1057 return ledgerMaster_.getValidLedgerIndex();
1063 return app_.validators().getQuorumKeys();
1071 return app_.getValidations().laggards(seq, trustedKeys);
1077 return validatorKeys_.keys.has_value();
1083 if (!positions && app_.getOPs().isFull())
1112 if (!validating && !j.
info())
1115 ss_ = std::make_unique<std::stringstream>();
1125 auto const duration = std::chrono::duration_cast<std::chrono::milliseconds>(
1128 outSs <<
header_ <<
"duration " << (duration.count() / 1000) <<
'.'
Decorator for streaming out compact json.
virtual void writeAlways(Severity level, std::string const &text)=0
Bypass filter and write text to the sink at the specified severity.
A generic endpoint for log messages.
Sink & sink() const
Returns the Sink associated with this Journal.
Stream trace() const
Severity stream access functions.
virtual Overlay & overlay()=0
virtual TimeKeeper & timeKeeper()=0
Holds transactions which were deferred to the next pass of consensus.
static std::uint32_t const seqJoin
NetClock::time_point const & closeTime() const
The current position on the consensus close time.
std::chrono::milliseconds read() const
Manages the acquisition and lifetime of transaction sets.
std::uint32_t getEarliestFetch()
bool getFullValidatedRange(std::uint32_t &minVal, std::uint32_t &maxVal)
void foreach(Function f) const
Visit every active peer.
Slice slice() const noexcept
void propose(RCLCxPeerPos::Proposal const &proposal)
Propose the given position to my peers.
ValidatorKeys const & validatorKeys_
Result onClose(RCLCxLedger const &ledger, NetClock::time_point const &closeTime, ConsensusMode mode)
Close the open ledger and return initial consensus position.
void onAccept(Result const &result, RCLCxLedger const &prevLedger, NetClock::duration const &closeResolution, ConsensusCloseTimes const &rawCloseTimes, ConsensusMode const &mode, Json::Value &&consensusJson, const bool validating)
Process the accepted ledger.
void share(RCLCxPeerPos const &peerPos)
Share the given proposal with all peers.
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.
Adaptor(Application &app, std::unique_ptr< FeeVote > &&feeVote, LedgerMaster &ledgerMaster, LocalTxs &localTxs, InboundTransactions &inboundTransactions, ValidatorKeys const &validatorKeys, beast::Journal journal)
void onModeChange(ConsensusMode before, ConsensusMode after)
Notified of change in consensus mode.
std::size_t laggards(Ledger_t::Seq const seq, hash_set< NodeKey_t > &trustedKeys) const
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.
bool validator() const
Whether I am a validator.
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.
std::optional< RCLCxLedger > acquireLedger(LedgerHash const &hash)
Attempt to acquire a specific ledger.
LedgerIndex getValidLedgerIndex() const
std::size_t proposersFinished(RCLCxLedger const &ledger, LedgerHash const &h) const
Number of proposers that have validated a ledger descended from requested ledger.
std::optional< RCLTxSet > acquireTxSet(RCLTxSet::ID const &setId)
Acquire the transaction set associated with a proposal.
bool hasOpenTransactions() const
Whether the open ledger has any transactions.
LedgerMaster & ledgerMaster_
bool haveValidated() const
void validate(RCLCxLedger const &ledger, RCLTxSet const &txns, bool proposing)
Validate the given ledger and share with peers as necessary.
std::uint64_t const valCookie_
bool preStartRound(RCLCxLedger const &prevLedger, hash_set< NodeID > const &nowTrusted)
Called before kicking off a new consensus round.
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.
void updateOperatingMode(std::size_t const positions) const
Update operating mode based on current peer positions.
std::pair< std::size_t, hash_set< NodeKey_t > > getQuorumKeys() const
void gotTxSet(NetClock::time_point const &now, RCLTxSet const &txSet)
void simulate(NetClock::time_point const &now, std::optional< std::chrono::milliseconds > consensusDelay)
bool validating() const
Whether we are validating consensus ledgers.
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
std::recursive_mutex mutex_
Consensus< Adaptor > consensus_
bool peerProposal(NetClock::time_point const &now, RCLCxPeerPos const &newProposal)
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.
void timerEntry(NetClock::time_point const &now, std::unique_ptr< std::stringstream > const &clog={})
Json::Value getJson(bool full) const
Represents a ledger in RCLConsensus.
Seq const & seq() const
Sequence number of the ledger.
ID const & id() const
Unique identifier (hash) of this ledger.
std::shared_ptr< Ledger const > ledger_
The ledger instance.
NetClock::time_point closeTime() const
The close time of this ledger.
ID const & parentID() const
Unique identifier (hash) of this ledger's parent.
A peer's signed, proposed position for use in RCLConsensus.
Proposal const & proposal() const
PublicKey const & publicKey() const
Public key of peer that sent the proposal.
Slice signature() const
Signature of the proposal (not necessarily verified)
uint256 const & suppressionID() const
Unique id used by hash router to suppress duplicates.
Represents a transaction in RCLConsensus.
ID const & id() const
The unique identifier/hash of the transaction.
boost::intrusive_ptr< SHAMapItem const > tx_
The SHAMapItem that represents the transaction.
Represents a set of transactions in RCLConsensus.
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(const char *label, bool validating, beast::Journal j)
std::unique_ptr< std::stringstream > ss_
Slice slice() const noexcept
time_point now() const override
Returns the current time, using the server's clock.
std::optional< std::pair< Seq, ID > > getPreferred(Ledger const &curr)
Return the sequence number and ID of the preferred working ledger.
Adaptor const & adaptor() const
Return the adaptor instance.
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.
Validator keys and manifest as set in configuration file.
std::optional< Keys > keys
T emplace_back(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::shared_ptr< Ledger > buildLedger(std::shared_ptr< Ledger const > const &parent, NetClock::time_point closeTime, const bool closeTimeCorrect, NetClock::duration closeResolution, Application &app, CanonicalTXSet &txns, std::set< TxID > &failedTxs, beast::Journal j)
Build a new ledger by applying consensus transactions.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
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::enable_if_t< std::is_integral< Integral >::value, Integral > rand_int()
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.
bool isPseudoTx(STObject const &tx)
Check whether a transaction is a pseudo-transaction.
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.
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.
@ CONNECTED
convinced we are talking to the network
@ FULL
we have the ledger and can even validate
csprng_engine & crypto_prng()
The default cryptographically secure PRNG.
@ MovedOn
The network has consensus without us.
@ Yes
We have consensus along with the network.
@ accepted
Manifest is valid.
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
Buffer signDigest(PublicKey const &pk, SecretKey const &sk, uint256 const &digest)
Generate a signature for a message digest.
boost::intrusive_ptr< SHAMapItem > make_shamapitem(uint256 const &tag, Slice data)
Rules makeRulesGivenLedger(DigestAwareReadView const &ledger, Rules const ¤t)
std::string to_string(base_uint< Bits, Tag > const &a)
@ ledgerMaster
ledger master data for signing
@ proposal
proposal for signing
void Rethrow()
Rethrow the exception currently being handled.
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
static bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Stores the set of initial close times.
Encapsulates the result of consensus.
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.