From 850d4ef7bdc8d59e3dfcdfcc4a8f0f49c327e4bf Mon Sep 17 00:00:00 2001 From: Aliaksandr Tsurko Date: Wed, 13 Nov 2024 19:45:25 +0100 Subject: [PATCH 1/3] Remove unnecessary generics --- node/src/client.rs | 84 +++------------ node/src/ethereum.rs | 239 +++++++++++++------------------------------ node/src/rpc.rs | 73 ++++++------- node/src/service.rs | 108 ++++++------------- 4 files changed, 146 insertions(+), 358 deletions(-) diff --git a/node/src/client.rs b/node/src/client.rs index c7196b5a9..dd7dfda45 100644 --- a/node/src/client.rs +++ b/node/src/client.rs @@ -1,76 +1,16 @@ -use scale_codec::Codec; -// Substrate +use node_subtensor_runtime::{opaque::Block, RuntimeApi}; use sc_executor::WasmExecutor; -use sp_runtime::traits::{Block as BlockT, MaybeDisplay}; - -use crate::ethereum::EthCompatRuntimeApiCollection; /// Full backend. -pub type FullBackend = sc_service::TFullBackend; +pub type FullBackend = sc_service::TFullBackend; /// Full client. -pub type FullClient = sc_service::TFullClient>; - -/// A set of APIs that every runtime must implement. -pub trait BaseRuntimeApiCollection: - sp_api::ApiExt - + sp_api::Metadata - + sp_block_builder::BlockBuilder - + sp_offchain::OffchainWorkerApi - + sp_session::SessionKeys - + sp_transaction_pool::runtime_api::TaggedTransactionQueue -{ -} - -impl BaseRuntimeApiCollection for Api -where - Block: BlockT, - Api: sp_api::ApiExt - + sp_api::Metadata - + sp_block_builder::BlockBuilder - + sp_offchain::OffchainWorkerApi - + sp_session::SessionKeys - + sp_transaction_pool::runtime_api::TaggedTransactionQueue, -{ -} - -/// A set of APIs that Subtensor runtime must implement. -pub trait RuntimeApiCollection< - Block: BlockT, - AuraId: Codec, - AccountId: Codec, - Nonce: Codec, - Balance: Codec + MaybeDisplay, ->: - BaseRuntimeApiCollection - + EthCompatRuntimeApiCollection - + sp_consensus_aura::AuraApi - + sp_consensus_grandpa::GrandpaApi - + frame_system_rpc_runtime_api::AccountNonceApi - + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi - + subtensor_custom_rpc_runtime_api::DelegateInfoRuntimeApi - + subtensor_custom_rpc_runtime_api::NeuronInfoRuntimeApi - + subtensor_custom_rpc_runtime_api::SubnetInfoRuntimeApi - + subtensor_custom_rpc_runtime_api::SubnetRegistrationRuntimeApi -{ -} - -impl - RuntimeApiCollection for Api -where - Block: BlockT, - AuraId: Codec, - AccountId: Codec, - Nonce: Codec, - Balance: Codec + MaybeDisplay, - Api: BaseRuntimeApiCollection - + EthCompatRuntimeApiCollection - + sp_consensus_aura::AuraApi - + sp_consensus_grandpa::GrandpaApi - + frame_system_rpc_runtime_api::AccountNonceApi - + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi - + subtensor_custom_rpc_runtime_api::DelegateInfoRuntimeApi - + subtensor_custom_rpc_runtime_api::NeuronInfoRuntimeApi - + subtensor_custom_rpc_runtime_api::SubnetInfoRuntimeApi - + subtensor_custom_rpc_runtime_api::SubnetRegistrationRuntimeApi, -{ -} +pub type FullClient = sc_service::TFullClient>; +/// Always enable runtime benchmark host functions, the genesis state +/// was built with them so we're stuck with them forever. +/// +/// They're just a noop, never actually get used if the runtime was not compiled with +/// `runtime-benchmarks`. +type HostFunctions = ( + sp_io::SubstrateHostFunctions, + frame_benchmarking::benchmarking::HostFunctions, +); diff --git a/node/src/ethereum.rs b/node/src/ethereum.rs index 337013a56..073635387 100644 --- a/node/src/ethereum.rs +++ b/node/src/ethereum.rs @@ -1,30 +1,23 @@ -use crate::rpc::EthDeps; +pub use fc_consensus::FrontierBlockImport; use fc_rpc::{ pending::AuraConsensusDataProvider, Debug, DebugApiServer, Eth, EthApiServer, EthConfig, EthDevSigner, EthFilter, EthFilterApiServer, EthPubSub, EthPubSubApiServer, EthSigner, EthTask, Net, NetApiServer, Web3, Web3ApiServer, }; -use fp_rpc::{ConvertTransaction, ConvertTransactionRuntimeApi, EthereumRuntimeRPCApi}; +pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool}; +/// Frontier DB backend type. +pub use fc_storage::{StorageOverride, StorageOverrideHandler}; +use fp_rpc::ConvertTransaction; use futures::future; use futures::StreamExt; use jsonrpsee::RpcModule; -use sc_client_api::{ - backend::{Backend, StorageProvider}, - client::BlockchainEvents, - AuxStore, UsageProvider, -}; -use sc_executor::HostFunctions; +use node_subtensor_runtime::opaque::Block; +use sc_client_api::client::BlockchainEvents; use sc_network_sync::SyncingService; use sc_rpc::SubscriptionTaskExecutor; use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; use sc_transaction_pool::ChainApi; use sc_transaction_pool_api::TransactionPool; -use sp_api::{CallApiAt, ConstructRuntimeApi, ProvideRuntimeApi}; -use sp_block_builder::BlockBuilder as BlockBuilderApi; -use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; -use sp_consensus_aura::sr25519::AuthorityId as AuraId; -use sp_consensus_aura::AuraApi; -use sp_core::H256; use sp_inherents::CreateInherentDataProviders; use sp_runtime::traits::Block as BlockT; use std::path::PathBuf; @@ -34,14 +27,10 @@ use std::{ sync::{Arc, Mutex}, }; -pub use fc_consensus::FrontierBlockImport; -pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool}; -/// Frontier DB backend type. -pub use fc_storage::{StorageOverride, StorageOverrideHandler}; - use crate::client::{FullBackend, FullClient}; +use crate::rpc::EthDeps; -pub type FrontierBackend = fc_db::Backend; +pub type FrontierBackend = fc_db::Backend; /// Avalailable frontier backend types. #[derive(Debug, Copy, Clone, Default, clap::ValueEnum)] @@ -126,46 +115,23 @@ pub fn new_frontier_partial( }) } -/// A set of APIs that ethereum-compatible runtimes must implement. -pub trait EthCompatRuntimeApiCollection: - sp_api::ApiExt - + fp_rpc::ConvertTransactionRuntimeApi - + fp_rpc::EthereumRuntimeRPCApi -{ -} - -impl EthCompatRuntimeApiCollection for Api -where - Block: BlockT, - Api: sp_api::ApiExt - + fp_rpc::ConvertTransactionRuntimeApi - + fp_rpc::EthereumRuntimeRPCApi, -{ -} - #[allow(clippy::too_many_arguments)] -pub async fn spawn_frontier_tasks( +pub async fn spawn_frontier_tasks( task_manager: &TaskManager, - client: Arc>, - backend: Arc>, - frontier_backend: Arc>>, + client: Arc, + backend: Arc, + frontier_backend: Arc, filter_pool: Option, - storage_override: Arc>, + storage_override: Arc>, fee_history_cache: FeeHistoryCache, fee_history_cache_limit: FeeHistoryCacheLimit, - sync: Arc>, + sync: Arc>, pubsub_notification_sinks: Arc< fc_mapping_sync::EthereumBlockNotificationSinks< - fc_mapping_sync::EthereumBlockNotification, + fc_mapping_sync::EthereumBlockNotification, >, >, -) where - B: BlockT, - RA: ConstructRuntimeApi>, - RA: Send + Sync + 'static, - RA::RuntimeApi: EthCompatRuntimeApiCollection, - HF: HostFunctions + 'static, -{ +) { // Spawn main mapping sync worker background task. match &*frontier_backend { fc_db::Backend::KeyValue(b) => { @@ -180,7 +146,7 @@ pub async fn spawn_frontier_tasks( storage_override.clone(), b.clone(), 3, - 0u32.into(), + 0u32, fc_mapping_sync::SyncStrategy::Normal, sync, pubsub_notification_sinks, @@ -233,25 +199,16 @@ pub async fn spawn_frontier_tasks( ); } -fn extend_rpc_aet_api( +fn extend_rpc_aet_api( io: &mut RpcModule<()>, - deps: &EthDeps, + deps: &EthDeps, ) -> Result<(), Box> where - B: BlockT, - C: CallApiAt + ProvideRuntimeApi, - C::Api: AuraApi - + BlockBuilderApi - + ConvertTransactionRuntimeApi - + EthereumRuntimeRPCApi, - C: HeaderBackend + HeaderMetadata, - C: BlockchainEvents + AuxStore + UsageProvider + StorageProvider + 'static, - BE: Backend + 'static, - P: TransactionPool + 'static, - A: ChainApi + 'static, - CT: ConvertTransaction<::Extrinsic> + Send + Sync + Clone + 'static, - CIDP: CreateInherentDataProviders + Send + Clone + 'static, - EC: EthConfig, + P: TransactionPool + 'static, + A: ChainApi + 'static, + CT: ConvertTransaction<::Extrinsic> + Send + Sync + Clone + 'static, + CIDP: CreateInherentDataProviders + Send + Clone + 'static, + EC: EthConfig, { let mut signers = Vec::new(); if deps.enable_dev_signer { @@ -259,7 +216,7 @@ where } io.merge( - Eth::::new( + Eth::::new( deps.client.clone(), deps.pool.clone(), deps.graph.clone(), @@ -285,24 +242,15 @@ where Ok(()) } -fn extend_rpc_eth_filter( +fn extend_rpc_eth_filter( io: &mut RpcModule<()>, - deps: &EthDeps, + deps: &EthDeps, ) -> Result<(), Box> where - B: BlockT, - C: CallApiAt + ProvideRuntimeApi, - C::Api: AuraApi - + BlockBuilderApi - + ConvertTransactionRuntimeApi - + EthereumRuntimeRPCApi, - C: HeaderBackend + HeaderMetadata, - C: BlockchainEvents + AuxStore + UsageProvider + StorageProvider + 'static, - BE: Backend + 'static, - P: TransactionPool + 'static, - A: ChainApi + 'static, - CT: ConvertTransaction<::Extrinsic> + Send + Sync + Clone + 'static, - CIDP: CreateInherentDataProviders + Send + Clone + 'static, + P: TransactionPool + 'static, + A: ChainApi + 'static, + CT: ConvertTransaction<::Extrinsic> + Send + Sync + Clone + 'static, + CIDP: CreateInherentDataProviders + Send + Clone + 'static, { if let Some(filter_pool) = deps.filter_pool.clone() { io.merge( @@ -322,30 +270,21 @@ where } // Function for EthPubSub merge -fn extend_rpc_eth_pubsub( +fn extend_rpc_eth_pubsub( io: &mut RpcModule<()>, - deps: &EthDeps, + deps: &EthDeps, subscription_task_executor: SubscriptionTaskExecutor, pubsub_notification_sinks: Arc< fc_mapping_sync::EthereumBlockNotificationSinks< - fc_mapping_sync::EthereumBlockNotification, + fc_mapping_sync::EthereumBlockNotification, >, >, ) -> Result<(), Box> where - B: BlockT, - C: CallApiAt + ProvideRuntimeApi, - C::Api: AuraApi - + BlockBuilderApi - + ConvertTransactionRuntimeApi - + EthereumRuntimeRPCApi, - C: HeaderBackend + HeaderMetadata, - C: BlockchainEvents + AuxStore + UsageProvider + StorageProvider + 'static, - BE: Backend + 'static, - P: TransactionPool + 'static, - A: ChainApi + 'static, - CT: ConvertTransaction<::Extrinsic> + Send + Sync + 'static, - CIDP: CreateInherentDataProviders + Send + 'static, + P: TransactionPool + 'static, + A: ChainApi + 'static, + CT: ConvertTransaction<::Extrinsic> + Send + Sync + 'static, + CIDP: CreateInherentDataProviders + Send + 'static, { io.merge( EthPubSub::new( @@ -361,24 +300,15 @@ where Ok(()) } -fn extend_rpc_net( +fn extend_rpc_net( io: &mut RpcModule<()>, - deps: &EthDeps, + deps: &EthDeps, ) -> Result<(), Box> where - B: BlockT, - C: CallApiAt + ProvideRuntimeApi, - C::Api: AuraApi - + BlockBuilderApi - + ConvertTransactionRuntimeApi - + EthereumRuntimeRPCApi, - C: HeaderBackend + HeaderMetadata, - C: BlockchainEvents + AuxStore + UsageProvider + StorageProvider + 'static, - BE: Backend + 'static, - P: TransactionPool + 'static, - A: ChainApi + 'static, - CT: ConvertTransaction<::Extrinsic> + Send + Sync + 'static, - CIDP: CreateInherentDataProviders + Send + 'static, + P: TransactionPool + 'static, + A: ChainApi + 'static, + CT: ConvertTransaction<::Extrinsic> + Send + Sync + 'static, + CIDP: CreateInherentDataProviders + Send + 'static, { io.merge( Net::new( @@ -391,47 +321,29 @@ where Ok(()) } -fn extend_rpc_web3( +fn extend_rpc_web3( io: &mut RpcModule<()>, - deps: &EthDeps, + deps: &EthDeps, ) -> Result<(), Box> where - B: BlockT, - C: CallApiAt + ProvideRuntimeApi, - C::Api: AuraApi - + BlockBuilderApi - + ConvertTransactionRuntimeApi - + EthereumRuntimeRPCApi, - C: HeaderBackend + HeaderMetadata, - C: BlockchainEvents + AuxStore + UsageProvider + StorageProvider + 'static, - BE: Backend + 'static, - P: TransactionPool + 'static, - A: ChainApi + 'static, - CT: ConvertTransaction<::Extrinsic> + Send + Sync + 'static, - CIDP: CreateInherentDataProviders + Send + 'static, + P: TransactionPool + 'static, + A: ChainApi + 'static, + CT: ConvertTransaction<::Extrinsic> + Send + Sync + 'static, + CIDP: CreateInherentDataProviders + Send + 'static, { io.merge(Web3::new(deps.client.clone()).into_rpc())?; Ok(()) } -fn extend_rpc_debug( +fn extend_rpc_debug( io: &mut RpcModule<()>, - deps: &EthDeps, + deps: &EthDeps, ) -> Result<(), Box> where - B: BlockT, - C: CallApiAt + ProvideRuntimeApi, - C::Api: AuraApi - + BlockBuilderApi - + ConvertTransactionRuntimeApi - + EthereumRuntimeRPCApi, - C: HeaderBackend + HeaderMetadata, - C: BlockchainEvents + AuxStore + UsageProvider + StorageProvider + 'static, - BE: Backend + 'static, - P: TransactionPool + 'static, - A: ChainApi + 'static, - CT: ConvertTransaction<::Extrinsic> + Send + Sync + 'static, - CIDP: CreateInherentDataProviders + Send + 'static, + P: TransactionPool + 'static, + A: ChainApi + 'static, + CT: ConvertTransaction<::Extrinsic> + Send + Sync + 'static, + CIDP: CreateInherentDataProviders + Send + 'static, { io.merge( Debug::new( @@ -446,43 +358,34 @@ where } /// Extend RpcModule with Eth RPCs -pub fn create_eth( +pub fn create_eth( mut io: RpcModule<()>, - deps: EthDeps, + deps: EthDeps, subscription_task_executor: SubscriptionTaskExecutor, pubsub_notification_sinks: Arc< fc_mapping_sync::EthereumBlockNotificationSinks< - fc_mapping_sync::EthereumBlockNotification, + fc_mapping_sync::EthereumBlockNotification, >, >, ) -> Result, Box> where - B: BlockT, - C: CallApiAt + ProvideRuntimeApi, - C::Api: AuraApi - + BlockBuilderApi - + ConvertTransactionRuntimeApi - + EthereumRuntimeRPCApi, - C: HeaderBackend + HeaderMetadata, - C: BlockchainEvents + AuxStore + UsageProvider + StorageProvider + 'static, - BE: Backend + 'static, - P: TransactionPool + 'static, - A: ChainApi + 'static, - CT: ConvertTransaction<::Extrinsic> + Send + Sync + Clone + 'static, - CIDP: CreateInherentDataProviders + Send + Clone + 'static, - EC: EthConfig, + P: TransactionPool + 'static, + A: ChainApi + 'static, + CT: ConvertTransaction<::Extrinsic> + Send + Sync + Clone + 'static, + CIDP: CreateInherentDataProviders + Send + Clone + 'static, + EC: EthConfig, { - extend_rpc_aet_api::(&mut io, &deps)?; - extend_rpc_eth_filter::(&mut io, &deps)?; - extend_rpc_eth_pubsub::( + extend_rpc_aet_api::(&mut io, &deps)?; + extend_rpc_eth_filter::(&mut io, &deps)?; + extend_rpc_eth_pubsub::( &mut io, &deps, subscription_task_executor, pubsub_notification_sinks, )?; - extend_rpc_net::(&mut io, &deps)?; - extend_rpc_web3::(&mut io, &deps)?; - extend_rpc_debug::(&mut io, &deps)?; + extend_rpc_net::(&mut io, &deps)?; + extend_rpc_web3::(&mut io, &deps)?; + extend_rpc_debug::(&mut io, &deps)?; Ok(io) } diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 4f2063215..3b4729c71 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -9,34 +9,31 @@ use std::{collections::BTreeMap, sync::Arc}; use futures::channel::mpsc; -use crate::{client::RuntimeApiCollection, ethereum::create_eth}; pub use fc_rpc::EthBlockDataCacheTask; pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool}; use fc_storage::StorageOverride; use jsonrpsee::RpcModule; -use node_subtensor_runtime::{AccountId, Balance, Hash, Nonce}; -use sc_client_api::{ - backend::{Backend, StorageProvider}, - client::BlockchainEvents, - AuxStore, UsageProvider, -}; +use node_subtensor_runtime::opaque::Block; +use node_subtensor_runtime::Hash; use sc_consensus_manual_seal::EngineCommand; use sc_network::service::traits::NetworkService; use sc_network_sync::SyncingService; use sc_rpc::SubscriptionTaskExecutor; use sc_transaction_pool::{ChainApi, Pool}; use sc_transaction_pool_api::TransactionPool; -use sp_api::{CallApiAt, ProvideRuntimeApi}; -use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; -use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_core::H256; use sp_inherents::CreateInherentDataProviders; use sp_runtime::traits::Block as BlockT; +use crate::{ + client::{FullBackend, FullClient}, + ethereum::create_eth, +}; + /// Extra dependencies for Ethereum compatibility. -pub struct EthDeps { +pub struct EthDeps { /// The client instance to use. - pub client: Arc, + pub client: Arc, /// Transaction pool instance. pub pool: Arc

