6 #ifndef KAGOME_CONSENSUS_GRANDPA_GRANDPAIMPL 7 #define KAGOME_CONSENSUS_GRANDPA_GRANDPAIMPL 12 #include <boost/operators.hpp> 59 public std::enable_shared_from_this<GrandpaImpl> {
70 std::chrono::milliseconds(45
'000); 72 ~GrandpaImpl() override = default; 75 std::shared_ptr<application::AppStateManager> app_state_manager, 76 std::shared_ptr<Environment> environment, 77 std::shared_ptr<crypto::Ed25519Provider> crypto_provider, 78 std::shared_ptr<runtime::GrandpaApi> grandpa_api, 79 const std::shared_ptr<crypto::Ed25519Keypair> &keypair, 80 const application::ChainSpec &chain_spec, 81 std::shared_ptr<Clock> clock, 82 std::shared_ptr<libp2p::basic::Scheduler> scheduler, 83 std::shared_ptr<authority::AuthorityManager> authority_manager, 84 std::shared_ptr<network::Synchronizer> synchronizer, 85 std::shared_ptr<network::PeerManager> peer_manager, 86 std::shared_ptr<blockchain::BlockTree> block_tree, 87 std::shared_ptr<network::ReputationRepository> reputation_repository); 125 void onNeighborMessage(const libp2p::peer::PeerId &peer_id, 126 const network::GrandpaNeighborMessage &msg) override; 140 void onCatchUpRequest(const libp2p::peer::PeerId &peer_id, 141 const network::CatchUpRequest &msg) override; 156 void onCatchUpResponse(const libp2p::peer::PeerId &peer_id, 157 const network::CatchUpResponse &msg) override; 171 void onVoteMessage(const libp2p::peer::PeerId &peer_id, 172 const network::VoteMessage &msg) override; 183 void onCommitMessage(const libp2p::peer::PeerId &peer_id, 184 const network::FullCommitMessage &msg) override; 196 outcome::result<void> applyJustification( 197 const BlockInfo &block_info, 198 const GrandpaJustification &justification) override; 200 // Round processing method 210 void tryExecuteNextRound( 211 const std::shared_ptr<VotingRound> &round) override; 219 void updateNextRound(RoundNumber round_number) override; 229 std::optional<std::shared_ptr<VotingRound>> selectRound( 230 RoundNumber round_number, std::optional<VoterSetId> voter_set_id); 235 outcome::result<MovableRoundState> getLastCompletedRound() const; 245 std::shared_ptr<VotingRound> makeInitialRound( 246 const MovableRoundState &round_state, std::shared_ptr<VoterSet> voters); 253 std::shared_ptr<VotingRound> makeNextRound( 254 const std::shared_ptr<VotingRound> &previous_round); 260 void loadMissingBlocks(); 262 const Clock::Duration round_time_factor_; 264 std::shared_ptr<Environment> environment_; 265 std::shared_ptr<crypto::Ed25519Provider> crypto_provider_; 266 std::shared_ptr<runtime::GrandpaApi> grandpa_api_; 267 const std::shared_ptr<crypto::Ed25519Keypair> &keypair_; 268 std::shared_ptr<Clock> clock_; 269 std::shared_ptr<libp2p::basic::Scheduler> scheduler_; 270 std::shared_ptr<authority::AuthorityManager> authority_manager_; 271 std::shared_ptr<network::Synchronizer> synchronizer_; 272 std::shared_ptr<network::PeerManager> peer_manager_; 273 std::shared_ptr<blockchain::BlockTree> block_tree_; 274 std::shared_ptr<network::ReputationRepository> reputation_repository_; 276 std::shared_ptr<VotingRound> current_round_; 278 const std::tuple<libp2p::peer::PeerId, network::CatchUpRequest>> 279 pending_catchup_request_; 280 libp2p::basic::Scheduler::Handle catchup_request_timer_handle_; 281 libp2p::basic::Scheduler::Handle fallback_timer_handle_; 284 metrics::RegistryPtr metrics_registry_ = metrics::createRegistry(); 285 metrics::Gauge *metric_highest_round_; 287 log::Logger logger_ = log::createLogger("Grandpa", "grandpa"); 290 } // namespace kagome::consensus::grandpa 292 #endif // KAGOME_CONSENSUS_GRANDPA_GRANDPAIMPL
static constexpr Clock::Duration kCatchupRequestTimeout
Timeout of waiting catchup response for request.
typename ClockType::duration Duration
static const size_t kKeepRecentRounds
Maximum number of rounds we are keep to communication.
static const size_t kCatchUpThreshold