@@ -113,3 +113,147 @@ pub struct BlockCertificates {
113113 /// the block is the first block of a new [`Epoch`].
114114 pub epoch_finalization_entry : Option < EpochFinalizationEntry > ,
115115}
116+
117+ pub mod raw {
118+ //! This module contains the "raw" version of block certificates, where the
119+ //! finalizers are referenced by their finalization index, rather than
120+ //! `BakerId`.
121+
122+ use concordium_base:: {
123+ base:: { Epoch , Round } ,
124+ common:: Serial ,
125+ hashes:: BlockHash ,
126+ } ;
127+
128+ use super :: { QuorumSignature , TimeoutSignature } ;
129+
130+ /// The index of a finalizer in a particular finalization committee.
131+ #[ derive( concordium_base:: common:: Serialize , Clone , Copy , Debug , PartialEq ) ]
132+ pub struct FinalizerIndex {
133+ pub index : u32 ,
134+ }
135+
136+ impl From < FinalizerIndex > for usize {
137+ fn from ( value : FinalizerIndex ) -> Self { value. index as usize }
138+ }
139+
140+ /// The message that is multicast by a finalizer when validating and signing
141+ /// a block.
142+ #[ derive( Clone , Copy , Debug ) ]
143+ pub struct QuorumMessage {
144+ /// Signature on the relevant quorum signature message.
145+ pub signature : QuorumSignature ,
146+ /// Hash of the block that is signed.
147+ pub block : BlockHash ,
148+ /// Index of the finalizer signing the message.
149+ pub finalizer : FinalizerIndex ,
150+ /// Round of the block.
151+ pub round : Round ,
152+ /// Epoch of the block.
153+ pub epoch : Epoch ,
154+ }
155+
156+ /// A quorum certificate on a block. This certifies that 2/3 of the
157+ /// finalization committee signed the block.
158+ #[ derive( Clone , Debug ) ]
159+ pub struct QuorumCertificate {
160+ /// The hash of the block that is certified.
161+ pub block_hash : BlockHash ,
162+ /// The round of the block that is certified.
163+ pub round : Round ,
164+ /// The epoch of the block that is certified.
165+ pub epoch : Epoch ,
166+ /// The aggregated signature of the finalization committee
167+ /// on the block that is certified.
168+ pub aggregate_signature : QuorumSignature ,
169+ /// A vector of the finalizers that formed the quorum certificate
170+ /// i.e., the ones who have contributed to the aggregate signature.
171+ /// The finalizers are identified by their finalizer index, which refers
172+ /// to the finalization committee for the epoch.
173+ pub signatories : Vec < FinalizerIndex > ,
174+ }
175+
176+ /// A (non-aggregate) signature of a validator. This is used for the
177+ /// validator's signature on blocks it produces, as well as for some
178+ /// finalization messages.
179+ #[ derive( concordium_base:: common:: Serialize , Clone , Copy , Debug , Eq , PartialEq ) ]
180+ pub struct BlockSignature ( pub ed25519_dalek:: Signature ) ;
181+
182+ /// A timeout message including the sender's signature.
183+ #[ derive( Clone , Debug ) ]
184+ pub struct TimeoutMessage {
185+ /// Index of the finalizer signing the message.
186+ pub finalizer : FinalizerIndex ,
187+ /// Index of the round that timed out.
188+ pub round : Round ,
189+ /// Current epoch number of the finalizer sending the timeout message.
190+ /// This can be different from the epoch of the quorum certificate.
191+ pub epoch : Epoch ,
192+ /// Highest quorum certificate known to the finalizer at the time of
193+ /// timeout.
194+ pub quorum_certificate : QuorumCertificate ,
195+ /// Signature on the appropriate timeout signature message.
196+ pub signature : TimeoutSignature ,
197+ /// Signature of the finalizer on the timeout message as a whole.
198+ pub message_signature : BlockSignature ,
199+ }
200+
201+ /// The set of finalizers that signed in a particular round.
202+ #[ derive( Clone , Debug ) ]
203+ pub struct FinalizerRound {
204+ /// The round for which the finalizers signed.
205+ pub round : Round ,
206+ /// The finalizers that signed for the round.
207+ pub finalizers : Vec < FinalizerIndex > ,
208+ }
209+
210+ /// The timeout certificate serves as a proof that no block
211+ /// was created and/or distributed to the network in time.
212+ /// The [`TimeoutCertificate`] makes it possible for the consensus protocol
213+ /// to advance to the following round, thus giving (possibly) another baker
214+ /// the chance to bake a block.
215+ #[ derive( Clone , Debug ) ]
216+ pub struct TimeoutCertificate {
217+ /// The round that timed out.
218+ pub round : Round ,
219+ /// The minimum epoch of which signatures are included in
220+ /// the signature for the certificate.
221+ pub min_epoch : Epoch ,
222+ /// The rounds of which finalizers have their best quorum
223+ /// certificates in the [`Epoch`] `min_epoch`.
224+ pub qc_rounds_first_epoch : Vec < FinalizerRound > ,
225+ /// The rounds of which finalizers have their best quorum
226+ /// certificates in the [`Epoch`] `min_epoch` + 1.
227+ pub qc_rounds_second_epoch : Vec < FinalizerRound > ,
228+ /// The aggregate signature by the finalization committee which
229+ /// serves as a proof that the [`Round`] timed out, hence
230+ /// no block was added to the chain.
231+ pub aggregate_signature : TimeoutSignature ,
232+ }
233+
234+ /// A finalization entry that proves that a block is finalized.
235+ #[ derive( Clone , Debug ) ]
236+ pub struct FinalizationEntry {
237+ /// The quorum certificate of the finalized block.
238+ pub finalized_qc : QuorumCertificate ,
239+ /// The quorum certificate of the immediate successor of the block
240+ /// indicated by `finalized_qc`. This block must be in the same epoch
241+ /// and the next round as that of `finalized_qc`.
242+ pub successor_qc : QuorumCertificate ,
243+ /// The witness that proves that the block of the `successor_qc`
244+ /// is an immediate decendant of the block of the `finalized_qc`.
245+ pub successor_proof : super :: hashes:: SuccessorProof ,
246+ }
247+
248+ /// Collected timeout messages for a single round.
249+ #[ derive( Clone , Debug ) ]
250+ pub struct TimeoutMessages {
251+ /// The first epoch for which timeout messsages are present.
252+ pub first_epoch : Epoch ,
253+ /// The timeout messages for the first epoch.
254+ /// There should always be at least one.
255+ pub first_epoch_timeouts : Vec < TimeoutMessage > ,
256+ /// The timeout messages for the second epoch.
257+ pub second_epoch_timeouts : Vec < TimeoutMessage > ,
258+ }
259+ }
0 commit comments