, /// Graph pool instance. @@ -50,13 +47,13 @@ pub struct EthDeps { /// Network service pub network: Arc, /// Chain syncing service - pub sync: Arc>, + pub sync: Arc>, /// Frontier Backend. - pub frontier_backend: Arc>, + pub frontier_backend: Arc>, /// Ethereum data access overrides. - pub storage_override: Arc>, + pub storage_override: Arc>, /// Cache for Ethereum block data. - pub block_data_cache: Arc>, + pub block_data_cache: Arc>, /// EthFilterApi pool. pub filter_pool: Option, /// Maximum number of logs in a query. @@ -75,52 +72,44 @@ pub struct EthDeps { } /// Default Eth RPC configuration -pub struct DefaultEthConfig(std::marker::PhantomData<(C, BE)>); +pub struct DefaultEthConfig; -impl fc_rpc::EthConfig for DefaultEthConfig -where - B: BlockT, - C: StorageProvider + Sync + Send + 'static, - BE: Backend + 'static, -{ +impl fc_rpc::EthConfig for DefaultEthConfig { type EstimateGasAdapter = (); - type RuntimeStorageOverride = - fc_rpc::frontier_backend_client::SystemAccountId20StorageOverride; + type RuntimeStorageOverride = fc_rpc::frontier_backend_client::SystemAccountId20StorageOverride< + Block, + FullClient, + FullBackend, + >; } /// Full client dependencies. -pub struct FullDeps { +pub struct FullDeps { /// The client instance to use. - pub client: Arc, + pub client: Arc, /// Transaction pool instance. pub pool: Arc

