Repository navigation
fix(storage): hash the map key in storage get --key - #180
Merged
illuzen merged 2 commits intoOct 19, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
n13
approved these changes
Oct 19, 2026
n13
left a comment
Contributor
There was a problem hiding this comment.
Reviewer model: GPT-6.1 Sol
APPROVE — no blocking findings in the diff from a74fd735fdb7cae2381b66dbaaa513630c0d58d9 to f3b638795462d5a0c6f8c02ee2ac2dd148a0c83e.
The seven hasher implementations match Subxt's storage-key construction. The caller selects metadata for the requested block before looking up the hasher; plain values and maps requiring multiple hashers return errors. The complete --storage-key path remains valid, and other keyed storage reads already use Subxt.
Validation:
SKIP_CIRCUIT_BUILD=1 cargo test --locked --lib cli::storage::tests: 8 passed, including both new regression tests.cargo +nightly-2026-08-31 fmt --all -- --check: passed.git diff --check a74fd735fdb7cae2381b66dbaaa513630c0d58d9...f3b638795462d5a0c6f8c02ee2ac2dd148a0c83e: passed.- GitHub format, dependency cooldown, Clippy/documentation, and security-audit checks passed. The Linux/macOS build-and-test and example jobs are still running.
Local validation was limited to the storage tests; circuit generation was skipped.
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.
Summary
quantus storage get --pallet <P> --name <N> --key <K> --key-type <T>builds the storage key astwox128(P) ++ twox128(N) ++ encode(K). It never applies the map's hasher. ForSystem::Account(Blake2_128Concat), the example in the--keyhelp text, the resulting key does not exist, so the command always prints "No value found". (#27 worked around this by passing a hand-built--storage-key.)This PR looks up the entry's hasher in the live metadata and applies it to the encoded key (all seven
StorageHashervariants). Using--keyon a plain value, or on a map with more than one key, now returns a clear error instead of silently querying a key that does not exist.Before (key built by the CLI) vs. what subxt's codegen produces for
System::Account([7; 32]):Testing
storage_map_key_matches_codegen_for_system_account, which compares againstget_address_bytesfor the generatedSystem::Accountaddress using the checked-in metadata, andstorage_map_key_rejects_plain_storage_value. Both fail onmainand pass with this change.cargo test --lib,cargo clippy --all-targets -- -D warnings,cargo +nightly-2026-08-31 fmt --check. The only test failure isbatch_verifier::loads_private_and_public_batch_verifiers, which needs generated circuit bins that I skipped withSKIP_CIRCUIT_BUILD=1.I used an AI assistant (Claude) while preparing this. I reproduced the issue and checked the fix and tests myself.
🤖 Generated with Claude Code