Repository navigation
[v2] fix(ast): spell storage layout types as solc labels them - #2203
Merged
Merged
Conversation
Storage layout type names used the prefix-free internal spelling, which reduces every function type to `function` and drops the `struct `/`enum `/ `contract ` prefixes and `address payable` that solc's storageLayout labels carry. They now use solc's `Type::toString(true)` spelling, the same one the ABI `internalType` already renders, extended to mappings so nested keys and values keep their prefixes. Fixes #2196.
|
Contributor
|
| Branch | bas/storage-layout-solc-type-labels |
| Testbed | ci |
🐰 View full continuous benchmarking report in Bencher
⚠️ WARNING: Truncated view!The full continuous benchmarking report exceeds the maximum length allowed on this platform.
nebasuke
marked this pull request as ready for review
September 25, 2026 22:05
nebasuke
added a commit
that referenced
this pull request
Oct 9, 2026
#2215 gives the storage layout a types table shaped like solc's, so `storage_types` now follows each item's type through both tables at once (array bases, mapping keys and values, struct members) and compares label, numberOfBytes and encoding, instead of the item's type label alone. The two tables key types differently, so they are paired by walking, not by name. The same checks run on `transientStorageLayout`. The #2196 entry goes: #2203 fixed the labels it tolerated.
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.
Fixes #2196 by using
solc's spelling for storage layout types.Claude summary
Fixes #2196. Storage layout type names now read as solc's
storageLayoutlabels:struct S,enum C.E,contract I,address payable, and function types with their signature,function (uint256,struct Store.TokenData) view returns (string), also inside mappings and arrays.Before, they used the prefix-free internal spelling, which drops all four and reduces every function
type to the bare word
function.solc spells both its storage labels and the JSON ABI
internalTypewithType::toString(true),which Slang already renders for the ABI. The storage layout now uses that spelling, which gains a
mapping case so that keys and values keep their prefixes too.
StorageItem::type_name()changes for every user-defined,address payableand function type.Tests
A new fixture asserts solc 0.8.35's labels for one source covering function types (bare, in a
mapping,
external,pure,payable), structs in mappings and arrays, enums, interfaces,address payablenext toaddress, a user-defined value type and a nested mapping. It fails onmainwith every one of those differences; five existing expectations gain theirstructprefix.Corpus
With #2199's
storage_typescheck comparing exactly (no prefix normalisation), over the wholeSourcify 0.8.x corpus (2,326,676 contracts):
storage_typesfailuresstorage_layoutfailuresmainEvery other bucket is unchanged: with this PR the census passes 2,286,059 contracts, as
maindidbefore the storage checks existed.
Performance
The solc spelling builds more text per storage item, and building it with nested
format!callscost +2.3% instructions on
compute_contracts_abifor cooldogs, the Bencher alert on the firstcommit. The second commit writes each type name into one buffer instead, which puts the ABI
benchmarks below
main. Bencher on the tip, no alerts; the other benchmarks don't move:compute_contracts_abiNot here
Internal signatures keep the prefix-free spelling, so two overloads differing only in a
function-typed parameter still share one,
f(function).