@@ -2113,7 +2113,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
2113
2113
. fork_choice_write_lock ( )
2114
2114
. on_attestation (
2115
2115
self . slot ( ) ?,
2116
- verified. indexed_attestation ( ) ,
2116
+ verified. indexed_attestation ( ) . to_ref ( ) ,
2117
2117
AttestationFromBlock :: False ,
2118
2118
)
2119
2119
. map_err ( Into :: into)
@@ -2465,7 +2465,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
2465
2465
// Add to fork choice.
2466
2466
self . canonical_head
2467
2467
. fork_choice_write_lock ( )
2468
- . on_attester_slashing ( attester_slashing. as_inner ( ) ) ;
2468
+ . on_attester_slashing ( attester_slashing. as_inner ( ) . to_ref ( ) ) ;
2469
2469
2470
2470
// Add to the op pool (if we have the ability to propose blocks).
2471
2471
if self . eth1_chain . is_some ( ) {
@@ -3820,7 +3820,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3820
3820
continue ;
3821
3821
}
3822
3822
} ;
3823
- slasher. accept_attestation ( indexed_attestation. clone ( ) ) ;
3823
+ slasher. accept_attestation ( indexed_attestation. clone_as_indexed_attestation ( ) ) ;
3824
3824
}
3825
3825
}
3826
3826
}
@@ -3839,7 +3839,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3839
3839
if block. slot ( ) + 2 * T :: EthSpec :: slots_per_epoch ( ) >= current_slot {
3840
3840
metrics:: observe (
3841
3841
& metrics:: OPERATIONS_PER_BLOCK_ATTESTATION ,
3842
- block. body ( ) . attestations ( ) . len ( ) as f64 ,
3842
+ block. body ( ) . attestations ( ) . count ( ) as f64 ,
3843
3843
) ;
3844
3844
3845
3845
if let Ok ( sync_aggregate) = block. body ( ) . sync_aggregate ( ) {
@@ -4859,7 +4859,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
4859
4859
metrics:: start_timer ( & metrics:: BLOCK_PRODUCTION_UNAGGREGATED_TIMES ) ;
4860
4860
for attestation in self . naive_aggregation_pool . read ( ) . iter ( ) {
4861
4861
let import = |attestation : & Attestation < T :: EthSpec > | {
4862
- let attesting_indices = get_attesting_indices_from_state ( & state, attestation) ?;
4862
+ let attesting_indices =
4863
+ get_attesting_indices_from_state ( & state, attestation. to_ref ( ) ) ?;
4863
4864
self . op_pool
4864
4865
. insert_attestation ( attestation. clone ( ) , attesting_indices)
4865
4866
} ;
@@ -4909,7 +4910,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
4909
4910
attestations. retain ( |att| {
4910
4911
verify_attestation_for_block_inclusion (
4911
4912
& state,
4912
- att,
4913
+ att. to_ref ( ) ,
4913
4914
& mut tmp_ctxt,
4914
4915
VerifySignatures :: True ,
4915
4916
& self . spec ,
@@ -5040,6 +5041,72 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
5040
5041
bls_to_execution_changes,
5041
5042
} = partial_beacon_block;
5042
5043
5044
+ let ( attester_slashings_base, attester_slashings_electra) =
5045
+ attester_slashings. into_iter ( ) . fold (
5046
+ ( Vec :: new ( ) , Vec :: new ( ) ) ,
5047
+ |( mut base, mut electra) , slashing| {
5048
+ match slashing {
5049
+ AttesterSlashing :: Base ( slashing) => base. push ( slashing) ,
5050
+ AttesterSlashing :: Electra ( slashing) => electra. push ( slashing) ,
5051
+ }
5052
+ ( base, electra)
5053
+ } ,
5054
+ ) ;
5055
+ let ( attestations_base, attestations_electra) = attestations. into_iter ( ) . fold (
5056
+ ( Vec :: new ( ) , Vec :: new ( ) ) ,
5057
+ |( mut base, mut electra) , attestation| {
5058
+ match attestation {
5059
+ Attestation :: Base ( attestation) => base. push ( attestation) ,
5060
+ Attestation :: Electra ( attestation) => electra. push ( attestation) ,
5061
+ }
5062
+ ( base, electra)
5063
+ } ,
5064
+ ) ;
5065
+
5066
+ // TODO(electra): figure out what should *actually* be done here when we have attestations / attester_slashings of the wrong type
5067
+ match & state {
5068
+ BeaconState :: Base ( _)
5069
+ | BeaconState :: Altair ( _)
5070
+ | BeaconState :: Merge ( _)
5071
+ | BeaconState :: Capella ( _)
5072
+ | BeaconState :: Deneb ( _) => {
5073
+ if !attestations_electra. is_empty ( ) {
5074
+ error ! (
5075
+ self . log,
5076
+ "Tried to produce block with attestations of the wrong type" ;
5077
+ "slot" => slot,
5078
+ "attestations" => attestations_electra. len( ) ,
5079
+ ) ;
5080
+ }
5081
+ if !attester_slashings_electra. is_empty ( ) {
5082
+ error ! (
5083
+ self . log,
5084
+ "Tried to produce block with attester slashings of the wrong type" ;
5085
+ "slot" => slot,
5086
+ "attester_slashings" => attester_slashings_electra. len( ) ,
5087
+ ) ;
5088
+ }
5089
+ }
5090
+ BeaconState :: Electra ( _) => {
5091
+ if !attestations_base. is_empty ( ) {
5092
+ error ! (
5093
+ self . log,
5094
+ "Tried to produce block with attestations of the wrong type" ;
5095
+ "slot" => slot,
5096
+ "attestations" => attestations_base. len( ) ,
5097
+ ) ;
5098
+ }
5099
+ if !attester_slashings_base. is_empty ( ) {
5100
+ error ! (
5101
+ self . log,
5102
+ "Tried to produce block with attester slashings of the wrong type" ;
5103
+ "slot" => slot,
5104
+ "attester_slashings" => attester_slashings_base. len( ) ,
5105
+ ) ;
5106
+ }
5107
+ }
5108
+ } ;
5109
+
5043
5110
let ( inner_block, maybe_blobs_and_proofs, execution_payload_value) = match & state {
5044
5111
BeaconState :: Base ( _) => (
5045
5112
BeaconBlock :: Base ( BeaconBlockBase {
@@ -5052,8 +5119,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
5052
5119
eth1_data,
5053
5120
graffiti,
5054
5121
proposer_slashings : proposer_slashings. into ( ) ,
5055
- attester_slashings : attester_slashings . into ( ) ,
5056
- attestations : attestations . into ( ) ,
5122
+ attester_slashings : attester_slashings_base . into ( ) ,
5123
+ attestations : attestations_base . into ( ) ,
5057
5124
deposits : deposits. into ( ) ,
5058
5125
voluntary_exits : voluntary_exits. into ( ) ,
5059
5126
_phantom : PhantomData ,
@@ -5073,8 +5140,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
5073
5140
eth1_data,
5074
5141
graffiti,
5075
5142
proposer_slashings : proposer_slashings. into ( ) ,
5076
- attester_slashings : attester_slashings . into ( ) ,
5077
- attestations : attestations . into ( ) ,
5143
+ attester_slashings : attester_slashings_base . into ( ) ,
5144
+ attestations : attestations_base . into ( ) ,
5078
5145
deposits : deposits. into ( ) ,
5079
5146
voluntary_exits : voluntary_exits. into ( ) ,
5080
5147
sync_aggregate : sync_aggregate
@@ -5100,8 +5167,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
5100
5167
eth1_data,
5101
5168
graffiti,
5102
5169
proposer_slashings : proposer_slashings. into ( ) ,
5103
- attester_slashings : attester_slashings . into ( ) ,
5104
- attestations : attestations . into ( ) ,
5170
+ attester_slashings : attester_slashings_base . into ( ) ,
5171
+ attestations : attestations_base . into ( ) ,
5105
5172
deposits : deposits. into ( ) ,
5106
5173
voluntary_exits : voluntary_exits. into ( ) ,
5107
5174
sync_aggregate : sync_aggregate
@@ -5132,8 +5199,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
5132
5199
eth1_data,
5133
5200
graffiti,
5134
5201
proposer_slashings : proposer_slashings. into ( ) ,
5135
- attester_slashings : attester_slashings . into ( ) ,
5136
- attestations : attestations . into ( ) ,
5202
+ attester_slashings : attester_slashings_base . into ( ) ,
5203
+ attestations : attestations_base . into ( ) ,
5137
5204
deposits : deposits. into ( ) ,
5138
5205
voluntary_exits : voluntary_exits. into ( ) ,
5139
5206
sync_aggregate : sync_aggregate
@@ -5166,8 +5233,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
5166
5233
eth1_data,
5167
5234
graffiti,
5168
5235
proposer_slashings : proposer_slashings. into ( ) ,
5169
- attester_slashings : attester_slashings . into ( ) ,
5170
- attestations : attestations . into ( ) ,
5236
+ attester_slashings : attester_slashings_base . into ( ) ,
5237
+ attestations : attestations_base . into ( ) ,
5171
5238
deposits : deposits. into ( ) ,
5172
5239
voluntary_exits : voluntary_exits. into ( ) ,
5173
5240
sync_aggregate : sync_aggregate
@@ -5204,8 +5271,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
5204
5271
eth1_data,
5205
5272
graffiti,
5206
5273
proposer_slashings : proposer_slashings. into ( ) ,
5207
- attester_slashings : attester_slashings . into ( ) ,
5208
- attestations : attestations . into ( ) ,
5274
+ attester_slashings : attester_slashings_electra . into ( ) ,
5275
+ attestations : attestations_electra . into ( ) ,
5209
5276
deposits : deposits. into ( ) ,
5210
5277
voluntary_exits : voluntary_exits. into ( ) ,
5211
5278
sync_aggregate : sync_aggregate
@@ -5216,6 +5283,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
5216
5283
bls_to_execution_changes : bls_to_execution_changes. into ( ) ,
5217
5284
blob_kzg_commitments : kzg_commitments
5218
5285
. ok_or ( BlockProductionError :: InvalidPayloadFork ) ?,
5286
+ // TODO(electra): finish consolidations when they're more spec'd out
5287
+ consolidations : Vec :: new ( ) . into ( ) ,
5219
5288
} ,
5220
5289
} ) ,
5221
5290
maybe_blobs_and_proofs,
@@ -5321,7 +5390,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
5321
5390
self . log,
5322
5391
"Produced beacon block" ;
5323
5392
"parent" => ?block. parent_root( ) ,
5324
- "attestations" => block. body( ) . attestations ( ) . len ( ) ,
5393
+ "attestations" => block. body( ) . attestations_len ( ) ,
5325
5394
"slot" => block. slot( )
5326
5395
) ;
5327
5396
0 commit comments