@@ -17,7 +17,7 @@ use tree_hash_derive::TreeHash;
1717
1818/// A block of the `BeaconChain`.
1919#[ superstruct(
20- variants( Base , Altair , Merge , Eip4844 ) ,
20+ variants( Base , Altair , Merge , Capella , Eip4844 ) ,
2121 variant_attributes(
2222 derive(
2323 Debug ,
@@ -48,7 +48,7 @@ use tree_hash_derive::TreeHash;
4848#[ cfg_attr( feature = "arbitrary-fuzz" , derive( arbitrary:: Arbitrary ) ) ]
4949#[ tree_hash( enum_behaviour = "transparent" ) ]
5050#[ ssz( enum_behaviour = "transparent" ) ]
51- pub struct BeaconBlock < T : EthSpec , Payload : ExecPayload < T > = FullPayload < T > > {
51+ pub struct BeaconBlock < T : EthSpec , Payload : AbstractExecPayload < T > = FullPayload < T > > {
5252 #[ superstruct( getter( copy) ) ]
5353 pub slot : Slot ,
5454 #[ superstruct( getter( copy) ) ]
@@ -64,16 +64,22 @@ pub struct BeaconBlock<T: EthSpec, Payload: ExecPayload<T> = FullPayload<T>> {
6464 pub body : BeaconBlockBodyAltair < T , Payload > ,
6565 #[ superstruct( only( Merge ) , partial_getter( rename = "body_merge" ) ) ]
6666 pub body : BeaconBlockBodyMerge < T , Payload > ,
67+ #[ superstruct( only( Capella ) , partial_getter( rename = "body_capella" ) ) ]
68+ pub body : BeaconBlockBodyCapella < T , Payload > ,
6769 #[ superstruct( only( Eip4844 ) , partial_getter( rename = "body_eip4844" ) ) ]
6870 pub body : BeaconBlockBodyEip4844 < T , Payload > ,
6971}
7072
7173pub type BlindedBeaconBlock < E > = BeaconBlock < E , BlindedPayload < E > > ;
7274
73- impl < T : EthSpec , Payload : ExecPayload < T > > SignedRoot for BeaconBlock < T , Payload > { }
74- impl < ' a , T : EthSpec , Payload : ExecPayload < T > > SignedRoot for BeaconBlockRef < ' a , T , Payload > { }
75+ impl < T : EthSpec , Payload : AbstractExecPayload < T > > SignedRoot for BeaconBlock < T , Payload > { }
76+ impl < ' a , T : EthSpec , Payload : AbstractExecPayload < T > > SignedRoot
77+ for BeaconBlockRef < ' a , T , Payload >
78+ {
79+ }
7580
76- impl < T : EthSpec , Payload : ExecPayload < T > > BeaconBlock < T , Payload > {
81+ impl < T : EthSpec , Payload : AbstractExecPayload < T > > BeaconBlock < T , Payload > {
82+ // FIXME: deal with capella / eip4844 forks here as well
7783 /// Returns an empty block to be used during genesis.
7884 pub fn empty ( spec : & ChainSpec ) -> Self {
7985 if spec. bellatrix_fork_epoch == Some ( T :: genesis_epoch ( ) ) {
@@ -180,7 +186,7 @@ impl<T: EthSpec, Payload: ExecPayload<T>> BeaconBlock<T, Payload> {
180186 }
181187}
182188
183- impl < ' a , T : EthSpec , Payload : ExecPayload < T > > BeaconBlockRef < ' a , T , Payload > {
189+ impl < ' a , T : EthSpec , Payload : AbstractExecPayload < T > > BeaconBlockRef < ' a , T , Payload > {
184190 /// Returns the name of the fork pertaining to `self`.
185191 ///
186192 /// Will return an `Err` if `self` has been instantiated to a variant conflicting with the fork
@@ -191,6 +197,7 @@ impl<'a, T: EthSpec, Payload: ExecPayload<T>> BeaconBlockRef<'a, T, Payload> {
191197 BeaconBlockRef :: Base { .. } => ForkName :: Base ,
192198 BeaconBlockRef :: Altair { .. } => ForkName :: Altair ,
193199 BeaconBlockRef :: Merge { .. } => ForkName :: Merge ,
200+ BeaconBlockRef :: Capella { .. } => ForkName :: Capella ,
194201 BeaconBlockRef :: Eip4844 { .. } => ForkName :: Eip4844 ,
195202 } ;
196203
@@ -245,12 +252,12 @@ impl<'a, T: EthSpec, Payload: ExecPayload<T>> BeaconBlockRef<'a, T, Payload> {
245252
246253 /// Extracts a reference to an execution payload from a block, returning an error if the block
247254 /// is pre-merge.
248- pub fn execution_payload ( & self ) -> Result < & Payload , Error > {
255+ pub fn execution_payload ( & self ) -> Result < Payload :: Ref < ' a > , Error > {
249256 self . body ( ) . execution_payload ( )
250257 }
251258}
252259
253- impl < ' a , T : EthSpec , Payload : ExecPayload < T > > BeaconBlockRefMut < ' a , T , Payload > {
260+ impl < ' a , T : EthSpec , Payload : AbstractExecPayload < T > > BeaconBlockRefMut < ' a , T , Payload > {
254261 /// Convert a mutable reference to a beacon block to a mutable ref to its body.
255262 pub fn body_mut ( self ) -> BeaconBlockBodyRefMut < ' a , T , Payload > {
256263 map_beacon_block_ref_mut_into_beacon_block_body_ref_mut ! ( & ' a _, self , |block, cons| cons(
@@ -259,7 +266,7 @@ impl<'a, T: EthSpec, Payload: ExecPayload<T>> BeaconBlockRefMut<'a, T, Payload>
259266 }
260267}
261268
262- impl < T : EthSpec , Payload : ExecPayload < T > > BeaconBlockBase < T , Payload > {
269+ impl < T : EthSpec , Payload : AbstractExecPayload < T > > BeaconBlockBase < T , Payload > {
263270 /// Returns an empty block to be used during genesis.
264271 pub fn empty ( spec : & ChainSpec ) -> Self {
265272 BeaconBlockBase {
@@ -380,7 +387,7 @@ impl<T: EthSpec, Payload: ExecPayload<T>> BeaconBlockBase<T, Payload> {
380387 }
381388}
382389
383- impl < T : EthSpec , Payload : ExecPayload < T > > BeaconBlockAltair < T , Payload > {
390+ impl < T : EthSpec , Payload : AbstractExecPayload < T > > BeaconBlockAltair < T , Payload > {
384391 /// Returns an empty Altair block to be used during genesis.
385392 pub fn empty ( spec : & ChainSpec ) -> Self {
386393 BeaconBlockAltair {
@@ -439,7 +446,7 @@ impl<T: EthSpec, Payload: ExecPayload<T>> BeaconBlockAltair<T, Payload> {
439446 }
440447}
441448
442- impl < T : EthSpec , Payload : ExecPayload < T > > BeaconBlockMerge < T , Payload > {
449+ impl < T : EthSpec , Payload : AbstractExecPayload < T > > BeaconBlockMerge < T , Payload > {
443450 /// Returns an empty Merge block to be used during genesis.
444451 pub fn empty ( spec : & ChainSpec ) -> Self {
445452 BeaconBlockMerge {
@@ -461,7 +468,7 @@ impl<T: EthSpec, Payload: ExecPayload<T>> BeaconBlockMerge<T, Payload> {
461468 deposits : VariableList :: empty ( ) ,
462469 voluntary_exits : VariableList :: empty ( ) ,
463470 sync_aggregate : SyncAggregate :: empty ( ) ,
464- execution_payload : Payload :: default ( ) ,
471+ execution_payload : Payload :: Merge :: default ( ) ,
465472 } ,
466473 }
467474 }
@@ -536,7 +543,7 @@ macro_rules! impl_from {
536543 parent_root,
537544 state_root,
538545 body,
539- } , payload)
546+ } , payload. map ( Into :: into ) )
540547 }
541548 }
542549 }
@@ -545,6 +552,7 @@ macro_rules! impl_from {
545552impl_from ! ( BeaconBlockBase , <E , FullPayload <E >>, <E , BlindedPayload <E >>, |body: BeaconBlockBodyBase <_, _>| body. into( ) ) ;
546553impl_from ! ( BeaconBlockAltair , <E , FullPayload <E >>, <E , BlindedPayload <E >>, |body: BeaconBlockBodyAltair <_, _>| body. into( ) ) ;
547554impl_from ! ( BeaconBlockMerge , <E , FullPayload <E >>, <E , BlindedPayload <E >>, |body: BeaconBlockBodyMerge <_, _>| body. into( ) ) ;
555+ impl_from ! ( BeaconBlockCapella , <E , FullPayload <E >>, <E , BlindedPayload <E >>, |body: BeaconBlockBodyCapella <_, _>| body. into( ) ) ;
548556impl_from ! ( BeaconBlockEip4844 , <E , FullPayload <E >>, <E , BlindedPayload <E >>, |body: BeaconBlockBodyEip4844 <_, _>| body. into( ) ) ;
549557
550558// We can clone blocks with payloads to blocks without payloads, without cloning the payload.
@@ -576,6 +584,7 @@ macro_rules! impl_clone_as_blinded {
576584impl_clone_as_blinded ! ( BeaconBlockBase , <E , FullPayload <E >>, <E , BlindedPayload <E >>) ;
577585impl_clone_as_blinded ! ( BeaconBlockAltair , <E , FullPayload <E >>, <E , BlindedPayload <E >>) ;
578586impl_clone_as_blinded ! ( BeaconBlockMerge , <E , FullPayload <E >>, <E , BlindedPayload <E >>) ;
587+ impl_clone_as_blinded ! ( BeaconBlockCapella , <E , FullPayload <E >>, <E , BlindedPayload <E >>) ;
579588impl_clone_as_blinded ! ( BeaconBlockEip4844 , <E , FullPayload <E >>, <E , BlindedPayload <E >>) ;
580589
581590// A reference to a full beacon block can be cloned into a blinded beacon block, without cloning the
0 commit comments