diff --git a/book/cli/reth/debug/execution.md b/book/cli/reth/debug/execution.md index c34eb8d7e..a6475535e 100644 --- a/book/cli/reth/debug/execution.md +++ b/book/cli/reth/debug/execution.md @@ -177,18 +177,28 @@ Networking: --max-inbound-peers Maximum number of inbound requests. default: 30 - --max-pending-imports - Max number of transactions to import concurrently. + --max-tx-reqs + Max concurrent `GetPooledTransactions` requests. - [default: 4096] + [default: 130] - --max-seen-tx-history + --max-tx-reqs-peer + Max concurrent `GetPooledTransactions` requests per peer. + + [default: 1] + + --max-seen-tx-history Max number of seen transactions to remember per peer. Default is 320 transaction hashes. [default: 320] + --max-pending-imports + Max number of transactions to import concurrently. + + [default: 4096] + --pooled-tx-response-soft-limit Experimental, for usage in research. Sets the max accumulated byte size of transactions to pack in one response. diff --git a/book/cli/reth/debug/in-memory-merkle.md b/book/cli/reth/debug/in-memory-merkle.md index 1a089711f..2c9b4b4c6 100644 --- a/book/cli/reth/debug/in-memory-merkle.md +++ b/book/cli/reth/debug/in-memory-merkle.md @@ -177,18 +177,28 @@ Networking: --max-inbound-peers Maximum number of inbound requests. default: 30 - --max-pending-imports - Max number of transactions to import concurrently. + --max-tx-reqs + Max concurrent `GetPooledTransactions` requests. - [default: 4096] + [default: 130] - --max-seen-tx-history + --max-tx-reqs-peer + Max concurrent `GetPooledTransactions` requests per peer. + + [default: 1] + + --max-seen-tx-history Max number of seen transactions to remember per peer. Default is 320 transaction hashes. [default: 320] + --max-pending-imports + Max number of transactions to import concurrently. + + [default: 4096] + --pooled-tx-response-soft-limit Experimental, for usage in research. Sets the max accumulated byte size of transactions to pack in one response. diff --git a/book/cli/reth/debug/merkle.md b/book/cli/reth/debug/merkle.md index b996248f6..be683bca2 100644 --- a/book/cli/reth/debug/merkle.md +++ b/book/cli/reth/debug/merkle.md @@ -177,18 +177,28 @@ Networking: --max-inbound-peers Maximum number of inbound requests. default: 30 - --max-pending-imports - Max number of transactions to import concurrently. + --max-tx-reqs + Max concurrent `GetPooledTransactions` requests. - [default: 4096] + [default: 130] - --max-seen-tx-history + --max-tx-reqs-peer + Max concurrent `GetPooledTransactions` requests per peer. + + [default: 1] + + --max-seen-tx-history Max number of seen transactions to remember per peer. Default is 320 transaction hashes. [default: 320] + --max-pending-imports + Max number of transactions to import concurrently. + + [default: 4096] + --pooled-tx-response-soft-limit Experimental, for usage in research. Sets the max accumulated byte size of transactions to pack in one response. diff --git a/book/cli/reth/debug/replay-engine.md b/book/cli/reth/debug/replay-engine.md index 2889487dd..bf9b63896 100644 --- a/book/cli/reth/debug/replay-engine.md +++ b/book/cli/reth/debug/replay-engine.md @@ -177,18 +177,28 @@ Networking: --max-inbound-peers Maximum number of inbound requests. default: 30 - --max-pending-imports - Max number of transactions to import concurrently. + --max-tx-reqs + Max concurrent `GetPooledTransactions` requests. - [default: 4096] + [default: 130] - --max-seen-tx-history + --max-tx-reqs-peer + Max concurrent `GetPooledTransactions` requests per peer. + + [default: 1] + + --max-seen-tx-history Max number of seen transactions to remember per peer. Default is 320 transaction hashes. [default: 320] + --max-pending-imports + Max number of transactions to import concurrently. + + [default: 4096] + --pooled-tx-response-soft-limit Experimental, for usage in research. Sets the max accumulated byte size of transactions to pack in one response. diff --git a/book/cli/reth/node.md b/book/cli/reth/node.md index bf167c6a2..a9937a8af 100644 --- a/book/cli/reth/node.md +++ b/book/cli/reth/node.md @@ -169,18 +169,28 @@ Networking: --max-inbound-peers Maximum number of inbound requests. default: 30 - --max-pending-imports - Max number of transactions to import concurrently. + --max-tx-reqs + Max concurrent `GetPooledTransactions` requests. - [default: 4096] + [default: 130] - --max-seen-tx-history + --max-tx-reqs-peer + Max concurrent `GetPooledTransactions` requests per peer. + + [default: 1] + + --max-seen-tx-history Max number of seen transactions to remember per peer. Default is 320 transaction hashes. [default: 320] + --max-pending-imports + Max number of transactions to import concurrently. + + [default: 4096] + --pooled-tx-response-soft-limit Experimental, for usage in research. Sets the max accumulated byte size of transactions to pack in one response. diff --git a/book/cli/reth/p2p.md b/book/cli/reth/p2p.md index 7bda2a578..42d6c8415 100644 --- a/book/cli/reth/p2p.md +++ b/book/cli/reth/p2p.md @@ -154,18 +154,28 @@ Networking: --max-inbound-peers Maximum number of inbound requests. default: 30 - --max-pending-imports - Max number of transactions to import concurrently. + --max-tx-reqs + Max concurrent `GetPooledTransactions` requests. - [default: 4096] + [default: 130] - --max-seen-tx-history + --max-tx-reqs-peer + Max concurrent `GetPooledTransactions` requests per peer. + + [default: 1] + + --max-seen-tx-history Max number of seen transactions to remember per peer. Default is 320 transaction hashes. [default: 320] + --max-pending-imports + Max number of transactions to import concurrently. + + [default: 4096] + --pooled-tx-response-soft-limit Experimental, for usage in research. Sets the max accumulated byte size of transactions to pack in one response. diff --git a/book/cli/reth/stage/run.md b/book/cli/reth/stage/run.md index b4f47d0d8..1f42dba7b 100644 --- a/book/cli/reth/stage/run.md +++ b/book/cli/reth/stage/run.md @@ -220,18 +220,28 @@ Networking: --max-inbound-peers Maximum number of inbound requests. default: 30 - --max-pending-imports - Max number of transactions to import concurrently. + --max-tx-reqs + Max concurrent `GetPooledTransactions` requests. - [default: 4096] + [default: 130] - --max-seen-tx-history + --max-tx-reqs-peer + Max concurrent `GetPooledTransactions` requests per peer. + + [default: 1] + + --max-seen-tx-history Max number of seen transactions to remember per peer. Default is 320 transaction hashes. [default: 320] + --max-pending-imports + Max number of transactions to import concurrently. + + [default: 4096] + --pooled-tx-response-soft-limit Experimental, for usage in research. Sets the max accumulated byte size of transactions to pack in one response. diff --git a/book/cli/reth/stage/unwind.md b/book/cli/reth/stage/unwind.md index 930cb8ff7..a88883e11 100644 --- a/book/cli/reth/stage/unwind.md +++ b/book/cli/reth/stage/unwind.md @@ -182,18 +182,28 @@ Networking: --max-inbound-peers Maximum number of inbound requests. default: 30 - --max-pending-imports - Max number of transactions to import concurrently. + --max-tx-reqs + Max concurrent `GetPooledTransactions` requests. - [default: 4096] + [default: 130] - --max-seen-tx-history + --max-tx-reqs-peer + Max concurrent `GetPooledTransactions` requests per peer. + + [default: 1] + + --max-seen-tx-history Max number of seen transactions to remember per peer. Default is 320 transaction hashes. [default: 320] + --max-pending-imports + Max number of transactions to import concurrently. + + [default: 4096] + --pooled-tx-response-soft-limit Experimental, for usage in research. Sets the max accumulated byte size of transactions to pack in one response. diff --git a/crates/net/network/src/transactions/config.rs b/crates/net/network/src/transactions/config.rs index 5d9455b6e..3dd77514d 100644 --- a/crates/net/network/src/transactions/config.rs +++ b/crates/net/network/src/transactions/config.rs @@ -5,6 +5,9 @@ use super::{ DEFAULT_SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESP_ON_PACK_GET_POOLED_TRANSACTIONS_REQ, SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESPONSE, }; +use crate::transactions::constants::tx_fetcher::{ + DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS, DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS_PER_PEER, +}; /// Configuration for managing transactions within the network. #[derive(Debug, Clone)] @@ -29,6 +32,11 @@ impl Default for TransactionsManagerConfig { #[derive(Debug, Constructor, Clone)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TransactionFetcherConfig { + /// Max inflight [`GetPooledTransactions`](reth_eth_wire::GetPooledTransactions) requests. + pub max_inflight_requests: u32, + /// Max inflight [`GetPooledTransactions`](reth_eth_wire::GetPooledTransactions) requests per + /// peer. + pub max_inflight_requests_per_peer: u8, /// Soft limit for the byte size of a /// [`PooledTransactions`](reth_eth_wire::PooledTransactions) response on assembling a /// [`GetPooledTransactions`](reth_eth_wire::GetPooledTransactions) request. Spec'd at 2 @@ -42,7 +50,13 @@ pub struct TransactionFetcherConfig { impl Default for TransactionFetcherConfig { fn default() -> Self { - Self { soft_limit_byte_size_pooled_transactions_response: SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESPONSE, soft_limit_byte_size_pooled_transactions_response_on_pack_request: DEFAULT_SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESP_ON_PACK_GET_POOLED_TRANSACTIONS_REQ + Self { + max_inflight_requests: DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS, + max_inflight_requests_per_peer: DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS_PER_PEER, + soft_limit_byte_size_pooled_transactions_response: + SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESPONSE, + soft_limit_byte_size_pooled_transactions_response_on_pack_request: + DEFAULT_SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESP_ON_PACK_GET_POOLED_TRANSACTIONS_REQ } } } diff --git a/crates/node/core/src/args/network.rs b/crates/node/core/src/args/network.rs index abec8f915..53891ff0b 100644 --- a/crates/node/core/src/args/network.rs +++ b/crates/node/core/src/args/network.rs @@ -1,6 +1,12 @@ //! clap [Args](clap::Args) for network related arguments. -use crate::version::P2P_CLIENT_VERSION; +use std::{ + net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}, + ops::Not, + path::PathBuf, + sync::Arc, +}; + use clap::Args; use reth_chainspec::ChainSpec; use reth_config::Config; @@ -12,8 +18,14 @@ use reth_discv5::{ use reth_net_nat::NatResolver; use reth_network::{ transactions::{ - constants::tx_manager::{ - DEFAULT_MAX_COUNT_PENDING_POOL_IMPORTS, DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER, + constants::{ + tx_fetcher::{ + DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS, + DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS_PER_PEER, + }, + tx_manager::{ + DEFAULT_MAX_COUNT_PENDING_POOL_IMPORTS, DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER, + }, }, TransactionFetcherConfig, TransactionsManagerConfig, DEFAULT_SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESP_ON_PACK_GET_POOLED_TRANSACTIONS_REQ, @@ -23,12 +35,8 @@ use reth_network::{ }; use reth_network_peers::{mainnet_nodes, TrustedPeer}; use secp256k1::SecretKey; -use std::{ - net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}, - ops::Not, - path::PathBuf, - sync::Arc, -}; + +use crate::version::P2P_CLIENT_VERSION; /// Parameters for configuring the network more granularity via CLI #[derive(Debug, Clone, Args, PartialEq, Eq)] @@ -99,16 +107,24 @@ pub struct NetworkArgs { #[arg(long)] pub max_inbound_peers: Option, - #[arg(long = "max-pending-imports", value_name = "COUNT", default_value_t = DEFAULT_MAX_COUNT_PENDING_POOL_IMPORTS, verbatim_doc_comment)] - /// Max number of transactions to import concurrently. - pub max_pending_pool_imports: usize, + /// Max concurrent `GetPooledTransactions` requests. + #[arg(long = "max-tx-reqs", value_name = "COUNT", default_value_t = DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS, verbatim_doc_comment)] + pub max_concurrent_tx_requests: u32, + + /// Max concurrent `GetPooledTransactions` requests per peer. + #[arg(long = "max-tx-reqs-peer", value_name = "COUNT", default_value_t = DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS_PER_PEER, verbatim_doc_comment)] + pub max_concurrent_tx_requests_per_peer: u8, /// Max number of seen transactions to remember per peer. /// /// Default is 320 transaction hashes. - #[arg(long = "max-seen-tx-history", value_name = "MAX_SEEN_TX_HISTORY", default_value_t = DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER, verbatim_doc_comment)] + #[arg(long = "max-seen-tx-history", value_name = "COUNT", default_value_t = DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER, verbatim_doc_comment)] pub max_seen_tx_history: u32, + #[arg(long = "max-pending-imports", value_name = "COUNT", default_value_t = DEFAULT_MAX_COUNT_PENDING_POOL_IMPORTS, verbatim_doc_comment)] + /// Max number of transactions to import concurrently. + pub max_pending_pool_imports: usize, + /// Experimental, for usage in research. Sets the max accumulated byte size of transactions /// to pack in one response. /// Spec'd at 2MiB. @@ -171,6 +187,8 @@ impl NetworkArgs { // Configure transactions manager let transactions_manager_config = TransactionsManagerConfig { transaction_fetcher_config: TransactionFetcherConfig::new( + self.max_concurrent_tx_requests, + self.max_concurrent_tx_requests_per_peer, self.soft_limit_byte_size_pooled_transactions_response, self.soft_limit_byte_size_pooled_transactions_response_on_pack_request, ), @@ -272,6 +290,8 @@ impl Default for NetworkArgs { port: DEFAULT_DISCOVERY_PORT, max_outbound_peers: None, max_inbound_peers: None, + max_concurrent_tx_requests: DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS, + max_concurrent_tx_requests_per_peer: DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS_PER_PEER, soft_limit_byte_size_pooled_transactions_response: SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESPONSE, soft_limit_byte_size_pooled_transactions_response_on_pack_request: DEFAULT_SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESP_ON_PACK_GET_POOLED_TRANSACTIONS_REQ,