@@ -8,7 +8,7 @@ use serde_utils;
8
8
use ssz:: { Decode , DecodeError , Encode } ;
9
9
use ssz_derive:: { Decode , Encode } ;
10
10
use ssz_types:: {
11
- typenum:: { U1099511627776 , U16777216 , U2048 , U4 , U65536 , U8192 } ,
11
+ typenum:: { U1099511627776 , U134217728 , U16777216 , U2048 , U262144 , U4 , U65536 , U8192 } ,
12
12
BitVector , FixedVector , VariableList ,
13
13
} ;
14
14
use superstruct:: superstruct;
@@ -18,12 +18,16 @@ use tree_hash_derive::TreeHash;
18
18
use crate :: consensus:: {
19
19
body:: { Checkpoint , Eth1Data } ,
20
20
execution_payload:: {
21
- ExecutionPayloadHeaderBellatrix , ExecutionPayloadHeaderCapella , ExecutionPayloadHeaderDeneb ,
21
+ ExecutionPayloadHeaderBellatrix , ExecutionPayloadHeaderCapella ,
22
+ ExecutionPayloadHeaderDeneb , ExecutionPayloadHeaderElectra ,
22
23
} ,
23
24
fork:: ForkName ,
24
25
header:: BeaconBlockHeader ,
25
26
historical_summaries:: HistoricalSummaries ,
26
27
participation_flags:: ParticipationFlags ,
28
+ pending_balance_deposit:: PendingDeposit ,
29
+ pending_consolidation:: PendingConsolidation ,
30
+ pending_partial_withdrawal:: PendingPartialWithdrawal ,
27
31
proof:: build_merkle_proof_for_index,
28
32
pubkey:: PubKey ,
29
33
sync_committee:: SyncCommittee ,
@@ -39,10 +43,13 @@ type JustificationBitsLength = U4;
39
43
40
44
pub type RootsPerHistoricalRoot = FixedVector < B256 , SlotsPerHistoricalRoot > ;
41
45
pub type HistoricalRoots = VariableList < B256 , HistoricalRootsLimit > ;
46
+ pub type PendingDepositsLimit = U134217728 ;
47
+ pub type PendingPartialWithdrawalsLimit = U134217728 ;
48
+ pub type PendingConsolidationsLimit = U262144 ;
42
49
43
50
/// The state of the `BeaconChain` at some slot.
44
51
#[ superstruct(
45
- variants( Bellatrix , Capella , Deneb ) ,
52
+ variants( Bellatrix , Capella , Deneb , Electra ) ,
46
53
variant_attributes(
47
54
derive(
48
55
Clone ,
@@ -101,9 +108,9 @@ pub struct BeaconState {
101
108
pub slashings : FixedVector < u64 , EpochsPerSlashingsVector > ,
102
109
103
110
// Participation (Altair and later)
104
- #[ superstruct( only( Bellatrix , Capella , Deneb ) ) ]
111
+ #[ superstruct( only( Bellatrix , Capella , Deneb , Electra ) ) ]
105
112
pub previous_epoch_participation : VariableList < ParticipationFlags , ValidatorRegistryLimit > ,
106
- #[ superstruct( only( Bellatrix , Capella , Deneb ) ) ]
113
+ #[ superstruct( only( Bellatrix , Capella , Deneb , Electra ) ) ]
107
114
pub current_epoch_participation : VariableList < ParticipationFlags , ValidatorRegistryLimit > ,
108
115
109
116
// Finality
@@ -116,14 +123,14 @@ pub struct BeaconState {
116
123
pub finalized_checkpoint : Checkpoint ,
117
124
118
125
// Inactivity
119
- #[ superstruct( only( Bellatrix , Capella , Deneb ) ) ]
126
+ #[ superstruct( only( Bellatrix , Capella , Deneb , Electra ) ) ]
120
127
#[ serde( deserialize_with = "ssz_types::serde_utils::quoted_u64_var_list::deserialize" ) ]
121
128
pub inactivity_scores : VariableList < u64 , ValidatorRegistryLimit > ,
122
129
123
130
// Light-client sync committees
124
- #[ superstruct( only( Bellatrix , Capella , Deneb ) ) ]
131
+ #[ superstruct( only( Bellatrix , Capella , Deneb , Electra ) ) ]
125
132
pub current_sync_committee : Arc < SyncCommittee > ,
126
- #[ superstruct( only( Bellatrix , Capella , Deneb ) ) ]
133
+ #[ superstruct( only( Bellatrix , Capella , Deneb , Electra ) ) ]
127
134
pub next_sync_committee : Arc < SyncCommittee > ,
128
135
129
136
// Execution
@@ -142,17 +149,47 @@ pub struct BeaconState {
142
149
partial_getter( rename = "latest_execution_payload_header_deneb" )
143
150
) ]
144
151
pub latest_execution_payload_header : ExecutionPayloadHeaderDeneb ,
152
+ #[ superstruct(
153
+ only( Electra ) ,
154
+ partial_getter( rename = "latest_execution_payload_header_electra" )
155
+ ) ]
156
+ pub latest_execution_payload_header : ExecutionPayloadHeaderElectra ,
145
157
146
158
// Capella
147
- #[ superstruct( only( Capella , Deneb ) , partial_getter( copy) ) ]
159
+ #[ superstruct( only( Capella , Deneb , Electra ) , partial_getter( copy) ) ]
148
160
#[ serde( deserialize_with = "as_u64" ) ]
149
161
pub next_withdrawal_index : u64 ,
150
- #[ superstruct( only( Capella , Deneb ) , partial_getter( copy) ) ]
162
+ #[ superstruct( only( Capella , Deneb , Electra ) , partial_getter( copy) ) ]
151
163
#[ serde( deserialize_with = "as_u64" ) ]
152
164
pub next_withdrawal_validator_index : u64 ,
153
165
// Deep history valid from Capella onwards.
154
- #[ superstruct( only( Capella , Deneb ) ) ]
166
+ #[ superstruct( only( Capella , Deneb , Electra ) ) ]
155
167
pub historical_summaries : HistoricalSummaries ,
168
+
169
+ // Electra
170
+ #[ superstruct( only( Electra ) , partial_getter( copy) ) ]
171
+ #[ serde( deserialize_with = "as_u64" ) ]
172
+ pub deposit_requests_start_index : u64 ,
173
+ #[ superstruct( only( Electra ) , partial_getter( copy) ) ]
174
+ #[ serde( deserialize_with = "as_u64" ) ]
175
+ pub deposit_balance_to_consume : u64 ,
176
+ #[ superstruct( only( Electra ) , partial_getter( copy) ) ]
177
+ #[ serde( deserialize_with = "as_u64" ) ]
178
+ pub exit_balance_to_consume : u64 ,
179
+ #[ superstruct( only( Electra ) , partial_getter( copy) ) ]
180
+ pub earliest_exit_epoch : Epoch ,
181
+ #[ superstruct( only( Electra ) , partial_getter( copy) ) ]
182
+ #[ serde( deserialize_with = "as_u64" ) ]
183
+ pub consolidation_balance_to_consume : u64 ,
184
+ #[ superstruct( only( Electra ) , partial_getter( copy) ) ]
185
+ pub earliest_consolidation_epoch : Epoch ,
186
+ #[ superstruct( only( Electra ) ) ]
187
+ pub pending_deposits : VariableList < PendingDeposit , PendingDepositsLimit > ,
188
+ #[ superstruct( only( Electra ) ) ]
189
+ pub pending_partial_withdrawals :
190
+ VariableList < PendingPartialWithdrawal , PendingPartialWithdrawalsLimit > ,
191
+ #[ superstruct( only( Electra ) ) ]
192
+ pub pending_consolidations : VariableList < PendingConsolidation , PendingConsolidationsLimit > ,
156
193
}
157
194
158
195
impl BeaconState {
@@ -161,6 +198,7 @@ impl BeaconState {
161
198
ForkName :: Bellatrix => BeaconStateBellatrix :: from_ssz_bytes ( bytes) . map ( Self :: Bellatrix ) ,
162
199
ForkName :: Capella => BeaconStateCapella :: from_ssz_bytes ( bytes) . map ( Self :: Capella ) ,
163
200
ForkName :: Deneb => BeaconStateDeneb :: from_ssz_bytes ( bytes) . map ( Self :: Deneb ) ,
201
+ ForkName :: Electra => BeaconStateElectra :: from_ssz_bytes ( bytes) . map ( Self :: Electra ) ,
164
202
}
165
203
}
166
204
}
0 commit comments