1#ifndef XRPL_APP_CONSENSUS_RCLCONSENSUS_H_INCLUDED 
    2#define XRPL_APP_CONSENSUS_RCLCONSENSUS_H_INCLUDED 
    4#include <xrpld/app/consensus/RCLCensorshipDetector.h> 
    5#include <xrpld/app/consensus/RCLCxLedger.h> 
    6#include <xrpld/app/consensus/RCLCxPeerPos.h> 
    7#include <xrpld/app/consensus/RCLCxTx.h> 
    8#include <xrpld/app/misc/FeeVote.h> 
    9#include <xrpld/app/misc/NegativeUNLVote.h> 
   10#include <xrpld/consensus/Consensus.h> 
   11#include <xrpld/core/JobQueue.h> 
   13#include <xrpl/beast/utility/Journal.h> 
   14#include <xrpl/protocol/RippleLedgerHash.h> 
   15#include <xrpl/shamap/SHAMap.h> 
   26class InboundTransactions;
 
  336            protocol::NodeEvent ne,
 
  338            bool haveCorrectLCL);
 
  379            bool closeTimeCorrect,
 
 
 
  536    std::chrono::steady_clock::time_point 
start_;
 
 
A generic endpoint for log messages.
 
Holds transactions which were deferred to the next pass of consensus.
 
Generic implementation of consensus algorithm.
 
Manages the acquisition and lifetime of transaction sets.
 
Manager to create NegativeUNL votes.
 
std::chrono::time_point< NetClock > time_point
 
void propose(RCLCxPeerPos::Proposal const &proposal)
Propose the given position to my peers.
 
ValidatorKeys const  & validatorKeys_
 
std::atomic< ConsensusMode > mode_
 
InboundTransactions & inboundTransactions_
 
std::atomic< std::size_t > prevProposers_
 
Result onClose(RCLCxLedger const &ledger, NetClock::time_point const &closeTime, ConsensusMode mode)
Close the open ledger and return initial consensus position.
 
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.
 
ConsensusMode mode() const
 
std::chrono::milliseconds prevRoundTime() const
 
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
 
RCLCensorshipDetector< TxID, LedgerIndex > censorshipDetector_
 
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.
 
std::unique_ptr< FeeVote > feeVote_
 
LedgerIndex getValidLedgerIndex() const
 
LedgerHash acquiringLedger_
 
std::size_t proposersFinished(RCLCxLedger const &ledger, LedgerHash const &h) const
Number of proposers that have validated a ledger descended from requested ledger.
 
NegativeUNLVote nUnlVote_
 
std::size_t prevProposers() const
 
ConsensusParms const & parms() const
Consensus simulation parameters.
 
NetClock::time_point lastValidationTime_
 
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 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::atomic< std::chrono::milliseconds > prevRoundTime_
 
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.
 
std::atomic< bool > validating_
 
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
 
Manages the generic consensus algorithm for use by the RCL.
 
RCLConsensus(RCLConsensus const &)=delete
 
void gotTxSet(NetClock::time_point const &now, RCLTxSet const &txSet)
 
std::size_t prevProposers() const
Get the number of proposing peers that participated in the previous round.
 
void simulate(NetClock::time_point const &now, std::optional< std::chrono::milliseconds > consensusDelay)
 
ConsensusPhase phase() const
 
bool validating() const
Whether we are validating consensus ledgers.
 
RCLConsensus & operator=(RCLConsensus const &)=delete
 
std::chrono::milliseconds prevRoundTime() const
Get duration of the previous round.
 
ConsensusMode mode() const
 
static constexpr unsigned int censorshipWarnInternal
Warn for transactions that haven't been included every so many ledgers.
 
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={})
 
ConsensusParms const & parms() const
 
Json::Value getJson(bool full) const
 
RCLCxLedger::ID prevLedgerID() const
 
Represents a ledger in RCLConsensus.
 
LedgerHash ID
Unique identifier of a ledger.
 
LedgerIndex Seq
Sequence number of a ledger.
 
A peer's signed, proposed position for use in RCLConsensus.
 
Represents a transaction in RCLConsensus.
 
Represents a set of transactions in RCLConsensus.
 
Collects logging information.
 
std::unique_ptr< std::stringstream > const & ss()
 
std::chrono::steady_clock::time_point start_
 
std::unique_ptr< std::stringstream > ss_
 
Validator keys and manifest as set in configuration file.
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
ConsensusMode
Represents how a node currently participates in Consensus.
 
@ proposing
We are normal participant in consensus and propose our position.
 
@ observing
We are observing peer positions, but not proposing our position.
 
base_uint< 160, detail::NodeIDTag > NodeID
NodeID is a 160-bit hash representing one node.
 
boost::outcome_v2::result< T, std::error_code > Result
 
ConsensusPhase
Phases of consensus for a single ledger round.
 
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
 
@ ledgerMaster
ledger master data for signing
 
@ proposal
proposal for signing
 
Stores the set of initial close times.
 
Consensus algorithm parameters.
 
Encapsulates the result of consensus.