From 5b998ccd50b9861e5c267bd175f16a7c49683ebe Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Thu, 23 May 2024 23:27:51 +0200 Subject: [PATCH] make clippy happy: more fixes here and there --- cumulus/client/service/src/lib.rs | 2 +- cumulus/polkadot-parachain/src/rpc.rs | 6 ++-- cumulus/polkadot-parachain/src/service.rs | 33 +++++++++-------- .../service/benches/transaction_throughput.rs | 2 +- cumulus/test/service/src/lib.rs | 19 +++++----- polkadot/node/service/src/lib.rs | 17 ++++----- polkadot/rpc/src/lib.rs | 4 +-- .../bin/node/cli/benches/transaction_pool.rs | 16 +++------ substrate/bin/node/cli/src/service.rs | 9 +++-- .../client/consensus/manual-seal/src/lib.rs | 11 +++--- .../consensus/manual-seal/src/seal_block.rs | 4 +-- substrate/client/service/src/lib.rs | 2 +- substrate/client/service/test/src/lib.rs | 12 +++---- .../client/transaction-pool/src/builder.rs | 35 ++++++++++++++----- substrate/client/transaction-pool/src/lib.rs | 4 +-- .../src/single_state_txpool/mod.rs | 2 +- templates/minimal/node/src/rpc.rs | 4 +-- templates/minimal/node/src/service.rs | 17 ++++----- templates/parachain/node/src/rpc.rs | 4 +-- templates/parachain/node/src/service.rs | 19 +++++----- templates/solochain/node/src/rpc.rs | 4 +-- templates/solochain/node/src/service.rs | 17 ++++----- 22 files changed, 134 insertions(+), 109 deletions(-) diff --git a/cumulus/client/service/src/lib.rs b/cumulus/client/service/src/lib.rs index 9b5f0bec5387..9a789fc95df6 100644 --- a/cumulus/client/service/src/lib.rs +++ b/cumulus/client/service/src/lib.rs @@ -416,7 +416,7 @@ pub struct BuildNetworkParams< pub net_config: sc_network::config::FullNetworkConfiguration::Hash, Network>, pub client: Arc, - pub transaction_pool: Arc>, + pub transaction_pool: Arc>, pub para_id: ParaId, pub relay_chain_interface: RCInterface, pub spawn_handle: SpawnTaskHandle, diff --git a/cumulus/polkadot-parachain/src/rpc.rs b/cumulus/polkadot-parachain/src/rpc.rs index caee14e55522..5c212d1ad900 100644 --- a/cumulus/polkadot-parachain/src/rpc.rs +++ b/cumulus/polkadot-parachain/src/rpc.rs @@ -32,7 +32,7 @@ use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; pub type RpcExtension = jsonrpsee::RpcModule<()>; /// Full client dependencies -pub struct FullDeps { +pub struct FullDeps { /// The client instance to use. pub client: Arc, /// Transaction pool instance. @@ -57,7 +57,7 @@ where C::Api: frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BlockBuilder, - P: TransactionPool + Sync + Send + 'static, + P: TransactionPool + Sync + Send + 'static + ?Sized, B: sc_client_api::Backend + Send + Sync + 'static, B::State: sc_client_api::backend::StateBackend>, { @@ -91,7 +91,7 @@ where C::Api: frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BlockBuilder, - P: TransactionPool + Sync + Send + 'static, + P: TransactionPool + Sync + Send + 'static + ?Sized, { use frame_rpc_system::{System, SystemApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; diff --git a/cumulus/polkadot-parachain/src/service.rs b/cumulus/polkadot-parachain/src/service.rs index 12eda3e8a9cb..7a8eaf543327 100644 --- a/cumulus/polkadot-parachain/src/service.rs +++ b/cumulus/polkadot-parachain/src/service.rs @@ -87,7 +87,7 @@ pub type Service = PartialComponents< ParachainBackend, (), sc_consensus::DefaultImportQueue, - sc_transaction_pool::FullPool>, + sc_transaction_pool::TransactionPoolImpl>, (ParachainBlockImport, Option, Option), >; @@ -154,13 +154,14 @@ where telemetry }); - let transaction_pool = sc_transaction_pool::BasicPool::new_full( - config.transaction_pool.clone(), - config.role.is_authority().into(), - config.prometheus_registry(), - task_manager.spawn_essential_handle(), - client.clone(), - ); + let transaction_pool = sc_transaction_pool::Builder::new() + .with_options(config.transaction_pool.clone()) + .build( + config.role.is_authority().into(), + config.prometheus_registry(), + task_manager.spawn_essential_handle(), + client.clone(), + ); let block_import = ParachainBlockImport::new(client.clone(), backend.clone()); @@ -214,7 +215,7 @@ where DenyUnsafe, Arc>, Arc, - Arc>>, + Arc>>, ) -> Result, sc_service::Error> + 'static, BIQ: FnOnce( @@ -231,7 +232,7 @@ where Option, &TaskManager, Arc, - Arc>>, + Arc>>, Arc>, KeystorePtr, Duration, @@ -464,7 +465,7 @@ fn build_parachain_rpc_extensions( deny_unsafe: sc_rpc::DenyUnsafe, client: Arc>, backend: Arc, - pool: Arc>>, + pool: Arc>>, ) -> Result, sc_service::Error> where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, @@ -482,7 +483,7 @@ fn build_contracts_rpc_extensions( deny_unsafe: sc_rpc::DenyUnsafe, client: Arc>, _backend: Arc, - pool: Arc>>, + pool: Arc>>, ) -> Result, sc_service::Error> { let deps = crate::rpc::FullDeps { client: client.clone(), pool: pool.clone(), deny_unsafe }; @@ -866,7 +867,9 @@ fn start_relay_chain_consensus( telemetry: Option, task_manager: &TaskManager, relay_chain_interface: Arc, - transaction_pool: Arc>>, + transaction_pool: Arc< + sc_transaction_pool::TransactionPoolImpl>, + >, _sync_oracle: Arc>, _keystore: KeystorePtr, _relay_chain_slot_duration: Duration, @@ -937,7 +940,9 @@ fn start_lookahead_aura_consensus( telemetry: Option, task_manager: &TaskManager, relay_chain_interface: Arc, - transaction_pool: Arc>>, + transaction_pool: Arc< + sc_transaction_pool::TransactionPoolImpl>, + >, sync_oracle: Arc>, keystore: KeystorePtr, relay_chain_slot_duration: Duration, diff --git a/cumulus/test/service/benches/transaction_throughput.rs b/cumulus/test/service/benches/transaction_throughput.rs index 011eb4c7d50e..27a59dc8221f 100644 --- a/cumulus/test/service/benches/transaction_throughput.rs +++ b/cumulus/test/service/benches/transaction_throughput.rs @@ -20,7 +20,7 @@ use criterion::{criterion_group, criterion_main, BatchSize, Criterion, Throughpu use cumulus_client_cli::get_raw_genesis_header; use cumulus_test_runtime::{AccountId, BalancesCall, ExistentialDeposit, SudoCall}; use futures::{future, StreamExt}; -use sc_transaction_pool_api::{TransactionPool as _, TransactionSource, TransactionStatus}; +use sc_transaction_pool_api::{TransactionSource, TransactionStatus}; use sp_core::{crypto::Pair, sr25519}; use sp_runtime::OpaqueExtrinsic; diff --git a/cumulus/test/service/src/lib.rs b/cumulus/test/service/src/lib.rs index f2a612803861..1494339e9026 100644 --- a/cumulus/test/service/src/lib.rs +++ b/cumulus/test/service/src/lib.rs @@ -129,7 +129,7 @@ pub type Backend = TFullBackend; pub type ParachainBlockImport = TParachainBlockImport, Backend>; /// Transaction pool type used by the test service -pub type TransactionPool = Arc>; +pub type TransactionPool = Arc>; /// Recovery handle that fails regularly to simulate unavailable povs. pub struct FailingRecoveryHandle { @@ -177,7 +177,7 @@ pub type Service = PartialComponents< Backend, (), sc_consensus::import_queue::BasicQueue, - sc_transaction_pool::FullPool, + sc_transaction_pool::TransactionPoolImpl, ParachainBlockImport, >; @@ -212,13 +212,14 @@ pub fn new_partial( let block_import = ParachainBlockImport::new(client.clone(), backend.clone()); - let transaction_pool = sc_transaction_pool::BasicPool::new_full( - config.transaction_pool.clone(), - config.role.is_authority().into(), - config.prometheus_registry(), - task_manager.spawn_essential_handle(), - client.clone(), - ); + let transaction_pool = sc_transaction_pool::Builder::new() + .with_options(config.transaction_pool.clone()) + .build( + config.role.is_authority().into(), + config.prometheus_registry(), + task_manager.spawn_essential_handle(), + client.clone(), + ); let slot_duration = sc_consensus_aura::slot_duration(&*client)?; let import_queue = cumulus_client_consensus_aura::import_queue::( diff --git a/polkadot/node/service/src/lib.rs b/polkadot/node/service/src/lib.rs index 665533e9bc70..a433c05e9f0b 100644 --- a/polkadot/node/service/src/lib.rs +++ b/polkadot/node/service/src/lib.rs @@ -476,7 +476,7 @@ fn new_partial( FullBackend, ChainSelection, sc_consensus::DefaultImportQueue, - sc_transaction_pool::FullPool, + sc_transaction_pool::TransactionPoolImpl, ( impl Fn( polkadot_rpc::DenyUnsafe, @@ -502,13 +502,14 @@ fn new_partial( where ChainSelection: 'static + SelectChain, { - let transaction_pool = sc_transaction_pool::BasicPool::new_full( - config.transaction_pool.clone(), - config.role.is_authority().into(), - config.prometheus_registry(), - task_manager.spawn_essential_handle(), - client.clone(), - ); + let transaction_pool = sc_transaction_pool::Builder::new() + .with_options(config.transaction_pool.clone()) + .build( + config.role.is_authority().into(), + config.prometheus_registry(), + task_manager.spawn_essential_handle(), + client.clone(), + ); let grandpa_hard_forks = if config.chain_spec.is_kusama() { grandpa_support::kusama_hard_forks() diff --git a/polkadot/rpc/src/lib.rs b/polkadot/rpc/src/lib.rs index 4455efd3b533..786fd16349b9 100644 --- a/polkadot/rpc/src/lib.rs +++ b/polkadot/rpc/src/lib.rs @@ -72,7 +72,7 @@ pub struct BeefyDeps { } /// Full client dependencies -pub struct FullDeps { +pub struct FullDeps { /// The client instance to use. pub client: Arc, /// Transaction pool instance. @@ -110,7 +110,7 @@ where C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BabeApi, C::Api: BlockBuilder, - P: TransactionPool + Sync + Send + 'static, + P: TransactionPool + Sync + Send + 'static + ?Sized, SC: SelectChain + 'static, B: sc_client_api::Backend + Send + Sync + 'static, B::State: sc_client_api::StateBackend>, diff --git a/substrate/bin/node/cli/benches/transaction_pool.rs b/substrate/bin/node/cli/benches/transaction_pool.rs index c4488415b983..611700278638 100644 --- a/substrate/bin/node/cli/benches/transaction_pool.rs +++ b/substrate/bin/node/cli/benches/transaction_pool.rs @@ -16,8 +16,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use std::time::Duration; - use criterion::{criterion_group, criterion_main, BatchSize, Criterion, Throughput}; use futures::{future, StreamExt}; use kitchensink_runtime::{constants::currency::*, BalancesCall, SudoCall}; @@ -30,8 +28,7 @@ use sc_service::{ }, BasePath, Configuration, Role, }; -use sc_transaction_pool::PoolLimit; -use sc_transaction_pool_api::{TransactionPool as _, TransactionSource, TransactionStatus}; +use sc_transaction_pool_api::{TransactionSource, TransactionStatus}; use sp_core::{crypto::Pair, sr25519}; use sp_keyring::Sr25519Keyring; use sp_runtime::OpaqueExtrinsic; @@ -56,12 +53,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase { impl_version: "1.0".into(), role: Role::Authority, tokio_handle: tokio_handle.clone(), - transaction_pool: TransactionPoolOptions { - ready: PoolLimit { count: 100_000, total_bytes: 100 * 1024 * 1024 }, - future: PoolLimit { count: 100_000, total_bytes: 100 * 1024 * 1024 }, - reject_future_transactions: false, - ban_time: Duration::from_secs(30 * 60), - }, + transaction_pool: TransactionPoolOptions::new_for_benchmarks(), network: network_config, keystore: KeystoreConfig::InMemory, database: DatabaseSource::RocksDb { path: root.join("db"), cache_size: 128 }, @@ -246,7 +238,7 @@ fn transaction_pool_benchmarks(c: &mut Criterion) { runtime.block_on(future::join_all(prepare_extrinsics.into_iter().map(|tx| { submit_tx_and_wait_for_inclusion( - &node.transaction_pool, + &*node.transaction_pool, tx, &node.client, true, @@ -258,7 +250,7 @@ fn transaction_pool_benchmarks(c: &mut Criterion) { |extrinsics| { runtime.block_on(future::join_all(extrinsics.into_iter().map(|tx| { submit_tx_and_wait_for_inclusion( - &node.transaction_pool, + &*node.transaction_pool, tx, &node.client, false, diff --git a/substrate/bin/node/cli/src/service.rs b/substrate/bin/node/cli/src/service.rs index 3254518b2165..d207d8bcc04c 100644 --- a/substrate/bin/node/cli/src/service.rs +++ b/substrate/bin/node/cli/src/service.rs @@ -69,6 +69,9 @@ type FullGrandpaBlockImport = type FullBeefyBlockImport = beefy::import::BeefyBlockImport; +/// The transaction pool type definition. +pub type TransactionPool = sc_transaction_pool::TransactionPoolImpl; + /// The minimum period of blocks on which justifications will be /// imported and generated. const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512; @@ -162,7 +165,7 @@ pub fn new_partial( FullBackend, FullSelectChain, sc_consensus::DefaultImportQueue, - sc_transaction_pool::TransactionPoolImpl, + sc_transaction_pool::TransactionPoolImpl, ( impl Fn( node_rpc::DenyUnsafe, @@ -375,7 +378,7 @@ pub struct NewFullBase { /// The syncing service of the node. pub sync: Arc>, /// The transaction pool of the node. - pub transaction_pool: Arc>, + pub transaction_pool: Arc>, /// The rpc handlers of the node. pub rpc_handlers: RpcHandlers, } @@ -849,7 +852,7 @@ mod tests { use sc_consensus_epochs::descendent_query; use sc_keystore::LocalKeystore; use sc_service_test::TestNetNode; - use sc_transaction_pool_api::{ChainEvent, MaintainedTransactionPool}; + use sc_transaction_pool_api::ChainEvent; use sp_consensus::{BlockOrigin, Environment, Proposer}; use sp_core::crypto::Pair; use sp_inherents::InherentDataProvider; diff --git a/substrate/client/consensus/manual-seal/src/lib.rs b/substrate/client/consensus/manual-seal/src/lib.rs index 8fc7e7ecab2f..8ea0cfab7975 100644 --- a/substrate/client/consensus/manual-seal/src/lib.rs +++ b/substrate/client/consensus/manual-seal/src/lib.rs @@ -87,7 +87,8 @@ where } /// Params required to start the manual sealing authorship task. -pub struct ManualSealParams, TP, SC, CS, CIDP, P> { +pub struct ManualSealParams, TP: ?Sized, SC, CS, CIDP, P> +{ /// Block import instance. pub block_import: BI, @@ -115,7 +116,7 @@ pub struct ManualSealParams, TP, SC, C } /// Params required to start the instant sealing authorship task. -pub struct InstantSealParams, TP, SC, CIDP, P> { +pub struct InstantSealParams, TP: ?Sized, SC, CIDP, P> { /// Block import instance for well. importing blocks. pub block_import: BI, @@ -171,7 +172,7 @@ pub async fn run_manual_seal( E::Proposer: Proposer, CS: Stream::Hash>> + Unpin + 'static, SC: SelectChain + 'static, - TP: TransactionPool, + TP: TransactionPool + ?Sized, CIDP: CreateInherentDataProviders, P: codec::Encode + Send + Sync + 'static, { @@ -229,7 +230,7 @@ pub async fn run_instant_seal( E: Environment + 'static, E::Proposer: Proposer, SC: SelectChain + 'static, - TP: TransactionPool, + TP: TransactionPool + ?Sized, CIDP: CreateInherentDataProviders, P: codec::Encode + Send + Sync + 'static, { @@ -279,7 +280,7 @@ pub async fn run_instant_seal_and_finalize( E: Environment + 'static, E::Proposer: Proposer, SC: SelectChain + 'static, - TP: TransactionPool, + TP: TransactionPool + ?Sized, CIDP: CreateInherentDataProviders, P: codec::Encode + Send + Sync + 'static, { diff --git a/substrate/client/consensus/manual-seal/src/seal_block.rs b/substrate/client/consensus/manual-seal/src/seal_block.rs index 716e889ec039..1e9c2d1b40eb 100644 --- a/substrate/client/consensus/manual-seal/src/seal_block.rs +++ b/substrate/client/consensus/manual-seal/src/seal_block.rs @@ -33,7 +33,7 @@ use std::{sync::Arc, time::Duration}; pub const MAX_PROPOSAL_DURATION: u64 = 10; /// params for sealing a new block -pub struct SealBlockParams<'a, B: BlockT, BI, SC, C: ProvideRuntimeApi, E, TP, CIDP, P> { +pub struct SealBlockParams<'a, B: BlockT, BI, SC, C: ProvideRuntimeApi, E, TP: ?Sized, CIDP, P> { /// if true, empty blocks(without extrinsics) will be created. /// otherwise, will return Error::EmptyTransactionPool. pub create_empty: bool, @@ -80,7 +80,7 @@ pub async fn seal_block( C: HeaderBackend + ProvideRuntimeApi, E: Environment, E::Proposer: Proposer, - TP: TransactionPool, + TP: TransactionPool + ?Sized, SC: SelectChain, CIDP: CreateInherentDataProviders, P: codec::Encode + Send + Sync + 'static, diff --git a/substrate/client/service/src/lib.rs b/substrate/client/service/src/lib.rs index ceb8f14997b6..2ee2c0d58e3b 100644 --- a/substrate/client/service/src/lib.rs +++ b/substrate/client/service/src/lib.rs @@ -88,7 +88,7 @@ pub use sc_rpc::{ RandomIntegerSubscriptionId, RandomStringSubscriptionId, RpcSubscriptionIdProvider, }; pub use sc_tracing::TracingReceiver; -pub use sc_transaction_pool::Options as TransactionPoolOptions; +pub use sc_transaction_pool::TransactionPoolOptions; pub use sc_transaction_pool_api::{error::IntoPoolError, InPoolTransaction, TransactionPool}; #[doc(hidden)] pub use std::{ops::Deref, result::Result, sync::Arc}; diff --git a/substrate/client/service/test/src/lib.rs b/substrate/client/service/test/src/lib.rs index f19b5a19739e..3d93a82a524d 100644 --- a/substrate/client/service/test/src/lib.rs +++ b/substrate/client/service/test/src/lib.rs @@ -69,7 +69,7 @@ pub trait TestNetNode: Clone + Future> + Send + 'stat type Backend: Backend; type Executor: CallExecutor + Send + Sync; type RuntimeApi: Send + Sync; - type TransactionPool: TransactionPool; + type TransactionPool: TransactionPool + ?Sized; fn client(&self) -> Arc>; fn transaction_pool(&self) -> Arc; @@ -78,7 +78,7 @@ pub trait TestNetNode: Clone + Future> + Send + 'stat fn spawn_handle(&self) -> SpawnTaskHandle; } -pub struct TestNetComponents { +pub struct TestNetComponents { task_manager: Arc>, client: Arc>, transaction_pool: Arc, @@ -86,7 +86,7 @@ pub struct TestNetComponents { sync: Arc>, } -impl +impl TestNetComponents { pub fn new( @@ -106,7 +106,7 @@ impl } } -impl Clone +impl Clone for TestNetComponents { fn clone(&self) -> Self { @@ -120,7 +120,7 @@ impl Clone } } -impl Future +impl Future for TestNetComponents { type Output = Result<(), Error>; @@ -137,7 +137,7 @@ where TBackend: sc_client_api::Backend + Send + Sync + 'static, TExec: CallExecutor + Send + Sync + 'static, TRtApi: Send + Sync + 'static, - TExPool: TransactionPool + Send + Sync + 'static, + TExPool: TransactionPool + Send + Sync + 'static + ?Sized, { type Block = TBl; type Backend = TBackend; diff --git a/substrate/client/transaction-pool/src/builder.rs b/substrate/client/transaction-pool/src/builder.rs index a0d99542677c..7b08b8c9b844 100644 --- a/substrate/client/transaction-pool/src/builder.rs +++ b/substrate/client/transaction-pool/src/builder.rs @@ -1,5 +1,5 @@ use sp_runtime::traits::Block as BlockT; -use std::{marker::PhantomData, sync::Arc}; +use std::{marker::PhantomData, sync::Arc, time::Duration}; use crate::{ graph::IsValidator, single_state_txpool::single_state_txpool::FullPool as SingleStateFullPool, @@ -58,6 +58,25 @@ impl TransactionPoolOptions { TransactionPoolOptions { options, txpool_type } } + + /// Creates predefined options for benchmarking + pub fn new_for_benchmarks() -> TransactionPoolOptions { + TransactionPoolOptions { + options: crate::graph::Options { + ready: crate::graph::base_pool::Limit { + count: 100_000, + total_bytes: 100 * 1024 * 1024, + }, + future: crate::graph::base_pool::Limit { + count: 100_000, + total_bytes: 100 * 1024 * 1024, + }, + reject_future_transactions: false, + ban_time: Duration::from_secs(30 * 60), + }, + txpool_type: TransactionPoolType::SingleState, + } + } } use crate::{common::api::FullChainApi, graph::ChainApi}; @@ -67,7 +86,7 @@ use crate::{common::api::FullChainApi, graph::ChainApi}; /// /// This trait defines the requirements for a full client transaction pool, ensuring /// that it can handle transactions submission and maintenance. -pub trait FullClientTransactionPool: +pub trait FullClientTransactionPool: MaintainedTransactionPool< Block = Block, Hash = crate::graph::ExtrinsicHash>, @@ -93,7 +112,7 @@ where { } -impl FullClientTransactionPool for P +impl FullClientTransactionPool for P where Block: BlockT, Client: sp_api::ProvideRuntimeApi @@ -123,15 +142,15 @@ where /// `FullClientTransactionPool` with the given `Client` and `Block` types. /// /// This trait object abstracts away the specific implementations of the transaction pool. -pub type TransactionPoolImpl = dyn FullClientTransactionPool; +pub type TransactionPoolImpl = dyn FullClientTransactionPool; /// Builder allowing to create specific instance of transaction pool. -pub struct Builder { +pub struct Builder { options: TransactionPoolOptions, _phantom: PhantomData<(Client, Block)>, } -impl Builder +impl Builder where Block: BlockT, Client: sp_api::ProvideRuntimeApi @@ -148,7 +167,7 @@ where Client::Api: sp_transaction_pool::runtime_api::TaggedTransactionQueue, { /// Creates new instance of `Builder` - pub fn new() -> Builder { + pub fn new() -> Builder { Builder { options: Default::default(), _phantom: Default::default() } } @@ -165,7 +184,7 @@ where prometheus: Option<&PrometheusRegistry>, spawner: impl SpawnEssentialNamed, client: Arc, - ) -> Arc> { + ) -> Arc> { match self.options.txpool_type { TransactionPoolType::SingleState => SingleStateFullPool::new_full( self.options.options, diff --git a/substrate/client/transaction-pool/src/lib.rs b/substrate/client/transaction-pool/src/lib.rs index 96b996abee74..d68b88aaa82a 100644 --- a/substrate/client/transaction-pool/src/lib.rs +++ b/substrate/client/transaction-pool/src/lib.rs @@ -32,8 +32,8 @@ use std::{future::Future, pin::Pin, sync::Arc}; pub(crate) const LOG_TARGET: &str = "txpool"; -pub use graph::{ChainApi, Options}; -pub use single_state_txpool::notification_future; +pub use graph::{base_pool::Limit as PoolLimit, ChainApi, Options}; +pub use single_state_txpool::{notification_future, RevalidationType}; //benches: pub use graph::Pool; diff --git a/substrate/client/transaction-pool/src/single_state_txpool/mod.rs b/substrate/client/transaction-pool/src/single_state_txpool/mod.rs index f8b900d89a2d..089cbdda8857 100644 --- a/substrate/client/transaction-pool/src/single_state_txpool/mod.rs +++ b/substrate/client/transaction-pool/src/single_state_txpool/mod.rs @@ -21,4 +21,4 @@ mod revalidation; pub(crate) mod single_state_txpool; -pub use single_state_txpool::{notification_future, BasicPool}; +pub use single_state_txpool::{notification_future, BasicPool, RevalidationType}; diff --git a/templates/minimal/node/src/rpc.rs b/templates/minimal/node/src/rpc.rs index d0c417a93d7a..220eaaae64ee 100644 --- a/templates/minimal/node/src/rpc.rs +++ b/templates/minimal/node/src/rpc.rs @@ -32,7 +32,7 @@ use substrate_frame_rpc_system::{System, SystemApiServer}; pub use sc_rpc_api::DenyUnsafe; /// Full client dependencies. -pub struct FullDeps { +pub struct FullDeps { /// The client instance to use. pub client: Arc, /// Transaction pool instance. @@ -55,7 +55,7 @@ where + 'static, C::Api: sp_block_builder::BlockBuilder, C::Api: substrate_frame_rpc_system::AccountNonceApi, - P: TransactionPool + 'static, + P: TransactionPool + 'static + ?Sized, { let mut module = RpcModule::new(()); let FullDeps { client, pool, deny_unsafe } = deps; diff --git a/templates/minimal/node/src/service.rs b/templates/minimal/node/src/service.rs index d84df95dc192..b8ea444c0cda 100644 --- a/templates/minimal/node/src/service.rs +++ b/templates/minimal/node/src/service.rs @@ -45,7 +45,7 @@ pub type Service = sc_service::PartialComponents< FullBackend, FullSelectChain, sc_consensus::DefaultImportQueue, - sc_transaction_pool::FullPool, + sc_transaction_pool::TransactionPoolImpl, Option, >; @@ -78,13 +78,14 @@ pub fn new_partial(config: &Configuration) -> Result { let select_chain = sc_consensus::LongestChain::new(backend.clone()); - let transaction_pool = sc_transaction_pool::BasicPool::new_full( - config.transaction_pool.clone(), - config.role.is_authority().into(), - config.prometheus_registry(), - task_manager.spawn_essential_handle(), - client.clone(), - ); + let transaction_pool = sc_transaction_pool::Builder::new() + .with_options(config.transaction_pool.clone()) + .build( + config.role.is_authority().into(), + config.prometheus_registry(), + task_manager.spawn_essential_handle(), + client.clone(), + ); let import_queue = sc_consensus_manual_seal::import_queue( Box::new(client.clone()), diff --git a/templates/parachain/node/src/rpc.rs b/templates/parachain/node/src/rpc.rs index bb52b974f0ce..28ba8f77eac2 100644 --- a/templates/parachain/node/src/rpc.rs +++ b/templates/parachain/node/src/rpc.rs @@ -19,7 +19,7 @@ use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; pub type RpcExtension = jsonrpsee::RpcModule<()>; /// Full client dependencies -pub struct FullDeps { +pub struct FullDeps { /// The client instance to use. pub client: Arc, /// Transaction pool instance. @@ -42,7 +42,7 @@ where C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: BlockBuilder, - P: TransactionPool + Sync + Send + 'static, + P: TransactionPool + Sync + Send + 'static + ?Sized, { use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use substrate_frame_rpc_system::{System, SystemApiServer}; diff --git a/templates/parachain/node/src/service.rs b/templates/parachain/node/src/service.rs index ad4689c6e55d..1babea75da4c 100644 --- a/templates/parachain/node/src/service.rs +++ b/templates/parachain/node/src/service.rs @@ -54,7 +54,7 @@ pub type Service = PartialComponents< ParachainBackend, (), sc_consensus::DefaultImportQueue, - sc_transaction_pool::FullPool, + sc_transaction_pool::TransactionPoolImpl, (ParachainBlockImport, Option, Option), >; @@ -103,13 +103,14 @@ pub fn new_partial(config: &Configuration) -> Result telemetry }); - let transaction_pool = sc_transaction_pool::BasicPool::new_full( - config.transaction_pool.clone(), - config.role.is_authority().into(), - config.prometheus_registry(), - task_manager.spawn_essential_handle(), - client.clone(), - ); + let transaction_pool = sc_transaction_pool::Builder::new() + .with_options(config.transaction_pool.clone()) + .build( + config.role.is_authority().into(), + config.prometheus_registry(), + task_manager.spawn_essential_handle(), + client.clone(), + ); let block_import = ParachainBlockImport::new(client.clone(), backend.clone()); @@ -168,7 +169,7 @@ fn start_consensus( telemetry: Option, task_manager: &TaskManager, relay_chain_interface: Arc, - transaction_pool: Arc>, + transaction_pool: Arc>, sync_oracle: Arc>, keystore: KeystorePtr, relay_chain_slot_duration: Duration, diff --git a/templates/solochain/node/src/rpc.rs b/templates/solochain/node/src/rpc.rs index fe2b6ca72ede..35ab40095310 100644 --- a/templates/solochain/node/src/rpc.rs +++ b/templates/solochain/node/src/rpc.rs @@ -17,7 +17,7 @@ use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; pub use sc_rpc_api::DenyUnsafe; /// Full client dependencies. -pub struct FullDeps { +pub struct FullDeps { /// The client instance to use. pub client: Arc, /// Transaction pool instance. @@ -37,7 +37,7 @@ where C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BlockBuilder, - P: TransactionPool + 'static, + P: TransactionPool + 'static + ?Sized, { use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use substrate_frame_rpc_system::{System, SystemApiServer}; diff --git a/templates/solochain/node/src/service.rs b/templates/solochain/node/src/service.rs index 06d4b8ab7a59..8d188ffd9f9d 100644 --- a/templates/solochain/node/src/service.rs +++ b/templates/solochain/node/src/service.rs @@ -28,7 +28,7 @@ pub type Service = sc_service::PartialComponents< FullBackend, FullSelectChain, sc_consensus::DefaultImportQueue, - sc_transaction_pool::FullPool, + sc_transaction_pool::TransactionPoolImpl, ( sc_consensus_grandpa::GrandpaBlockImport, sc_consensus_grandpa::LinkHalf, @@ -64,13 +64,14 @@ pub fn new_partial(config: &Configuration) -> Result { let select_chain = sc_consensus::LongestChain::new(backend.clone()); - let transaction_pool = sc_transaction_pool::BasicPool::new_full( - config.transaction_pool.clone(), - config.role.is_authority().into(), - config.prometheus_registry(), - task_manager.spawn_essential_handle(), - client.clone(), - ); + let transaction_pool = sc_transaction_pool::Builder::new() + .with_options(config.transaction_pool.clone()) + .build( + config.role.is_authority().into(), + config.prometheus_registry(), + task_manager.spawn_essential_handle(), + client.clone(), + ); let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import( client.clone(),