From 18b13c0cf3ddc59e814e8f57977043e5a60b1fff Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Fri, 17 Nov 2023 18:28:15 +0400 Subject: [PATCH] fix up merge --- core/src/commands/execute_block.rs | 23 +++++-------------- core/src/commands/offchain_worker.rs | 33 ++++++++++++++-------------- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/core/src/commands/execute_block.rs b/core/src/commands/execute_block.rs index f06aad82ffa..8acde3f74a3 100644 --- a/core/src/commands/execute_block.rs +++ b/core/src/commands/execute_block.rs @@ -94,16 +94,6 @@ where HostFns: HostFunctions, { let executor = build_executor::(&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::(&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?; @@ -121,14 +111,13 @@ where let prev_block_live_state = live_state.to_prev_block_live_state::().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::( - &shared, - &executor, - None, - TryRuntimeFeatureCheck::Check, - SpecVersionCheck::Skip, - ) + .to_ext::(&shared, &executor, None, runtime_checks) .await?; // Execute the desired block on top of it diff --git a/core/src/commands/offchain_worker.rs b/core/src/commands/offchain_worker.rs index a6853935994..39cec03495b 100644 --- a/core/src/commands/offchain_worker.rs +++ b/core/src/commands/offchain_worker.rs @@ -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, }; @@ -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::(&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::()?; - let prev_block_live_state = live_state.to_prev_block_live_state::().await?; - // Get state for the prev block + let prev_block_live_state = live_state.to_prev_block_live_state::().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::(&shared, &executor, None, runtime_checks) .await?;