mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 07:37:57 +00:00
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:
Generated
+153
-153
File diff suppressed because it is too large
Load Diff
@@ -31,7 +31,7 @@
|
||||
use millau_runtime::{self, opaque::Block, RuntimeApi};
|
||||
use sc_client_api::{ExecutorProvider, RemoteBackend};
|
||||
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
|
||||
pub use sc_executor::NativeExecutor;
|
||||
pub use sc_executor::NativeElseWasmExecutor;
|
||||
|
||||
use sc_keystore::LocalKeystore;
|
||||
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
|
||||
@@ -41,9 +41,9 @@ use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
// Our native executor instance.
|
||||
pub struct Executor;
|
||||
pub struct ExecutorDispatch;
|
||||
|
||||
impl sc_executor::NativeExecutionDispatch for Executor {
|
||||
impl sc_executor::NativeExecutionDispatch for ExecutorDispatch {
|
||||
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||
|
||||
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||
@@ -55,7 +55,7 @@ impl sc_executor::NativeExecutionDispatch for Executor {
|
||||
}
|
||||
}
|
||||
|
||||
type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;
|
||||
type FullClient = sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;
|
||||
type FullBackend = sc_service::TFullBackend<Block>;
|
||||
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
use rialto_runtime::{self, opaque::Block, RuntimeApi};
|
||||
use sc_client_api::{ExecutorProvider, RemoteBackend};
|
||||
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
|
||||
pub use sc_executor::NativeExecutor;
|
||||
pub use sc_executor::NativeElseWasmExecutor;
|
||||
|
||||
use sc_keystore::LocalKeystore;
|
||||
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
|
||||
@@ -43,9 +43,9 @@ use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
// Our native executor instance.
|
||||
pub struct Executor;
|
||||
pub struct ExecutorDispatch;
|
||||
|
||||
impl sc_executor::NativeExecutionDispatch for Executor {
|
||||
impl sc_executor::NativeExecutionDispatch for ExecutorDispatch {
|
||||
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||
|
||||
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||
@@ -57,7 +57,7 @@ impl sc_executor::NativeExecutionDispatch for Executor {
|
||||
}
|
||||
}
|
||||
|
||||
type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;
|
||||
type FullClient = sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;
|
||||
type FullBackend = sc_service::TFullBackend<Block>;
|
||||
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
||||
|
||||
|
||||
@@ -376,23 +376,29 @@ pub fn run() -> Result<()> {
|
||||
#[cfg(feature = "kusama-native")]
|
||||
if chain_spec.is_kusama() {
|
||||
return Ok(runner.sync_run(|config| {
|
||||
cmd.run::<service::kusama_runtime::Block, service::KusamaExecutor>(config)
|
||||
.map_err(|e| Error::SubstrateCli(e))
|
||||
cmd.run::<service::kusama_runtime::Block, service::KusamaExecutorDispatch>(
|
||||
config,
|
||||
)
|
||||
.map_err(|e| Error::SubstrateCli(e))
|
||||
})?)
|
||||
}
|
||||
|
||||
#[cfg(feature = "westend-native")]
|
||||
if chain_spec.is_westend() {
|
||||
return Ok(runner.sync_run(|config| {
|
||||
cmd.run::<service::westend_runtime::Block, service::WestendExecutor>(config)
|
||||
.map_err(|e| Error::SubstrateCli(e))
|
||||
cmd.run::<service::westend_runtime::Block, service::WestendExecutorDispatch>(
|
||||
config,
|
||||
)
|
||||
.map_err(|e| Error::SubstrateCli(e))
|
||||
})?)
|
||||
}
|
||||
|
||||
// else we assume it is polkadot.
|
||||
Ok(runner.sync_run(|config| {
|
||||
cmd.run::<service::polkadot_runtime::Block, service::PolkadotExecutor>(config)
|
||||
.map_err(|e| Error::SubstrateCli(e))
|
||||
cmd.run::<service::polkadot_runtime::Block, service::PolkadotExecutorDispatch>(
|
||||
config,
|
||||
)
|
||||
.map_err(|e| Error::SubstrateCli(e))
|
||||
})?)
|
||||
},
|
||||
Some(Subcommand::Key(cmd)) => Ok(cmd.run(&cli)?),
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -74,23 +74,24 @@ use telemetry::TelemetryWorker;
|
||||
use telemetry::{Telemetry, TelemetryWorkerHandle};
|
||||
|
||||
#[cfg(feature = "rococo-native")]
|
||||
pub use polkadot_client::RococoExecutor;
|
||||
pub use polkadot_client::RococoExecutorDispatch;
|
||||
|
||||
#[cfg(feature = "westend-native")]
|
||||
pub use polkadot_client::WestendExecutor;
|
||||
pub use polkadot_client::WestendExecutorDispatch;
|
||||
|
||||
#[cfg(feature = "kusama-native")]
|
||||
pub use polkadot_client::KusamaExecutor;
|
||||
pub use polkadot_client::KusamaExecutorDispatch;
|
||||
|
||||
pub use chain_spec::{KusamaChainSpec, PolkadotChainSpec, RococoChainSpec, WestendChainSpec};
|
||||
pub use consensus_common::{block_validation::Chain, Proposal, SelectChain};
|
||||
pub use polkadot_client::{
|
||||
AbstractClient, Client, ClientHandle, ExecuteWithClient, FullBackend, FullClient,
|
||||
PolkadotExecutor, RuntimeApiCollection,
|
||||
PolkadotExecutorDispatch, RuntimeApiCollection,
|
||||
};
|
||||
pub use polkadot_primitives::v1::{Block, BlockId, CollatorPair, Hash, Id as ParaId};
|
||||
pub use sc_client_api::{Backend, CallExecutor, ExecutionStrategy};
|
||||
pub use sc_consensus::{BlockImport, LongestChain};
|
||||
use sc_executor::NativeElseWasmExecutor;
|
||||
pub use sc_executor::NativeExecutionDispatch;
|
||||
pub use service::{
|
||||
config::{DatabaseSource, PrometheusConfig},
|
||||
@@ -294,10 +295,10 @@ fn jaeger_launch_collector_with_agent(
|
||||
#[cfg(feature = "full-node")]
|
||||
type FullSelectChain = relay_chain_selection::SelectRelayChainWithFallback<FullBackend>;
|
||||
#[cfg(feature = "full-node")]
|
||||
type FullGrandpaBlockImport<RuntimeApi, Executor> = grandpa::GrandpaBlockImport<
|
||||
type FullGrandpaBlockImport<RuntimeApi, ExecutorDispatch> = grandpa::GrandpaBlockImport<
|
||||
FullBackend,
|
||||
Block,
|
||||
FullClient<RuntimeApi, Executor>,
|
||||
FullClient<RuntimeApi, ExecutorDispatch>,
|
||||
FullSelectChain,
|
||||
>;
|
||||
|
||||
@@ -305,30 +306,30 @@ type FullGrandpaBlockImport<RuntimeApi, Executor> = grandpa::GrandpaBlockImport<
|
||||
type LightBackend = service::TLightBackendWithHash<Block, sp_runtime::traits::BlakeTwo256>;
|
||||
|
||||
#[cfg(feature = "light-node")]
|
||||
type LightClient<RuntimeApi, Executor> =
|
||||
service::TLightClientWithBackend<Block, RuntimeApi, Executor, LightBackend>;
|
||||
type LightClient<RuntimeApi, ExecutorDispatch> =
|
||||
service::TLightClientWithBackend<Block, RuntimeApi, ExecutorDispatch, LightBackend>;
|
||||
|
||||
#[cfg(feature = "full-node")]
|
||||
fn new_partial<RuntimeApi, Executor>(
|
||||
fn new_partial<RuntimeApi, ExecutorDispatch>(
|
||||
config: &mut Configuration,
|
||||
jaeger_agent: Option<std::net::SocketAddr>,
|
||||
telemetry_worker_handle: Option<TelemetryWorkerHandle>,
|
||||
) -> Result<
|
||||
service::PartialComponents<
|
||||
FullClient<RuntimeApi, Executor>,
|
||||
FullClient<RuntimeApi, ExecutorDispatch>,
|
||||
FullBackend,
|
||||
FullSelectChain,
|
||||
sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, Executor>>,
|
||||
sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, Executor>>,
|
||||
sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
|
||||
sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
|
||||
(
|
||||
impl service::RpcExtensionBuilder,
|
||||
(
|
||||
babe::BabeBlockImport<
|
||||
Block,
|
||||
FullClient<RuntimeApi, Executor>,
|
||||
FullGrandpaBlockImport<RuntimeApi, Executor>,
|
||||
FullClient<RuntimeApi, ExecutorDispatch>,
|
||||
FullGrandpaBlockImport<RuntimeApi, ExecutorDispatch>,
|
||||
>,
|
||||
grandpa::LinkHalf<Block, FullClient<RuntimeApi, Executor>, FullSelectChain>,
|
||||
grandpa::LinkHalf<Block, FullClient<RuntimeApi, ExecutorDispatch>, FullSelectChain>,
|
||||
babe::BabeLink<Block>,
|
||||
beefy_gadget::notification::BeefySignedCommitmentSender<Block>,
|
||||
),
|
||||
@@ -340,11 +341,13 @@ fn new_partial<RuntimeApi, Executor>(
|
||||
Error,
|
||||
>
|
||||
where
|
||||
RuntimeApi:
|
||||
ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>> + Send + Sync + 'static,
|
||||
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
RuntimeApi::RuntimeApi:
|
||||
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
|
||||
Executor: NativeExecutionDispatch + 'static,
|
||||
ExecutorDispatch: NativeExecutionDispatch + 'static,
|
||||
{
|
||||
set_prometheus_registry(config)?;
|
||||
|
||||
@@ -365,10 +368,17 @@ where
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
let executor = NativeElseWasmExecutor::<ExecutorDispatch>::new(
|
||||
config.wasm_method,
|
||||
config.default_heap_pages,
|
||||
config.max_runtime_instances,
|
||||
);
|
||||
|
||||
let (client, backend, keystore_container, task_manager) =
|
||||
service::new_full_parts::<Block, RuntimeApi, Executor>(
|
||||
service::new_full_parts::<Block, RuntimeApi, _>(
|
||||
&config,
|
||||
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
|
||||
executor,
|
||||
)?;
|
||||
let client = Arc::new(client);
|
||||
|
||||
@@ -562,16 +572,18 @@ impl IsCollator {
|
||||
|
||||
/// Returns the active leaves the overseer should start with.
|
||||
#[cfg(feature = "full-node")]
|
||||
async fn active_leaves<RuntimeApi, Executor>(
|
||||
async fn active_leaves<RuntimeApi, ExecutorDispatch>(
|
||||
select_chain: &impl SelectChain<Block>,
|
||||
client: &FullClient<RuntimeApi, Executor>,
|
||||
client: &FullClient<RuntimeApi, ExecutorDispatch>,
|
||||
) -> Result<Vec<BlockInfo>, Error>
|
||||
where
|
||||
RuntimeApi:
|
||||
ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>> + Send + Sync + 'static,
|
||||
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
RuntimeApi::RuntimeApi:
|
||||
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
|
||||
Executor: NativeExecutionDispatch + 'static,
|
||||
ExecutorDispatch: NativeExecutionDispatch + 'static,
|
||||
{
|
||||
let best_block = select_chain.best_chain().await?;
|
||||
|
||||
@@ -613,7 +625,7 @@ where
|
||||
/// This is an advanced feature and not recommended for general use. Generally, `build_full` is
|
||||
/// a better choice.
|
||||
#[cfg(feature = "full-node")]
|
||||
pub fn new_full<RuntimeApi, Executor, OverseerGenerator>(
|
||||
pub fn new_full<RuntimeApi, ExecutorDispatch, OverseerGenerator>(
|
||||
mut config: Configuration,
|
||||
is_collator: IsCollator,
|
||||
grandpa_pause: Option<(u32, u32)>,
|
||||
@@ -622,13 +634,15 @@ pub fn new_full<RuntimeApi, Executor, OverseerGenerator>(
|
||||
telemetry_worker_handle: Option<TelemetryWorkerHandle>,
|
||||
program_path: Option<std::path::PathBuf>,
|
||||
overseer_gen: OverseerGenerator,
|
||||
) -> Result<NewFull<Arc<FullClient<RuntimeApi, Executor>>>, Error>
|
||||
) -> Result<NewFull<Arc<FullClient<RuntimeApi, ExecutorDispatch>>>, Error>
|
||||
where
|
||||
RuntimeApi:
|
||||
ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>> + Send + Sync + 'static,
|
||||
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
RuntimeApi::RuntimeApi:
|
||||
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
|
||||
Executor: NativeExecutionDispatch + 'static,
|
||||
ExecutorDispatch: NativeExecutionDispatch + 'static,
|
||||
OverseerGenerator: OverseerGen,
|
||||
{
|
||||
use polkadot_node_network_protocol::request_response::IncomingRequest;
|
||||
@@ -660,7 +674,11 @@ where
|
||||
import_queue,
|
||||
transaction_pool,
|
||||
other: (rpc_extensions_builder, import_setup, rpc_setup, slot_duration, mut telemetry),
|
||||
} = new_partial::<RuntimeApi, Executor>(&mut config, jaeger_agent, telemetry_worker_handle)?;
|
||||
} = new_partial::<RuntimeApi, ExecutorDispatch>(
|
||||
&mut config,
|
||||
jaeger_agent,
|
||||
telemetry_worker_handle,
|
||||
)?;
|
||||
|
||||
let prometheus_registry = config.prometheus_registry().cloned();
|
||||
|
||||
@@ -824,7 +842,7 @@ where
|
||||
|
||||
let overseer_handle = if let Some((authority_discovery_service, keystore)) = maybe_params {
|
||||
let (overseer, overseer_handle) = overseer_gen
|
||||
.generate::<service::SpawnTaskHandle, FullClient<RuntimeApi, Executor>>(
|
||||
.generate::<service::SpawnTaskHandle, FullClient<RuntimeApi, ExecutorDispatch>>(
|
||||
OverseerGenArgs {
|
||||
leaves: active_leaves,
|
||||
keystore,
|
||||
@@ -1220,21 +1238,29 @@ pub fn new_chain_ops(
|
||||
#[cfg(feature = "rococo-native")]
|
||||
if config.chain_spec.is_rococo() || config.chain_spec.is_wococo() {
|
||||
let service::PartialComponents { client, backend, import_queue, task_manager, .. } =
|
||||
new_partial::<rococo_runtime::RuntimeApi, RococoExecutor>(config, jaeger_agent, None)?;
|
||||
new_partial::<rococo_runtime::RuntimeApi, RococoExecutorDispatch>(
|
||||
config,
|
||||
jaeger_agent,
|
||||
None,
|
||||
)?;
|
||||
return Ok((Arc::new(Client::Rococo(client)), backend, import_queue, task_manager))
|
||||
}
|
||||
|
||||
#[cfg(feature = "kusama-native")]
|
||||
if config.chain_spec.is_kusama() {
|
||||
let service::PartialComponents { client, backend, import_queue, task_manager, .. } =
|
||||
new_partial::<kusama_runtime::RuntimeApi, KusamaExecutor>(config, jaeger_agent, None)?;
|
||||
new_partial::<kusama_runtime::RuntimeApi, KusamaExecutorDispatch>(
|
||||
config,
|
||||
jaeger_agent,
|
||||
None,
|
||||
)?;
|
||||
return Ok((Arc::new(Client::Kusama(client)), backend, import_queue, task_manager))
|
||||
}
|
||||
|
||||
#[cfg(feature = "westend-native")]
|
||||
if config.chain_spec.is_westend() {
|
||||
let service::PartialComponents { client, backend, import_queue, task_manager, .. } =
|
||||
new_partial::<westend_runtime::RuntimeApi, WestendExecutor>(
|
||||
new_partial::<westend_runtime::RuntimeApi, WestendExecutorDispatch>(
|
||||
config,
|
||||
jaeger_agent,
|
||||
None,
|
||||
@@ -1243,7 +1269,11 @@ pub fn new_chain_ops(
|
||||
}
|
||||
|
||||
let service::PartialComponents { client, backend, import_queue, task_manager, .. } =
|
||||
new_partial::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(config, jaeger_agent, None)?;
|
||||
new_partial::<polkadot_runtime::RuntimeApi, PolkadotExecutorDispatch>(
|
||||
config,
|
||||
jaeger_agent,
|
||||
None,
|
||||
)?;
|
||||
Ok((Arc::new(Client::Polkadot(client)), backend, import_queue, task_manager))
|
||||
}
|
||||
|
||||
@@ -1252,20 +1282,20 @@ pub fn new_chain_ops(
|
||||
pub fn build_light(config: Configuration) -> Result<(TaskManager, RpcHandlers), Error> {
|
||||
#[cfg(feature = "rococo-native")]
|
||||
if config.chain_spec.is_rococo() || config.chain_spec.is_wococo() {
|
||||
return new_light::<rococo_runtime::RuntimeApi, RococoExecutor>(config)
|
||||
return new_light::<rococo_runtime::RuntimeApi, RococoExecutorDispatch>(config)
|
||||
}
|
||||
|
||||
#[cfg(feature = "kusama-native")]
|
||||
if config.chain_spec.is_kusama() {
|
||||
return new_light::<kusama_runtime::RuntimeApi, KusamaExecutor>(config)
|
||||
return new_light::<kusama_runtime::RuntimeApi, KusamaExecutorDispatch>(config)
|
||||
}
|
||||
|
||||
#[cfg(feature = "westend-native")]
|
||||
if config.chain_spec.is_westend() {
|
||||
return new_light::<westend_runtime::RuntimeApi, WestendExecutor>(config)
|
||||
return new_light::<westend_runtime::RuntimeApi, WestendExecutorDispatch>(config)
|
||||
}
|
||||
|
||||
new_light::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(config)
|
||||
new_light::<polkadot_runtime::RuntimeApi, PolkadotExecutorDispatch>(config)
|
||||
}
|
||||
|
||||
#[cfg(feature = "full-node")]
|
||||
@@ -1280,7 +1310,7 @@ pub fn build_full(
|
||||
) -> Result<NewFull<Client>, Error> {
|
||||
#[cfg(feature = "rococo-native")]
|
||||
if config.chain_spec.is_rococo() || config.chain_spec.is_wococo() {
|
||||
return new_full::<rococo_runtime::RuntimeApi, RococoExecutor, _>(
|
||||
return new_full::<rococo_runtime::RuntimeApi, RococoExecutorDispatch, _>(
|
||||
config,
|
||||
is_collator,
|
||||
grandpa_pause,
|
||||
@@ -1295,7 +1325,7 @@ pub fn build_full(
|
||||
|
||||
#[cfg(feature = "kusama-native")]
|
||||
if config.chain_spec.is_kusama() {
|
||||
return new_full::<kusama_runtime::RuntimeApi, KusamaExecutor, _>(
|
||||
return new_full::<kusama_runtime::RuntimeApi, KusamaExecutorDispatch, _>(
|
||||
config,
|
||||
is_collator,
|
||||
grandpa_pause,
|
||||
@@ -1310,7 +1340,7 @@ pub fn build_full(
|
||||
|
||||
#[cfg(feature = "westend-native")]
|
||||
if config.chain_spec.is_westend() {
|
||||
return new_full::<westend_runtime::RuntimeApi, WestendExecutor, _>(
|
||||
return new_full::<westend_runtime::RuntimeApi, WestendExecutorDispatch, _>(
|
||||
config,
|
||||
is_collator,
|
||||
grandpa_pause,
|
||||
@@ -1323,7 +1353,7 @@ pub fn build_full(
|
||||
.map(|full| full.with_client(Client::Westend))
|
||||
}
|
||||
|
||||
new_full::<polkadot_runtime::RuntimeApi, PolkadotExecutor, _>(
|
||||
new_full::<polkadot_runtime::RuntimeApi, PolkadotExecutorDispatch, _>(
|
||||
config,
|
||||
is_collator,
|
||||
grandpa_pause,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user