Ground keccak chains for nested reference heads - #5
Merged
Conversation
A mapping, dynamic array or bytes/string declared inside a struct or an array element could not be named at all. buildStaticIndex built variableBaseSlots from layout.storage, which lists top-level entries only, so referenceVariablesBySlot never saw a nested head, groundHash could not ground keccak(key || headSlot), and every access to such an entry resolved as unresolved — the product silently failed to name storage it otherwise understands. buildStaticIndex already decodes the layout for cellsBySlot, and that model carries every nested head as a collapsed span with its exact base slot and dotted path. Index those too. Verified end to end with a real compiled contract: a write to nest.inner[addr] inside a struct now resolves exact as `nest.inner[0xaa..]` where it previously reported unresolved. Two consumers get the same fix for free — string/bytes migration annotation and the bytes-data chunk labels both look variables up in the same index, so nested bytes/string heads now annotate correctly as well. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
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 defect
A mapping, dynamic array or
bytes/stringdeclared inside a struct or anarray element could not be named at all. Every access to one resolved as
unresolved— the product silently failed to name storage it otherwiseunderstands perfectly.
buildStaticIndexbuiltvariableBaseSlotsfromlayout.storage(
packages/semantics/src/resolve.ts:60-63), which lists top-level entriesonly. For
struct Nested { uint256 head; mapping(address => uint256) inner; }the layout entry is
nest; the mapping member is not there. SoreferenceVariablesBySlot(chains.ts:31) never saw the head,groundHashcould not groundkeccak(key ‖ headSlot), and the chain died.This was found while planning
slotscope-xu8(v1.4). The first diagnosis wasthat a nested head merely lost its display name; it is worse than that — the
resolution never happens.
The fix
buildStaticIndexalready decodes the layout to populatecellsBySlot, and thatmodel carries every nested head as a
CollapsedStorageSpanwith its exact baseslot, its dotted path (
nest.inner,pairs[1].m) and — since #4 — the solcencoding. Index those spans too. Eight lines, no new traversal, no new source of
truth.
Two consumers get the same repair for free, because both look variables up in
that index: string/bytes migration annotation (
resolve.ts:226) and thebytes-data chunk labels (
chains.ts:277). Nestedbytes/stringheads nowannotate correctly as well.
Verification
The new test in
chains.test.tscompiles and executes a real contract ratherthan asserting against a hand-built layout, and was confirmed failing first
(
expected 'unresolved' to be 'exact'). A write tonest.inner[addr]nowresolves exact as
nest.inner[0xaa…]with its value decoded.format:check,lint,typechecktest:unittest:e2efixtures:verifyrelease:verifyCloses
slotscope-02a. Unblocksslotscope-xu8(v1.4), which needs namingsettled before its UI work.
🤖 Generated with Claude Code