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

fix(anvil): return correct data for queries at forked block #8428

Merged
merged 3 commits into from
Jul 12, 2024

Conversation

klkvr
Copy link
Member

@klkvr klkvr commented Jul 12, 2024

Motivation

Closes #4700

This is similar to #4140, however, 4140 was always initializing AtGenesisStateDb with self.db. Thus, all queries at fork_block were returning data from latest state.

It seems that we can safely use states[fork_block], because snapshots recorded in do_mine_block already contain inserted genesis accounts

let db = self.db.read().await.current_state();
// store current state before executing all transactions
self.states.write().insert(best_hash, db);

however, I might be missing something

Solution

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@mattsse mattsse merged commit 758630e into master Jul 12, 2024
20 checks passed
@mattsse mattsse deleted the klkvr/fix-anvil-fork-block-query branch July 12, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Anvil returns wrong account balance for last remote block after sending transaction
3 participants