-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix(anvil): set storage.best_number correctly
#9215
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
Conversation
|
@yash-atreya I added a test here, basically dumping state locally from gh issue recreate and reloading / make sure balance properly retrieved, feel free to include in PR if OK |
@grandizzy thanks for this. I've added a more comprehensive test. ptal. |
anvil): introduce account_at in ForkedStorageanvil): set storage.best_number correctly
|
@yash-atreya I suspect this is supposed to close #8493 too? If so, could you please update description to include it? thank you |
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.
lgtm!
* feat(`anvil`): persist accounts in `ForkedStorage` * load accounts * test * fix(`anvil`): override storage.best_number with fork_block_num if loading state on a fork url * Revert "load accounts" This reverts commit b650f56. * Revert "feat(`anvil`): persist accounts in `ForkedStorage`" This reverts commit 456da15. * nit --------- Co-authored-by: grandizzy <grandizzy.the.egg@gmail.com> * nit --------- Co-authored-by: grandizzy <grandizzy.the.egg@gmail.com>
Motivation
Closes #9053 + Closes #8493
This arises when
--fork-urland--load-stateare used together.Solution
Introduceaccount_atinForkedStoragewhich stores the state of accounts at specific block numbers.Populateaccount_atusing the provided state file.Solution is a lot simpler.
We are correctly loading the data to the db:
foundry/crates/anvil/src/eth/backend/mem/mod.rs
Line 925 in 4012ade
However, the
storage.best_numberi.e head of the chain is not correctly set when--load-stateis used with--fork-url. We continue to setstorage.best_number = state.block.numberwhich is incorrect as thebest_numbershould befork_block_number.This issue is observed when
fork_block_number>state.block_number. In this case while all state data has been correctly loaded to the db, we fetch via the provider due to this check.foundry/crates/anvil/src/eth/api.rs
Line 683 in 4012ade
Setting
storage.best_number = fork_block_numberfixes thisTest