Skip to content

Commit

Permalink
fix up merge
Browse files Browse the repository at this point in the history
  • Loading branch information
liamaharon committed Nov 17, 2023
1 parent 42025ee commit 18b13c0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 33 deletions.
23 changes: 6 additions & 17 deletions core/src/commands/execute_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,6 @@ where
HostFns: HostFunctions,
{
let executor = build_executor::<HostFns>(&shared);
let runtime_checks = RuntimeChecks {
name_matches: shared.check_spec_name,
version_increases: false,
try_runtime_feature_enabled: true,
};
let ext = command
.state
.to_ext::<Block, HostFns>(&shared, &executor, None, runtime_checks)
.await?;

// get the block number associated with this block.
let block_ws_uri = command.block_ws_uri();
let rpc = ws_client(&block_ws_uri).await?;
Expand All @@ -121,14 +111,13 @@ where
let prev_block_live_state = live_state.to_prev_block_live_state::<Block>().await?;

// Get state for the prev block
let runtime_checks = RuntimeChecks {
name_matches: shared.check_spec_name,
version_increases: false,
try_runtime_feature_enabled: true,
};
let ext = State::Live(prev_block_live_state)
.to_ext::<Block, HostFns>(
&shared,
&executor,
None,
TryRuntimeFeatureCheck::Check,
SpecVersionCheck::Skip,
)
.to_ext::<Block, HostFns>(&shared, &executor, None, runtime_checks)
.await?;

// Execute the desired block on top of it
Expand Down
33 changes: 17 additions & 16 deletions core/src/commands/offchain_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ use sp_runtime::traits::{Block as BlockT, NumberFor};
use substrate_rpc_client::{ws_client, ChainApi};

use crate::{
build_executor,
commands::execute_block::next_hash_of,
full_extensions, parse, rpc_err_handler,
state::{LiveState, RuntimeChecks, SpecVersionCheck, State, TryRuntimeFeatureCheck},
build_executor, full_extensions, parse, rpc_err_handler,
state::{LiveState, RuntimeChecks, State},
state_machine_call, SharedParams, LOG_TARGET,
};

Expand Down Expand Up @@ -75,25 +73,28 @@ where
HostFns: HostFunctions,
{
let executor = build_executor(&shared);
// we first build the externalities with the remote code.
let runtime_checks = RuntimeChecks {
name_matches: shared.check_spec_name,
version_increases: false,
try_runtime_feature_enabled: true,
};
let ext = command
.state
.to_ext::<Block, HostFns>(&shared, &executor, None, runtime_checks)
.await?;

// get the block number associated with this block.
let block_ws_uri = command.header_ws_uri();
let rpc = ws_client(&block_ws_uri).await?;

let live_state = match command.state {
State::Live(live_state) => live_state,
_ => {
unreachable!("execute block currently only supports Live state")
}
};

// The block we want to *execute* at is the block passed by the user
let execute_at = live_state.at::<Block>()?;

let prev_block_live_state = live_state.to_prev_block_live_state::<Block>().await?;

// Get state for the prev block
let prev_block_live_state = live_state.to_prev_block_live_state::<Block>().await?;
let runtime_checks = RuntimeChecks {
name_matches: shared.check_spec_name,
version_increases: false,
try_runtime_feature_enabled: true,
};
let ext = State::Live(prev_block_live_state)
.to_ext::<Block, HostFns>(&shared, &executor, None, runtime_checks)
.await?;
Expand Down

0 comments on commit 18b13c0

Please sign in to comment.