, /// Manual seal command sink pub command_sink: Option>>, /// Ethereum-compatibility specific dependencies. - pub eth: EthDeps, + pub eth: EthDeps, } /// Instantiate all full RPC extensions. -pub fn create_full( - deps: FullDeps, +pub fn create_full( + deps: FullDeps, subscription_task_executor: SubscriptionTaskExecutor, pubsub_notification_sinks: Arc< fc_mapping_sync::EthereumBlockNotificationSinks< - fc_mapping_sync::EthereumBlockNotification, + fc_mapping_sync::EthereumBlockNotification, >, >, ) -> Result, Box> where - B: BlockT, - C: CallApiAt + ProvideRuntimeApi, - C::Api: RuntimeApiCollection, - C: HeaderBackend + HeaderMetadata + 'static, - C: BlockchainEvents + AuxStore + UsageProvider + StorageProvider, - BE: Backend + 'static, - P: TransactionPool + 'static, - A: ChainApi + 'static, - CIDP: CreateInherentDataProviders + Send + Clone + 'static, - CT: fp_rpc::ConvertTransaction<::Extrinsic> + Send + Sync + Clone + 'static, + P: TransactionPool + 'static, + A: ChainApi + 'static, + CIDP: CreateInherentDataProviders + Send + Clone + 'static, + CT: fp_rpc::ConvertTransaction<::Extrinsic> + Send + Sync + Clone + 'static, { use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use sc_consensus_manual_seal::rpc::{ManualSeal, ManualSealApiServer}; @@ -155,7 +144,7 @@ where } // Ethereum compatibility RPCs - let module = create_eth::<_, _, _, _, _, _, _, DefaultEthConfig>( + let module = create_eth::<_, _, _, _, DefaultEthConfig>( module, eth, subscription_task_executor, diff --git a/node/src/service.rs b/node/src/service.rs index 84a3a1255..22e167949 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -1,13 +1,7 @@ //! Service and ServiceFactory implementation. Specialized wrapper over substrate service. -use crate::cli::Sealing; -use crate::client::{FullBackend, FullClient}; -use crate::ethereum::{ - db_config_dir, new_frontier_partial, spawn_frontier_tasks, BackendType, EthConfiguration, - FrontierBackend, FrontierBlockImport, FrontierPartialComponents, StorageOverride, - StorageOverrideHandler, -}; use futures::{channel::mpsc, future, FutureExt}; +use node_subtensor_runtime::{opaque::Block, RuntimeApi, TransactionConverter}; use sc_client_api::{Backend as BackendT, BlockBackend}; use sc_consensus::{BasicQueue, BoxBlockImport}; use sc_consensus_grandpa::BlockNumberOps; @@ -24,30 +18,22 @@ use std::{cell::RefCell, path::Path}; use std::{sync::Arc, time::Duration}; use substrate_prometheus_endpoint::Registry; -// Runtime -use node_subtensor_runtime::{opaque::Block, RuntimeApi, TransactionConverter}; +use crate::cli::Sealing; +use crate::client::{FullBackend, FullClient}; +use crate::ethereum::{ + db_config_dir, new_frontier_partial, spawn_frontier_tasks, BackendType, EthConfiguration, + FrontierBackend, FrontierBlockImport, FrontierPartialComponents, StorageOverride, + StorageOverrideHandler, +}; /// The minimum period of blocks on which justifications will be /// imported and generated. const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512; -/// Always enable runtime benchmark host functions, the genesis state -/// was built with them so we're stuck with them forever. -/// -/// They're just a noop, never actually get used if the runtime was not compiled with -/// `runtime-benchmarks`. -pub type HostFunctions = ( - sp_io::SubstrateHostFunctions, - frame_benchmarking::benchmarking::HostFunctions, -); - -pub type Backend = FullBackend; -pub type Client = FullClient; - -type FullSelectChain = sc_consensus::LongestChain, B>; -type GrandpaBlockImport = - sc_consensus_grandpa::GrandpaBlockImport, B, C, FullSelectChain>; -type GrandpaLinkHalf = sc_consensus_grandpa::LinkHalf>; +type FullSelectChain = sc_consensus::LongestChain; +type GrandpaBlockImport = + sc_consensus_grandpa::GrandpaBlockImport; +type GrandpaLinkHalf = sc_consensus_grandpa::LinkHalf; pub fn new_partial( config: &Configuration, @@ -55,34 +41,29 @@ pub fn new_partial( build_import_queue: BIQ, ) -> Result< PartialComponents< - Client, - FullBackend, - FullSelectChain, + FullClient, + FullBackend, + FullSelectChain, BasicQueue, - FullPool, + FullPool, ( Option, BoxBlockImport, - GrandpaLinkHalf, - FrontierBackend, + GrandpaLinkHalf, + FrontierBackend, Arc>, ), >, ServiceError, > where - // B: BlockT, - // RA: ConstructRuntimeApi, - // RA: Send + Sync + 'static, - // RA::RuntimeApi: RuntimeApiCollection, - // HF: HostFunctionsT + 'static, BIQ: FnOnce( - Arc, + Arc, &Configuration, &EthConfiguration, &TaskManager, Option, - GrandpaBlockImport, + GrandpaBlockImport, ) -> Result<(BasicQueue, BoxBlockImport), ServiceError>, { let telemetry = config @@ -188,20 +169,15 @@ where /// Build the import queue for the template runtime (aura + grandpa). pub fn build_aura_grandpa_import_queue( - client: Arc, + client: Arc, config: &Configuration, eth_config: &EthConfiguration, task_manager: &TaskManager, telemetry: Option, - grandpa_block_import: GrandpaBlockImport, + grandpa_block_import: GrandpaBlockImport, ) -> Result<(BasicQueue, BoxBlockImport), ServiceError> where - // B: BlockT, NumberFor: BlockNumberOps, - // RA: ConstructRuntimeApi>, - // RA: Send + Sync + 'static, - // RA::RuntimeApi: RuntimeApiCollection, - // HF: HostFunctionsT + 'static, { let frontier_block_import = FrontierBlockImport::new(grandpa_block_import.clone(), client.clone()); @@ -239,20 +215,13 @@ where /// Build the import queue for the template runtime (manual seal). pub fn build_manual_seal_import_queue( - client: Arc, + client: Arc, config: &Configuration, _eth_config: &EthConfiguration, task_manager: &TaskManager, _telemetry: Option, - _grandpa_block_import: GrandpaBlockImport, -) -> Result<(BasicQueue, BoxBlockImport), ServiceError> -// where - // B: BlockT, - // RA: ConstructRuntimeApi>, - // RA: Send + Sync + 'static, - // RA::RuntimeApi: RuntimeApiCollection, - // HF: HostFunctionsT + 'static, -{ + _grandpa_block_import: GrandpaBlockImport, +) -> Result<(BasicQueue, BoxBlockImport), ServiceError> { let frontier_block_import = FrontierBlockImport::new(client.clone(), client); Ok(( sc_consensus_manual_seal::import_queue( @@ -271,13 +240,7 @@ pub async fn new_full( sealing: Option, ) -> Result where - // B: BlockT, NumberFor: BlockNumberOps, - // ::Header: Unpin, - // RA: ConstructRuntimeApi>, - // RA: Send + Sync + 'static, - // RA::RuntimeApi: RuntimeApiCollection, - // HF: HostFunctionsT + 'static, NB: sc_network::NetworkBackend::Hash>, { let build_import_queue = if sealing.is_some() { @@ -649,11 +612,11 @@ pub fn new_chain_ops( eth_config: &EthConfiguration, ) -> Result< ( - Arc, - Arc, + Arc, + Arc, BasicQueue, TaskManager, - FrontierBackend, + FrontierBackend, ), ServiceError, > { @@ -673,9 +636,9 @@ pub fn new_chain_ops( fn run_manual_seal_authorship( eth_config: &EthConfiguration, sealing: Sealing, - client: Arc, - transaction_pool: Arc>, - select_chain: FullSelectChain, + client: Arc, + transaction_pool: Arc>, + select_chain: FullSelectChain, block_import: BoxBlockImport, task_manager: &TaskManager, prometheus_registry: Option<&Registry>, @@ -683,14 +646,7 @@ fn run_manual_seal_authorship( commands_stream: mpsc::Receiver< sc_consensus_manual_seal::rpc::EngineCommand<::Hash>, >, -) -> Result<(), ServiceError> -// where - // B: BlockT, - // RA: ConstructRuntimeApi>, - // RA: Send + Sync + 'static, - // RA::RuntimeApi: RuntimeApiCollection, - // HF: HostFunctionsT + 'static, -{ +) -> Result<(), ServiceError> { let proposer_factory = sc_basic_authorship::ProposerFactory::new( task_manager.spawn_handle(), client.clone(), From 22f039768a12cc14e661241a8236357eab369071 Mon Sep 17 00:00:00 2001 From: Aliaksandr Tsurko Date: Wed, 13 Nov 2024 20:37:40 +0100 Subject: [PATCH 2/3] Fix benchmarks compilation --- node/src/benchmarking.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/node/src/benchmarking.rs b/node/src/benchmarking.rs index a97550071..cee1cb4ac 100644 --- a/node/src/benchmarking.rs +++ b/node/src/benchmarking.rs @@ -2,7 +2,7 @@ //! //! Should only be used for benchmarking as it may break in other contexts. -use crate::service::Client; +use crate::client::FullClient; use node_subtensor_runtime as runtime; use node_subtensor_runtime::check_nonce; @@ -21,12 +21,12 @@ use std::{sync::Arc, time::Duration}; // // Note: Should only be used for benchmarking. pub struct RemarkBuilder { - client: Arc, + client: Arc, } impl RemarkBuilder { // Creates a new [`Self`] from the given client. - pub fn new(client: Arc) -> Self { + pub fn new(client: Arc) -> Self { Self { client } } } @@ -58,14 +58,14 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder { // // Note: Should only be used for benchmarking. pub struct TransferKeepAliveBuilder { - client: Arc, + client: Arc, dest: AccountId, value: Balance, } impl TransferKeepAliveBuilder { // Creates a new [`Self`] from the given client. - pub fn new(client: Arc, dest: AccountId, value: Balance) -> Self { + pub fn new(client: Arc, dest: AccountId, value: Balance) -> Self { Self { client, dest, @@ -105,7 +105,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder { // // Note: Should only be used for benchmarking. pub fn create_benchmark_extrinsic( - client: &Client, + client: &FullClient, sender: sp_core::sr25519::Pair, call: runtime::RuntimeCall, nonce: u32, From 90927da3da49646e379fb45270cfd27e935f14bb Mon Sep 17 00:00:00 2001 From: Aliaksandr Tsurko Date: Wed, 13 Nov 2024 20:51:40 +0100 Subject: [PATCH 3/3] Update spec version --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 2455da5d0..cca99f654 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -160,7 +160,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 208, + spec_version: 209, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1,