From 0216e78f5c567a83b8d151fe45db226b45facd9c Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Fri, 9 Aug 2024 06:08:14 +0800 Subject: [PATCH] feat: make additional validation tasks size configurable (#10200) Co-authored-by: Matthias Seitz --- book/cli/reth/node.md | 5 +++++ crates/ethereum/node/src/node.rs | 2 +- crates/node/core/src/args/txpool.rs | 9 +++++++-- crates/optimism/node/src/node.rs | 2 +- crates/transaction-pool/src/config.rs | 3 +++ crates/transaction-pool/src/lib.rs | 5 +++-- examples/custom-node-components/src/main.rs | 2 +- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/book/cli/reth/node.md b/book/cli/reth/node.md index 205dcfd65..5bcf9d14d 100644 --- a/book/cli/reth/node.md +++ b/book/cli/reth/node.md @@ -430,6 +430,11 @@ TxPool: --txpool.no-local-transactions-propagation Flag to toggle local transaction propagation + --txpool.additional-validation-tasks + Number of additional transaction validation tasks to spawn + + [default: 1] + Builder: --builder.extradata Block extra data set by the payload builder diff --git a/crates/ethereum/node/src/node.rs b/crates/ethereum/node/src/node.rs index 319fd2cf0..63fbe0688 100644 --- a/crates/ethereum/node/src/node.rs +++ b/crates/ethereum/node/src/node.rs @@ -144,7 +144,7 @@ where .with_head_timestamp(ctx.head().timestamp) .kzg_settings(ctx.kzg_settings()?) .with_local_transactions_config(pool_config.local_transactions_config.clone()) - .with_additional_tasks(1) + .with_additional_tasks(ctx.config().txpool.additional_validation_tasks) .build_with_tasks( ctx.provider().clone(), ctx.task_executor().clone(), diff --git a/crates/node/core/src/args/txpool.rs b/crates/node/core/src/args/txpool.rs index 12fc6bd79..9e10893e0 100644 --- a/crates/node/core/src/args/txpool.rs +++ b/crates/node/core/src/args/txpool.rs @@ -6,8 +6,9 @@ use reth_primitives::Address; use reth_transaction_pool::{ blobstore::disk::DEFAULT_MAX_CACHED_BLOBS, validate::DEFAULT_MAX_TX_INPUT_BYTES, LocalTransactionConfig, PoolConfig, PriceBumpConfig, SubPoolLimit, DEFAULT_PRICE_BUMP, - REPLACE_BLOB_PRICE_BUMP, TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER, - TXPOOL_SUBPOOL_MAX_SIZE_MB_DEFAULT, TXPOOL_SUBPOOL_MAX_TXS_DEFAULT, + DEFAULT_TXPOOL_ADDITIONAL_VALIDATION_TASKS, REPLACE_BLOB_PRICE_BUMP, + TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER, TXPOOL_SUBPOOL_MAX_SIZE_MB_DEFAULT, + TXPOOL_SUBPOOL_MAX_TXS_DEFAULT, }; /// Parameters for debugging purposes #[derive(Debug, Clone, Args, PartialEq, Eq)] @@ -63,6 +64,9 @@ pub struct TxPoolArgs { /// Flag to toggle local transaction propagation. #[arg(long = "txpool.no-local-transactions-propagation")] pub no_local_transactions_propagation: bool, + /// Number of additional transaction validation tasks to spawn. + #[arg(long = "txpool.additional-validation-tasks", alias = "txpool.additional_validation_tasks", default_value_t = DEFAULT_TXPOOL_ADDITIONAL_VALIDATION_TASKS)] + pub additional_validation_tasks: usize, } impl Default for TxPoolArgs { @@ -82,6 +86,7 @@ impl Default for TxPoolArgs { no_locals: false, locals: Default::default(), no_local_transactions_propagation: false, + additional_validation_tasks: DEFAULT_TXPOOL_ADDITIONAL_VALIDATION_TASKS, } } } diff --git a/crates/optimism/node/src/node.rs b/crates/optimism/node/src/node.rs index 9fc1f9b85..ac7711dd2 100644 --- a/crates/optimism/node/src/node.rs +++ b/crates/optimism/node/src/node.rs @@ -155,7 +155,7 @@ where let validator = TransactionValidationTaskExecutor::eth_builder(ctx.chain_spec()) .with_head_timestamp(ctx.head().timestamp) .kzg_settings(ctx.kzg_settings()?) - .with_additional_tasks(1) + .with_additional_tasks(ctx.config().txpool.additional_validation_tasks) .build_with_tasks( ctx.provider().clone(), ctx.task_executor().clone(), diff --git a/crates/transaction-pool/src/config.rs b/crates/transaction-pool/src/config.rs index 2f90e3006..6e143916a 100644 --- a/crates/transaction-pool/src/config.rs +++ b/crates/transaction-pool/src/config.rs @@ -10,6 +10,9 @@ pub const TXPOOL_SUBPOOL_MAX_TXS_DEFAULT: usize = 10_000; /// The default maximum allowed size of the given subpool. pub const TXPOOL_SUBPOOL_MAX_SIZE_MB_DEFAULT: usize = 20; +/// The default additional validation tasks size. +pub const DEFAULT_TXPOOL_ADDITIONAL_VALIDATION_TASKS: usize = 1; + /// Default price bump (in %) for the transaction pool underpriced check. pub const DEFAULT_PRICE_BUMP: u128 = 10; diff --git a/crates/transaction-pool/src/lib.rs b/crates/transaction-pool/src/lib.rs index 4bf22e62c..448a67d4d 100644 --- a/crates/transaction-pool/src/lib.rs +++ b/crates/transaction-pool/src/lib.rs @@ -163,8 +163,9 @@ pub use crate::{ blobstore::{BlobStore, BlobStoreError}, config::{ LocalTransactionConfig, PoolConfig, PriceBumpConfig, SubPoolLimit, DEFAULT_PRICE_BUMP, - REPLACE_BLOB_PRICE_BUMP, TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER, - TXPOOL_SUBPOOL_MAX_SIZE_MB_DEFAULT, TXPOOL_SUBPOOL_MAX_TXS_DEFAULT, + DEFAULT_TXPOOL_ADDITIONAL_VALIDATION_TASKS, REPLACE_BLOB_PRICE_BUMP, + TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER, TXPOOL_SUBPOOL_MAX_SIZE_MB_DEFAULT, + TXPOOL_SUBPOOL_MAX_TXS_DEFAULT, }, error::PoolResult, ordering::{CoinbaseTipOrdering, Priority, TransactionOrdering}, diff --git a/examples/custom-node-components/src/main.rs b/examples/custom-node-components/src/main.rs index 007d6fe0f..2c44e18d8 100644 --- a/examples/custom-node-components/src/main.rs +++ b/examples/custom-node-components/src/main.rs @@ -55,7 +55,7 @@ where let validator = TransactionValidationTaskExecutor::eth_builder(ctx.chain_spec()) .with_head_timestamp(ctx.head().timestamp) .kzg_settings(ctx.kzg_settings()?) - .with_additional_tasks(5) + .with_additional_tasks(ctx.config().txpool.additional_validation_tasks) .build_with_tasks( ctx.provider().clone(), ctx.task_executor().clone(),