Skip to content

Commit 6e1c4e9

Browse files
authored
Register storage-proof-size host function (#146)
## Problem `execute-block` and `follow-chain` fail on blocks that contain signed extrinsics, for any runtime that uses `cumulus-pallet-weight-reclaim`: ``` Execution aborted due to trap: call to a missing function env:ext_storage_proof_size_storage_proof_size_version_1 ``` The CLI registers only `sp_io::SubstrateHostFunctions`. The weight-reclaim transaction extension calls the cumulus `storage_proof_size` host function on every signed extrinsic. The executor cannot resolve it, so block execution traps. All current system-chain runtimes use this pallet (checked: 9 runtimes in polkadot-sdk, 11 in runtimes). The two commands are therefore unusable against modern parachains. ## Fix Register `cumulus_primitives_proof_size_hostfunction::storage_proof_size::HostFunctions` next to the substrate host functions. One line in `cli/main.rs`, plus the dependency. When no proof recording is active, the host function returns `u64::MAX`. Weight-reclaim treats that as "recording disabled" and skips reclaim. This is the correct behavior for try-runtime execution. ## Validation Controlled A/B on a local `asset-hub-westend` dev chain (omni-node, runtime with `try-runtime` feature): | Binary | Block content | Result | |---|---|---| | unpatched | only inherents (block 486) | executes | | unpatched | one signed `Balances::transfer_keep_alive` (block 487) | trap: missing function | | patched | same block 487 | `Block #487 successfully executed` | The empty-block success explains why the bug can go unnoticed: it only appears when a block carries a signed extrinsic. Also verified against ~500 blocks with `follow-chain --try-state Proxy` on the same chain: no traps, try-state hooks run per block.
1 parent 31453aa commit 6e1c4e9

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ substrate-rpc-client = { version = "~0.33", git = "https://github.com/paritytech
7272
polkadot-primitives = { version = "~7.0", git = "https://github.com/paritytech/polkadot-sdk", rev = "e1c5425b23f1" }
7373
cumulus-primitives-parachain-inherent = { version = "~0.7", git = "https://github.com/paritytech/polkadot-sdk", rev = "e1c5425b23f1" }
7474
cumulus-primitives-core = { version = "~0.7", git = "https://github.com/paritytech/polkadot-sdk", rev = "e1c5425b23f1" }
75+
cumulus-primitives-proof-size-hostfunction = { version = "~0.2", git = "https://github.com/paritytech/polkadot-sdk", rev = "e1c5425b23f1" }
7576
cumulus-client-parachain-inherent = { version = "~0.1", git = "https://github.com/paritytech/polkadot-sdk", rev = "e1c5425b23f1" }
7677

7778
# Local

cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ parity-scale-codec = { workspace = true, features = ["derive"] }
2222
tokio = { workspace = true, features = ["full"] }
2323

2424
sp-io = { workspace = true }
25+
cumulus-primitives-proof-size-hostfunction = { workspace = true }
2526
sp-core = { workspace = true }
2627
sp-runtime = { workspace = true }
2728
sp-state-machine = { workspace = true }

cli/main.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,15 @@ async fn main() {
360360
init_env();
361361

362362
let cmd = TryRuntime::parse();
363-
cmd.run::<Block<Header<u32, BlakeTwo256>, OpaqueExtrinsic>, sp_io::SubstrateHostFunctions>()
364-
.await
365-
.unwrap();
363+
// The cumulus `storage_proof_size` host function must be registered in addition to the
364+
// substrate ones: runtimes built with `cumulus-pallet-weight-reclaim` (all current system
365+
// chains) call it during the dispatch of every signed extrinsic, and block execution traps
366+
// with "call to a missing function" if it is absent. Without proof recording (the case
367+
// here) it returns `u64::MAX`, which weight-reclaim interprets as "recording disabled".
368+
cmd.run::<Block<Header<u32, BlakeTwo256>, OpaqueExtrinsic>, (
369+
sp_io::SubstrateHostFunctions,
370+
cumulus_primitives_proof_size_hostfunction::storage_proof_size::HostFunctions,
371+
)>()
372+
.await
373+
.unwrap();
366374
}

0 commit comments

Comments
 (0)