Companion PR for 'Make choosing an executor an explicit part of service construction' (#9525) (#3615)

* Companion PR

* Update a few files

* Run cargo fmt

* Do better at renaming things

* More renamings

* More fixes

* oops

* Fix simnet problems

* fix compilation

* Update substrate

Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Ashley
2021-08-18 15:26:30 +02:00
committed by GitHub
parent e3eb5fda68
commit d88dec65fb
9 changed files with 277 additions and 237 deletions
+3 -2
View File
@@ -28,7 +28,8 @@ use sp_runtime::BuildStorage;
pub use block_builder::*;
pub use polkadot_test_runtime as runtime;
pub use polkadot_test_service::{
construct_extrinsic, construct_transfer_extrinsic, Client, FullBackend, PolkadotTestExecutor,
construct_extrinsic, construct_transfer_extrinsic, Client, FullBackend,
PolkadotTestExecutorDispatch,
};
pub use substrate_test_client::*;
@@ -36,7 +37,7 @@ pub use substrate_test_client::*;
pub type Executor = client::LocalCallExecutor<
Block,
FullBackend,
sc_executor::NativeExecutor<PolkadotTestExecutor>,
sc_executor::NativeElseWasmExecutor<PolkadotTestExecutorDispatch>,
>;
/// Test client builder for Polkadot.
@@ -27,6 +27,7 @@ use polkadot_runtime::{
use polkadot_runtime_common::claims;
use sc_consensus_babe::BabeBlockImport;
use sc_consensus_manual_seal::consensus::babe::SlotTimestampProvider;
use sc_executor::NativeElseWasmExecutor;
use sc_service::{TFullBackend, TFullClient};
use sp_runtime::{app_crypto::sp_core::H256, generic::Era, AccountId32};
use std::{error::Error, future::Future, str::FromStr};
@@ -40,11 +41,11 @@ type BlockImport<B, BE, C, SC> = BabeBlockImport<B, C, GrandpaBlockImport<BE, B,
type Block = polkadot_primitives::v1::Block;
type SelectChain = sc_consensus::LongestChain<TFullBackend<Block>, Block>;
/// Declare an instance of the native executor named `Executor`. Include the wasm binary as the
/// Declare an instance of the native executor named `ExecutorDispatch`. Include the wasm binary as the
/// equivalent wasm code.
pub struct Executor;
pub struct ExecutorDispatch;
impl sc_executor::NativeExecutionDispatch for Executor {
impl sc_executor::NativeExecutionDispatch for ExecutorDispatch {
type ExtendHostFunctions =
(benchmarking::benchmarking::HostFunctions, SignatureVerificationOverride);
@@ -62,14 +63,14 @@ pub struct PolkadotChainInfo;
impl ChainInfo for PolkadotChainInfo {
type Block = Block;
type Executor = Executor;
type ExecutorDispatch = ExecutorDispatch;
type Runtime = Runtime;
type RuntimeApi = RuntimeApi;
type SelectChain = SelectChain;
type BlockImport = BlockImport<
Self::Block,
TFullBackend<Self::Block>,
TFullClient<Self::Block, RuntimeApi, Self::Executor>,
TFullClient<Self::Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>,
Self::SelectChain,
>;
type SignedExtras = polkadot_runtime::SignedExtra;
@@ -98,14 +99,14 @@ pub async fn dispatch_with_root<T>(
where
T: ChainInfo<
Block = Block,
Executor = Executor,
ExecutorDispatch = ExecutorDispatch,
Runtime = Runtime,
RuntimeApi = RuntimeApi,
SelectChain = SelectChain,
BlockImport = BlockImport<
Block,
TFullBackend<Block>,
TFullClient<Block, RuntimeApi, Executor>,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>,
SelectChain,
>,
SignedExtras = polkadot_runtime::SignedExtra,
+5 -5
View File
@@ -54,11 +54,11 @@ use substrate_test_client::{
BlockchainEventsExt, RpcHandlersExt, RpcTransactionError, RpcTransactionOutput,
};
/// Declare an instance of the native executor named `PolkadotTestExecutor`. Include the wasm binary as the
/// Declare an instance of the native executor named `PolkadotTestExecutorDispatch`. Include the wasm binary as the
/// equivalent wasm code.
pub struct PolkadotTestExecutor;
pub struct PolkadotTestExecutorDispatch;
impl sc_executor::NativeExecutionDispatch for PolkadotTestExecutor {
impl sc_executor::NativeExecutionDispatch for PolkadotTestExecutorDispatch {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
@@ -71,7 +71,7 @@ impl sc_executor::NativeExecutionDispatch for PolkadotTestExecutor {
}
/// The client type being used by the test service.
pub type Client = FullClient<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutor>;
pub type Client = FullClient<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutorDispatch>;
pub use polkadot_service::FullBackend;
@@ -82,7 +82,7 @@ pub fn new_full(
is_collator: IsCollator,
worker_program_path: Option<PathBuf>,
) -> Result<NewFull<Arc<Client>>, Error> {
polkadot_service::new_full::<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutor, _>(
polkadot_service::new_full::<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutorDispatch, _>(
config,
is_collator,
None,