Kagome
Polkadot Runtime Engine in C++17
collator_messages.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_COLLATOR_DECLARE_HPP
7 #define KAGOME_COLLATOR_DECLARE_HPP
8 
9 #include <boost/variant.hpp>
10 #include <scale/bitvec.hpp>
11 #include <tuple>
12 #include <type_traits>
13 #include <vector>
14 
15 #include "common/blob.hpp"
17 #include "crypto/hasher.hpp"
18 #include "primitives/common.hpp"
20 #include "primitives/digest.hpp"
21 #include "scale/tie.hpp"
22 #include "storage/trie/types.hpp"
23 
24 namespace kagome::network {
25  using Signature = crypto::Sr25519Signature;
26  using ParachainId = uint32_t;
27  using CollatorPublicKey = crypto::Sr25519PublicKey;
28  using ValidatorIndex = uint32_t;
33  using ChunkProof = std::vector<common::Buffer>;
34 
36  template <typename Payload>
37  struct Signed {
38  SCALE_TIE(3);
39 
40  static_assert(std::is_same_v<std::decay_t<Payload>, Payload>);
41 
43  Payload payload;
48  };
49 
51  using Dummy = std::tuple<>;
52 
54  using ViewUpdate = Dummy;
55 
61  SCALE_TIE(1);
62 
64  };
65 
71  SCALE_TIE(3);
72 
76  };
78 
80  struct ErasureChunk {
81  SCALE_TIE(3);
82 
89  };
90 
94  struct ParachainBlock {
95  SCALE_TIE(1);
96 
98  };
100 
105  SCALE_TIE(9);
106 
110  CollatorPublicKey collator_id;
122  };
123 
129  SCALE_TIE(2);
130 
133  };
134 
136  SCALE_TIE(2);
137 
140  };
141 
142  using ReqCollationResponseData = boost::variant<CollationResponse>;
143 
149  SCALE_TIE(2);
150 
153  };
154 
159  SCALE_TIE(1);
160 
162  };
163 
165  SCALE_TIE(2);
166 
169  };
170 
172  SCALE_TIE(6);
173 
174  std::vector<UpwardMessage> upward_msgs;
175  std::vector<OutboundHorizontal>
177  std::optional<ParachainRuntime>
181  uint32_t watermark;
183  };
186 
188  SCALE_TIE(2);
189 
192  };
195 
196  using CandidateState = boost::variant<
197  Dummy,
201  >;
203 
204  struct Statement {
205  SCALE_TIE(3);
206 
210  };
211 
212  struct Seconded {
213  SCALE_TIE(2);
214 
215  primitives::BlockHash relay_parent;
217  };
218 
221 
226  using CollationMessage = boost::variant<
229  Dummy,
231  Dummy,
232  Seconded
233  >;
234 
238  using ProtocolMessage =
239  boost::variant<CollationMessage
240  >;
241 
245  using WireMessage = boost::variant<Dummy,
247  ViewUpdate
248  >;
249 
251  const CandidateReceipt &receipt) {
252  return hasher.blake2b_256(scale::encode(receipt).value());
253  }
254 
256  const CommittedCandidateReceipt &receipt) {
257  return candidateHash(
258  hasher,
260  receipt.descriptor,
261  hasher.blake2b_256(scale::encode(receipt.commitments).value()),
262  });
263  }
264 
266  const CandidateState &statement) {
267  if (auto receipt = boost::get<CommittedCandidateReceipt>(&statement)) {
268  return candidateHash(hasher, *receipt);
269  }
270  return boost::get<CandidateHash>(statement);
271  }
272 } // namespace kagome::network
273 
274 #endif // KAGOME_COLLATOR_DECLARE_HPP
Class represents arbitrary (including empty) byte buffer.
Definition: buffer.hpp:29
uint32_t downward_msgs_count
parachain head data
primitives::BlockHash relay_parent
boost::variant< CollatorDeclaration, CollatorAdvertisement, Dummy, Dummy, Seconded > CollationMessage
Statement statement
relay parent hash
Dummy ViewUpdate
ViewUpdate message. Maybe will be implemented later.
common::Buffer chunk
The erasure-encoded chunk of data belonging to the candidate block.
storage::trie::RootHash erasure_encoding_root
Hash of the PoV block.
std::optional< ParachainRuntime > opt_para_runtime
outbound horizontal messages
primitives::BlockHash persisted_data_hash
Collators public key.
primitives::BlockHash para_runtime_hash
Hash of the parachain head data of this candidate.
crypto::Sr25519PublicKey CollatorPublicKey
boost::variant< CollationMessage > ProtocolMessage
Payload signed by validator.
ValidatorIndex validator_index
Index of validator in validator list.
primitives::BlockHash para_head_hash
Collator signature of the concatenated components.
boost::variant< Dummy, CommittedCandidateReceipt, primitives::BlockHash > CandidateState
virtual Hash256 blake2b_256(gsl::span< const uint8_t > buffer) const =0
blake2b_256 function calculates 32-byte blake2b hash
std::vector< OutboundHorizontal > outbound_hor_msgs
upward messages
SLBuffer< std::numeric_limits< size_t >::max()> Buffer
Definition: buffer.hpp:244
primitives::BlockHash commitments_hash
Candidate descriptor.
UpwardMessage upward_msg
Parachain Id is recepient id.
HeadData para_head
new parachain runtime if present
std::tuple<> Dummy
NU element.
CandidateCommitments commitments
Candidate descriptor.
ChunkProof proof
Proof for this chunk&#39;s branch in the Merkle tree.
common::Hash256 BlockHash
Definition: block_id.hpp:15
std::vector< common::Buffer > ChunkProof
primitives::BlockHash relay_parent
Parachain Id.
ParachainId para_id
Hash of the relay chain block.
CandidateHash candidateHash(const crypto::Hasher &hasher, const CandidateReceipt &receipt)
boost::variant< Dummy, ProtocolMessage, ViewUpdate > WireMessage
boost::variant< CollationResponse > ReqCollationResponseData
Signature signature
Signature of SigningContext::signable(payload).
std::vector< UpwardMessage > upward_msgs
ValidatorIndex index
The index of this erasure-encoded chunk of data.
crypto::Sr25519Signature Signature
A chunk of erasure-encoded block data.
ParachainBlock pov
Candidate receipt.
primitives::BlockHash pov_hash
Hash of the persisted validation data.
ParachainId para_id
Public key of the collator.