Kagome
Polkadot Runtime Engine in C++17
kagome::consensus::grandpa::VotingRound Class Referenceabstract

#include <voting_round.hpp>

Inheritance diagram for kagome::consensus::grandpa::VotingRound:
Collaboration diagram for kagome::consensus::grandpa::VotingRound:

Public Types

enum  Propagation : bool { Propagation::NEEDLESS = false, Propagation::REQUESTED = true }
 
using IsPreviousRoundChanged = Tagged< bool, struct IsPreviousRoundChanged >
 
using IsPrevotesChanged = Tagged< bool, struct IsPrevotesChanged >
 
using IsPrecommitsChanged = Tagged< bool, struct IsPrecommitsChanged >
 

Public Member Functions

virtual ~VotingRound ()=default
 
virtual RoundNumber roundNumber () const =0
 
virtual VoterSetId voterSetId () const =0
 
virtual bool completable () const =0
 
virtual BlockInfo lastFinalizedBlock () const =0
 
virtual BlockInfo bestPrevoteCandidate ()=0
 
virtual BlockInfo bestFinalCandidate ()=0
 
virtual const std::optional< BlockInfo > & finalizedBlock () const =0
 
virtual MovableRoundState state () const =0
 
virtual void play ()=0
 
virtual void end ()=0
 
virtual void doProposal ()=0
 
virtual void doPrevote ()=0
 Calculate prevote and broadcast signed prevote message. More...
 
virtual void doPrecommit ()=0
 Calculate precommit and broadcast signed precommit message. More...
 
virtual void doFinalize ()=0
 Collect and save justifications finalizing this round. More...
 
virtual void doCommit ()=0
 Broadcast commit message. More...
 
virtual void doCatchUpResponse (const libp2p::peer::PeerId &peer_id)=0
 
virtual void onProposal (const SignedMessage &primary_propose, Propagation propagation)=0
 
virtual bool onPrevote (const SignedMessage &prevote, Propagation propagation)=0
 
virtual bool onPrecommit (const SignedMessage &precommit, Propagation propagation)=0
 
virtual void update (IsPreviousRoundChanged is_previous_round_changed, IsPrevotesChanged is_prevotes_changed, IsPrecommitsChanged is_precommits_changed)=0
 
virtual std::shared_ptr< VotingRoundgetPreviousRound () const =0
 
virtual void forgetPreviousRound ()=0
 
virtual outcome::result< void > applyJustification (const BlockInfo &block_info, const GrandpaJustification &justification)=0
 
virtual void attemptToFinalizeRound ()=0
 executes algorithm Attempt-To-Finalize-Round More...
 

Detailed Description

Handles execution of one grandpa round. For details

See also
VotingRoundImpl

Definition at line 18 of file voting_round.hpp.

Member Typedef Documentation

Member Enumeration Documentation

Enumerator
NEEDLESS 
REQUESTED 

Definition at line 77 of file voting_round.hpp.

Constructor & Destructor Documentation

virtual kagome::consensus::grandpa::VotingRound::~VotingRound ( )
virtualdefault

Member Function Documentation

virtual outcome::result<void> kagome::consensus::grandpa::VotingRound::applyJustification ( const BlockInfo block_info,
const GrandpaJustification justification 
)
pure virtual
virtual void kagome::consensus::grandpa::VotingRound::attemptToFinalizeRound ( )
pure virtual

executes algorithm Attempt-To-Finalize-Round

Implemented in kagome::consensus::grandpa::VotingRoundImpl.

virtual BlockInfo kagome::consensus::grandpa::VotingRound::bestFinalCandidate ( )
pure virtual
virtual BlockInfo kagome::consensus::grandpa::VotingRound::bestPrevoteCandidate ( )
pure virtual
virtual bool kagome::consensus::grandpa::VotingRound::completable ( ) const
pure virtual
virtual void kagome::consensus::grandpa::VotingRound::doCatchUpResponse ( const libp2p::peer::PeerId &  peer_id)
pure virtual

