mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 01:41:09 +00:00
Make choosing an executor (native/wasm) an explicit part of service construction (#9525)
* Split native executor stuff from wasm executor stuff * Remove `native_runtime_version` in places * Fix warning * Fix test warning * Remove redundant NativeRuntimeInfo trait * Add a warning for use_native * Run cargo fmt * Revert "Add a warning for use_native" This reverts commit 9494f765a06037e991dd60524f2ed1b14649bfd6. * Make choosing an executor (native/wasm) an explicit part of service construction * Add Cargo.lock * Rename Executor to ExecutorDispatch * Update bin/node/executor/src/lib.rs Co-authored-by: Squirrel <gilescope@gmail.com> * Fix tests * Fix minor node-executor error * Fix node cli command thing Co-authored-by: Squirrel <gilescope@gmail.com>
This commit is contained in:
@@ -37,7 +37,7 @@ use sc_client_api::{
|
||||
};
|
||||
use sc_client_db::{Backend, DatabaseSettings};
|
||||
use sc_consensus::import_queue::ImportQueue;
|
||||
use sc_executor::{NativeExecutionDispatch, NativeExecutor, RuntimeVersionOf};
|
||||
use sc_executor::RuntimeVersionOf;
|
||||
use sc_keystore::LocalKeystore;
|
||||
use sc_network::{
|
||||
block_request_handler::{self, BlockRequestHandler},
|
||||
@@ -128,39 +128,39 @@ where
|
||||
}
|
||||
|
||||
/// Full client type.
|
||||
pub type TFullClient<TBl, TRtApi, TExecDisp> =
|
||||
Client<TFullBackend<TBl>, TFullCallExecutor<TBl, TExecDisp>, TBl, TRtApi>;
|
||||
pub type TFullClient<TBl, TRtApi, TExec> =
|
||||
Client<TFullBackend<TBl>, TFullCallExecutor<TBl, TExec>, TBl, TRtApi>;
|
||||
|
||||
/// Full client backend type.
|
||||
pub type TFullBackend<TBl> = sc_client_db::Backend<TBl>;
|
||||
|
||||
/// Full client call executor type.
|
||||
pub type TFullCallExecutor<TBl, TExecDisp> =
|
||||
crate::client::LocalCallExecutor<TBl, sc_client_db::Backend<TBl>, NativeExecutor<TExecDisp>>;
|
||||
pub type TFullCallExecutor<TBl, TExec> =
|
||||
crate::client::LocalCallExecutor<TBl, sc_client_db::Backend<TBl>, TExec>;
|
||||
|
||||
/// Light client type.
|
||||
pub type TLightClient<TBl, TRtApi, TExecDisp> =
|
||||
TLightClientWithBackend<TBl, TRtApi, TExecDisp, TLightBackend<TBl>>;
|
||||
pub type TLightClient<TBl, TRtApi, TExec> =
|
||||
TLightClientWithBackend<TBl, TRtApi, TExec, TLightBackend<TBl>>;
|
||||
|
||||
/// Light client backend type.
|
||||
pub type TLightBackend<TBl> =
|
||||
sc_light::Backend<sc_client_db::light::LightStorage<TBl>, HashFor<TBl>>;
|
||||
|
||||
/// Light call executor type.
|
||||
pub type TLightCallExecutor<TBl, TExecDisp> = sc_light::GenesisCallExecutor<
|
||||
pub type TLightCallExecutor<TBl, TExec> = sc_light::GenesisCallExecutor<
|
||||
sc_light::Backend<sc_client_db::light::LightStorage<TBl>, HashFor<TBl>>,
|
||||
crate::client::LocalCallExecutor<
|
||||
TBl,
|
||||
sc_light::Backend<sc_client_db::light::LightStorage<TBl>, HashFor<TBl>>,
|
||||
NativeExecutor<TExecDisp>,
|
||||
TExec,
|
||||
>,
|
||||
>;
|
||||
|
||||
type TFullParts<TBl, TRtApi, TExecDisp> =
|
||||
(TFullClient<TBl, TRtApi, TExecDisp>, Arc<TFullBackend<TBl>>, KeystoreContainer, TaskManager);
|
||||
type TFullParts<TBl, TRtApi, TExec> =
|
||||
(TFullClient<TBl, TRtApi, TExec>, Arc<TFullBackend<TBl>>, KeystoreContainer, TaskManager);
|
||||
|
||||
type TLightParts<TBl, TRtApi, TExecDisp> = (
|
||||
Arc<TLightClient<TBl, TRtApi, TExecDisp>>,
|
||||
type TLightParts<TBl, TRtApi, TExec> = (
|
||||
Arc<TLightClient<TBl, TRtApi, TExec>>,
|
||||
Arc<TLightBackend<TBl>>,
|
||||
KeystoreContainer,
|
||||
TaskManager,
|
||||
@@ -172,12 +172,9 @@ pub type TLightBackendWithHash<TBl, THash> =
|
||||
sc_light::Backend<sc_client_db::light::LightStorage<TBl>, THash>;
|
||||
|
||||
/// Light client type with a specific backend.
|
||||
pub type TLightClientWithBackend<TBl, TRtApi, TExecDisp, TBackend> = Client<
|
||||
pub type TLightClientWithBackend<TBl, TRtApi, TExec, TBackend> = Client<
|
||||
TBackend,
|
||||
sc_light::GenesisCallExecutor<
|
||||
TBackend,
|
||||
crate::client::LocalCallExecutor<TBl, TBackend, NativeExecutor<TExecDisp>>,
|
||||
>,
|
||||
sc_light::GenesisCallExecutor<TBackend, crate::client::LocalCallExecutor<TBl, TBackend, TExec>>,
|
||||
TBl,
|
||||
TRtApi,
|
||||
>;
|
||||
@@ -262,26 +259,28 @@ impl KeystoreContainer {
|
||||
}
|
||||
|
||||
/// Creates a new full client for the given config.
|
||||
pub fn new_full_client<TBl, TRtApi, TExecDisp>(
|
||||
pub fn new_full_client<TBl, TRtApi, TExec>(
|
||||
config: &Configuration,
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
) -> Result<TFullClient<TBl, TRtApi, TExecDisp>, Error>
|
||||
executor: TExec,
|
||||
) -> Result<TFullClient<TBl, TRtApi, TExec>, Error>
|
||||
where
|
||||
TBl: BlockT,
|
||||
TExecDisp: NativeExecutionDispatch + 'static,
|
||||
TExec: CodeExecutor + RuntimeVersionOf + Clone,
|
||||
TBl::Hash: FromStr,
|
||||
{
|
||||
new_full_parts(config, telemetry).map(|parts| parts.0)
|
||||
new_full_parts(config, telemetry, executor).map(|parts| parts.0)
|
||||
}
|
||||
|
||||
/// Create the initial parts of a full node.
|
||||
pub fn new_full_parts<TBl, TRtApi, TExecDisp>(
|
||||
pub fn new_full_parts<TBl, TRtApi, TExec>(
|
||||
config: &Configuration,
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
) -> Result<TFullParts<TBl, TRtApi, TExecDisp>, Error>
|
||||
executor: TExec,
|
||||
) -> Result<TFullParts<TBl, TRtApi, TExec>, Error>
|
||||
where
|
||||
TBl: BlockT,
|
||||
TExecDisp: NativeExecutionDispatch + 'static,
|
||||
TExec: CodeExecutor + RuntimeVersionOf + Clone,
|
||||
TBl::Hash: FromStr,
|
||||
{
|
||||
let keystore_container = KeystoreContainer::new(&config.keystore)?;
|
||||
@@ -291,12 +290,6 @@ where
|
||||
TaskManager::new(config.task_executor.clone(), registry)?
|
||||
};
|
||||
|
||||
let executor = NativeExecutor::<TExecDisp>::new(
|
||||
config.wasm_method,
|
||||
config.default_heap_pages,
|
||||
config.max_runtime_instances,
|
||||
);
|
||||
|
||||
let chain_spec = &config.chain_spec;
|
||||
let fork_blocks = get_extension::<ForkBlocks<TBl>>(chain_spec.extensions())
|
||||
.cloned()
|
||||
@@ -368,13 +361,14 @@ where
|
||||
}
|
||||
|
||||
/// Create the initial parts of a light node.
|
||||
pub fn new_light_parts<TBl, TRtApi, TExecDisp>(
|
||||
pub fn new_light_parts<TBl, TRtApi, TExec>(
|
||||
config: &Configuration,
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
) -> Result<TLightParts<TBl, TRtApi, TExecDisp>, Error>
|
||||
executor: TExec,
|
||||
) -> Result<TLightParts<TBl, TRtApi, TExec>, Error>
|
||||
where
|
||||
TBl: BlockT,
|
||||
TExecDisp: NativeExecutionDispatch + 'static,
|
||||
TExec: CodeExecutor + RuntimeVersionOf + Clone,
|
||||
{
|
||||
let keystore_container = KeystoreContainer::new(&config.keystore)?;
|
||||
let task_manager = {
|
||||
@@ -382,12 +376,6 @@ where
|
||||
TaskManager::new(config.task_executor.clone(), registry)?
|
||||
};
|
||||
|
||||
let executor = NativeExecutor::<TExecDisp>::new(
|
||||
config.wasm_method,
|
||||
config.default_heap_pages,
|
||||
config.max_runtime_instances,
|
||||
);
|
||||
|
||||
let db_storage = {
|
||||
let db_settings = sc_client_db::DatabaseSettings {
|
||||
state_cache_size: config.state_cache_size,
|
||||
|
||||
Reference in New Issue
Block a user