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
+15 -13
View File
@@ -23,6 +23,7 @@ use polkadot_primitives::v1::{
AccountId, Balance, Block, BlockNumber, Hash, Header, Nonce, ParachainHost,
};
use sc_client_api::{AuxStore, Backend as BackendT, BlockchainEvents, KeyIterator, UsageProvider};
use sc_executor::NativeElseWasmExecutor;
use sp_api::{CallApiAt, NumberFor, ProvideRuntimeApi};
use sp_blockchain::HeaderBackend;
use sp_consensus::BlockStatus;
@@ -36,12 +37,13 @@ use std::sync::Arc;
pub type FullBackend = sc_service::TFullBackend<Block>;
pub type FullClient<RuntimeApi, Executor> = sc_service::TFullClient<Block, RuntimeApi, Executor>;
pub type FullClient<RuntimeApi, ExecutorDispatch> =
sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;
/// The native executor instance for Polkadot.
pub struct PolkadotExecutor;
pub struct PolkadotExecutorDispatch;
impl sc_executor::NativeExecutionDispatch for PolkadotExecutor {
impl sc_executor::NativeExecutionDispatch for PolkadotExecutorDispatch {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
@@ -55,10 +57,10 @@ impl sc_executor::NativeExecutionDispatch for PolkadotExecutor {
#[cfg(feature = "kusama")]
/// The native executor instance for Kusama.
pub struct KusamaExecutor;
pub struct KusamaExecutorDispatch;
#[cfg(feature = "kusama")]
impl sc_executor::NativeExecutionDispatch for KusamaExecutor {
impl sc_executor::NativeExecutionDispatch for KusamaExecutorDispatch {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
@@ -72,10 +74,10 @@ impl sc_executor::NativeExecutionDispatch for KusamaExecutor {
#[cfg(feature = "westend")]
/// The native executor instance for Westend.
pub struct WestendExecutor;
pub struct WestendExecutorDispatch;
#[cfg(feature = "westend")]
impl sc_executor::NativeExecutionDispatch for WestendExecutor {
impl sc_executor::NativeExecutionDispatch for WestendExecutorDispatch {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
@@ -89,10 +91,10 @@ impl sc_executor::NativeExecutionDispatch for WestendExecutor {
#[cfg(feature = "rococo")]
/// The native executor instance for Rococo.
pub struct RococoExecutor;
pub struct RococoExecutorDispatch;
#[cfg(feature = "rococo")]
impl sc_executor::NativeExecutionDispatch for RococoExecutor {
impl sc_executor::NativeExecutionDispatch for RococoExecutorDispatch {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
@@ -247,13 +249,13 @@ macro_rules! with_client {
/// See [`ExecuteWithClient`] for more information.
#[derive(Clone)]
pub enum Client {
Polkadot(Arc<FullClient<polkadot_runtime::RuntimeApi, PolkadotExecutor>>),
Polkadot(Arc<FullClient<polkadot_runtime::RuntimeApi, PolkadotExecutorDispatch>>),
#[cfg(feature = "westend")]
Westend(Arc<FullClient<westend_runtime::RuntimeApi, WestendExecutor>>),
Westend(Arc<FullClient<westend_runtime::RuntimeApi, WestendExecutorDispatch>>),
#[cfg(feature = "kusama")]
Kusama(Arc<FullClient<kusama_runtime::RuntimeApi, KusamaExecutor>>),
Kusama(Arc<FullClient<kusama_runtime::RuntimeApi, KusamaExecutorDispatch>>),
#[cfg(feature = "rococo")]
Rococo(Arc<FullClient<rococo_runtime::RuntimeApi, RococoExecutor>>),
Rococo(Arc<FullClient<rococo_runtime::RuntimeApi, RococoExecutorDispatch>>),
}
impl ClientHandle for Client {