diff --git a/prdoc/pr_9214.prdoc b/prdoc/pr_9214.prdoc new file mode 100644 index 0000000000000..fd13d2dee8027 --- /dev/null +++ b/prdoc/pr_9214.prdoc @@ -0,0 +1,10 @@ +title: Enable proof recording in trace_block +doc: + - audience: Node Dev + description: | + The RPC method `state_traceBlock` never enables proof recording, which causes it to fail on any substrate chain that uses `StorageWeightReclaim` with a storage root mismatch error. + + This PR enables proof recording in `trace_block`. This change is transparent to users and requires no configuration changes. +crates: + - name: sc-tracing + bump: minor \ No newline at end of file diff --git a/substrate/client/tracing/src/block/mod.rs b/substrate/client/tracing/src/block/mod.rs index 3ebbc3d97e171..d034a6b035836 100644 --- a/substrate/client/tracing/src/block/mod.rs +++ b/substrate/client/tracing/src/block/mod.rs @@ -228,7 +228,18 @@ where if let Err(e) = dispatcher::with_default(&dispatch, || { let span = tracing::info_span!(target: TRACE_TARGET, "trace_block"); let _enter = span.enter(); - self.client.runtime_api().execute_block(parent_hash, block) + + let mut runtime_api = self.client.runtime_api(); + + // Enable proof recording + runtime_api.record_proof(); + let recorder = runtime_api + .proof_recorder() + .expect("Proof recording is enabled in the line above; qed."); + runtime_api.register_extension(ProofSizeExt::new(recorder)); + + // Replay block + runtime_api.execute_block(parent_hash, block) }) { return Err(Error::Dispatch(format!( "Failed to collect traces and execute block: {}",