-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Improved error message when forking with non archive node #5131
Improved error message when forking with non archive node #5131
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like where this is going! I have a few nits, mainly:
- slimming down abstractions and the complexity and doing things in a most straightforward manner
- Checking if we can actually fork recent blocks with non-archive nodes, as I strongly believe this is the case (fwiw most RPC urls used are not archive nodes and work perfectly for tests, we shouldn't block people from using them)
Hey, thanks for the review! Just to clarify: the warning is not displayed if a node successfully returns older blocks, so I don't think it should a problem when forking from a recent block with a non-archive node. I'm addressing the other issues. |
Co-authored-by: evalir <[email protected]>
Co-authored-by: evalir <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aight this seems correct now! @mattsse would love your eyes on this if possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, ty, big QoL improvement and should hopefully prevent new foundry issues for non archive nodes
// the block, and the block number is less than equal the latest block, then | ||
// the user is forking from a non-archive node with an older block number. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this sounds correct
Motivation
Improve error message when a user forks from an older block with a non-archive node. Motivated by #4962
Solution
The solution is to log the following message when an RPC error was caused with high certainty by forking from a non-archive node:
We can detect this if we get an RPC error message that includes "missing trie node", e.g.:
Or if we try to fetch an older block and
get_block
returns null.I chose
error
log level in thecli
create instead ofwarning
as warnings don't seem to be logged by default and I didn't want to change to default log levels. I put the warning message into the panic message in theanvil
crate aserror
level logs don't seem to be logged by default inanvil
.As an alternative solution I explored creating a separate error type for forking from a non-archive node, but ultimately decided against it for the following reasons:
Testing
A repro for #4962 can be found in this repository: https://github.com/agostbiro/foundry-fork-error-repro/
I tested the changes locally by running
forge test
on the repro and by runninganvil
in fork mode with an older block using a non-archive node.Reviewing
Many of the changes in
anvil/src/config.rs
are an unfortunate consequence ofrustfmt
deciding on a different formatting for the file after I changed a few lines. I isolated the formatting changes in a separate commit.