@@ -8,6 +8,7 @@ use core::{
88 pin:: Pin ,
99 task:: { ready, Context , Poll } ,
1010} ;
11+ use derive_more:: { Deref , DerefMut } ;
1112use reth_primitives_traits:: transaction:: signed:: SignedTransaction ;
1213use reth_scroll_primitives:: { ScrollBlock , ScrollTransactionSigned } ;
1314use scroll_alloy_consensus:: L1_MESSAGE_TRANSACTION_TYPE ;
@@ -83,69 +84,84 @@ impl arbitrary::Arbitrary<'_> for BlockInfo {
8384 }
8485}
8586
86- /// A type alias for a wrapper around a type to which a L1 finalized block number is attached.
87- pub type WithFinalizedBlockNumber < T > = WithBlockNumber < T > ;
88-
8987/// A wrapper around a type to which a block number is attached.
90- #[ derive( Debug , Default , Copy , Clone , PartialEq , Eq ) ]
91- pub struct WithBlockNumber < T > {
92- /// The block number.
93- pub number : u64 ,
88+ #[ derive( Debug , Deref , DerefMut , Default , Copy , Clone , PartialEq , Eq ) ]
89+ pub struct WithL2BlockNumber < T > {
90+ /// The L2 block number.
91+ pub l2_block : u64 ,
9492 /// The wrapped type.
93+ #[ deref]
94+ #[ deref_mut]
9595 pub inner : T ,
9696}
9797
98- impl < T > WithBlockNumber < T > {
98+ impl < T > WithL2BlockNumber < T > {
9999 /// Returns a new instance of a [`WithBlockNumber`] wrapper.
100- pub const fn new ( number : u64 , inner : T ) -> Self {
101- Self { number , inner }
100+ pub const fn new ( l2_block : u64 , inner : T ) -> Self {
101+ Self { l2_block , inner }
102102 }
103103}
104104
105- impl < T : Future + Unpin > Future for WithBlockNumber < T > {
106- type Output = WithBlockNumber < <T as Future >:: Output > ;
105+ impl < T : Future + Unpin > Future for WithL2BlockNumber < T > {
106+ type Output = WithL2BlockNumber < <T as Future >:: Output > ;
107107
108108 fn poll ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
109- let block_number = self . number ;
109+ let block_number = self . l2_block ;
110110 let inner = ready ! ( Pin :: new( & mut self . get_mut( ) . inner) . poll( cx) ) ;
111- Poll :: Ready ( WithBlockNumber :: new ( block_number, inner) )
111+ Poll :: Ready ( WithL2BlockNumber :: new ( block_number, inner) )
112+ }
113+ }
114+
115+ /// A wrapper around a type to which a block number is attached.
116+ #[ derive( Debug , Deref , DerefMut , Default , Copy , Clone , PartialEq , Eq ) ]
117+ pub struct WithL1FinalizedBlockNumber < T > {
118+ /// The block number.
119+ pub l1_block : u64 ,
120+ /// The wrapped type.
121+ #[ deref]
122+ #[ deref_mut]
123+ pub inner : T ,
124+ }
125+
126+ impl < T > WithL1FinalizedBlockNumber < T > {
127+ /// Returns a new instance of a [`WithBlockNumber`] wrapper.
128+ pub const fn new ( l1_block : u64 , inner : T ) -> Self {
129+ Self { l1_block, inner }
112130 }
113131}
114132
115- /// A type alias for a wrapper around a type to which a finalized batch information is attached.
116- pub type WithFinalizedBatchInfo < T > = WithBatchInfo < T > ;
133+ impl < T : Future + Unpin > Future for WithL1FinalizedBlockNumber < T > {
134+ type Output = WithL1FinalizedBlockNumber < < T as Future > :: Output > ;
117135
118- /// A type alias for a wrapper around a type to which a committed batch information is attached.
119- pub type WithCommittedBatchInfo < T > = WithBatchInfo < T > ;
136+ fn poll ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
137+ let block_number = self . l1_block ;
138+ let inner = ready ! ( Pin :: new( & mut self . get_mut( ) . inner) . poll( cx) ) ;
139+ Poll :: Ready ( WithL1FinalizedBlockNumber :: new ( block_number, inner) )
140+ }
141+ }
120142
121143/// A wrapper around a type to which a batch information is attached.
122- #[ derive( Debug , Default , Copy , Clone , PartialEq , Eq ) ]
144+ #[ derive( Debug , Deref , DerefMut , Default , Copy , Clone , PartialEq , Eq ) ]
123145pub struct WithBatchInfo < T > {
124- /// The l1 block number associated with the batch.
125- pub number : u64 ,
126146 /// The index of the batch.
127147 pub index : u64 ,
148+ /// The hash of the batch.
149+ pub hash : B256 ,
128150 /// The wrapped type.
151+ #[ deref]
152+ #[ deref_mut]
129153 pub inner : T ,
130154}
131155
132156impl < T > WithBatchInfo < T > {
133157 /// Returns a new instance of a [`WithBatchInfo`] wrapper.
134- pub const fn new ( index : u64 , number : u64 , inner : T ) -> Self {
135- Self { index, number , inner }
158+ pub const fn new ( index : u64 , hash : B256 , inner : T ) -> Self {
159+ Self { index, hash , inner }
136160 }
137161}
138162
139- impl < T : Future + Unpin > Future for WithBatchInfo < T > {
140- type Output = WithBatchInfo < <T as Future >:: Output > ;
141-
142- fn poll ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
143- let block_number = self . number ;
144- let index = self . index ;
145- let inner = ready ! ( Pin :: new( & mut self . get_mut( ) . inner) . poll( cx) ) ;
146- Poll :: Ready ( WithBatchInfo :: new ( index, block_number, inner) )
147- }
148- }
163+ /// Type alias for a wrapper type with the full L2 metadata.
164+ pub type WithFullL2Meta < T > = WithL1FinalizedBlockNumber < WithL2BlockNumber < WithBatchInfo < T > > > ;
149165
150166/// This struct represents an L2 block with a vector the hashes of the L1 messages included in the
151167/// block.
0 commit comments