Make Catch-Up-Response based on current round and send to requesting peer

Implemented in kagome::consensus::grandpa::VotingRoundImpl.

virtual void kagome::consensus::grandpa::VotingRound::doCommit ( )
pure virtual

Broadcast commit message.

Implemented in kagome::consensus::grandpa::VotingRoundImpl.

virtual void kagome::consensus::grandpa::VotingRound::doFinalize ( )
pure virtual

Collect and save justifications finalizing this round.

Implemented in kagome::consensus::grandpa::VotingRoundImpl.

virtual void kagome::consensus::grandpa::VotingRound::doPrecommit ( )
pure virtual

Calculate precommit and broadcast signed precommit message.

Implemented in kagome::consensus::grandpa::VotingRoundImpl.

virtual void kagome::consensus::grandpa::VotingRound::doPrevote ( )
pure virtual

Calculate prevote and broadcast signed prevote message.

Implemented in kagome::consensus::grandpa::VotingRoundImpl.

virtual void kagome::consensus::grandpa::VotingRound::doProposal ( )
pure virtual

During the primary propose we:

  1. Check if we are the primary for the current round. If not execution of the method is finished
  2. We can send primary propose only if the estimate from last round state is greater than finalized. If we cannot send propose, method is finished
  3. Primary propose is the last rounds estimate.
  4. After all steps above are done we broadcast propose
  5. We store what we have broadcasted in primary_vote_ field

Implemented in kagome::consensus::grandpa::VotingRoundImpl.

virtual void kagome::consensus::grandpa::VotingRound::end ( )
pure virtual
virtual const std::optional<BlockInfo>& kagome::consensus::grandpa::VotingRound::finalizedBlock ( ) const
pure virtual
virtual void kagome::consensus::grandpa::VotingRound::forgetPreviousRound ( )
pure virtual

Removes previous round to limit chain of rounds

Implemented in kagome::consensus::grandpa::VotingRoundImpl.

virtual std::shared_ptr<VotingRound> kagome::consensus::grandpa::VotingRound::getPreviousRound ( ) const
pure virtual
Returns
previous known round for current

Implemented in kagome::consensus::grandpa::VotingRoundImpl.

virtual BlockInfo kagome::consensus::grandpa::VotingRound::lastFinalizedBlock ( ) const
pure virtual
virtual bool kagome::consensus::grandpa::VotingRound::onPrecommit ( const SignedMessage precommit,
Propagation  propagation 
)
pure virtual
virtual bool kagome::consensus::grandpa::VotingRound::onPrevote ( const SignedMessage prevote,
Propagation  propagation 
)
pure virtual
virtual void kagome::consensus::grandpa::VotingRound::onProposal ( const SignedMessage primary_propose,
Propagation  propagation 
)
pure virtual
virtual void kagome::consensus::grandpa::VotingRound::play ( )
pure virtual
virtual RoundNumber kagome::consensus::grandpa::VotingRound::roundNumber ( ) const
pure virtual
virtual MovableRoundState kagome::consensus::grandpa::VotingRound::state ( ) const
pure virtual
virtual void kagome::consensus::grandpa::VotingRound::update ( IsPreviousRoundChanged  is_previous_round_changed,
IsPrevotesChanged  is_prevotes_changed,
IsPrecommitsChanged  is_precommits_changed 
)
pure virtual

Updates inner state if something (see params) was changed since last call

Parameters
is_previous_round_changedis true if previous round is changed
is_prevotes_changedis true if new prevote was accepted
is_precommits_changedis true if new precommits was accepted
Returns
true if finalized block was changed during update

Implemented in kagome::consensus::grandpa::VotingRoundImpl.

virtual VoterSetId kagome::consensus::grandpa::VotingRound::voterSetId ( ) const
pure virtual

The documentation for this class was generated from the following file: