Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(net): expose max concurrent GetPooledTransactions reqs in cli #10358

Merged
merged 11 commits into from
Aug 22, 2024
18 changes: 14 additions & 4 deletions book/cli/reth/debug/execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,28 @@ Networking:
--max-inbound-peers <MAX_INBOUND_PEERS>
Maximum number of inbound requests. default: 30

--max-pending-imports <COUNT>
Max number of transactions to import concurrently.
--max-tx-reqs <COUNT>
Max concurrent `GetPooledTransactions` requests.

[default: 4096]
[default: 130]

--max-tx-reqs-peer <COUNT>
Max concurrent `GetPooledTransactions` requests per peer.

[default: 1]

--max-seen-tx-history <MAX_SEEN_TX_HISTORY>
--max-seen-tx-history <COUNT>
Max number of seen transactions to remember per peer.

Default is 320 transaction hashes.

[default: 320]

--max-pending-imports <COUNT>
Max number of transactions to import concurrently.

[default: 4096]

--pooled-tx-response-soft-limit <BYTES>
Experimental, for usage in research. Sets the max accumulated byte size of transactions
to pack in one response.
Expand Down
18 changes: 14 additions & 4 deletions book/cli/reth/debug/in-memory-merkle.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,28 @@ Networking:
--max-inbound-peers <MAX_INBOUND_PEERS>
Maximum number of inbound requests. default: 30

--max-pending-imports <COUNT>
Max number of transactions to import concurrently.
--max-tx-reqs <COUNT>
Max concurrent `GetPooledTransactions` requests.

[default: 4096]
[default: 130]

--max-tx-reqs-peer <COUNT>
Max concurrent `GetPooledTransactions` requests per peer.

[default: 1]

--max-seen-tx-history <MAX_SEEN_TX_HISTORY>
--max-seen-tx-history <COUNT>
Max number of seen transactions to remember per peer.

Default is 320 transaction hashes.

[default: 320]

--max-pending-imports <COUNT>
Max number of transactions to import concurrently.

[default: 4096]

--pooled-tx-response-soft-limit <BYTES>
Experimental, for usage in research. Sets the max accumulated byte size of transactions
to pack in one response.
Expand Down
18 changes: 14 additions & 4 deletions book/cli/reth/debug/merkle.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,28 @@ Networking:
--max-inbound-peers <MAX_INBOUND_PEERS>
Maximum number of inbound requests. default: 30

--max-pending-imports <COUNT>
Max number of transactions to import concurrently.
--max-tx-reqs <COUNT>
Max concurrent `GetPooledTransactions` requests.

[default: 4096]
[default: 130]

--max-tx-reqs-peer <COUNT>
Max concurrent `GetPooledTransactions` requests per peer.

[default: 1]

--max-seen-tx-history <MAX_SEEN_TX_HISTORY>
--max-seen-tx-history <COUNT>
Max number of seen transactions to remember per peer.

Default is 320 transaction hashes.

[default: 320]

--max-pending-imports <COUNT>
Max number of transactions to import concurrently.

[default: 4096]

--pooled-tx-response-soft-limit <BYTES>
Experimental, for usage in research. Sets the max accumulated byte size of transactions
to pack in one response.
Expand Down
18 changes: 14 additions & 4 deletions book/cli/reth/debug/replay-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,28 @@ Networking:
--max-inbound-peers <MAX_INBOUND_PEERS>
Maximum number of inbound requests. default: 30

--max-pending-imports <COUNT>
Max number of transactions to import concurrently.
--max-tx-reqs <COUNT>
Max concurrent `GetPooledTransactions` requests.

[default: 4096]
[default: 130]

--max-tx-reqs-peer <COUNT>
Max concurrent `GetPooledTransactions` requests per peer.

[default: 1]

--max-seen-tx-history <MAX_SEEN_TX_HISTORY>
--max-seen-tx-history <COUNT>
Max number of seen transactions to remember per peer.

Default is 320 transaction hashes.

[default: 320]

--max-pending-imports <COUNT>
Max number of transactions to import concurrently.

[default: 4096]

--pooled-tx-response-soft-limit <BYTES>
Experimental, for usage in research. Sets the max accumulated byte size of transactions
to pack in one response.
Expand Down
18 changes: 14 additions & 4 deletions book/cli/reth/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,28 @@ Networking:
--max-inbound-peers <MAX_INBOUND_PEERS>
Maximum number of inbound requests. default: 30

