diff --git a/Cargo.lock b/Cargo.lock index fcc0a964..f7f4a9b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2476,7 +2476,6 @@ dependencies = [ "sp-blockchain", "sp-core", "sp-runtime", - "sp-transaction-pool", "substrate-prometheus-endpoint", ] @@ -5840,6 +5839,7 @@ dependencies = [ "cumulus-relay-chain-interface", "cumulus-relay-chain-minimal-node", "cumulus-relay-chain-rpc-interface", + "custom-pool", "frame-benchmarking", "frame-benchmarking-cli", "futures", diff --git a/node/Cargo.toml b/node/Cargo.toml index 74b43585..02a28894 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -24,6 +24,7 @@ hex-literal = { workspace = true } testnet-runtime = { workspace = true } mainnet-runtime = { workspace = true } runtime-common = { workspace = true } +custom-pool = { workspace = true } # Substrate frame-benchmarking = { workspace = true } diff --git a/node/src/service.rs b/node/src/service.rs index 7654ad71..75140a2b 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -473,7 +473,6 @@ where } #[allow(clippy::too_many_arguments)] - fn start_consensus( client: Arc>, backend: Arc, @@ -516,7 +515,7 @@ where let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording( task_manager.spawn_handle(), client.clone(), - transaction_pool, + Arc::new(custom_pool::CustomPool::new(transaction_pool)), prometheus_registry, telemetry.clone(), ); diff --git a/primitives/custom-pool/Cargo.toml b/primitives/custom-pool/Cargo.toml index 2c72fd3b..930381dd 100644 --- a/primitives/custom-pool/Cargo.toml +++ b/primitives/custom-pool/Cargo.toml @@ -11,12 +11,9 @@ sc-transaction-pool-api = { workspace = true } sp-api = { workspace = true } sp-blockchain = { workspace = true } sp-runtime = {workspace = true} -sp-transaction-pool = { workspace = true } sp-core = { workspace = true } substrate-prometheus-endpoint = { workspace = true } - - [features] default = ["std"] std = [] diff --git a/primitives/custom-pool/src/lib.rs b/primitives/custom-pool/src/lib.rs index 7bbd267a..40d51b0a 100644 --- a/primitives/custom-pool/src/lib.rs +++ b/primitives/custom-pool/src/lib.rs @@ -1,32 +1,29 @@ -use sc_transaction_pool::{BasicPool, RevalidationType}; -use sc_transaction_pool::{ChainApi,FullChainApi, Options}; +use futures::Future; use sc_transaction_pool_api::{ ImportNotificationStream, PoolFuture, PoolStatus, ReadyTransactions, TransactionFor, TransactionPool, TransactionSource, TransactionStatusStreamFor, TxHash, }; -use sp_core::traits::SpawnEssentialNamed; use sp_runtime::traits::{Block as BlockT, NumberFor}; -use futures::Future; -use substrate_prometheus_endpoint::Registry as PrometheusRegistry; use std::{collections::HashMap, pin::Pin, sync::Arc}; -pub type FullPool = CustomPool, Block>; +pub struct CustomPool { + inner_pool: Arc, +} -pub struct CustomPool -where - Block: BlockT, - PoolApi: ChainApi, -{ - inner_pool: BasicPool, +impl CustomPool { + pub fn new(inner_pool: Arc) -> Self { + Self { inner_pool } + } } -impl + 'static, Block: BlockT> TransactionPool - for CustomPool +impl TransactionPool for CustomPool +where + I: TransactionPool, { - type Block = as TransactionPool>::Block; - type Hash = as TransactionPool>::Hash; - type InPoolTransaction = as TransactionPool>::InPoolTransaction; - type Error = as TransactionPool>::Error; + type Block = I::Block; + type Hash = I::Hash; + type InPoolTransaction = I::InPoolTransaction; + type Error = I::Error; fn submit_at( &self, @@ -52,11 +49,12 @@ impl + 'static, Block: BlockT> TransactionPool source: TransactionSource, xt: TransactionFor, ) -> PoolFuture>>, Self::Error> { - self.inner_pool.submit_and_watch(at, source, xt) + self.inner_pool.submit_and_watch(at, source, xt) } - fn remove_invalid(&self, hashes: &[TxHash]) -> Vec> { - self.inner_pool.remove_invalid(hashes) + fn remove_invalid(&self, _: &[TxHash]) -> Vec> { + // Don't do anything on purpose. + Vec::new() } fn status(&self) -> PoolStatus { @@ -100,43 +98,3 @@ impl + 'static, Block: BlockT> TransactionPool self.inner_pool.futures() } } - -impl FullPool -where - Block: BlockT, - Client: sp_api::ProvideRuntimeApi - + sc_client_api::BlockBackend - + sc_client_api::blockchain::HeaderBackend - + sp_runtime::traits::BlockIdTo - + sc_client_api::ExecutorProvider - + sc_client_api::UsageProvider - + sp_blockchain::HeaderMetadata - + Send - + Sync - + 'static, - Client::Api: sp_transaction_pool::runtime_api::TaggedTransactionQueue, -{ - /// Create new basic transaction pool for a full node with the provided api. - pub fn new_full( - options: Options, - is_validator: IsValidator, - prometheus: Option<&PrometheusRegistry>, - spawner: impl SpawnEssentialNamed, - client: Arc, - ) -> Arc, Block>> { - let pool_api = Arc::new(FullChainApi::new(client.clone(), prometheus, &spawner)); - let pool = Arc::new(BasicPool::with_revalidation_type( - options, - is_validator, - pool_api, - prometheus, - RevalidationType::Full, - spawner, - client.usage_info().chain.best_number, - client.usage_info().chain.best_hash, - client.usage_info().chain.finalized_hash, - )); - - pool - } -}