@@ -5,7 +5,7 @@ use crate::{
55
66use alloy_primitives:: {
77 bytes:: { Buf , BufMut } ,
8- keccak256, B256 , U256 ,
8+ keccak256, B256 ,
99} ;
1010
1111/// The batch header for V0.
@@ -24,7 +24,7 @@ pub struct BatchHeaderV0 {
2424 /// The parent batch hash.
2525 pub parent_batch_hash : B256 ,
2626 /// A bitmap to indicate which L1 messages are skipped in the batch.
27- pub skipped_l1_message_bitmap : Vec < U256 > ,
27+ pub skipped_l1_message_bitmap : Vec < u8 > ,
2828}
2929
3030impl BatchHeaderV0 {
@@ -38,7 +38,7 @@ impl BatchHeaderV0 {
3838 total_l1_message_popped : u64 ,
3939 data_hash : B256 ,
4040 parent_batch_hash : B256 ,
41- skipped_l1_message_bitmap : Vec < U256 > ,
41+ skipped_l1_message_bitmap : Vec < u8 > ,
4242 ) -> Self {
4343 Self {
4444 version,
@@ -69,7 +69,9 @@ impl BatchHeaderV0 {
6969
7070 let skipped_l1_message_bitmap: Vec < _ > = buf
7171 . chunks ( SKIPPED_L1_MESSAGE_BITMAP_ITEM_BYTES_SIZE )
72- . map ( |chunk| U256 :: from_be_slice ( chunk) )
72+ . flatten ( )
73+ . rev ( )
74+ . copied ( )
7375 . collect ( ) ;
7476
7577 // check leftover bytes are correct.
@@ -78,7 +80,7 @@ impl BatchHeaderV0 {
7880 {
7981 return Err ( DecodingError :: Eof )
8082 }
81- buf. advance ( skipped_l1_message_bitmap. len ( ) * SKIPPED_L1_MESSAGE_BITMAP_ITEM_BYTES_SIZE ) ;
83+ buf. advance ( skipped_l1_message_bitmap. len ( ) ) ;
8284
8385 Ok ( Self {
8486 version,
@@ -104,12 +106,7 @@ impl BatchHeaderV0 {
104106 bytes. put_slice ( & self . data_hash . 0 ) ;
105107 bytes. put_slice ( & self . parent_batch_hash . 0 ) ;
106108
107- let skipped_l1_message_flat_bitmap = self
108- . skipped_l1_message_bitmap
109- . iter ( )
110- . flat_map ( |u| u. to_be_bytes :: < 32 > ( ) )
111- . collect :: < Vec < _ > > ( ) ;
112- bytes. put_slice ( & skipped_l1_message_flat_bitmap) ;
109+ bytes. put_slice ( & self . skipped_l1_message_bitmap ) ;
113110
114111 keccak256 ( bytes)
115112 }
@@ -119,7 +116,7 @@ impl BatchHeaderV0 {
119116mod tests {
120117 use crate :: decoding:: { test_utils:: read_to_bytes, v0:: BatchHeaderV0 } ;
121118
122- use alloy_primitives:: { b256, U256 } ;
119+ use alloy_primitives:: b256;
123120 use alloy_sol_types:: SolCall ;
124121 use scroll_l1:: abi:: calls:: commitBatchCall;
125122
@@ -139,7 +136,34 @@ mod tests {
139136 33 ,
140137 b256 ! ( "2aa3eeb5adebb96a49736583c744b89b0b3be45056e8e178106a42ab2cd1a063" ) ,
141138 b256 ! ( "c0173d7e3561501cf57913763c7c34716216092a222a99fe8b85dcb466730f56" ) ,
142- vec ! [ U256 :: ZERO ] ,
139+ vec ! [ 0 ; 32 ] ,
140+ ) ;
141+ assert_eq ! ( header, expected) ;
142+
143+ Ok ( ( ) )
144+ }
145+
146+ #[ test]
147+ fn test_should_decode_header_with_skipped_l1_messages ( ) -> eyre:: Result < ( ) > {
148+ // <https://sepolia.etherscan.io/tx/0xacacfe48bed1944d6586ca8f0bec3ecd10ea0a99e104517f75845b8602dcab31>
149+ let raw_commit_calldata =
150+ read_to_bytes ( "./testdata/calldata_v0_with_skipped_l1_messages.bin" ) ?;
151+ let commit_calldata = commitBatchCall:: abi_decode ( & raw_commit_calldata) ?;
152+
153+ let mut raw_batch_header = & * commit_calldata. parent_batch_header . to_vec ( ) ;
154+ let header = BatchHeaderV0 :: try_from_buf ( & mut raw_batch_header) ?;
155+
156+ let expected = BatchHeaderV0 :: new (
157+ 0 ,
158+ 100 ,
159+ 3 ,
160+ 22 ,
161+ b256 ! ( "4867e8b3c751abf5f0f8cd8e3e91f78ff15011b48b981ad742cb42dfd746844c" ) ,
162+ b256 ! ( "b4d0a673c704d567eebcd758802ce87cf103b16acbae7c52b2807928fd8dc76e" ) ,
163+ vec ! [
164+ 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
165+ 0 , 0 , 0 , 0 ,
166+ ] ,
143167 ) ;
144168 assert_eq ! ( header, expected) ;
145169
@@ -156,7 +180,7 @@ mod tests {
156180 33 ,
157181 b256 ! ( "2aa3eeb5adebb96a49736583c744b89b0b3be45056e8e178106a42ab2cd1a063" ) ,
158182 b256 ! ( "c0173d7e3561501cf57913763c7c34716216092a222a99fe8b85dcb466730f56" ) ,
159- vec ! [ U256 :: ZERO ] ,
183+ vec ! [ 0 ; 32 ] ,
160184 ) ;
161185
162186 let expected = b256 ! ( "A7F7C528E1827D3E64E406C76DE6C750D5FC3DE3DE4386E6C69958A89461D064" ) ;
0 commit comments