Kagome
Polkadot Runtime Engine in C++17
kagome::consensus::grandpa::EnvironmentImpl Class Reference

#include <environment_impl.hpp>

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

Public Member Functions

 EnvironmentImpl (std::shared_ptr< blockchain::BlockTree > block_tree, std::shared_ptr< blockchain::BlockHeaderRepository > header_repository, std::shared_ptr< authority::AuthorityManager > authority_manager, std::shared_ptr< network::GrandpaTransmitter > transmitter)
 
 ~EnvironmentImpl () override=default
 
void setJustificationObserver (std::weak_ptr< JustificationObserver > justification_observer) override
 
outcome::result< bool > hasBlock (const primitives::BlockHash &block) const override
 Checks if {. More...
 
outcome::result< std::vector< primitives::BlockHash > > getAncestry (const primitives::BlockHash &base, const primitives::BlockHash &block) const override
 Get the ancestry of a {. More...
 
bool hasAncestry (const primitives::BlockHash &base, const primitives::BlockHash &block) const override
 Check if block is ancestor for second one. More...
 
outcome::result< BlockInfobestChainContaining (const primitives::BlockHash &base, std::optional< VoterSetId > voter_set_id) const override
 
outcome::result< void > onCatchUpRequested (const libp2p::peer::PeerId &peer_id, VoterSetId set_id, RoundNumber round_number) override
 
outcome::result< void > onCatchUpRespond (const libp2p::peer::PeerId &peer_id, VoterSetId set_id, RoundNumber round_number, std::vector< SignedPrevote > prevote_justification, std::vector< SignedPrecommit > precommit_justification, BlockInfo best_final_candidate) override
 
void sendState (const libp2p::peer::PeerId &peer_id, const MovableRoundState &state, VoterSetId voter_set_id) override
 
outcome::result< void > onVoted (RoundNumber round, VoterSetId set_id, const SignedMessage &vote) override
 
outcome::result< void > onCommitted (RoundNumber round, VoterSetId voter_ser_id, const BlockInfo &vote, const GrandpaJustification &justification) override
 
outcome::result< void > onNeighborMessageSent (RoundNumber round, VoterSetId set_id, BlockNumber last_finalized) override
 
outcome::result< void > applyJustification (const BlockInfo &block_info, const primitives::Justification &justification) override
 
outcome::result< void > finalize (VoterSetId id, const GrandpaJustification &justification) override
 
outcome::result< GrandpaJustificationgetJustification (const BlockHash &block_hash) override
 
- Public Member Functions inherited from kagome::consensus::grandpa::Environment
 ~Environment () override=default
 
- Public Member Functions inherited from kagome::consensus::grandpa::Chain
virtual ~Chain ()=default
 
bool isEqualOrDescendOf (const primitives::BlockHash &base, const primitives::BlockHash &block) const
 

Private Attributes

std::shared_ptr< blockchain::BlockTreeblock_tree_
 
std::shared_ptr< blockchain::BlockHeaderRepositoryheader_repository_
 
std::shared_ptr< authority::AuthorityManagerauthority_manager_
 
std::shared_ptr< network::GrandpaTransmittertransmitter_
 
std::weak_ptr< JustificationObserverjustification_observer_
 
log::Logger logger_
 

Additional Inherited Members

- Public Types inherited from kagome::consensus::grandpa::Environment
using CompleteHandler = std::function< void(outcome::result< MovableRoundState >)>
 

Detailed Description

Definition at line 20 of file environment_impl.hpp.

Constructor & Destructor Documentation

kagome::consensus::grandpa::EnvironmentImpl::EnvironmentImpl ( std::shared_ptr< blockchain::BlockTree block_tree,
std::shared_ptr< blockchain::BlockHeaderRepository header_repository,
std::shared_ptr< authority::AuthorityManager authority_manager,
std::shared_ptr< network::GrandpaTransmitter transmitter 
)

Definition at line 25 of file environment_impl.cpp.

kagome::consensus::grandpa::EnvironmentImpl::~EnvironmentImpl ( )
overridedefault

Member Function Documentation

outcome::result< void > kagome::consensus::grandpa::EnvironmentImpl::applyJustification ( const BlockInfo block_info,
const primitives::Justification justification 
)
overridevirtual

Validate provided {

Parameters
justification}for finalization {
block}.If it valid finalize {
block}and save {
justification}in storage.
blockis observed block info
justificationjustification of finalization of provided block
Returns
nothing or on error

Implements kagome::consensus::grandpa::Environment.

Definition at line 211 of file environment_impl.cpp.

outcome::result< BlockInfo > kagome::consensus::grandpa::EnvironmentImpl::bestChainContaining ( const primitives::BlockHash base,
std::optional< VoterSetId voter_set_id 
) const
overridevirtual
Returns
the hash of the best block whose chain contains the given block hash, even if that block is {
Parameters
base}itself. If base is unknown, return None.

Implements kagome::consensus::grandpa::Chain.

Definition at line 63 of file environment_impl.cpp.

outcome::result< void > kagome::consensus::grandpa::EnvironmentImpl::finalize ( VoterSetId  id,
const GrandpaJustification justification 
)
overridevirtual

Triggered when blovk

Parameters
blockjustified by
justificationshould be applied to the storage

Implements kagome::consensus::grandpa::Environment.

Definition at line 232 of file environment_impl.cpp.

outcome::result< std::vector< BlockHash > > kagome::consensus::grandpa::EnvironmentImpl::getAncestry ( const primitives::BlockHash base,
const primitives::BlockHash block 
) const
overridevirtual

Get the ancestry of a {.

Parameters
block}up to the {
base}hash. Should be in reverse order from block's parent.
Returns
If the block is not a descendant of base, returns an error.

Implements kagome::consensus::grandpa::Chain.

Definition at line 46 of file environment_impl.cpp.

outcome::result< GrandpaJustification > kagome::consensus::grandpa::EnvironmentImpl::getJustification ( const BlockHash block_hash)
overridevirtual

Returns justification for given block

Parameters
block_hashhash of the block that we are trying to get justification for
Returns
GrandpaJustification containing signed precommits for given block if there is such justification. Error otherwise

Implements kagome::consensus::grandpa::Environment.

Definition at line 243 of file environment_impl.cpp.

bool kagome::consensus::grandpa::EnvironmentImpl::hasAncestry ( const primitives::BlockHash base,
const primitives::BlockHash block 
) const
overridevirtual

Check if block is ancestor for second one.

Parameters
baseis potential ancestor
blockis testee block
Returns
true, if
Parameters
baseis ancestor for
block

Implements kagome::consensus::grandpa::Chain.

Definition at line 58 of file environment_impl.cpp.

outcome::result< bool > kagome::consensus::grandpa::EnvironmentImpl::hasBlock ( const primitives::BlockHash block) const
overridevirtual

Checks if {.

Parameters
block}exists locally
Returns
true iff block exists

Implements kagome::consensus::grandpa::Chain.

Definition at line 41 of file environment_impl.cpp.

outcome::result< void > kagome::consensus::grandpa::EnvironmentImpl::onCatchUpRequested ( const libp2p::peer::PeerId &  peer_id,
VoterSetId  set_id,
RoundNumber  round_number 
)
overridevirtual

Make catch-up-request

Implements kagome::consensus::grandpa::Environment.

Definition at line 93 of file environment_impl.cpp.

outcome::result< void > kagome::consensus::grandpa::EnvironmentImpl::onCatchUpRespond ( const libp2p::peer::PeerId &  peer_id,
VoterSetId  set_id,
RoundNumber  round_number,
std::vector< SignedPrevote prevote_justification,
std::vector< SignedPrecommit precommit_justification,
BlockInfo  best_final_candidate 
)
overridevirtual

Make catch-up-response

Implements kagome::consensus::grandpa::Environment.

Definition at line 103 of file environment_impl.cpp.

outcome::result< void > kagome::consensus::grandpa::EnvironmentImpl::onCommitted ( RoundNumber  round,
VoterSetId  voter_ser_id,
const BlockInfo vote,
const GrandpaJustification justification 
)
overridevirtual

Triggered when current peer appears in given round and has given voter_ser_id intends to send committed vote justified by provided justification

Implements kagome::consensus::grandpa::Environment.

Definition at line 173 of file environment_impl.cpp.

outcome::result< void > kagome::consensus::grandpa::EnvironmentImpl::onNeighborMessageSent ( RoundNumber  round,
VoterSetId  set_id,
BlockNumber  last_finalized 
)
overridevirtual

Triggered when current peer should send neighbor message

Parameters
roundcurrent round
set_idid of actual voter set
last_finalizedlast known finalized block

Implements kagome::consensus::grandpa::Environment.

Definition at line 199 of file environment_impl.cpp.

outcome::result< void > kagome::consensus::grandpa::EnvironmentImpl::onVoted ( RoundNumber  round,
VoterSetId  set_id,
const SignedMessage vote 
)
overridevirtual

Note that we've done a vote in the given round. Triggered when current peer appears in provided round with provided set_id and given vote is ready to be sent.

Implements kagome::consensus::grandpa::Environment.

Definition at line 121 of file environment_impl.cpp.

void kagome::consensus::grandpa::EnvironmentImpl::sendState ( const libp2p::peer::PeerId &  peer_id,
const MovableRoundState state,
VoterSetId  voter_set_id 
)
overridevirtual

Propagate round state

Implements kagome::consensus::grandpa::Environment.

Definition at line 141 of file environment_impl.cpp.

void kagome::consensus::grandpa::EnvironmentImpl::setJustificationObserver ( std::weak_ptr< JustificationObserver justification_observer)
inlineoverridevirtual

Sets back-link to Grandpa

Implements kagome::consensus::grandpa::Environment.

Definition at line 32 of file environment_impl.hpp.

Member Data Documentation

std::shared_ptr<authority::AuthorityManager> kagome::consensus::grandpa::EnvironmentImpl::authority_manager_
private

Definition at line 104 of file environment_impl.hpp.

std::shared_ptr<blockchain::BlockTree> kagome::consensus::grandpa::EnvironmentImpl::block_tree_
private

Definition at line 102 of file environment_impl.hpp.

std::shared_ptr<blockchain::BlockHeaderRepository> kagome::consensus::grandpa::EnvironmentImpl::header_repository_
private

Definition at line 103 of file environment_impl.hpp.

std::weak_ptr<JustificationObserver> kagome::consensus::grandpa::EnvironmentImpl::justification_observer_
private

Definition at line 106 of file environment_impl.hpp.

log::Logger kagome::consensus::grandpa::EnvironmentImpl::logger_
private

Definition at line 108 of file environment_impl.hpp.

std::shared_ptr<network::GrandpaTransmitter> kagome::consensus::grandpa::EnvironmentImpl::transmitter_
private

Definition at line 105 of file environment_impl.hpp.


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