diff --git a/node/src/service.rs b/node/src/service.rs index fdd27b2218484d709ddd6d365a8c5f5b461f3ead..1369217a3f3e94ac0850162b94a72addcb3ae245 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -62,6 +62,7 @@ pub mod runtime_executor { pub use gdev_runtime as runtime; #[cfg(feature = "gtest")] pub use gtest_runtime as runtime; + use sc_executor::sp_wasm_interface::{Function, HostFunctionRegistry}; pub struct Executor; @@ -136,66 +137,22 @@ pub fn new_chain_ops( ), ServiceError, > { - match config.chain_spec.runtime_type() { - #[cfg(feature = "g1")] - RuntimeType::G1::G1 => { - let PartialComponents { - client, - backend, - import_queue, - task_manager, - .. - } = new_partial::<g1_runtime::RuntimeApi, runtime_executor::G1Executor>( - config, - manual_consensus, - )?; - Ok(( - Arc::new(Client::G1(client)), - backend, - import_queue, - task_manager, - )) - } - #[cfg(feature = "gtest")] - RuntimeType::GTest => { - let PartialComponents { - client, - backend, - import_queue, - task_manager, - .. - } = new_partial::<gtest_runtime::RuntimeApi, runtime_executor::GTestExecutor>( - config, - manual_consensus, - )?; - Ok(( - Arc::new(Client::GTest(client)), - backend, - import_queue, - task_manager, - )) - } - #[cfg(feature = "gdev")] - RuntimeType::GDev => { - let PartialComponents { - client, - backend, - import_queue, - task_manager, - .. - } = new_partial::<gdev_runtime::RuntimeApi, runtime_executor::Executor>( - config, - manual_consensus, - )?; - Ok(( - Arc::new(Client::GDev(client)), - backend, - import_queue, - task_manager, - )) - } - _ => panic!("unknown runtime"), - } + let PartialComponents { + client, + backend, + import_queue, + task_manager, + .. + } = new_partial::<runtime_executor::runtime::RuntimeApi, runtime_executor::Executor>( + config, + manual_consensus, + )?; + Ok(( + Arc::new(Client::Client(client)), + backend, + import_queue, + task_manager, + )) } type FullGrandpaBlockImport<RuntimeApi, Executor> = sc_consensus_grandpa::GrandpaBlockImport< diff --git a/node/src/service/client.rs b/node/src/service/client.rs index 8deea4aecca6547e4bf7d0a6d207e19acf0ebdea..04331317fd303527afd5333e470e820be288ead2 100644 --- a/node/src/service/client.rs +++ b/node/src/service/client.rs @@ -145,12 +145,14 @@ impl<Api> RuntimeApiCollection for Api where /// A client instance. #[derive(Clone)] pub enum Client { - #[cfg(feature = "g1")] - G1(Arc<super::FullClient<g1_runtime::RuntimeApi, super::runtime_executor::Executor>>), - #[cfg(feature = "gtest")] - GTest(Arc<super::FullClient<gtest_runtime::RuntimeApi, super::runtime_executor::Executor>>), - #[cfg(feature = "gdev")] - GDev(Arc<super::FullClient<gdev_runtime::RuntimeApi, super::runtime_executor::Executor>>), + Client( + Arc< + super::FullClient< + super::runtime_executor::runtime::RuntimeApi, + super::runtime_executor::Executor, + >, + >, + ), } macro_rules! with_client { @@ -162,22 +164,8 @@ macro_rules! with_client { } } => { match $self { - #[cfg(feature = "g1")] - Self::G1($client) => { - #[allow(unused_imports)] - use g1_runtime as runtime; - $( $code )* - } - #[cfg(feature = "gtest")] - Self::GTest($client) => { - #[allow(unused_imports)] - use gtest_runtime as runtime; - $( $code )* - } - #[cfg(feature = "gdev")] - Self::GDev($client) => { + Self::Client($client) => { #[allow(unused_imports)] - use gdev_runtime as runtime; $( $code )* } } @@ -196,50 +184,32 @@ impl ClientHandle for Client { } } -#[cfg(feature = "g1")] -impl From<Arc<super::FullClient<g1_runtime::RuntimeApi, super::runtime_executor::Executor>>> - for Client -{ - fn from( - client: Arc<super::FullClient<g1_runtime::RuntimeApi, super::runtime_executor::Executor>>, - ) -> Self { - Self::G1(client) - } -} - -#[cfg(feature = "gtest")] -impl From<Arc<super::FullClient<gtest_runtime::RuntimeApi, super::runtime_executor::Executor>>> - for Client +impl + From< + Arc< + super::FullClient< + super::runtime_executor::runtime::RuntimeApi, + super::runtime_executor::Executor, + >, + >, + > for Client { fn from( client: Arc< - super::FullClient<gtest_runtime::RuntimeApi, super::runtime_executor::Executor>, + super::FullClient< + super::runtime_executor::runtime::RuntimeApi, + super::runtime_executor::Executor, + >, >, ) -> Self { - Self::GTest(client) - } -} - -#[cfg(feature = "gdev")] -impl From<Arc<super::FullClient<gdev_runtime::RuntimeApi, super::runtime_executor::Executor>>> - for Client -{ - fn from( - client: Arc<super::FullClient<gdev_runtime::RuntimeApi, super::runtime_executor::Executor>>, - ) -> Self { - Self::GDev(client) + Self::Client(client) } } macro_rules! match_client { ($self:ident, $method:ident($($param:ident),*)) => { match $self { - #[cfg(feature = "g1")] - Self::G1(client) => client.$method($($param),*), - #[cfg(feature = "gtest")] - Self::GTest(client) => client.$method($($param),*), - #[cfg(feature = "gdev")] - Self::GDev(client) => client.$method($($param),*), + Self::Client(client) => client.$method($($param),*), } }; } @@ -336,7 +306,7 @@ use gtest_runtime as runtime; #[cfg(feature = "gtest")] type FullClient = super::FullClient<runtime::RuntimeApi, super::runtime_executor::Executor>; -#[cfg(any(feature = "gdev", feature = "gtest"))] +#[cfg(any(feature = "gdev", feature = "gtest", feature = "g1"))] impl BenchmarkCallSigner<runtime::RuntimeCall, sp_core::sr25519::Pair> for FullClient { fn sign_call( &self, diff --git a/runtime/g1/src/lib.rs b/runtime/g1/src/lib.rs index 64b716370645ae389873c616ceaecb720be7f6de..3ce455b521947adc07bc9f9370f9abadb5bf0d20 100644 --- a/runtime/g1/src/lib.rs +++ b/runtime/g1/src/lib.rs @@ -33,6 +33,7 @@ pub use common_runtime::{ constants::*, entities::*, handlers::*, AccountId, Address, Balance, BlockNumber, FullIdentificationOfImpl, GetCurrentEpochIndex, Hash, Header, IdtyIndex, Index, Signature, }; +pub use frame_system::Call as SystemCall; pub use pallet_balances::Call as BalancesCall; pub use pallet_identity::{IdtyStatus, IdtyValue}; pub use pallet_im_online::sr25519::AuthorityId as ImOnlineId;