Kagome
Polkadot Runtime Engine in C++17
grandpa_message.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_NETWORK_GRANDPAMESSAGE
7 #define KAGOME_NETWORK_GRANDPAMESSAGE
8 
9 #include <boost/variant.hpp>
10 
13 #include "scale/tie.hpp"
14 
15 namespace kagome::network {
16 
18  using consensus::grandpa::CompactCommit;
19  using consensus::grandpa::GrandpaJustification;
21  using consensus::grandpa::SignedMessage;
22  using consensus::grandpa::SignedPrecommit;
23  using consensus::grandpa::SignedPrevote;
24  using consensus::grandpa::VoteMessage;
27 
28  struct GrandpaVote : public VoteMessage {
29  using VoteMessage::VoteMessage;
30  explicit GrandpaVote(VoteMessage &&vm) noexcept
31  : VoteMessage(std::move(vm)){};
32  };
33 
34  // Network level commit message with topic information.
35  // @See
36  // https://github.com/paritytech/substrate/blob/polkadot-v0.9.7/client/finality-grandpa/src/communication/gossip.rs#L350
38  SCALE_TIE(3);
39 
40  // The round this message is from.
41  RoundNumber round{0};
42  // The voter set ID this message is from.
44  // The compact commit message.
45  CompactCommit message;
46  };
47 
49  SCALE_TIE(4);
50 
51  uint8_t version = 1;
55  };
56 
57  struct CatchUpRequest {
58  SCALE_TIE(2);
59 
62 
63  using Fingerprint = size_t;
64 
65  inline Fingerprint fingerprint() const {
66  auto result = std::hash<RoundNumber>()(round_number);
67 
68  boost::hash_combine(result, std::hash<VoterSetId>()(voter_set_id));
69  return result;
70  };
71  };
72 
73  struct CatchUpResponse {
74  SCALE_TIE(5);
75 
76  VoterSetId voter_set_id{};
77  RoundNumber round_number{};
78  std::vector<SignedPrevote> prevote_justification;
79  std::vector<SignedPrecommit> precommit_justification;
81  };
82 
83  // @See
84  // https://github.com/paritytech/substrate/blob/polkadot-v0.9.7/client/finality-grandpa/src/communication/gossip.rs#L318
85  using GrandpaMessage =
87  boost::variant<GrandpaVote, // 0
88  FullCommitMessage, // 1
90  CatchUpRequest, // 3
92 
93 } // namespace kagome::network
94 
95 #endif // KAGOME_NETWORK_GRANDPAMESSAGE
boost::variant< GrandpaVote, FullCommitMessage, GrandpaNeighborMessage, CatchUpRequest, CatchUpResponse > GrandpaMessage
STL namespace.
std::vector< SignedPrevote > prevote_justification
#define SCALE_TIE(N)
Definition: tie.hpp:11
primitives::BlockInfo BlockInfo
Definition: structs.hpp:29
string version
Definition: conf.py:16
uint32_t BlockNumber
Definition: common.hpp:18
Fingerprint fingerprint() const
primitives::BlockNumber BlockNumber
Definition: common.hpp:24
std::vector< SignedPrecommit > precommit_justification
GrandpaVote(VoteMessage &&vm) noexcept