Repository navigation
bugc: give a storage mapping's pointer a template for its entry - #371
Merged
Merged
Conversation
Contributor
|
gnidan
force-pushed
the
bugc-mapping-entries
branch
from
October 7, 2026 03:56
a2c5b30 to
2cdd738
Compare
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.
A storage mapping's pointer gave only the mapping's slot, so a debugger could not find
players[alice]or its members from it. This gives the pointer a template for the mapping's entry, in the shape of thet_mappingtemplates that solc emits on its pointer-templates PR (argotorg/solidity#16990).For
players: mapping<address, Player>at slot 4, the pointer is now atemplatescollection around the region at the mapping's slot:{ "templates": { "entry": { "expect": ["slot", "key"], "for": { "define": { "slot": { "$keccak256": [{ "$wordsized": "key" }, { "$wordsized": "slot" }] } }, "in": { "group": [{ "name": "value-score", "...": "..." }, "..."] } } } }, "in": { "location": "storage", "slot": 4 } }As in solc, the template expects
slot(the mapping's slot) andkey, and the entry is at keccak256(key . slot), each a word. A value type there is a region namedvalue; a struct's members are namedvalue-<member>(value-score,value-combo, ...), with their offsets in the entry's slots as at a variable's own slot. A debugger readsplayers[k]with{ templates, in: { define: { slot: 4, key: k }, in: { template: "entry" } } }.bugc has no
info/resourcesto hold templates, so they sit in the variable's own pointer, all in onetemplatescollection at its root, and are named by the mapping's place instead of by a type id:entryfor a mapping variable,<name>-entryfor a mapping membername, andvalue-entryfor a mapping in an entry (value-value-entrytwo deep). For a nested mapping, the outer entry'svalueregion is the inner mapping's slot, which is theslotfor the inner template.A string member in an entry uses #369's generator with the
value-prefix, soplayers[k].nameresolves end to end asvalue-name-data(the name solc's templates give it too). #369's test read a mapping entry by calling the generator directly; it now reads it through the template.The test runs a contract with
mapping<address, Player>(a string member),mapping<address, uint256>andmapping<address, mapping<uint256, uint8>>at levels 0 to 3, stores entries for three keys (one name long enough for the long form), and resolves each entry with@ethdebug/pointersagainst the storage. This is debug info only: the bytecode of every example, of the test contract and of the Arcade demo contract is the same as before at levels 0 to 3.