fix(storage): correct Created/Selfdestructed flag interaction in AccountUpdate merge#4
Open
wpank wants to merge 2 commits into
Open
Conversation
…untUpdate merge When merging account updates, a create followed by a selfdestruct left both flags set simultaneously. This caused build_batches() to only bump the storage generation counter by 1 instead of 2, allowing ghost storage slots from between the CREATE2 and SELFDESTRUCT to survive under the new generation. Future deployments at the same address via CREATE2 could then read stale storage. Two fixes applied: 1. In AccountUpdate::merge(), clear self.created when selfdestructed is true. A selfdestruct supersedes a prior create -- the account does not exist at the end of the changeset. 2. In build_batches(), count generation bumps independently for created and selfdestructed flags (defense-in-depth), so even if both flags are somehow set, the generation increments by 2 rather than 1. Added 6 tests covering: - create-then-selfdestruct clears created flag - selfdestruct-then-create preserves created flag - both flags in a single merge - generation bump for created, selfdestruct, and both Closes #141 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AccountUpdate::merge()to clear thecreatedflag whenselfdestructedis applied, preventing both flags from being simultaneously true after a CREATE2 followed by SELFDESTRUCT in the same changesetbuild_batches()to count generation bumps independently forcreatedandselfdestructedflags (defense-in-depth), ensuring the generation counter increments by 2 when both transitions occurTest plan
cargo test -p kora-qmdb-- all 42 tests pass (6 new)cargo check -p kora-qmdb-- compiles cleanCloses #141
🤖 Generated with Claude Code