Kagome
Polkadot Runtime Engine in C++17
parachains_inherent_data.hpp
Go to the documentation of this file.
1 
6 #include <scale/bitvec.hpp>
7 
8 #include "common/stub.hpp"
9 #include "common/tagged.hpp"
10 #include "common/unused.hpp"
12 #include "primitives/common.hpp"
13 
14 namespace kagome::consensus::babe {
15  using Signature = crypto::Ed25519Signature; // FIXME check actual type
16  using ParachainId = uint32_t;
17  using CollatorPublicKey =
18  crypto::Ed25519PublicKey; // FIXME check actual type
19 
24 
28 
31 
34 
37 
40 
43 
46 
49  };
50 
51  scale::ScaleEncoderStream &operator<<(scale::ScaleEncoderStream &s,
52  const CandidateDescriptor &data) {
53  // clang-format off
54  return s << data.parachain_id
56  << data.collator_public_key
57  << data.validation_data_hash
58  << data.pov_block_hash
59  << data.merkle
60  << data.collator_signature
62  << data.parachain_runtime_hash;
63  // clang-format on
64  }
65 
66  scale::ScaleDecoderStream &operator>>(scale::ScaleDecoderStream &s,
67  CandidateDescriptor &data) {
68  // clang-format off
69  return s >> data.parachain_id
71  >> data.collator_public_key
72  >> data.validation_data_hash
73  >> data.pov_block_hash
74  >> data.merkle
75  >> data.collator_signature
77  >> data.parachain_runtime_hash;
78  // clang-format on
79  }
80 
82  struct RecipientTag {};
83  using Recipient = Stub<RecipientTag>; // FIXME
84 
86  struct UpwardMessageTag {};
88 
93 
96  };
97 
98  scale::ScaleEncoderStream &operator<<(scale::ScaleEncoderStream &s,
99  const OutboundHrmpMessage &data) {
100  return s << data.recipient << data.message;
101  }
102 
103  scale::ScaleDecoderStream &operator>>(scale::ScaleDecoderStream &s,
104  OutboundHrmpMessage &data) {
105  return s >> data.recipient >> data.message;
106  }
107 
112  std::vector<common::Buffer> upward_messages;
113 
116  std::vector<OutboundHrmpMessage> outbound_messages;
117 
119  std::optional<common::Buffer>
120  new_parachain_runtime; // FIXME check actual type
121 
124 
129 
133  uint32_t watermark;
134  };
135 
136  scale::ScaleEncoderStream &operator<<(scale::ScaleEncoderStream &s,
137  const CandidateCommitments &data) {
138  // clang-format off
139  return s << data.upward_messages
140  << data.outbound_messages
141  << data.new_parachain_runtime
142  << data.parachain_head_data
144  << data.watermark;
145  // clang-format on
146  }
147 
148  scale::ScaleDecoderStream &operator>>(scale::ScaleDecoderStream &s,
149  CandidateCommitments &data) {
150  // clang-format off
151  return s >> data.upward_messages
152  >> data.outbound_messages
153  >> data.new_parachain_runtime
154  >> data.parachain_head_data
156  >> data.watermark;
157  // clang-format on
158  }
159 
166  };
167 
168  scale::ScaleEncoderStream &operator<<(scale::ScaleEncoderStream &s,
169  const CandidateReceipt &data) {
170  return s << data.descriptor << data.commitments;
171  }
172 
173  scale::ScaleDecoderStream &operator>>(scale::ScaleDecoderStream &s,
174  CandidateReceipt &data) {
175  return s >> data.descriptor >> data.commitments;
176  }
177 
183  using Attestation = boost::variant<Unused<0>, // 0
186 
190 
192  std::vector<Attestation> validity_votes;
193 
195  scale::BitVec indices;
196  };
197 
198  scale::ScaleEncoderStream &operator<<(scale::ScaleEncoderStream &s,
199  const CommittedCandidate &data) {
200  // clang-format off
201  return s << data.candidate
202  << data.validity_votes
203  << data.indices;
204  // clang-format on
205  }
206 
207  scale::ScaleDecoderStream &operator>>(scale::ScaleDecoderStream &s,
208  CommittedCandidate &data) {
209  // clang-format off
210  return s >> data.candidate
211  >> data.validity_votes
212  >> data.indices;
213  // clang-format on
214  }
215 
216  using DisputeStatement =
217  boost::variant<Tagged<Empty, struct ExplicitStatement>,
221 
222  struct Vote {
225  uint32_t validator_index;
226 
229 
232  };
233 
234  scale::ScaleEncoderStream &operator<<(scale::ScaleEncoderStream &s,
235  const Vote &data) {
236  // clang-format off
237  return s << data.validator_index
238  << data.signature
239  << data.statement;
240  // clang-format on
241  }
242 
243  scale::ScaleDecoderStream &operator>>(scale::ScaleDecoderStream &s,
244  Vote &data) {
245  // clang-format off
246  return s >> data.validator_index
247  >> data.signature
248  >> data.statement;
249  // clang-format on
250  }
251 
255  struct DisputeRequest {
258 
261  uint32_t session_index;
262 
265 
268  };
269 
270  scale::ScaleEncoderStream &operator<<(scale::ScaleEncoderStream &s,
271  const DisputeRequest &data) {
272  // clang-format off
273  return s << data.candidate
274  << data.session_index
275  << data.invalid_vote
276  << data.valid_vote;
277  // clang-format on
278  }
279 
280  scale::ScaleDecoderStream &operator>>(scale::ScaleDecoderStream &s,
281  DisputeRequest &data) {
282  // clang-format off
283  return s >> data.candidate
284  >> data.session_index
285  >> data.invalid_vote
286  >> data.valid_vote;
287  // clang-format on
288  }
289 
295  std::vector<network::SignedBitfield> bitfields;
296 
298  std::vector<Empty> backed_candidates;
299 
301  std::vector<DisputeRequest> disputes;
302 
308  };
309 
310  scale::ScaleEncoderStream &operator<<(scale::ScaleEncoderStream &s,
311  const ParachainInherentData &data) {
312  // clang-format off
313  return s << data.bitfields
314  << data.backed_candidates
315  << data.disputes
316  << data.parent_header;
317  // clang-format on
318  }
319 
320  scale::ScaleDecoderStream &operator>>(scale::ScaleDecoderStream &s,
321  ParachainInherentData &data) {
322  // clang-format off
323  return s >> data.bitfields
324  >> data.backed_candidates
325  >> data.disputes
326  >> data.parent_header;
327  // clang-format on
328  }
329 
330 } // namespace kagome::consensus::babe
Class represents arbitrary (including empty) byte buffer.
Definition: buffer.hpp:29
std::vector< network::SignedBitfield > bitfields
std::vector< OutboundHrmpMessage > outbound_messages
Vote invalid_vote
The invalid vote that makes up the request.
DisputeStatement statement
A varying datatype and implies the dispute statement.
common::Hash256 validation_data_hash
The hash of the persisted validation data (Definition 188).
CandidateReceipt candidate
The candidate that is being disputed.
primitives::BlockHash pov_block_hash
The hash of the PoV block.
std::vector< Empty > backed_candidates
The array of backed candidates for inclusion in the current block.
scale::ScaleEncoderStream & operator<<(scale::ScaleEncoderStream &s, const CandidateDescriptor &data)
std::optional< common::Buffer > new_parachain_runtime
A new parachain Runtime in case of an update.
crypto::Ed25519PublicKey CollatorPublicKey
Signature collator_signature
The collator signature of the concatenated components.
common::Buffer parachain_head_data
The parachain head data (Section 6.8.4).
Vote valid_vote
The valid vote that makes this dispute request valid.
boost::variant< Tagged< Empty, struct ExplicitStatement >, Tagged< common::Hash256, struct SecondedStatement >, Tagged< common::Hash256, struct ValidStatement >, Tagged< Empty, struct AprovalVote >> DisputeStatement
scale::ScaleDecoderStream & operator>>(scale::ScaleDecoderStream &s, CandidateDescriptor &data)
CandidateReceipt candidate
Committed candidate receipt.
Signature signature
The signature of the validator.
common::Hash256 parachain_head_data_hash
The hash of the parachain head data (Section 6.8.4) of this candidate.
common::Hash256 parachain_runtime_hash
The hash of the parachain Runtime.
std::vector< DisputeRequest > disputes
Array of disputes.
An upward message as defined in Definition 7.8 (non existent definition)
std::vector< Attestation > validity_votes
An array of validity votes themselves, expressed as signatures.
common::Hash256 merkle
The root of the block’s erasure encoding Merkle tree.
The recipient Id as defined in Definition 7.5 (non existent definition)
boost::variant< Unused< 0 >, Tagged< Signature, struct Implicit >, Tagged< Signature, struct Explicit >> Attestation
CollatorPublicKey collator_public_key
The collators public key.
crypto::Ed25519Signature Signature
scale::BitVec indices
A bitfield of indices of the validators within the validator group.