Skip to content

fix(storage): correct Created/Selfdestructed flag interaction in AccountUpdate merge#4

Open
wpank wants to merge 2 commits into
Nunchi-trade:mainfrom
wpank:fix/storage-account-update-merge-flags
Open

fix(storage): correct Created/Selfdestructed flag interaction in AccountUpdate merge#4
wpank wants to merge 2 commits into
Nunchi-trade:mainfrom
wpank:fix/storage-account-update-merge-flags

Conversation

@wpank
Copy link
Copy Markdown

@wpank wpank commented May 30, 2026

Summary

  • Fix AccountUpdate::merge() to clear the created flag when selfdestructed is applied, preventing both flags from being simultaneously true after a CREATE2 followed by SELFDESTRUCT in the same changeset
  • Fix build_batches() to count generation bumps independently for created and selfdestructed flags (defense-in-depth), ensuring the generation counter increments by 2 when both transitions occur
  • Add 6 tests covering all flag interaction scenarios (create-then-selfdestruct, selfdestruct-then-create, both flags in single merge, and generation bump verification)

Test plan

  • cargo test -p kora-qmdb -- all 42 tests pass (6 new)
  • cargo check -p kora-qmdb -- compiles clean
  • Verify no ghost storage slots in CREATE2+SELFDESTRUCT scenario on testnet

Closes #141

🤖 Generated with Claude Code

will pankiewicz and others added 2 commits May 29, 2026 22:43
…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>
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.

1 participant