@@ -67,6 +67,7 @@ use anvil_core::eth::{
6767} ;
6868use anvil_rpc:: error:: RpcError ;
6969
70+ use alloy_chains:: NamedChain ;
7071use flate2:: { read:: GzDecoder , write:: GzEncoder , Compression } ;
7172use foundry_evm:: {
7273 backend:: { DatabaseError , DatabaseResult , RevertSnapshotAction } ,
@@ -1645,7 +1646,7 @@ impl Backend {
16451646 Some ( block. into_full_block ( transactions. into_iter ( ) . map ( |t| t. inner ) . collect ( ) ) )
16461647 }
16471648
1648- /// Takes a block as it's stored internally and returns the eth api conform block format
1649+ /// Takes a block as it's stored internally and returns the eth api conform block format.
16491650 pub fn convert_block ( & self , block : Block ) -> AlloyBlock {
16501651 let size = U256 :: from ( alloy_rlp:: encode ( & block) . len ( ) as u32 ) ;
16511652
@@ -1676,7 +1677,7 @@ impl Backend {
16761677 parent_beacon_block_root,
16771678 } = header;
16781679
1679- AlloyBlock {
1680+ let mut block = AlloyBlock {
16801681 header : AlloyHeader {
16811682 hash : Some ( hash) ,
16821683 parent_hash,
@@ -1709,7 +1710,23 @@ impl Backend {
17091710 uncles : vec ! [ ] ,
17101711 withdrawals : None ,
17111712 other : Default :: default ( ) ,
1712- }
1713+ } ;
1714+
1715+ // If Arbitrum, apply chain specifics to converted block.
1716+ if let Ok (
1717+ NamedChain :: Arbitrum |
1718+ NamedChain :: ArbitrumGoerli |
1719+ NamedChain :: ArbitrumNova |
1720+ NamedChain :: ArbitrumTestnet ,
1721+ ) = NamedChain :: try_from ( self . env . read ( ) . env . cfg . chain_id )
1722+ {
1723+ // Block number is the best number.
1724+ block. header . number = Some ( self . best_number ( ) ) ;
1725+ // Set `l1BlockNumber` field.
1726+ block. other . insert ( "l1BlockNumber" . to_string ( ) , number. into ( ) ) ;
1727+ }
1728+
1729+ block
17131730 }
17141731
17151732 /// Converts the `BlockNumber` into a numeric value
0 commit comments