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

core/state: revert pending storage updates if they revert to original #29661

Merged
merged 1 commit into from Apr 26, 2024

Conversation

karalabe
Copy link
Member

@karalabe karalabe commented Apr 26, 2024

There are two cases in state object updates that have unexpected leftovers:

  • Single tx sets slot from A -> B -> A. In this case the current code will mark the slot marked as updated, but won't prefetch it (that part was smarter). Later the commit (stateObject.updateTrie) will try to fetch the trie from the prefetcher, failing, after which it makes a fresh one from the db, only to throw it out because the slot didn't really change.
  • Tx1 sets slot from A -> B; after which tx2 sets the same slot from B -> A within the same block. The effect is similar, but the cause slightly different. Tx1 marks the slot updated, and tx2 leaves it as updated, even though it reverted to it's original.

The fix in this PR is fairly simple: whenever a slot is change back to it's original (during tx finalization), remove the update marker off of it (pending).

The PR also adds a log to stateObject.updateTrie to detect if we missed a similar case and be noisy about it.

Screenshot 2024-04-26 at 11 11 44

@karalabe karalabe added this to the 1.14.1 milestone Apr 26, 2024
@karalabe karalabe force-pushed the statedb-avoid-spurious-entrie branch from 08375ae to e377c89 Compare April 26, 2024 08:05
@karalabe karalabe force-pushed the statedb-avoid-spurious-entrie branch from e377c89 to 5302716 Compare April 26, 2024 08:07
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

@karalabe karalabe merged commit 8d42e11 into ethereum:master Apr 26, 2024
3 checks passed
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.

None yet

3 participants