mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 08:11:03 +00:00
Companion PR for 'Simplify NativeExecutionDispatch and remove the native_executor_instance!' (9562) (#3643)
* Companion PR * Add test executors * Change comment to doc comment * Update node/test/service/src/lib.rs * Improve comments * update Substrate Co-authored-by: parity-processbot <>
This commit is contained in:
Generated
+440
-636
File diff suppressed because it is too large
Load Diff
@@ -31,7 +31,6 @@
|
|||||||
use millau_runtime::{self, opaque::Block, RuntimeApi};
|
use millau_runtime::{self, opaque::Block, RuntimeApi};
|
||||||
use sc_client_api::{ExecutorProvider, RemoteBackend};
|
use sc_client_api::{ExecutorProvider, RemoteBackend};
|
||||||
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
|
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
|
||||||
use sc_executor::native_executor_instance;
|
|
||||||
pub use sc_executor::NativeExecutor;
|
pub use sc_executor::NativeExecutor;
|
||||||
|
|
||||||
use sc_keystore::LocalKeystore;
|
use sc_keystore::LocalKeystore;
|
||||||
@@ -42,12 +41,19 @@ use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
|||||||
use std::{sync::Arc, time::Duration};
|
use std::{sync::Arc, time::Duration};
|
||||||
|
|
||||||
// Our native executor instance.
|
// Our native executor instance.
|
||||||
native_executor_instance!(
|
pub struct Executor;
|
||||||
pub Executor,
|
|
||||||
millau_runtime::api::dispatch,
|
impl sc_executor::NativeExecutionDispatch for Executor {
|
||||||
millau_runtime::native_version,
|
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||||
frame_benchmarking::benchmarking::HostFunctions,
|
|
||||||
);
|
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||||
|
millau_runtime::api::dispatch(method, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn native_version() -> sc_executor::NativeVersion {
|
||||||
|
millau_runtime::native_version()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;
|
type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;
|
||||||
type FullBackend = sc_service::TFullBackend<Block>;
|
type FullBackend = sc_service::TFullBackend<Block>;
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
use rialto_runtime::{self, opaque::Block, RuntimeApi};
|
use rialto_runtime::{self, opaque::Block, RuntimeApi};
|
||||||
use sc_client_api::{ExecutorProvider, RemoteBackend};
|
use sc_client_api::{ExecutorProvider, RemoteBackend};
|
||||||
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
|
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
|
||||||
use sc_executor::native_executor_instance;
|
|
||||||
pub use sc_executor::NativeExecutor;
|
pub use sc_executor::NativeExecutor;
|
||||||
|
|
||||||
use sc_keystore::LocalKeystore;
|
use sc_keystore::LocalKeystore;
|
||||||
@@ -44,12 +43,19 @@ use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
|||||||
use std::{sync::Arc, time::Duration};
|
use std::{sync::Arc, time::Duration};
|
||||||
|
|
||||||
// Our native executor instance.
|
// Our native executor instance.
|
||||||
native_executor_instance!(
|
pub struct Executor;
|
||||||
pub Executor,
|
|
||||||
rialto_runtime::api::dispatch,
|
impl sc_executor::NativeExecutionDispatch for Executor {
|
||||||
rialto_runtime::native_version,
|
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||||
frame_benchmarking::benchmarking::HostFunctions,
|
|
||||||
);
|
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||||
|
rialto_runtime::api::dispatch(method, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn native_version() -> sc_executor::NativeVersion {
|
||||||
|
rialto_runtime::native_version()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;
|
type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;
|
||||||
type FullBackend = sc_service::TFullBackend<Block>;
|
type FullBackend = sc_service::TFullBackend<Block>;
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ use polkadot_primitives::v1::{
|
|||||||
AccountId, Balance, Block, BlockNumber, Hash, Header, Nonce, ParachainHost,
|
AccountId, Balance, Block, BlockNumber, Hash, Header, Nonce, ParachainHost,
|
||||||
};
|
};
|
||||||
use sc_client_api::{AuxStore, Backend as BackendT, BlockchainEvents, KeyIterator, UsageProvider};
|
use sc_client_api::{AuxStore, Backend as BackendT, BlockchainEvents, KeyIterator, UsageProvider};
|
||||||
use sc_executor::native_executor_instance;
|
|
||||||
use sp_api::{CallApiAt, NumberFor, ProvideRuntimeApi};
|
use sp_api::{CallApiAt, NumberFor, ProvideRuntimeApi};
|
||||||
use sp_blockchain::HeaderBackend;
|
use sp_blockchain::HeaderBackend;
|
||||||
use sp_consensus::BlockStatus;
|
use sp_consensus::BlockStatus;
|
||||||
@@ -39,36 +38,71 @@ pub type FullBackend = sc_service::TFullBackend<Block>;
|
|||||||
|
|
||||||
pub type FullClient<RuntimeApi, Executor> = sc_service::TFullClient<Block, RuntimeApi, Executor>;
|
pub type FullClient<RuntimeApi, Executor> = sc_service::TFullClient<Block, RuntimeApi, Executor>;
|
||||||
|
|
||||||
native_executor_instance!(
|
/// The native executor instance for Polkadot.
|
||||||
pub PolkadotExecutor,
|
pub struct PolkadotExecutor;
|
||||||
polkadot_runtime::api::dispatch,
|
|
||||||
polkadot_runtime::native_version,
|
impl sc_executor::NativeExecutionDispatch for PolkadotExecutor {
|
||||||
frame_benchmarking::benchmarking::HostFunctions,
|
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||||
);
|
|
||||||
|
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||||
|
polkadot_runtime::api::dispatch(method, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn native_version() -> sc_executor::NativeVersion {
|
||||||
|
polkadot_runtime::native_version()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "kusama")]
|
#[cfg(feature = "kusama")]
|
||||||
native_executor_instance!(
|
/// The native executor instance for Kusama.
|
||||||
pub KusamaExecutor,
|
pub struct KusamaExecutor;
|
||||||
kusama_runtime::api::dispatch,
|
|
||||||
kusama_runtime::native_version,
|
#[cfg(feature = "kusama")]
|
||||||
frame_benchmarking::benchmarking::HostFunctions,
|
impl sc_executor::NativeExecutionDispatch for KusamaExecutor {
|
||||||
);
|
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||||
|
|
||||||
|
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||||
|
kusama_runtime::api::dispatch(method, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn native_version() -> sc_executor::NativeVersion {
|
||||||
|
kusama_runtime::native_version()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "westend")]
|
#[cfg(feature = "westend")]
|
||||||
native_executor_instance!(
|
/// The native executor instance for Westend.
|
||||||
pub WestendExecutor,
|
pub struct WestendExecutor;
|
||||||
westend_runtime::api::dispatch,
|
|
||||||
westend_runtime::native_version,
|
#[cfg(feature = "westend")]
|
||||||
frame_benchmarking::benchmarking::HostFunctions,
|
impl sc_executor::NativeExecutionDispatch for WestendExecutor {
|
||||||
);
|
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||||
|
|
||||||
|
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||||
|
westend_runtime::api::dispatch(method, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn native_version() -> sc_executor::NativeVersion {
|
||||||
|
westend_runtime::native_version()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "rococo")]
|
#[cfg(feature = "rococo")]
|
||||||
native_executor_instance!(
|
/// The native executor instance for Rococo.
|
||||||
pub RococoExecutor,
|
pub struct RococoExecutor;
|
||||||
rococo_runtime::api::dispatch,
|
|
||||||
rococo_runtime::native_version,
|
#[cfg(feature = "rococo")]
|
||||||
frame_benchmarking::benchmarking::HostFunctions,
|
impl sc_executor::NativeExecutionDispatch for RococoExecutor {
|
||||||
);
|
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||||
|
|
||||||
|
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||||
|
rococo_runtime::api::dispatch(method, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn native_version() -> sc_executor::NativeVersion {
|
||||||
|
rococo_runtime::native_version()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A set of APIs that polkadot-like runtimes must implement.
|
/// A set of APIs that polkadot-like runtimes must implement.
|
||||||
pub trait RuntimeApiCollection:
|
pub trait RuntimeApiCollection:
|
||||||
|
|||||||
@@ -40,12 +40,22 @@ type BlockImport<B, BE, C, SC> = BabeBlockImport<B, C, GrandpaBlockImport<BE, B,
|
|||||||
type Block = polkadot_primitives::v1::Block;
|
type Block = polkadot_primitives::v1::Block;
|
||||||
type SelectChain = sc_consensus::LongestChain<TFullBackend<Block>, Block>;
|
type SelectChain = sc_consensus::LongestChain<TFullBackend<Block>, Block>;
|
||||||
|
|
||||||
sc_executor::native_executor_instance!(
|
/// Declare an instance of the native executor named `Executor`. Include the wasm binary as the
|
||||||
pub Executor,
|
/// equivalent wasm code.
|
||||||
polkadot_runtime::api::dispatch,
|
pub struct Executor;
|
||||||
polkadot_runtime::native_version,
|
|
||||||
(benchmarking::benchmarking::HostFunctions, SignatureVerificationOverride),
|
impl sc_executor::NativeExecutionDispatch for Executor {
|
||||||
);
|
type ExtendHostFunctions =
|
||||||
|
(benchmarking::benchmarking::HostFunctions, SignatureVerificationOverride);
|
||||||
|
|
||||||
|
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||||
|
polkadot_runtime::api::dispatch(method, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn native_version() -> sc_executor::NativeVersion {
|
||||||
|
polkadot_runtime::native_version()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// `ChainInfo` implementation.
|
/// `ChainInfo` implementation.
|
||||||
pub struct PolkadotChainInfo;
|
pub struct PolkadotChainInfo;
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ use polkadot_test_runtime::{
|
|||||||
};
|
};
|
||||||
use sc_chain_spec::ChainSpec;
|
use sc_chain_spec::ChainSpec;
|
||||||
use sc_client_api::execution_extensions::ExecutionStrategies;
|
use sc_client_api::execution_extensions::ExecutionStrategies;
|
||||||
use sc_executor::native_executor_instance;
|
|
||||||
use sc_network::{
|
use sc_network::{
|
||||||
config::{NetworkConfiguration, TransportConfig},
|
config::{NetworkConfiguration, TransportConfig},
|
||||||
multiaddr,
|
multiaddr,
|
||||||
@@ -55,12 +54,21 @@ use substrate_test_client::{
|
|||||||
BlockchainEventsExt, RpcHandlersExt, RpcTransactionError, RpcTransactionOutput,
|
BlockchainEventsExt, RpcHandlersExt, RpcTransactionError, RpcTransactionOutput,
|
||||||
};
|
};
|
||||||
|
|
||||||
native_executor_instance!(
|
/// Declare an instance of the native executor named `PolkadotTestExecutor`. Include the wasm binary as the
|
||||||
pub PolkadotTestExecutor,
|
/// equivalent wasm code.
|
||||||
polkadot_test_runtime::api::dispatch,
|
pub struct PolkadotTestExecutor;
|
||||||
polkadot_test_runtime::native_version,
|
|
||||||
frame_benchmarking::benchmarking::HostFunctions,
|
impl sc_executor::NativeExecutionDispatch for PolkadotTestExecutor {
|
||||||
);
|
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||||
|
|
||||||
|
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||||
|
polkadot_test_runtime::api::dispatch(method, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn native_version() -> sc_executor::NativeVersion {
|
||||||
|
polkadot_test_runtime::native_version()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The client type being used by the test service.
|
/// 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, PolkadotTestExecutor>;
|
||||||
|
|||||||
Reference in New Issue
Block a user