light-base: child-trie support for chainHead_v1_storage#3278
Merged
Conversation
Adds child-trie reads to chainHead_v1_storage so callers can read contract storage (or any default child trie) without going through a runtime call. - sync_service: new `child_storage_query` that fetches a child storage proof, resolves the child root from the main trie at `:child_storage:default:<child_trie>`, and verifies each requested key against it. Only Value and Hash request types are supported. - json_rpc_service: chainHead_v1_storage routes to `child_storage_query` when `childTrie` is set, and rejects unsupported request types in that mode with `-32000`. - codec: `build_child_storage_proof_request` now sends the prefixed `:child_storage:default:<child_trie>` key in field 3 of the protobuf RemoteReadChildRequest. Substrate's `ChildType::from_prefixed_key` rejects the bare child trie name with `InvalidChildStorageKey`, so the prefix must be present. This path was previously unexercised because runtime calls prefer call proofs for small parameters.
skunert
reviewed
Jun 1, 2026
Addresses two review comments on #3278: - Add `trie::default_child_trie_root_key` (and `DEFAULT_CHILD_STORAGE_PREFIX`) for the `:child_storage:default:<trie_id>` lookup key. Use it from the new child-storage codec and effective-root resolution, plus the pre-existing duplicates in `runtime_call.rs`, `state_request.rs`, `runtime_service.rs` (both call sites), and `sync_service/parachain.rs`. - Replace the isomorphic `ChildStorageProofRequestError` -> `StorageProofRequestError` squash in `StorageQuery::advance` with a proper `StorageQueryNetworkError` wrapper that preserves which side the error came from. `StorageQueryErrorDetail::Network` now carries the wrapper. Small helpers on it (`is_no_connection`, `is_request_too_large`, `protocol_request_error`) keep the existing branching logic and `is_network_problem` readable.
lexnv
reviewed
Jun 2, 2026
skunert
approved these changes
Jun 2, 2026
Merged
lrubasze
added a commit
that referenced
this pull request
Jun 2, 2026
This is to: - publish `smoldot-v3.2.0` npm. - publish crates `smoldot-light v1.2.0`, `smoldot v1.2.0` ## Changes ### Added - `chainHead_v1_storage` can now read child-trie storage (the default child trie), letting callers read e.g. contract storage directly without going through a runtime call. ([#3278](#3278)) - Implement the `ext_trie_blake2_256_verify_proof_version_1` and `ext_trie_blake2_256_verify_proof_version_2` host functions. The verifier handles Substrate's compact proof format (as produced by `sp_trie::generate_trie_proof`). ([#3263](#3263)) ### Fixed - `ext_transaction_index_index_version_1` and `ext_transaction_index_renew_version_1` now consume their parameters with the correct wasm value types (3xI32 and 2xI32 respectively), fixing a wasm-executor crash when a substrate runtime calls either function. Behavior remains a no-op since smoldot is a light client. ([#3263](#3263))
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
chainHead_v1_storageso callers can read contract storage (or any default child trie) without going through a runtime call.