test(ethexe-runtime-common): repro for stale region hash on full-region clear (auto-tester) — refs #5373#5528
Draft
grishasobol wants to merge 1 commit into
Draft
Conversation
…es remove_and_store_regions (auto-tester) a07d9f041168 — refs #5373 Co-Authored-By: Claude Opus 4.7 (1M context) <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.
MemoryPages::remove_and_store_regionsleaves a stale region hash inself[region_idx]when removing the last page in a region. The aggregateMemoryPageshash does not change after the removal, despite the region being observationally empty.Scenario:
invalid_combinationHash:
a07d9f041168Unit:
ethexe-runtime-commonTracks: closed issue #5373 "Update of memory pages keeps hash of empty region" — the
// TODO #5373marker is still present in the source.Observed
Reproduces 3/3 deterministically.
Rubric items satisfied
// TODO #5373atethexe/runtime/common/src/state.rs:1058explicitly marks this code as broken; closed issue #5373 documents the invariant: "Update of memory pages keeps hash of empty region" must NOT happen.Root cause
region.store(storage)returnsMaybeHashOf::empty()for an empty region (no pages left after removal)..to_inner()then returnsNone, so the if-let block does not execute andself[region_idx]retains the OLD (non-empty) region hash from before the removal.Suggested fix
Replace the if-let with an unconditional update that handles both branches:
This requires
selfto holdMaybeHashOf<Region>per slot (or an analogous "empty" sentinel) so an empty region is representable. Currentlyself[region_idx]isHashOf<...>, so a one-line replacement is not enough — the bug is correctly tagged with the TODO because a small refactor of the index type is needed.Note: closed issue #5373 already proposes this work. This PR provides a failing test that fixes a closed-but-not-implemented issue should be marked with.
Practical reachability
Anywhere
pallet-gear-stylepage lifecycle clears regions:gr_exit, terminated programs, lazy-page release on full-region eviction. State-hash mismatch across nodes is consensus-critical for ethexe — nodes that handle this code path differently (e.g. different versions during an upgrade) would diverge at commitment time.Test source
Generated by
/gear-dev:tester(auto-tester). This is a draft PR — requires human review before merge. Closed issue #5373 may need reopening since the TODO is still in source.