feat(u): add u slot subcommand for Solidity storage slot computation#5475
Open
bit2swaz wants to merge 2 commits into
Open
feat(u): add u slot subcommand for Solidity storage slot computation#5475bit2swaz wants to merge 2 commits into
u slot subcommand for Solidity storage slot computation#5475bit2swaz wants to merge 2 commits into
Conversation
|
@bit2swaz is attempting to deploy a commit to the unionbuild Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
@benluelo lmk if any changes are needed :) |
benluelo
reviewed
Jun 23, 2026
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.
Closes #3417.
What this does
Adds a
u slotsubcommand (aliasu s) to theuCLI. Given a Solidity storage layout type and an ordered list of keys, it prints the storage slot as a0x-prefixed 32-byte hex value to stdout.Keys go outermost to innermost. The output is bare (no label), so it pipes into other tools without any stripping.
Implementation
tools/u/src/slot.rswith three private functions:parse_layout(wraps the bare type in a dummy state variable sosyn-soliditycan parse it),parse_mapping_key(maps a Solidity key type and string value toMappingKey), andbuild_slot(walks the type tree consuming keys front-to-back, allocating eachSlotnode in atyped_arena::Arenato satisfy the borrow-based lifetime constraints).solidity-slotlibrary unchanged.main.rsasCmd::Slotwith visible aliass.syn-solidityandtyped-arenato workspace dependencies.Test coverage
14 unit tests covering: nested mapping + array layout parsing, all supported key types (
uint256,uint64,bytes32,string), rejection of unsupported types and malformed inputs, the known-answer vector from the issue, too-few and too-many keys, a single mapping, a single dynamic array, and abytes32key.Checklist
cargo clippy -p u --all-targetspassescargo fmt -p uproduces no diffcargo test -p upasses (14/14)tools/ucrate, no new crate