@@ -10,16 +10,9 @@ use crate::{
1010 state:: ValidatorRegistryLimit ,
1111} ;
1212
13- /// Envelope carrying a block and its aggregated signatures.
1413#[ derive( Clone , Encode , Decode ) ]
1514pub struct SignedBlock {
16- /// The block being signed.
1715 pub message : Block ,
18-
19- /// Aggregated signature payload for the block.
20- ///
21- /// Contains per-attestation aggregated proofs and the proposer's signature
22- /// over the block root using the proposal key.
2316 pub signature : BlockSignatures ,
2417}
2518
@@ -33,116 +26,66 @@ impl core::fmt::Debug for SignedBlock {
3326 }
3427}
3528
36- /// Signature payload for the block.
3729#[ derive( Clone , Encode , Decode ) ]
3830pub struct BlockSignatures {
39- /// Attestation signatures for the aggregated attestations in the block body.
40- ///
41- /// Each entry corresponds to an aggregated attestation from the block body and
42- /// contains the leanVM aggregated signature proof bytes for the participating validators.
43- ///
44- /// TODO:
45- /// - Eventually this field will be replaced by a single SNARK aggregating *all* signatures.
31+ /// One aggregated proof per attestation in the block body.
4632 pub attestation_signatures : AttestationSignatures ,
47-
48- /// Proposer's signature over the block root using the proposal key.
33+ /// Proposer's signature over `hash_tree_root(block)` using the proposal key.
4934 pub proposer_signature : XmssSignature ,
5035}
5136
52- /// List of per-attestation aggregated signature proofs.
53- ///
54- /// Each entry corresponds to an aggregated attestation from the block body.
55- ///
56- /// It contains:
57- /// - the participants bitfield,
58- /// - proof bytes from leanVM signature aggregation.
5937pub type AttestationSignatures =
6038 ssz_types:: VariableList < AggregatedSignatureProof , ValidatorRegistryLimit > ;
6139
62- /// Cryptographic proof that a set of validators signed a message.
63- ///
64- /// This container encapsulates the output of the leanVM signature aggregation,
65- /// combining the participant set with the proof bytes. This design ensures
66- /// the proof is self-describing: it carries information about which validators
67- /// it covers.
68- ///
69- /// The proof can verify that all participants signed the same message in the
70- /// same epoch, using a single verification operation instead of checking
71- /// each signature individually.
40+ /// Aggregated leanVM signature proof covering a set of validators.
7241#[ derive( Debug , Clone , Encode , Decode ) ]
7342pub struct AggregatedSignatureProof {
74- /// Bitfield indicating which validators' signatures are included.
7543 pub participants : AggregationBits ,
76- /// The raw aggregated proof bytes from leanVM.
7744 pub proof_data : ByteListMiB ,
7845}
7946
8047pub type ByteListMiB = ByteList < U1048576 > ;
8148
8249impl AggregatedSignatureProof {
83- /// Create a new aggregated signature proof.
8450 pub fn new ( participants : AggregationBits , proof_data : ByteListMiB ) -> Self {
8551 Self {
8652 participants,
8753 proof_data,
8854 }
8955 }
9056
91- /// Create an empty proof with the given participants bitfield.
92- ///
93- /// Used as a placeholder when actual aggregation is not yet implemented.
57+ /// Empty proof (placeholder for test paths without real aggregation).
9458 pub fn empty ( participants : AggregationBits ) -> Self {
9559 Self {
9660 participants,
9761 proof_data : ByteList :: empty ( ) ,
9862 }
9963 }
10064
101- /// Returns the validator indices that are set in the participants bitfield.
10265 pub fn participant_indices ( & self ) -> impl Iterator < Item = u64 > + ' _ {
10366 validator_indices ( & self . participants )
10467 }
10568}
10669
107- /// The header of a block, containing metadata.
108- ///
109- /// Block headers summarize blocks without storing full content. The header
110- /// includes references to the parent and the resulting state. It also contains
111- /// a hash of the block body.
112- ///
113- /// Headers are smaller than full blocks. They're useful for tracking the chain
114- /// without storing everything.
11570#[ derive( Debug , Clone , PartialEq , Eq , Serialize , Encode , Decode , TreeHash ) ]
11671pub struct BlockHeader {
117- /// The slot in which the block was proposed
11872 pub slot : u64 ,
119- /// The index of the validator that proposed the block
12073 pub proposer_index : u64 ,
121- /// The root of the parent block
12274 pub parent_root : H256 ,
123- /// The root of the state after applying transactions in this block
12475 pub state_root : H256 ,
125- /// The root of the block body
12676 pub body_root : H256 ,
12777}
12878
129- /// A complete block including header and body.
13079#[ derive( Debug , Clone , Encode , Decode , TreeHash ) ]
13180pub struct Block {
132- /// The slot in which the block was proposed.
13381 pub slot : u64 ,
134- /// The index of the validator that proposed the block.
13582 pub proposer_index : u64 ,
136- /// The root of the parent block.
13783 pub parent_root : H256 ,
138- /// The root of the state after applying transactions in this block.
13984 pub state_root : H256 ,
140- /// The block's payload.
14185 pub body : BlockBody ,
14286}
14387
14488impl Block {
145- /// Extract the block header, computing the body root.
14689 pub fn header ( & self ) -> BlockHeader {
14790 BlockHeader {
14891 slot : self . slot ,
@@ -153,10 +96,6 @@ impl Block {
15396 }
15497 }
15598
156- /// Reconstruct a block from header and body.
157- ///
158- /// The caller should ensure that `header.body_root` matches `body.tree_hash_root()`.
159- /// This is verified with a debug assertion but not in release builds.
16099 pub fn from_header_and_body ( header : BlockHeader , body : BlockBody ) -> Self {
161100 debug_assert_eq ! (
162101 header. body_root,
@@ -173,19 +112,10 @@ impl Block {
173112 }
174113}
175114
176- /// The body of a block, containing payload data.
177- ///
178- /// Currently, the main operation is voting. Validators submit attestations which are
179- /// packaged into blocks.
180115#[ derive( Debug , Default , Clone , Encode , Decode , TreeHash ) ]
181116pub struct BlockBody {
182- /// Plain validator attestations carried in the block body.
183- ///
184- /// Individual signatures live in the aggregated block signature list, so
185- /// these entries contain only attestation data without per-attestation signatures.
186117 pub attestations : AggregatedAttestations ,
187118}
188119
189- /// List of aggregated attestations included in a block.
190120pub type AggregatedAttestations =
191121 ssz_types:: VariableList < AggregatedAttestation , ValidatorRegistryLimit > ;
0 commit comments