@@ -2113,7 +2113,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
21132113 . fork_choice_write_lock ( )
21142114 . on_attestation (
21152115 self . slot ( ) ?,
2116- verified. indexed_attestation ( ) ,
2116+ verified. indexed_attestation ( ) . to_ref ( ) ,
21172117 AttestationFromBlock :: False ,
21182118 )
21192119 . map_err ( Into :: into)
@@ -2465,7 +2465,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
24652465 // Add to fork choice.
24662466 self . canonical_head
24672467 . fork_choice_write_lock ( )
2468- . on_attester_slashing ( attester_slashing. as_inner ( ) ) ;
2468+ . on_attester_slashing ( attester_slashing. as_inner ( ) . to_ref ( ) ) ;
24692469
24702470 // Add to the op pool (if we have the ability to propose blocks).
24712471 if self . eth1_chain . is_some ( ) {
@@ -3820,7 +3820,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
38203820 continue ;
38213821 }
38223822 } ;
3823- slasher. accept_attestation ( indexed_attestation. clone ( ) ) ;
3823+ slasher. accept_attestation ( indexed_attestation. clone_as_indexed_attestation ( ) ) ;
38243824 }
38253825 }
38263826 }
@@ -3839,7 +3839,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
38393839 if block. slot ( ) + 2 * T :: EthSpec :: slots_per_epoch ( ) >= current_slot {
38403840 metrics:: observe (
38413841 & metrics:: OPERATIONS_PER_BLOCK_ATTESTATION ,
3842- block. body ( ) . attestations ( ) . len ( ) as f64 ,
3842+ block. body ( ) . attestations ( ) . count ( ) as f64 ,
38433843 ) ;
38443844
38453845 if let Ok ( sync_aggregate) = block. body ( ) . sync_aggregate ( ) {
@@ -4859,7 +4859,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
48594859 metrics:: start_timer ( & metrics:: BLOCK_PRODUCTION_UNAGGREGATED_TIMES ) ;
48604860 for attestation in self . naive_aggregation_pool . read ( ) . iter ( ) {
48614861 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 ( ) ) ?;
48634864 self . op_pool
48644865 . insert_attestation ( attestation. clone ( ) , attesting_indices)
48654866 } ;
@@ -4909,7 +4910,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
49094910 attestations. retain ( |att| {
49104911 verify_attestation_for_block_inclusion (
49114912 & state,
4912- att,
4913+ att. to_ref ( ) ,
49134914 & mut tmp_ctxt,
49144915 VerifySignatures :: True ,
49154916 & self . spec ,
@@ -5040,6 +5041,72 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
50405041 bls_to_execution_changes,
50415042 } = partial_beacon_block;
50425043
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+
50435110 let ( inner_block, maybe_blobs_and_proofs, execution_payload_value) = match & state {
50445111 BeaconState :: Base ( _) => (
50455112 BeaconBlock :: Base ( BeaconBlockBase {
@@ -5052,8 +5119,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
50525119 eth1_data,
50535120 graffiti,
50545121 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 ( ) ,
50575124 deposits : deposits. into ( ) ,
50585125 voluntary_exits : voluntary_exits. into ( ) ,
50595126 _phantom : PhantomData ,
@@ -5073,8 +5140,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
50735140 eth1_data,
50745141 graffiti,
50755142 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 ( ) ,
50785145 deposits : deposits. into ( ) ,
50795146 voluntary_exits : voluntary_exits. into ( ) ,
50805147 sync_aggregate : sync_aggregate
@@ -5100,8 +5167,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
51005167 eth1_data,
51015168 graffiti,
51025169 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 ( ) ,
51055172 deposits : deposits. into ( ) ,
51065173 voluntary_exits : voluntary_exits. into ( ) ,
51075174 sync_aggregate : sync_aggregate
@@ -5132,8 +5199,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
51325199 eth1_data,
51335200 graffiti,
51345201 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 ( ) ,
51375204 deposits : deposits. into ( ) ,
51385205 voluntary_exits : voluntary_exits. into ( ) ,
51395206 sync_aggregate : sync_aggregate
@@ -5166,8 +5233,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
51665233 eth1_data,
51675234 graffiti,
51685235 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 ( ) ,
51715238 deposits : deposits. into ( ) ,
51725239 voluntary_exits : voluntary_exits. into ( ) ,
51735240 sync_aggregate : sync_aggregate
@@ -5204,8 +5271,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
52045271 eth1_data,
52055272 graffiti,
52065273 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 ( ) ,
52095276 deposits : deposits. into ( ) ,
52105277 voluntary_exits : voluntary_exits. into ( ) ,
52115278 sync_aggregate : sync_aggregate
@@ -5216,6 +5283,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
52165283 bls_to_execution_changes : bls_to_execution_changes. into ( ) ,
52175284 blob_kzg_commitments : kzg_commitments
52185285 . ok_or ( BlockProductionError :: InvalidPayloadFork ) ?,
5286+ // TODO(electra): finish consolidations when they're more spec'd out
5287+ consolidations : Vec :: new ( ) . into ( ) ,
52195288 } ,
52205289 } ) ,
52215290 maybe_blobs_and_proofs,
@@ -5321,7 +5390,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
53215390 self . log,
53225391 "Produced beacon block" ;
53235392 "parent" => ?block. parent_root( ) ,
5324- "attestations" => block. body( ) . attestations ( ) . len ( ) ,
5393+ "attestations" => block. body( ) . attestations_len ( ) ,
53255394 "slot" => block. slot( )
53265395 ) ;
53275396
0 commit comments