20 #ifndef RIPPLE_APP_CONSENSUS_RCLCONSENSUS_H_INCLUDED
21 #define RIPPLE_APP_CONSENSUS_RCLCONSENSUS_H_INCLUDED
23 #include <ripple/app/consensus/RCLCensorshipDetector.h>
24 #include <ripple/app/consensus/RCLCxLedger.h>
25 #include <ripple/app/consensus/RCLCxPeerPos.h>
26 #include <ripple/app/consensus/RCLCxTx.h>
27 #include <ripple/app/misc/FeeVote.h>
28 #include <ripple/app/misc/NegativeUNLVote.h>
29 #include <ripple/basics/CountedObject.h>
30 #include <ripple/basics/Log.h>
31 #include <ripple/beast/utility/Journal.h>
32 #include <ripple/consensus/Consensus.h>
33 #include <ripple/core/JobQueue.h>
34 #include <ripple/overlay/Message.h>
35 #include <ripple/protocol/RippleLedgerHash.h>
36 #include <ripple/protocol/STValidation.h>
37 #include <ripple/shamap/SHAMap.h>
43 class InboundTransactions;
351 protocol::NodeEvent ne,
353 bool haveCorrectLCL);
394 bool closeTimeCorrect,
RCLCxLedger::ID prevLedgerID() const
ConsensusPhase phase() const
std::atomic< std::chrono::milliseconds > prevRoundTime_
A peer's signed, proposed position for use in RCLConsensus.
const std::uint64_t valCookie_
LedgerIndex Seq
Sequence number of a ledger.
std::chrono::milliseconds prevRoundTime() const
Json::Value getJson(bool full) const
std::atomic< ConsensusMode > mode_
std::unique_ptr< FeeVote > feeVote_
void startRound(NetClock::time_point const &now, RCLCxLedger::ID const &prevLgrId, RCLCxLedger const &prevLgr, hash_set< NodeID > const &nowUntrusted, hash_set< NodeID > const &nowTrusted)
Adjust the set of trusted validators and kick-off the next round of consensus.
base_uint< 160, detail::NodeIDTag > NodeID
NodeID is a 160-bit hash representing one node.
std::optional< RCLCxLedger > acquireLedger(LedgerHash const &hash)
Attempt to acquire a specific ledger.
Consensus< Adaptor > consensus_
bool preStartRound(RCLCxLedger const &prevLedger, hash_set< NodeID > const &nowTrusted)
Called before kicking off a new consensus round.
std::recursive_mutex mutex_
bool hasOpenTransactions() const
Whether the open ledger has any transactions.
Generic implementation of consensus algorithm.
void gotTxSet(NetClock::time_point const &now, RCLTxSet const &txSet)
uint256 getPrevLedger(uint256 ledgerID, RCLCxLedger const &ledger, ConsensusMode mode)
Get the ID of the previous ledger/last closed ledger(LCL) on the network.
void timerEntry(NetClock::time_point const &now)
NegativeUNLVote nUnlVote_
Result onClose(RCLCxLedger const &ledger, NetClock::time_point const &closeTime, ConsensusMode mode)
Close the open ledger and return initial consensus position.
Encapsulates the result of consensus.
ConsensusParms const & parms() const
Consensus simulation parameters.
Validator keys and manifest as set in configuration file.
Holds transactions which were deferred to the next pass of consensus.
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.
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.
void simulate(NetClock::time_point const &now, std::optional< std::chrono::milliseconds > consensusDelay)
void onAccept(Result const &result, RCLCxLedger const &prevLedger, NetClock::duration const &closeResolution, ConsensusCloseTimes const &rawCloseTimes, ConsensusMode const &mode, Json::Value &&consensusJson)
Process the accepted ledger.
@ observing
We are observing peer positions, but not proposing our position.
void updateOperatingMode(std::size_t const positions) const
Update operating mode based on current peer positions.
Manages the generic consensus algorithm for use by the RCL.
bool haveValidated() const
std::size_t prevProposers() const
std::size_t laggards(Ledger_t::Seq const seq, hash_set< NodeKey_t > &trustedKeys) const
void share(RCLCxPeerPos const &peerPos)
Share the given proposal with all peers.
bool peerProposal(NetClock::time_point const &now, RCLCxPeerPos const &newProposal)
Represents a set of transactions in RCLConsensus.
void validate(RCLCxLedger const &ledger, RCLTxSet const &txns, bool proposing)
Validate the given ledger and share with peers as necessary.
ConsensusMode mode() const
ConsensusPhase
Phases of consensus for a single ledger round.
Adaptor(Application &app, std::unique_ptr< FeeVote > &&feeVote, LedgerMaster &ledgerMaster, LocalTxs &localTxs, InboundTransactions &inboundTransactions, ValidatorKeys const &validatorKeys, beast::Journal journal)
ConsensusMode mode() const
A generic endpoint for log messages.
RCLCensorshipDetector< TxID, LedgerIndex > censorshipDetector_
void notify(protocol::NodeEvent ne, RCLCxLedger const &ledger, bool haveCorrectLCL)
Notify peers of a consensus state change.
bool validator() const
Whether I am a validator.
ConsensusParms const & parms() const
std::optional< RCLTxSet > acquireTxSet(RCLTxSet::ID const &setId)
Acquire the transaction set associated with a proposal.
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.
constexpr static unsigned int censorshipWarnInternal
Warn for transactions that haven't been included every so many ledgers.
void onModeChange(ConsensusMode before, ConsensusMode after)
Notified of change in consensus mode.
Represents a ledger in RCLConsensus.
RCLConsensus & operator=(RCLConsensus const &)=delete
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::chrono::milliseconds prevRoundTime() const
Get duration of the previous round.
ConsensusMode
Represents how a node currently participates in Consensus.
LedgerIndex getValidLedgerIndex() const
Consensus algorithm parameters.
LedgerHash acquiringLedger_
std::atomic< bool > validating_
std::size_t prevProposers() const
Get the number of proposing peers that participated in the previous round.
LedgerMaster & ledgerMaster_
std::size_t proposersValidated(LedgerHash const &h) const
Number of proposers that have validated the given ledger.
static bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Manager to create NegativeUNL votes.
InboundTransactions & inboundTransactions_
bool validating() const
Whether we are validating consensus ledgers.
Represents a transaction in RCLConsensus.
void propose(RCLCxPeerPos::Proposal const &proposal)
Propose the given position to my peers.
NetClock::time_point lastValidationTime_
std::size_t proposersFinished(RCLCxLedger const &ledger, LedgerHash const &h) const
Number of proposers that have validated a ledger descended from requested ledger.
std::atomic< std::size_t > prevProposers_
ValidatorKeys const & validatorKeys_
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::pair< std::size_t, hash_set< NodeKey_t > > getQuorumKeys() const
Stores the set of initial close times.
Manages the acquisition and lifetime of transaction sets.