--max-pending-imports <COUNT>
Max number of transactions to import concurrently.
--max-tx-reqs <COUNT>
Max concurrent `GetPooledTransactions` requests.

[default: 4096]
[default: 130]

--max-tx-reqs-peer <COUNT>
Max concurrent `GetPooledTransactions` requests per peer.

[default: 1]

--max-seen-tx-history <MAX_SEEN_TX_HISTORY>
--max-seen-tx-history <COUNT>
Max number of seen transactions to remember per peer.

Default is 320 transaction hashes.

[default: 320]

--max-pending-imports <COUNT>
Max number of transactions to import concurrently.

[default: 4096]

--pooled-tx-response-soft-limit <BYTES>
Experimental, for usage in research. Sets the max accumulated byte size of transactions
to pack in one response.
Expand Down
18 changes: 14 additions & 4 deletions book/cli/reth/p2p.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,28 @@ Networking:
--max-inbound-peers <MAX_INBOUND_PEERS>
Maximum number of inbound requests. default: 30

--max-pending-imports <COUNT>
Max number of transactions to import concurrently.
--max-tx-reqs <COUNT>
Max concurrent `GetPooledTransactions` requests.

[default: 4096]
[default: 130]

--max-tx-reqs-peer <COUNT>
Max concurrent `GetPooledTransactions` requests per peer.

[default: 1]

--max-seen-tx-history <MAX_SEEN_TX_HISTORY>
--max-seen-tx-history <COUNT>
Max number of seen transactions to remember per peer.

Default is 320 transaction hashes.

[default: 320]

--max-pending-imports <COUNT>
Max number of transactions to import concurrently.

[default: 4096]

--pooled-tx-response-soft-limit <BYTES>
Experimental, for usage in research. Sets the max accumulated byte size of transactions
to pack in one response.
Expand Down
18 changes: 14 additions & 4 deletions book/cli/reth/stage/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,28 @@ Networking:
--max-inbound-peers <MAX_INBOUND_PEERS>
Maximum number of inbound requests. default: 30

--max-pending-imports <COUNT>
Max number of transactions to import concurrently.
--max-tx-reqs <COUNT>
Max concurrent `GetPooledTransactions` requests.

[default: 4096]
[default: 130]

--max-tx-reqs-peer <COUNT>
Max concurrent `GetPooledTransactions` requests per peer.

[default: 1]

--max-seen-tx-history <MAX_SEEN_TX_HISTORY>
--max-seen-tx-history <COUNT>
Max number of seen transactions to remember per peer.

Default is 320 transaction hashes.

[default: 320]

--max-pending-imports <COUNT>
Max number of transactions to import concurrently.

[default: 4096]

--pooled-tx-response-soft-limit <BYTES>
Experimental, for usage in research. Sets the max accumulated byte size of transactions
to pack in one response.
Expand Down
18 changes: 14 additions & 4 deletions book/cli/reth/stage/unwind.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,28 @@ Networking:
--max-inbound-peers <MAX_INBOUND_PEERS>
Maximum number of inbound requests. default: 30

--max-pending-imports <COUNT>
Max number of transactions to import concurrently.
--max-tx-reqs <COUNT>
Max concurrent `GetPooledTransactions` requests.

[default: 4096]
[default: 130]

--max-tx-reqs-peer <COUNT>
Max concurrent `GetPooledTransactions` requests per peer.

[default: 1]

--max-seen-tx-history <MAX_SEEN_TX_HISTORY>
--max-seen-tx-history <COUNT>
Max number of seen transactions to remember per peer.

Default is 320 transaction hashes.

[default: 320]

--max-pending-imports <COUNT>
Max number of transactions to import concurrently.

[default: 4096]

--pooled-tx-response-soft-limit <BYTES>
Experimental, for usage in research. Sets the max accumulated byte size of transactions
to pack in one response.
Expand Down
16 changes: 15 additions & 1 deletion crates/net/network/src/transactions/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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
Expand All @@ -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
}
}
}
46 changes: 33 additions & 13 deletions crates/node/core/src/args/network.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Expand All @@ -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)]
Expand Down Expand Up @@ -99,16 +107,24 @@ pub struct NetworkArgs {
#[arg(long)]
pub max_inbound_peers: Option<usize>,

#[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.
Expand Down Expand Up @@ -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,
),
Expand Down Expand Up @@ -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,
Expand Down
Loading