From 96a27165c8d40984ac84f6aead08e63294258e01 Mon Sep 17 00:00:00 2001 From: 0xverin <104152026+0xverin@users.noreply.github.com> Date: Tue, 31 Dec 2024 18:26:18 +0800 Subject: [PATCH 1/3] Fix post-checks test script environment variable (#3212) * fix script * change network --- tee-worker/identity/ts-tests/post-checks/config.ts | 5 +++-- tee-worker/identity/ts-tests/post-checks/package.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tee-worker/identity/ts-tests/post-checks/config.ts b/tee-worker/identity/ts-tests/post-checks/config.ts index 4829843cff..bff9a52f09 100644 --- a/tee-worker/identity/ts-tests/post-checks/config.ts +++ b/tee-worker/identity/ts-tests/post-checks/config.ts @@ -1,7 +1,8 @@ -import { byId } from '@litentry/chaindata'; +import { byId, ChainId } from '@litentry/chaindata'; // Change this to the environment you want to test -const chain = byId['litentry-prod']; +const network = process.env.LITENTRY_NETWORK; +const chain = byId[network as ChainId]; export const nodeEndpoint: string = chain.rpcs[0].url; export const enclaveEndpoint: string = chain.enclaveRpcs[0].url; diff --git a/tee-worker/identity/ts-tests/post-checks/package.json b/tee-worker/identity/ts-tests/post-checks/package.json index a4ae5f4326..deb3d4eb37 100644 --- a/tee-worker/identity/ts-tests/post-checks/package.json +++ b/tee-worker/identity/ts-tests/post-checks/package.json @@ -5,7 +5,7 @@ "type": "module", "main": "index.js", "scripts": { - "start": "LITENTRY_NETWORK='litentry-dev' mocha --timeout 20000 --exit --sort -r ts-node/register --loader=ts-node/esm ./tests/**/*.test.ts" + "start": "LITENTRY_NETWORK=${LITENTRY_NETWORK:-litentry-dev} mocha --timeout 20000 --exit --sort -r ts-node/register --loader=ts-node/esm ./tests/**/*.test.ts" }, "dependencies": { "@litentry/chaindata": "^0.2.0", From 1f9fe5a59d8a4a878c6d0d5f317d7721dd32215c Mon Sep 17 00:00:00 2001 From: Francisco Silva Date: Tue, 31 Dec 2024 11:26:54 +0100 Subject: [PATCH 2/3] only initialize in-memory state when starting the worker (#3213) --- tee-worker/identity/service/src/main_impl.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tee-worker/identity/service/src/main_impl.rs b/tee-worker/identity/service/src/main_impl.rs index ed91d151ee..ea3878dbe0 100644 --- a/tee-worker/identity/service/src/main_impl.rs +++ b/tee-worker/identity/service/src/main_impl.rs @@ -162,11 +162,6 @@ pub(crate) fn main() { enclave_metrics_receiver, ))); - // init in-memory store, it should be done after the o-call bridge is initialized - if let Err(e) = enclave.init_in_memory_state() { - error!("Failed to initialize in-memory state: {:?}", e); - } - #[cfg(feature = "dcap")] let quoting_enclave_target_info = match enclave.qe_get_target_info() { Ok(target_info) => Some(target_info), @@ -190,6 +185,11 @@ pub(crate) fn main() { let quote_size = None; if let Some(run_config) = config.run_config() { + // init in-memory store, it should be done after the o-call bridge is initialized + if let Err(e) = enclave.init_in_memory_state() { + error!("Failed to initialize in-memory state: {:?}", e); + } + let shard = extract_shard(run_config.shard(), enclave.as_ref()); info!("Worker Config: {:?}", config); From 125ed1c842e0269908f8fd6a3b0ddad2cf5cdb21 Mon Sep 17 00:00:00 2001 From: Kai <7630809+Kailai-Wang@users.noreply.github.com> Date: Tue, 31 Dec 2024 11:27:26 +0100 Subject: [PATCH 3/3] Use fake_runtime_api to simplify code (#3215) --- parachain/node/src/command.rs | 59 ++--- parachain/node/src/fake_runtime_api.rs | 333 +++++++++++++++++++++++++ parachain/node/src/main.rs | 1 + parachain/node/src/service.rs | 198 ++++----------- 4 files changed, 402 insertions(+), 189 deletions(-) create mode 100644 parachain/node/src/fake_runtime_api.rs diff --git a/parachain/node/src/command.rs b/parachain/node/src/command.rs index 4d98d96ccf..c6893c507b 100644 --- a/parachain/node/src/command.rs +++ b/parachain/node/src/command.rs @@ -171,20 +171,10 @@ impl SubstrateCli for RelayChainCli { macro_rules! construct_benchmark_partials { ($config:expr, |$partials:ident| $code:expr) => { if $config.chain_spec.is_litentry() { - let $partials = new_partial::( - &$config, - build_import_queue::, - false, - true, - )?; + let $partials = new_partial::<_>(&$config, build_import_queue, false, true)?; $code } else if $config.chain_spec.is_paseo() { - let $partials = new_partial::( - &$config, - build_import_queue::, - false, - true, - )?; + let $partials = new_partial::<_>(&$config, build_import_queue, false, true)?; $code } else { panic!("{}", UNSUPPORTED_CHAIN_MESSAGE) @@ -199,11 +189,10 @@ macro_rules! construct_async_run { if runner.config().chain_spec.is_litentry() { runner.async_run(|$config| { let $components = new_partial::< - litentry_parachain_runtime::RuntimeApi, _ >( &$config, - build_import_queue::, + build_import_queue, false, $cli.delayed_best_block, )?; @@ -213,11 +202,10 @@ macro_rules! construct_async_run { } else if runner.config().chain_spec.is_paseo() { runner.async_run(|$config| { let $components = new_partial::< - paseo_parachain_runtime::RuntimeApi, _ >( &$config, - build_import_queue::, + build_import_queue, false, $cli.delayed_best_block, )?; @@ -286,24 +274,22 @@ pub fn run() -> Result<()> { let runner = cli.create_runner(cmd)?; if runner.config().chain_spec.is_litentry() { runner.sync_run(|config| { - let sc_service::PartialComponents { client, .. } = - new_partial::( - &config, - build_import_queue::, - false, - cli.delayed_best_block, - )?; + let sc_service::PartialComponents { client, .. } = new_partial::<_>( + &config, + build_import_queue, + false, + cli.delayed_best_block, + )?; cmd.run(client) }) } else if runner.config().chain_spec.is_paseo() { runner.sync_run(|config| { - let sc_service::PartialComponents { client, .. } = - new_partial::( - &config, - build_import_queue::, - false, - cli.delayed_best_block, - )?; + let sc_service::PartialComponents { client, .. } = new_partial::<_>( + &config, + build_import_queue, + false, + cli.delayed_best_block, + )?; cmd.run(client) }) } else { @@ -383,12 +369,9 @@ pub fn run() -> Result<()> { runner.run_node_until_exit(|config| async move { if is_standalone { - return start_standalone_node::( - config, - evm_tracing_config, - ) - .await - .map_err(Into::into); + return start_standalone_node(config, evm_tracing_config) + .await + .map_err(Into::into); } let hwbench = if !cli.no_hardware_benchmarks { @@ -429,7 +412,7 @@ pub fn run() -> Result<()> { AdditionalConfig { evm_tracing_config, enable_evm_rpc: cli.enable_evm_rpc }; if config.chain_spec.is_litentry() { - start_node::( + start_node( config, polkadot_config, collator_options, @@ -442,7 +425,7 @@ pub fn run() -> Result<()> { .map(|r| r.0) .map_err(Into::into) } else if config.chain_spec.is_paseo() { - start_node::( + start_node( config, polkadot_config, collator_options, diff --git a/parachain/node/src/fake_runtime_api.rs b/parachain/node/src/fake_runtime_api.rs new file mode 100644 index 0000000000..f9af83645b --- /dev/null +++ b/parachain/node/src/fake_runtime_api.rs @@ -0,0 +1,333 @@ +// Copyright 2020-2024 Trust Computing GmbH. +// This file is part of Litentry. +// +// Litentry is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Litentry is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Litentry. If not, see . + +//! These are used to provide a type that implements these runtime APIs without requiring to import +//! the native runtimes. + +use core_primitives::{AccountId, AuraId, Balance, Nonce}; +use frame_support::weights::Weight; +use polkadot_primitives::Block; +use sp_core::{OpaqueMetadata, H160, H256, U256}; +use sp_runtime::{ + traits::Block as BlockT, + transaction_validity::{TransactionSource, TransactionValidity}, + ApplyExtrinsicResult, Permill, +}; + +#[allow(dead_code)] +pub struct Runtime; + +sp_api::impl_runtime_apis! { + impl sp_api::Core for Runtime { + fn version() -> sp_version::RuntimeVersion { + unimplemented!() + } + + fn execute_block(_: Block) { + unimplemented!() + } + + fn initialize_block(_: &::Header) -> sp_runtime::ExtrinsicInclusionMode { + unimplemented!() + } + } + + impl sp_api::Metadata for Runtime { + fn metadata() -> OpaqueMetadata { + unimplemented!() + } + + fn metadata_at_version(_: u32) -> Option { + unimplemented!() + } + + fn metadata_versions() -> Vec { + unimplemented!() + } + } + + impl sp_consensus_aura::AuraApi for Runtime { + fn slot_duration() -> sp_consensus_aura::SlotDuration { + unimplemented!() + } + + fn authorities() -> Vec { + unimplemented!() + } + } + + impl cumulus_primitives_aura::AuraUnincludedSegmentApi for Runtime { + fn can_build_upon( + _: ::Hash, + _: cumulus_primitives_aura::Slot, + ) -> bool { + unimplemented!() + } + } + + impl sp_block_builder::BlockBuilder for Runtime { + fn apply_extrinsic(_: ::Extrinsic) -> ApplyExtrinsicResult { + unimplemented!() + } + + fn finalize_block() -> ::Header { + unimplemented!() + } + + fn inherent_extrinsics(_: sp_inherents::InherentData) -> Vec<::Extrinsic> { + unimplemented!() + } + + fn check_inherents(_: Block, _: sp_inherents::InherentData) -> sp_inherents::CheckInherentsResult { + unimplemented!() + } + } + + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { + fn validate_transaction( + _: TransactionSource, + _: ::Extrinsic, + _: ::Hash, + ) -> TransactionValidity { + unimplemented!() + } + } + + impl sp_session::SessionKeys for Runtime { + fn generate_session_keys(_seed: Option>) -> Vec { + unimplemented!() + } + + fn decode_session_keys(_encoded: Vec) -> Option, sp_core::crypto::KeyTypeId)>> { + unimplemented!() + } + } + + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi for Runtime { + fn query_info( + _: ::Extrinsic, + _: u32, + ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo { + unimplemented!() + } + fn query_fee_details( + _: ::Extrinsic, + _: u32, + ) -> pallet_transaction_payment::FeeDetails { + unimplemented!() + } + fn query_weight_to_fee(_: Weight) -> Balance { + unimplemented!() + } + fn query_length_to_fee(_: u32) -> Balance { + unimplemented!() + } + } + + impl cumulus_primitives_core::CollectCollationInfo for Runtime { + fn collect_collation_info(_: &::Header) -> cumulus_primitives_core::CollationInfo { + unimplemented!() + } + } + + #[cfg(feature = "try-runtime")] + impl frame_try_runtime::TryRuntime for Runtime { + fn on_runtime_upgrade(_: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) { + unimplemented!() + } + + fn execute_block( + _: Block, + _: bool, + _: bool, + _: frame_try_runtime::TryStateSelect, + ) -> Weight { + unimplemented!() + } + } + + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(_: AccountId) -> Nonce { + unimplemented!() + } + } + + #[cfg(feature = "runtime-benchmarks")] + impl frame_benchmarking::Benchmark for Runtime { + fn benchmark_metadata(_: bool) -> ( + Vec, + Vec, + ) { + unimplemented!() + } + + fn dispatch_benchmark( + _: frame_benchmarking::BenchmarkConfig + ) -> Result, sp_runtime::RuntimeString> { + unimplemented!() + } + } + + impl sp_genesis_builder::GenesisBuilder for Runtime { + fn build_state(_: Vec) -> sp_genesis_builder::Result { + unimplemented!() + } + + fn get_preset(_id: &Option) -> Option> { + unimplemented!() + } + + fn preset_names() -> Vec { + unimplemented!() + } + } + + impl fp_rpc::EthereumRuntimeRPCApi for Runtime { + fn chain_id() -> u64 { + unimplemented!() + } + + fn account_basic(_address: H160) -> pallet_evm::Account { + unimplemented!() + } + + fn gas_price() -> U256 { + unimplemented!() + } + + fn account_code_at(_address: H160) -> Vec { + unimplemented!() + } + + fn author() -> H160 { + unimplemented!() + } + + fn storage_at(_address: H160, _index: U256) -> H256 { + unimplemented!() + } + + fn call( + _from: H160, + _to: H160, + _data: Vec, + _value: U256, + _gas_limit: U256, + _max_fee_per_gas: Option, + _max_priority_fee_per_gas: Option, + _nonce: Option, + _estimate: bool, + _access_list: Option)>>, + ) -> Result { + unimplemented!() + } + + fn create( + _from: H160, + _data: Vec, + _value: U256, + _gas_limit: U256, + _max_fee_per_gas: Option, + _max_priority_fee_per_gas: Option, + _nonce: Option, + _estimate: bool, + _access_list: Option)>>, + ) -> Result { + unimplemented!() + } + + fn current_transaction_statuses() -> Option> { + unimplemented!() + } + + fn current_block() -> Option { + unimplemented!() + } + + fn current_receipts() -> Option> { + unimplemented!() + } + + fn current_all() -> ( + Option, + Option>, + Option>, + ) { + unimplemented!() + } + + fn extrinsic_filter(_xts: Vec<::Extrinsic>) -> Vec { + unimplemented!() + } + + fn elasticity() -> Option { + unimplemented!() + } + + fn gas_limit_multiplier_support() {} + + fn pending_block(_xts: Vec<::Extrinsic>) -> (Option, Option>) { + unimplemented!() + } + + fn initialize_pending_block(_header: &::Header) { + unimplemented!() + } + } + + impl fp_rpc::ConvertTransactionRuntimeApi for Runtime { + fn convert_transaction(_transaction: pallet_ethereum::Transaction) -> ::Extrinsic { + unimplemented!() + } + } + + impl sp_offchain::OffchainWorkerApi for Runtime { + fn offchain_worker(_header: &::Header) { + unimplemented!() + } + } + + impl moonbeam_rpc_primitives_debug::DebugRuntimeApi for Runtime { + fn trace_transaction(_extrinsics: Vec<::Extrinsic>, _traced_transaction: &pallet_ethereum::Transaction, _header: &::Header) -> Result<(), sp_runtime::DispatchError> { + unimplemented!() + } + + fn trace_block(_extrinsics: Vec<::Extrinsic>, _known_transactions: Vec, _header: &::Header) -> Result<(), sp_runtime::DispatchError> { + unimplemented!() + } + + fn trace_call( + _header: &::Header, + _from: H160, + _to: H160, + _data: Vec, + _value: U256, + _gas_limit: U256, + _max_fee_per_gas: Option, + _max_priority_fee_per_gas: Option, + _nonce: Option, + _access_list: Option)>>, + ) -> Result<(), sp_runtime::DispatchError> { + unimplemented!() + } + } + + impl moonbeam_rpc_primitives_txpool::TxPoolRuntimeApi for Runtime { + fn extrinsic_filter(_xts_ready: Vec<::Extrinsic>, _xts_future: Vec<::Extrinsic>) -> moonbeam_rpc_primitives_txpool::TxPoolResponse { + unimplemented!() + } + } +} diff --git a/parachain/node/src/main.rs b/parachain/node/src/main.rs index 0bf81a5634..e4872656cb 100644 --- a/parachain/node/src/main.rs +++ b/parachain/node/src/main.rs @@ -21,6 +21,7 @@ mod cli; mod command; mod custom_txpool; mod evm_tracing_types; +mod fake_runtime_api; mod rpc; mod service; mod standalone_block_import; diff --git a/parachain/node/src/service.rs b/parachain/node/src/service.rs index d31c11bd24..5479cdf346 100644 --- a/parachain/node/src/service.rs +++ b/parachain/node/src/service.rs @@ -22,10 +22,11 @@ use crate::{ evm_tracing_types::{EthApi as EthApiCmd, EvmTracingConfig}, + fake_runtime_api::RuntimeApi as FakeRuntimeApi, standalone_block_import::StandaloneBlockImport, tracing::{self, RpcRequesters}, }; -pub use core_primitives::{AccountId, AuraId, Balance, Block, Hash, Nonce}; +pub use core_primitives::{AuraId, Block, Hash}; use cumulus_client_cli::CollatorOptions; use cumulus_client_collator::service::CollatorService; use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams}; @@ -58,7 +59,6 @@ use sc_network::{config::FullNetworkConfiguration, service::traits::NetworkBacke use sc_network_sync::SyncingService; use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; -use sp_api::ConstructRuntimeApi; use sp_keystore::KeystorePtr; use sp_runtime::app_crypto::AppCrypto; use sp_runtime::traits::Header; @@ -78,13 +78,13 @@ pub type HostFunctions = ( moonbeam_primitives_ext::moonbeam_ext::HostFunctions, ); -type ParachainClient = TFullClient>; +type ParachainClient = TFullClient>; type ParachainBackend = TFullBackend; -type ParachainBlockImport = TParachainBlockImport< +type ParachainBlockImport = TParachainBlockImport< Block, - FrontierBlockImport>, ParachainClient>, + FrontierBlockImport, ParachainClient>, ParachainBackend, >; @@ -94,39 +94,31 @@ type MaybeSelectChain = Option>; /// /// Use this macro if you don't actually need the full service, but just the builder in order to /// be able to perform chain operations. -pub fn new_partial( +pub fn new_partial( config: &Configuration, build_import_queue: BIQ, is_standalone: bool, delayed_best_block: bool, ) -> Result< PartialComponents< - ParachainClient, + ParachainClient, ParachainBackend, MaybeSelectChain, sc_consensus::DefaultImportQueue, - sc_transaction_pool::FullPool>, + sc_transaction_pool::FullPool, ( - ParachainBlockImport, + ParachainBlockImport, Option, Option, - Arc>>, + Arc>, ), >, sc_service::Error, > where - RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt - + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + fp_rpc::EthereumRuntimeRPCApi, BIQ: FnOnce( - Arc>, - ParachainBlockImport, + Arc, + ParachainBlockImport, &Configuration, Option, &TaskManager, @@ -157,7 +149,7 @@ where .build(); let (client, backend, keystore_container, task_manager) = - sc_service::new_full_parts_record_import::( + sc_service::new_full_parts_record_import::( config, telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), executor, @@ -237,7 +229,7 @@ pub struct AdditionalConfig { /// /// This is the actual implementation that is abstract over the executor and the runtime api. #[sc_tracing::logging::prefix_logs_with("Parachain")] -async fn start_node_impl( +async fn start_node_impl( parachain_config: Configuration, polkadot_config: Configuration, collator_options: CollatorOptions, @@ -249,47 +241,31 @@ async fn start_node_impl( hwbench: Option, additional_config: AdditionalConfig, delayed_best_block: bool, -) -> sc_service::error::Result<(TaskManager, Arc>)> +) -> sc_service::error::Result<(TaskManager, Arc)> where - RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt - + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + cumulus_primitives_aura::AuraUnincludedSegmentApi - + substrate_frame_rpc_system::AccountNonceApi - + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + fp_rpc::EthereumRuntimeRPCApi - + fp_rpc::ConvertTransactionRuntimeApi - + cumulus_primitives_core::CollectCollationInfo - + sp_consensus_aura::AuraApi - + moonbeam_rpc_primitives_debug::DebugRuntimeApi - + moonbeam_rpc_primitives_txpool::TxPoolRuntimeApi, RB: Fn( sc_rpc::DenyUnsafe, - Arc>, + Arc, Arc, - Arc>>, + Arc>, ) -> Result, sc_service::Error> + 'static, BIQ: FnOnce( - Arc>, - ParachainBlockImport, + Arc, + ParachainBlockImport, &Configuration, Option, &TaskManager, bool, ) -> Result, sc_service::Error>, SC: FnOnce( - Arc>, - ParachainBlockImport, + Arc, + ParachainBlockImport, Option<&Registry>, Option, &TaskManager, Arc, - Arc>>, + Arc>, KeystorePtr, Duration, ParaId, @@ -302,12 +278,8 @@ where { let parachain_config = prepare_node_config(parachain_config); - let params = new_partial::( - ¶chain_config, - build_import_queue, - false, - delayed_best_block, - )?; + let params = + new_partial::(¶chain_config, build_import_queue, false, delayed_best_block)?; let (block_import, mut telemetry, telemetry_worker_handle, frontier_backend) = params.other; let client = params.client.clone(); @@ -364,7 +336,7 @@ where storage_override, tracing_requesters, ethapi_cmd, - ) = start_node_evm_impl::( + ) = start_node_evm_impl( client.clone(), backend.clone(), frontier_backend.clone(), @@ -505,7 +477,7 @@ where } /// Start a litentry/rococo node. -pub async fn start_node( +pub async fn start_node( parachain_config: Configuration, polkadot_config: Configuration, collator_options: CollatorOptions, @@ -513,34 +485,16 @@ pub async fn start_node( hwbench: Option, additional_config: AdditionalConfig, delayed_best_block: bool, -) -> sc_service::error::Result<(TaskManager, Arc>)> -where - RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt - + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + cumulus_primitives_aura::AuraUnincludedSegmentApi - + substrate_frame_rpc_system::AccountNonceApi - + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + fp_rpc::EthereumRuntimeRPCApi - + fp_rpc::ConvertTransactionRuntimeApi - + cumulus_primitives_core::CollectCollationInfo - + sp_consensus_aura::AuraApi - + moonbeam_rpc_primitives_debug::DebugRuntimeApi - + moonbeam_rpc_primitives_txpool::TxPoolRuntimeApi, -{ - start_node_impl::>( +) -> sc_service::error::Result<(TaskManager, Arc)> { + start_node_impl::<_, _, _, sc_network::NetworkWorker<_, _>>( parachain_config, polkadot_config, collator_options, CollatorSybilResistance::Resistant, // Aura para_id, |_, _, _, _| Ok(RpcModule::new(())), - build_import_queue::, - start_lookahead_aura_consensus::, + build_import_queue, + start_lookahead_aura_consensus, hwbench, additional_config.clone(), delayed_best_block, @@ -549,25 +503,14 @@ where } /// Build the import queue for the litentry/rococo runtime. -pub fn build_import_queue( - client: Arc>, - block_import: ParachainBlockImport, +pub fn build_import_queue( + client: Arc, + block_import: ParachainBlockImport, config: &Configuration, telemetry: Option, task_manager: &TaskManager, is_standalone: bool, -) -> Result, sc_service::Error> -where - RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt - + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + fp_rpc::EthereumRuntimeRPCApi - + sp_consensus_aura::AuraApi, -{ +) -> Result, sc_service::Error> { if is_standalone { // aura import queue let slot_duration = sc_consensus_aura::slot_duration(&*client)?; @@ -662,28 +605,10 @@ where } // start a standalone node which doesn't need to connect to relaychain -pub async fn start_standalone_node( +pub async fn start_standalone_node( config: Configuration, evm_tracing_config: crate::evm_tracing_types::EvmTracingConfig, -) -> Result -where - RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt - + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + cumulus_primitives_aura::AuraUnincludedSegmentApi - + substrate_frame_rpc_system::AccountNonceApi - + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + fp_rpc::EthereumRuntimeRPCApi - + fp_rpc::ConvertTransactionRuntimeApi - + cumulus_primitives_core::CollectCollationInfo - + sp_consensus_aura::AuraApi - + moonbeam_rpc_primitives_debug::DebugRuntimeApi - + moonbeam_rpc_primitives_txpool::TxPoolRuntimeApi, -{ +) -> Result { let sc_service::PartialComponents { client, backend, @@ -693,7 +618,7 @@ where select_chain: maybe_select_chain, transaction_pool, other: (_, _, _, frontier_backend), - } = new_partial::(&config, build_import_queue::, true, true)?; + } = new_partial::<_>(&config, build_import_queue, true, true)?; // Sinks for pubsub notifications. // Everytime a new subscription is created, a new mpsc channel is added to the sink pool. @@ -735,7 +660,7 @@ where storage_override, tracing_requesters, ethapi_cmd, - ) = start_node_evm_impl::( + ) = start_node_evm_impl( client.clone(), backend.clone(), frontier_backend.clone(), @@ -908,10 +833,10 @@ where Ok(task_manager) } -pub fn start_node_evm_impl( - client: Arc>, +pub fn start_node_evm_impl( + client: Arc, backend: Arc, - frontier_backend: Arc>>, + frontier_backend: Arc>, task_manager: &mut TaskManager, config: &Configuration, evm_tracing_config: crate::evm_tracing_types::EvmTracingConfig, @@ -929,23 +854,7 @@ pub fn start_node_evm_impl( Arc>, RpcRequesters, Vec, -) -where - RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt - + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + cumulus_primitives_core::CollectCollationInfo - + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + substrate_frame_rpc_system::AccountNonceApi - + fp_rpc::EthereumRuntimeRPCApi - + fp_rpc::ConvertTransactionRuntimeApi - + moonbeam_rpc_primitives_debug::DebugRuntimeApi - + moonbeam_rpc_primitives_txpool::TxPoolRuntimeApi, -{ +) { let prometheus_registry = config.prometheus_registry().cloned(); let filter_pool: FilterPool = Arc::new(std::sync::Mutex::new(BTreeMap::new())); let fee_history_cache: FeeHistoryCache = Arc::new(std::sync::Mutex::new(BTreeMap::new())); @@ -1036,14 +945,14 @@ where } /// Start consensus using the lookahead aura collator. -fn start_lookahead_aura_consensus( - client: Arc>, - block_import: ParachainBlockImport, +fn start_lookahead_aura_consensus( + client: Arc, + block_import: ParachainBlockImport, prometheus_registry: Option<&Registry>, telemetry: Option, task_manager: &TaskManager, relay_chain_interface: Arc, - transaction_pool: Arc>>, + transaction_pool: Arc>, keystore: KeystorePtr, relay_chain_slot_duration: Duration, para_id: ParaId, @@ -1051,20 +960,7 @@ fn start_lookahead_aura_consensus( overseer_handle: OverseerHandle, announce_block: Arc>) + Send + Sync>, backend: Arc, -) -> Result<(), sc_service::Error> -where - RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt - + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + fp_rpc::EthereumRuntimeRPCApi - + sp_consensus_aura::AuraApi - + cumulus_primitives_aura::AuraUnincludedSegmentApi - + cumulus_primitives_core::CollectCollationInfo, -{ +) -> Result<(), sc_service::Error> { // TODO: use fork-aware txpool when paritytech/polkadot-sdk#4639 is included in a stable release // presumably in stable2412 // This is a workaround mentioned in https://github.com/paritytech/polkadot-sdk/issues/1202