You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This BlockEnv is then used in the TransactionExecutor which results in the block being mined with the incorrect block number (i.e l1BlockNumber + 1), instead of fork_block_number + 1.
Fix for this is a bit hacky:
In do_mine_block, for Arb specific chain_id's; temporarily set the env.block.number to storage.best_number (which is being correctly maintained). Use this modified BlockEnv in TransactionExecutor. After tx execution is complete and block is mined. Flip env.block.number back to maintain l1BlockNumber consistency.
yash-atreya
changed the title
bug(anvil): Arbitrum and anvil block mining inconsistency
bug(anvil): arbitrum and anvil block mining inconsistency
Oct 21, 2024
On arbitrum
env.block.number
isl1BlockNumber
. Seefoundry/crates/evm/core/src/utils.rs
Line 54 in 09824ad
So when we fork off of arbitrum the
env.block.number
is set tol1BlockNumber
that we get fromget_block(fork_block_number)
.However, upon mining a new block we increment
env.block.number
. Seefoundry/crates/anvil/src/eth/backend/mem/mod.rs
Line 1102 in 09824ad
This
BlockEnv
is then used in theTransactionExecutor
which results in the block being mined with the incorrect block number (i.el1BlockNumber + 1
), instead offork_block_number + 1
.Fix for this is a bit hacky:
In
do_mine_block
, for Arb specific chain_id's; temporarily set theenv.block.number
tostorage.best_number
(which is being correctly maintained). Use this modifiedBlockEnv
inTransactionExecutor
. After tx execution is complete and block is mined. Flipenv.block.number
back to maintainl1BlockNumber
consistency.@mattsse wdyt?
Originally posted by @yash-atreya in #9151 (comment)
The text was updated successfully, but these errors were encountered: