Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Fix try-runtime with create-snapshot (#13223)
Browse files Browse the repository at this point in the history
* Fix try-runtime with create-snapshot

* Apply review suggestions
  • Loading branch information
zjb0807 authored Jan 25, 2023
1 parent d22e68c commit d029225
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ where

let executor = build_executor::<HostFns>(&shared);
let _ = State::Live(command.from)
.into_ext::<Block, HostFns>(&shared, &executor, Some(path.into()))
.into_ext::<Block, HostFns>(&shared, &executor, Some(path.into()), false)
.await?;

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion utils/frame/try-runtime/cli/src/commands/execute_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ where
HostFns: HostFunctions,
{
let executor = build_executor::<HostFns>(&shared);
let ext = command.state.into_ext::<Block, HostFns>(&shared, &executor, None).await?;
let ext = command.state.into_ext::<Block, HostFns>(&shared, &executor, None, true).await?;

// get the block number associated with this block.
let block_ws_uri = command.block_ws_uri::<Block>();
Expand Down
2 changes: 1 addition & 1 deletion utils/frame/try-runtime/cli/src/commands/follow_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ where
pallet: vec![],
child_tree: true,
});
let ext = state.into_ext::<Block, HostFns>(&shared, &executor, None).await?;
let ext = state.into_ext::<Block, HostFns>(&shared, &executor, None, true).await?;
maybe_state_ext = Some(ext);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ where
{
let executor = build_executor(&shared);
// we first build the externalities with the remote code.
let ext = command.state.into_ext::<Block, HostFns>(&shared, &executor, None).await?;
let ext = command.state.into_ext::<Block, HostFns>(&shared, &executor, None, true).await?;

let header_ws_uri = command.header_ws_uri::<Block>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ where
HostFns: HostFunctions,
{
let executor = build_executor(&shared);
let ext = command.state.into_ext::<Block, HostFns>(&shared, &executor, None).await?;
let ext = command.state.into_ext::<Block, HostFns>(&shared, &executor, None, true).await?;

let (_, encoded_result) = state_machine_call_with_proof::<Block, HostFns>(
&ext,
Expand Down
7 changes: 5 additions & 2 deletions utils/frame/try-runtime/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ impl State {
shared: &SharedParams,
executor: &WasmExecutor<HostFns>,
state_snapshot: Option<SnapshotConfig>,
try_runtime_check: bool,
) -> sc_cli::Result<RemoteExternalities<Block>>
where
Block::Hash: FromStr,
Expand Down Expand Up @@ -707,8 +708,10 @@ impl State {
}

// whatever runtime we have in store now must have been compiled with try-runtime feature.
if !ensure_try_runtime::<Block, HostFns>(&executor, &mut ext) {
return Err("given runtime is NOT compiled with try-runtime feature!".into())
if try_runtime_check {
if !ensure_try_runtime::<Block, HostFns>(&executor, &mut ext) {
return Err("given runtime is NOT compiled with try-runtime feature!".into())
}
}

Ok(ext)
Expand Down

0 comments on commit d029225

Please sign in to comment.