Kagome
Polkadot Runtime Engine in C++17
|
#include <voting_round_impl.hpp>
Public Types | |
enum | Stage { Stage::INIT, Stage::START, Stage::START_PREVOTE, Stage::PREVOTE_RUNS, Stage::END_PREVOTE, Stage::START_PRECOMMIT, Stage::PRECOMMIT_RUNS, Stage::END_PRECOMMIT, Stage::START_WAITING, Stage::WAITING_RUNS, Stage::END_WAITING, Stage::COMPLETED } |
Public Types inherited from kagome::consensus::grandpa::VotingRound | |
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 | |
VotingRoundImpl (const std::shared_ptr< Grandpa > &grandpa, const GrandpaConfig &config, const std::shared_ptr< authority::AuthorityManager > authority_manager, const std::shared_ptr< Environment > &env, const std::shared_ptr< VoteCryptoProvider > &vote_crypto_provider, const std::shared_ptr< VoteTracker > &prevotes, const std::shared_ptr< VoteTracker > &precommits, const std::shared_ptr< VoteGraph > &vote_graph, const std::shared_ptr< Clock > &clock, const std::shared_ptr< libp2p::basic::Scheduler > &scheduler, const MovableRoundState &round_state) | |
VotingRoundImpl (const std::shared_ptr< Grandpa > &grandpa, const GrandpaConfig &config, const std::shared_ptr< authority::AuthorityManager > authority_manager, const std::shared_ptr< Environment > &env, const std::shared_ptr< VoteCryptoProvider > &vote_crypto_provider, const std::shared_ptr< VoteTracker > &prevotes, const std::shared_ptr< VoteTracker > &precommits, const std::shared_ptr< VoteGraph > &vote_graph, const std::shared_ptr< Clock > &clock, const std::shared_ptr< libp2p::basic::Scheduler > &scheduler, const std::shared_ptr< VotingRound > &previous_round) | |
void | play () override |
void | end () override |
void | startPrevoteStage () |
void | endPrevoteStage () |
void | startPrecommitStage () |
void | endPrecommitStage () |
void | startWaitingStage () |
void | endWaitingStage () |
void | doProposal () override |
void | doPrevote () override |
Calculate prevote and broadcast signed prevote message. More... | |
void | doPrecommit () override |
Calculate precommit and broadcast signed precommit message. More... | |
void | doFinalize () override |
Collect and save justifications finalizing this round. More... | |
void | doCommit () override |
Broadcast commit message. More... | |
outcome::result< void > | applyJustification (const BlockInfo &block_info, const GrandpaJustification &justification) override |
void | onProposal (const SignedMessage &proposal, Propagation propagation) override |
bool | onPrevote (const SignedMessage &prevote, Propagation propagation) override |
bool | onPrecommit (const SignedMessage &precommit, Propagation propagation) override |
void | update (IsPreviousRoundChanged is_previous_round_changed, IsPrevotesChanged is_prevotes_changed, IsPrecommitsChanged is_precommits_changed) override |
std::shared_ptr< VotingRound > | getPreviousRound () const override |
void | forgetPreviousRound () override |
void | attemptToFinalizeRound () override |
void | doCatchUpResponse (const libp2p::peer::PeerId &peer_id) override |
RoundNumber | roundNumber () const override |
VoterSetId | voterSetId () const override |
bool | completable () const override |
BlockInfo | lastFinalizedBlock () const override |
BlockInfo | bestPrevoteCandidate () override |
BlockInfo | bestFinalCandidate () override |
const std::optional< BlockInfo > & | finalizedBlock () const override |
MovableRoundState | state () const override |
void | sendNeighborMessage () |
Public Member Functions inherited from kagome::consensus::grandpa::VotingRound | |
virtual | ~VotingRound ()=default |
Protected Member Functions | |
VotingRoundImpl () | |
Private Member Functions | |
VotingRoundImpl (const std::shared_ptr< Grandpa > &grandpa, const GrandpaConfig &config, std::shared_ptr< authority::AuthorityManager > authority_manager, std::shared_ptr< Environment > env, std::shared_ptr< VoteCryptoProvider > vote_crypto_provider, std::shared_ptr< VoteTracker > prevotes, std::shared_ptr< VoteTracker > precommits, std::shared_ptr< VoteGraph > vote_graph, std::shared_ptr< Clock > clock, std::shared_ptr< libp2p::basic::Scheduler > scheduler) | |
bool | isPrimary (const Id &id) const |
Check if peer. More... | |
template<typename T > | |
outcome::result< void > | onSigned (const SignedMessage &vote) |
Triggered when we receive {. More... | |
bool | updateGrandpaGhost () |
bool | updateEstimate () |
std::vector< SignedPrevote > | getPrevoteJustification (const BlockInfo &estimate, const std::vector< VoteVariant > &votes) const |
std::vector< SignedPrecommit > | getPrecommitJustification (const BlockInfo &precommits, const std::vector< VoteVariant > &votes) const |
outcome::result< void > | validatePrecommitJustification (const BlockInfo &vote, const GrandpaJustification &justification) const |
void | sendProposal (const PrimaryPropose &primary_proposal) |
void | sendPrevote (const Prevote &prevote) |
void | sendPrecommit (const Precommit &precommit) |
void | pending () |
Private Attributes | |
std::shared_ptr< VoterSet > | voter_set_ |
const RoundNumber | round_number_ |
std::shared_ptr< VotingRound > | previous_round_ |
const Duration | duration_ |
bool | isPrimary_ = false |
size_t | threshold_ |
const std::optional< Id > | id_ |
std::chrono::milliseconds | start_time_ |
std::weak_ptr< Grandpa > | grandpa_ |
std::shared_ptr< authority::AuthorityManager > | authority_manager_ |
std::shared_ptr< const primitives::AuthorityList > | authorities_ |
std::shared_ptr< Environment > | env_ |
std::shared_ptr< VoteCryptoProvider > | vote_crypto_provider_ |
std::shared_ptr< VoteGraph > | graph_ |
std::shared_ptr< Clock > | clock_ |
std::shared_ptr< libp2p::basic::Scheduler > | scheduler_ |
std::function< void()> | on_complete_handler_ |
const std::chrono::milliseconds | pending_interval_ |
Stage | stage_ = Stage::INIT |
std::shared_ptr< VoteTracker > | prevotes_ |
std::shared_ptr< VoteTracker > | precommits_ |
std::vector< bool > | prevote_equivocators_ |
std::vector< bool > | precommit_equivocators_ |
std::optional< BlockInfo > | primary_vote_ |
std::optional< BlockInfo > | prevote_ |
std::optional< BlockInfo > | precommit_ |
BlockInfo | last_finalized_block_ |
std::optional< BlockInfo > | prevote_ghost_ |
std::optional< BlockInfo > | estimate_ |
std::optional< BlockInfo > | finalized_ |
libp2p::basic::Scheduler::Handle | stage_timer_handle_ |
libp2p::basic::Scheduler::Handle | pending_timer_handle_ |
log::Logger | logger_ = log::createLogger("VotingRound", "voting_round") |
bool | completable_ = false |
Definition at line 29 of file voting_round_impl.hpp.
Enumerator | |
---|---|
INIT | |
START | |
START_PREVOTE | |
PREVOTE_RUNS | |
END_PREVOTE | |
START_PRECOMMIT | |
PRECOMMIT_RUNS | |
END_PRECOMMIT | |
START_WAITING | |
WAITING_RUNS | |
END_WAITING | |
COMPLETED |
Definition at line 74 of file voting_round_impl.hpp.
|
private |
Definition at line 45 of file voting_round_impl.cpp.
|
inlineprotected |
Definition at line 45 of file voting_round_impl.hpp.
kagome::consensus::grandpa::VotingRoundImpl::VotingRoundImpl | ( | const std::shared_ptr< Grandpa > & | grandpa, |
const GrandpaConfig & | config, | ||
const std::shared_ptr< authority::AuthorityManager > | authority_manager, | ||
const std::shared_ptr< Environment > & | env, | ||
const std::shared_ptr< VoteCryptoProvider > & | vote_crypto_provider, | ||
const std::shared_ptr< VoteTracker > & | prevotes, | ||
const std::shared_ptr< VoteTracker > & | precommits, | ||
const std::shared_ptr< VoteGraph > & | vote_graph, | ||
const std::shared_ptr< Clock > & | clock, | ||
const std::shared_ptr< libp2p::basic::Scheduler > & | scheduler, | ||
const MovableRoundState & | round_state | ||
) |
Definition at line 123 of file voting_round_impl.cpp.
kagome::consensus::grandpa::VotingRoundImpl::VotingRoundImpl | ( | const std::shared_ptr< Grandpa > & | grandpa, |
const GrandpaConfig & | config, | ||
const std::shared_ptr< authority::AuthorityManager > | authority_manager, | ||
const std::shared_ptr< Environment > & | env, | ||
const std::shared_ptr< VoteCryptoProvider > & | vote_crypto_provider, | ||
const std::shared_ptr< VoteTracker > & | prevotes, | ||
const std::shared_ptr< VoteTracker > & | precommits, | ||
const std::shared_ptr< VoteGraph > & | vote_graph, | ||
const std::shared_ptr< Clock > & | clock, | ||
const std::shared_ptr< libp2p::basic::Scheduler > & | scheduler, | ||
const std::shared_ptr< VotingRound > & | previous_round | ||
) |
Definition at line 94 of file voting_round_impl.cpp.
|
overridevirtual |
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 682 of file voting_round_impl.cpp.
|
overridevirtual |
Checks if current round is completable and finalized block differs from the last round's finalized block. If so fin message is broadcasted to the network
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 838 of file voting_round_impl.cpp.
|
overridevirtual |
Block what has precommit supermajority. Should be descendant or equal of Best-PreVote-Candidate
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 1469 of file voting_round_impl.cpp.
|
overridevirtual |
Best block from descendants of previous round best-final-candidate
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 1435 of file voting_round_impl.cpp.
|
overridevirtual |
Round is completable when we have block (stored in current_state_.finalized) for which we have supermajority on both prevotes and precommits
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 1431 of file voting_round_impl.cpp.
|
overridevirtual |
Make Catch-Up-Response based on current round and send to requesting peer
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 1550 of file voting_round_impl.cpp.
|
overridevirtual |
Broadcast commit message.
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 651 of file voting_round_impl.cpp.
|
overridevirtual |
Collect and save justifications finalizing this round.
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 628 of file voting_round_impl.cpp.
|
overridevirtual |
Calculate precommit and broadcast signed precommit message.
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 571 of file voting_round_impl.cpp.
|
overridevirtual |
Calculate prevote and broadcast signed prevote message.
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 508 of file voting_round_impl.cpp.
|
overridevirtual |
During the primary propose we:
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 460 of file voting_round_impl.cpp.
|
overridevirtual |
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 450 of file voting_round_impl.cpp.
void kagome::consensus::grandpa::VotingRoundImpl::endPrecommitStage | ( | ) |
Definition at line 360 of file voting_round_impl.cpp.
void kagome::consensus::grandpa::VotingRoundImpl::endPrevoteStage | ( | ) |
Definition at line 295 of file voting_round_impl.cpp.
void kagome::consensus::grandpa::VotingRoundImpl::endWaitingStage | ( | ) |
Definition at line 434 of file voting_round_impl.cpp.
|
inlineoverridevirtual |
The block, which is being finalized during this round
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 232 of file voting_round_impl.hpp.
|
inlineoverridevirtual |
Removes previous round to limit chain of rounds
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 176 of file voting_round_impl.hpp.
|
private |
Prepare precommit justifications for provided estimate using provided votes
precommits | precommits that we need to prepare justification for |
votes | votes that correspond to provided precommits |
Definition at line 1519 of file voting_round_impl.cpp.
|
inlineoverridevirtual |
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 169 of file voting_round_impl.hpp.
|
private |
Prepare prevote justifications for provided estimate using provided votes
estimate | estimate that we need to prepare justification for |
votes | votes that correspond to provided estimate |
Definition at line 1488 of file voting_round_impl.cpp.
|
private |
|
inlineoverridevirtual |
Last finalized block
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 207 of file voting_round_impl.hpp.
|
overridevirtual |
Triggered when we receive precommit for the current round
precommit | is stored in precommit tracker and vote graph Then we try to update round state and finalize |
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 1017 of file voting_round_impl.cpp.
|
overridevirtual |
Triggered when we receive prevote for current round
prevote | is stored in prevote tracker and vote graph Then we try to update prevote ghost ( |
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 946 of file voting_round_impl.cpp.
|
overridevirtual |
Invoked when we received a primary propose for the current round Basically method just checks if received propose was produced by the primary and if so, it is stored in primary_vote_ field
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 874 of file voting_round_impl.cpp.
|
private |
Triggered when we receive {.
vote} | for the current peer |
Definition at line 1142 of file voting_round_impl.cpp.
|
private |
Definition at line 1583 of file voting_round_impl.cpp.
|
overridevirtual |
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 212 of file voting_round_impl.cpp.
|
overridevirtual |
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 866 of file voting_round_impl.cpp.
void kagome::consensus::grandpa::VotingRoundImpl::sendNeighborMessage | ( | ) |
Definition at line 1573 of file voting_round_impl.cpp.
|
private |
Definition at line 606 of file voting_round_impl.cpp.
|
private |
Definition at line 549 of file voting_round_impl.cpp.
|
private |
Definition at line 483 of file voting_round_impl.cpp.
void kagome::consensus::grandpa::VotingRoundImpl::startPrecommitStage | ( | ) |
Definition at line 314 of file voting_round_impl.cpp.
void kagome::consensus::grandpa::VotingRoundImpl::startPrevoteStage | ( | ) |
Definition at line 253 of file voting_round_impl.cpp.
void kagome::consensus::grandpa::VotingRoundImpl::startWaitingStage | ( | ) |
Definition at line 379 of file voting_round_impl.cpp.
|
overridevirtual |
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 1473 of file voting_round_impl.cpp.
|
overridevirtual |
Updates inner state if something (see params) was changed since last call
is_previous_round_changed | is true if previous round is changed |
is_prevotes_changed | is true if new prevote was accepted |
is_precommits_changed | is true if new precommits was accepted |
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 1084 of file voting_round_impl.cpp.
|
private |
Invoked during each onSingedPrecommit.
Definition at line 1278 of file voting_round_impl.cpp.
|
private |
Invoked during each onSingedPrevote. Updates current round's grandpa ghost. New grandpa-ghost is the highest block with supermajority of prevotes
Definition at line 1229 of file voting_round_impl.cpp.
|
private |
Checks if received vote has valid justification precommit
vote | - block for which justification is provided |
justification | - justification provided for checking |
Definition at line 750 of file voting_round_impl.cpp.
|
overridevirtual |
Implements kagome::consensus::grandpa::VotingRound.
Definition at line 870 of file voting_round_impl.cpp.
|
private |
Definition at line 312 of file voting_round_impl.hpp.
|
private |
Definition at line 311 of file voting_round_impl.hpp.
|
private |
Definition at line 316 of file voting_round_impl.hpp.
|
private |
Definition at line 369 of file voting_round_impl.hpp.
|
private |
Definition at line 304 of file voting_round_impl.hpp.
|
private |
Definition at line 313 of file voting_round_impl.hpp.
|
private |
Definition at line 361 of file voting_round_impl.hpp.
|
private |
Definition at line 362 of file voting_round_impl.hpp.
|
private |
Definition at line 310 of file voting_round_impl.hpp.
|
private |
Definition at line 315 of file voting_round_impl.hpp.
|
private |
Definition at line 307 of file voting_round_impl.hpp.
|
private |
Definition at line 305 of file voting_round_impl.hpp.
|
private |
Definition at line 354 of file voting_round_impl.hpp.
|
private |
Definition at line 367 of file voting_round_impl.hpp.
|
private |
Definition at line 319 of file voting_round_impl.hpp.
|
private |
Definition at line 325 of file voting_round_impl.hpp.
|
private |
Definition at line 365 of file voting_round_impl.hpp.
|
private |
Definition at line 351 of file voting_round_impl.hpp.
|
private |
Definition at line 338 of file voting_round_impl.hpp.
|
private |
Definition at line 333 of file voting_round_impl.hpp.
|
private |
Definition at line 302 of file voting_round_impl.hpp.
|
private |
Definition at line 346 of file voting_round_impl.hpp.
|
private |
Definition at line 337 of file voting_round_impl.hpp.
|
private |
Definition at line 359 of file voting_round_impl.hpp.
|
private |
Definition at line 332 of file voting_round_impl.hpp.
|
private |
Definition at line 342 of file voting_round_impl.hpp.
|
private |
Definition at line 301 of file voting_round_impl.hpp.
|
private |
Definition at line 317 of file voting_round_impl.hpp.
|
private |
Definition at line 330 of file voting_round_impl.hpp.
|
private |
Definition at line 364 of file voting_round_impl.hpp.
|
private |
Definition at line 308 of file voting_round_impl.hpp.
|
private |
Definition at line 306 of file voting_round_impl.hpp.
|
private |
Definition at line 314 of file voting_round_impl.hpp.
|
private |
Definition at line 300 of file voting_round_impl.hpp.