Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(anvil): arbitrum and anvil block mining inconsistency #9152

Closed
yash-atreya opened this issue Oct 21, 2024 · 0 comments · Fixed by #9153
Closed

bug(anvil): arbitrum and anvil block mining inconsistency #9152

yash-atreya opened this issue Oct 21, 2024 · 0 comments · Fixed by #9153
Assignees
Labels
C-anvil Command: anvil T-bug Type: bug

Comments

@yash-atreya
Copy link
Member

          There's a deeper issue with how we handle Arbitrum in anvil, which is causing the `test_arbitrum_fork_block_number` to fail.

On arbitrum env.block.number is l1BlockNumber. See

// on arbitrum `block.number` is the L1 block which is included in the

So when we fork off of arbitrum the env.block.number is set to l1BlockNumber that we get from get_block(fork_block_number).

However, upon mining a new block we incrementenv.block.number. See

env.block.number = env.block.number.saturating_add(U256::from(1));
.

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.

@mattsse wdyt?

Originally posted by @yash-atreya in #9151 (comment)

@github-project-automation github-project-automation bot moved this to Todo in Foundry Oct 21, 2024
@yash-atreya yash-atreya self-assigned this Oct 21, 2024
@yash-atreya yash-atreya changed the title bug(anvil): Arbitrum and anvil block mining inconsistency bug(anvil): arbitrum and anvil block mining inconsistency Oct 21, 2024
@yash-atreya yash-atreya added T-bug Type: bug C-anvil Command: anvil labels Oct 21, 2024
@yash-atreya yash-atreya moved this from Todo to Completed in Foundry Oct 21, 2024
@yash-atreya yash-atreya moved this from Completed to In Progress in Foundry Oct 21, 2024
@yash-atreya yash-atreya moved this from In Progress to Ready For Review in Foundry Oct 21, 2024
@github-project-automation github-project-automation bot moved this from Ready For Review to Done in Foundry Oct 21, 2024
@grandizzy grandizzy moved this from Done to Completed in Foundry Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-anvil Command: anvil T-bug Type: bug
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.

1 participant