Fix "entries seen" chip double-counting on reserved rows - #10
Merged
Conversation
…ce row A single history.push(7) reported "2 entries seen" instead of 1. runtimeView's derivedCountByBase counted distinct resolution LABELS per baseVariable, but a dynamic array push touches two storage slots under the same baseVariable: the declared length slot itself (read on entry, rewritten on exit — labeled "history.length") and the actual new element at a keccak-derived slot (labeled "history[0]"). Both got counted as if they were derived entries, so one push always overcounted by exactly one. derivedRows.ts's buildDerivedChildren already solves this correctly for the child-row rendering added in v1.4: it explicitly excludes a variable's own declared slot from the derived set (`if (declaredSlots.has(slot)) continue`), counting only slots that are genuinely keccak-derived. StorageGrid.tsx already computes that exact list per row as `children`; the chip now reads its length instead of the separate, buggy derivedCountByBase mechanism. This also fixes the struct-nesting gap flagged when v1.4 shipped: derivedCountByBase keyed on baseVariable (a name), which never matched a mapping declared inside a struct (s.m vs baseVariable "m"). byParentSlot keys on the actual slot number, so it's correct regardless of nesting. derivedCountByBase is now dead (was used nowhere else) and removed, along with its now-obsolete unit test. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
The bug
A single
history.push(7)in a constructor reports "2 entries seen" on thehistoryreserved row, not 1.Root cause
runtimeView.ts'sderivedCountByBasecounted distinct resolution labelsgrouped by
baseVariable. A dynamic array'spushtouches two storage slotsunder the same
baseVariable("history"):history.lengthbyresolveReferenceBaseSlot;history[0].Both got counted as if they were derived entries, so the label-based count always
overcounted a push by exactly one — the reserved slot's own bookkeeping access was
mistaken for a second entry.
The fix
derivedRows.ts'sbuildDerivedChildren— added in v1.4 for the child-rowrendering — already solves this correctly: it explicitly excludes a variable's own
declared slot from the derived set (
if (declaredSlots.has(slot)) continue),counting only slots that are genuinely keccak-derived.
StorageGrid.tsxalreadycomputes that exact list per row as
children(it drives the rendered child rows).The chip now reads
children.lengthinstead of the separate, buggyderivedCountByBasemechanism — one source of truth, so the chip and the rows cannever disagree.
Bonus fix, same root cause: this also resolves the struct-nesting gap flagged
when v1.4 shipped.
derivedCountByBasekeyed onbaseVariable(a name), whichnever matched a mapping declared inside a struct (
s.mvsbaseVariable: "m").byParentSlotkeys on the actual slot number, so it's correct regardless ofnesting.
derivedCountByBasewas used nowhere else, so it's removed entirely along with itsnow-obsolete unit test, rather than left as a second, disagreeing mechanism.
Verification
Reproduced the exact reported scenario as an e2e assertion first (confirmed it
failed against the old code — showed "2 entries seen" — before applying the fix),
then verified green after:
format:check,lint,typechecktest:unittest:e2e(storage.spec.ts)test:e2e(full suite)fixtures:verifyrelease:verifybuild:check🤖 Generated with Claude Code