-
Notifications
You must be signed in to change notification settings - Fork 2k
eth_blockNumber
returns L1 block for Arbitrum fork
#6749
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
Comments
I realized I was running an old version of Anvil. I updated to the latest:
Same result. |
I see, this makes me think calling this when we instantiate the fork is wrong: foundry/crates/evm/core/src/utils.rs Lines 163 to 169 in 177a1f4
but in solidity so this is a bit horrible. We want to fork off the L2, what should happen with the |
Partly related to #748, you can see the arbitrum |
hmm, okay so the right fix for abitrum would be to not use the l1blocknumber for the fork target block number (L2), but unclear what we should do to |
I believe this is correct, since the RPC returns the L2 block number, we want to use L2 block numbers as the fork blocks
Paging @gzeoneth to help confirm and decide the best course of action. Both of these options seem ok but I'm not sure what's best for users, but I think I'd avoid a 1:1 relation between and L1 and L2 block numbers since that will likely never occur in practice |
okay, I thought about this for a bit and I think we need to track the best block separately in a dedicated variable and not using the evm.blocknumber since this is different for arb mind taking this on @Evalir foundry/crates/anvil/src/eth/backend/mem/mod.rs Lines 492 to 501 in c5fd67b
|
Yes, the ArbBlockNumber (L2 block number) will need to be tracked separately. I think having |
Ok I see my issue was closed as a dupe, but does add some important context - this issue goes away if you do not specify -- |
isn't simpler to reuse storage best number e.g. /// Returns the current best number of the chain
pub fn best_number(&self) -> u64 {
- self.env.read().block.number.try_into().unwrap_or(u64::MAX)
+ self.blockchain.storage.read().best_number.try_into().unwrap_or(u64::MAX)
} |
@grandizzy hmm I think you're right, I'm not sure what we should do with the env block number once we mined new blocks, also increase by 1? |
@mattsse IMO that would be perfectly fine, the only thing to make sure is we don't get best block overwritten when mining new blocks, so line here https://github.com/foundry-rs/foundry/blob/master/crates/anvil/src/eth/backend/mem/mod.rs#L926 should probably be let block_number: U64 = storage.best_number.saturating_add(U64::from(1)); I will do a PR with proposed changes |
looks like a different issue and will address in same PR - specifics of chain (like the fact that on Arbitrum |
Component
Anvil
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (6defdce 2023-05-17T00:04:50.286076000Z)
What command(s) is the bug in?
anvil
Operating System
macOS (Apple Silicon)
Describe the bug
An Anvil fork of Arbitrum returns the L1 block number over JSON-RPC. Based on the Arbitrum docs and the behavior of other providers, I expected it to return the L2 block number.
The text was updated successfully, but these errors were encountered: