mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 10:01:17 +00:00
refactor(sc-executor): use wasm executor builder instead of old apis (#13740)
* refactor: use builder api for all executors * improve a lot * remove unused args * cleanup deps * fix inconsistency about heap alloc * add `heap_pages` back to try-runtime * fix * chore: reduce duplicated code for sc-service-test * cleanup code * fmt * improve test executor * improve * use #[deprecated] * set runtime_cache_size: 4 * fix and improve * refactor builder * fix * fix bench * fix tests * fix warnings * fix warnings * fix * fix * update by suggestions * update name
This commit is contained in:
@@ -45,6 +45,7 @@ use sp_trie::{LayoutV0, TrieConfiguration};
|
||||
use std::{collections::HashSet, sync::Arc};
|
||||
use substrate_test_runtime::TestAPI;
|
||||
use substrate_test_runtime_client::{
|
||||
new_native_or_wasm_executor,
|
||||
prelude::*,
|
||||
runtime::{
|
||||
genesismap::{insert_genesis_block, GenesisConfig},
|
||||
@@ -58,29 +59,6 @@ mod db;
|
||||
|
||||
const TEST_ENGINE_ID: ConsensusEngineId = *b"TEST";
|
||||
|
||||
pub struct ExecutorDispatch;
|
||||
|
||||
impl sc_executor::NativeExecutionDispatch for ExecutorDispatch {
|
||||
type ExtendHostFunctions = ();
|
||||
|
||||
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||
substrate_test_runtime_client::runtime::api::dispatch(method, data)
|
||||
}
|
||||
|
||||
fn native_version() -> sc_executor::NativeVersion {
|
||||
substrate_test_runtime_client::runtime::native_version()
|
||||
}
|
||||
}
|
||||
|
||||
fn executor() -> sc_executor::NativeElseWasmExecutor<ExecutorDispatch> {
|
||||
sc_executor::NativeElseWasmExecutor::new(
|
||||
sc_executor::WasmExecutionMethod::Interpreted,
|
||||
None,
|
||||
8,
|
||||
2,
|
||||
)
|
||||
}
|
||||
|
||||
fn construct_block(
|
||||
backend: &InMemoryBackend<BlakeTwo256>,
|
||||
number: BlockNumber,
|
||||
@@ -108,7 +86,7 @@ fn construct_block(
|
||||
StateMachine::new(
|
||||
backend,
|
||||
&mut overlay,
|
||||
&executor(),
|
||||
&new_native_or_wasm_executor(),
|
||||
"Core_initialize_block",
|
||||
&header.encode(),
|
||||
Default::default(),
|
||||
@@ -122,7 +100,7 @@ fn construct_block(
|
||||
StateMachine::new(
|
||||
backend,
|
||||
&mut overlay,
|
||||
&executor(),
|
||||
&new_native_or_wasm_executor(),
|
||||
"BlockBuilder_apply_extrinsic",
|
||||
&tx.encode(),
|
||||
Default::default(),
|
||||
@@ -136,7 +114,7 @@ fn construct_block(
|
||||
let ret_data = StateMachine::new(
|
||||
backend,
|
||||
&mut overlay,
|
||||
&executor(),
|
||||
&new_native_or_wasm_executor(),
|
||||
"BlockBuilder_finalize_block",
|
||||
&[],
|
||||
Default::default(),
|
||||
@@ -208,7 +186,7 @@ fn construct_genesis_should_work_with_native() {
|
||||
let _ = StateMachine::new(
|
||||
&backend,
|
||||
&mut overlay,
|
||||
&executor(),
|
||||
&new_native_or_wasm_executor(),
|
||||
"Core_execute_block",
|
||||
&b1data,
|
||||
Default::default(),
|
||||
@@ -241,7 +219,7 @@ fn construct_genesis_should_work_with_wasm() {
|
||||
let _ = StateMachine::new(
|
||||
&backend,
|
||||
&mut overlay,
|
||||
&executor(),
|
||||
&new_native_or_wasm_executor(),
|
||||
"Core_execute_block",
|
||||
&b1data,
|
||||
Default::default(),
|
||||
@@ -274,7 +252,7 @@ fn construct_genesis_with_bad_transaction_should_panic() {
|
||||
let r = StateMachine::new(
|
||||
&backend,
|
||||
&mut overlay,
|
||||
&executor(),
|
||||
&new_native_or_wasm_executor(),
|
||||
"Core_execute_block",
|
||||
&b1data,
|
||||
Default::default(),
|
||||
@@ -1910,7 +1888,7 @@ fn cleans_up_closed_notification_sinks_on_block_import() {
|
||||
use substrate_test_runtime_client::GenesisInit;
|
||||
|
||||
let backend = Arc::new(sc_client_api::in_mem::Backend::new());
|
||||
let executor = substrate_test_runtime_client::new_native_executor();
|
||||
let executor = new_native_or_wasm_executor();
|
||||
let client_config = sc_service::ClientConfig::default();
|
||||
|
||||
let genesis_block_builder = sc_service::GenesisBlockBuilder::new(
|
||||
|
||||
@@ -65,9 +65,7 @@ impl<G, E, F, U> Drop for TestNet<G, E, F, U> {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait TestNetNode:
|
||||
Clone + Future<Output = Result<(), sc_service::Error>> + Send + 'static
|
||||
{
|
||||
pub trait TestNetNode: Clone + Future<Output = Result<(), Error>> + Send + 'static {
|
||||
type Block: BlockT;
|
||||
type Backend: Backend<Self::Block>;
|
||||
type Executor: CallExecutor<Self::Block> + Send + Sync;
|
||||
@@ -128,7 +126,7 @@ impl<TBl: BlockT, TBackend, TExec, TRtApi, TExPool> Clone
|
||||
impl<TBl: BlockT, TBackend, TExec, TRtApi, TExPool> Future
|
||||
for TestNetComponents<TBl, TBackend, TExec, TRtApi, TExPool>
|
||||
{
|
||||
type Output = Result<(), sc_service::Error>;
|
||||
type Output = Result<(), Error>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
Pin::new(&mut self.task_manager.lock().future()).poll(cx)
|
||||
@@ -248,7 +246,7 @@ fn node_config<
|
||||
state_pruning: Default::default(),
|
||||
blocks_pruning: BlocksPruning::KeepFinalized,
|
||||
chain_spec: Box::new((*spec).clone()),
|
||||
wasm_method: sc_service::config::WasmExecutionMethod::Interpreted,
|
||||
wasm_method: Default::default(),
|
||||
wasm_runtime_overrides: Default::default(),
|
||||
execution_strategies: Default::default(),
|
||||
rpc_http: None,
|
||||
|
||||
Reference in New Issue
Block a user