From 7269cf28538d25d87bd85bb3594dc8616d674370 Mon Sep 17 00:00:00 2001 From: Roy <42067944+royvardhan@users.noreply.github.com> Date: Sun, 1 Sep 2024 01:34:38 +0530 Subject: [PATCH] chore: expose TransactionFetcher param in cli (#10635) --- book/cli/reth/debug/execution.md | 5 +++++ book/cli/reth/debug/in-memory-merkle.md | 5 +++++ book/cli/reth/debug/merkle.md | 5 +++++ book/cli/reth/debug/replay-engine.md | 5 +++++ book/cli/reth/node.md | 5 +++++ book/cli/reth/p2p.md | 5 +++++ book/cli/reth/stage/run.md | 5 +++++ book/cli/reth/stage/unwind.md | 5 +++++ crates/net/network/src/transactions/config.rs | 11 +++++++++-- crates/net/network/src/transactions/fetcher.rs | 11 ++++++++++- crates/node/core/src/args/network.rs | 8 +++++++- 11 files changed, 66 insertions(+), 4 deletions(-) diff --git a/book/cli/reth/debug/execution.md b/book/cli/reth/debug/execution.md index a6475535e..2f8732761 100644 --- a/book/cli/reth/debug/execution.md +++ b/book/cli/reth/debug/execution.md @@ -221,6 +221,11 @@ Networking: [default: 131072] + --max-tx-pending-fetch + Max capacity of cache of hashes for transactions pending fetch. + + [default: 25600] + --to The maximum block height diff --git a/book/cli/reth/debug/in-memory-merkle.md b/book/cli/reth/debug/in-memory-merkle.md index 2c9b4b4c6..112e9a9b0 100644 --- a/book/cli/reth/debug/in-memory-merkle.md +++ b/book/cli/reth/debug/in-memory-merkle.md @@ -221,6 +221,11 @@ Networking: [default: 131072] + --max-tx-pending-fetch + Max capacity of cache of hashes for transactions pending fetch. + + [default: 25600] + --retries The number of retries per request diff --git a/book/cli/reth/debug/merkle.md b/book/cli/reth/debug/merkle.md index be683bca2..c891cfc0e 100644 --- a/book/cli/reth/debug/merkle.md +++ b/book/cli/reth/debug/merkle.md @@ -221,6 +221,11 @@ Networking: [default: 131072] + --max-tx-pending-fetch + Max capacity of cache of hashes for transactions pending fetch. + + [default: 25600] + --retries The number of retries per request diff --git a/book/cli/reth/debug/replay-engine.md b/book/cli/reth/debug/replay-engine.md index bf9b63896..154f4464c 100644 --- a/book/cli/reth/debug/replay-engine.md +++ b/book/cli/reth/debug/replay-engine.md @@ -221,6 +221,11 @@ Networking: [default: 131072] + --max-tx-pending-fetch + Max capacity of cache of hashes for transactions pending fetch. + + [default: 25600] + --engine-api-store The path to read engine API messages from diff --git a/book/cli/reth/node.md b/book/cli/reth/node.md index 9217dc14f..934318678 100644 --- a/book/cli/reth/node.md +++ b/book/cli/reth/node.md @@ -213,6 +213,11 @@ Networking: [default: 131072] + --max-tx-pending-fetch + Max capacity of cache of hashes for transactions pending fetch. + + [default: 25600] + RPC: --http Enable the HTTP-RPC server diff --git a/book/cli/reth/p2p.md b/book/cli/reth/p2p.md index 42d6c8415..37bec56b8 100644 --- a/book/cli/reth/p2p.md +++ b/book/cli/reth/p2p.md @@ -198,6 +198,11 @@ Networking: [default: 131072] + --max-tx-pending-fetch + Max capacity of cache of hashes for transactions pending fetch. + + [default: 25600] + Datadir: --datadir The path to the data dir for all reth files and subdirectories. diff --git a/book/cli/reth/stage/run.md b/book/cli/reth/stage/run.md index 1f42dba7b..8bc87fd97 100644 --- a/book/cli/reth/stage/run.md +++ b/book/cli/reth/stage/run.md @@ -264,6 +264,11 @@ Networking: [default: 131072] + --max-tx-pending-fetch + Max capacity of cache of hashes for transactions pending fetch. + + [default: 25600] + Logging: --log.stdout.format The format to use for logs written to stdout diff --git a/book/cli/reth/stage/unwind.md b/book/cli/reth/stage/unwind.md index a88883e11..41b0a6640 100644 --- a/book/cli/reth/stage/unwind.md +++ b/book/cli/reth/stage/unwind.md @@ -226,6 +226,11 @@ Networking: [default: 131072] + --max-tx-pending-fetch + Max capacity of cache of hashes for transactions pending fetch. + + [default: 25600] + --offline If this is enabled, then all stages except headers, bodies, and sender recovery will be unwound diff --git a/crates/net/network/src/transactions/config.rs b/crates/net/network/src/transactions/config.rs index 3dd77514d..b8023ca79 100644 --- a/crates/net/network/src/transactions/config.rs +++ b/crates/net/network/src/transactions/config.rs @@ -6,7 +6,8 @@ use super::{ 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, + DEFAULT_MAX_CAPACITY_CACHE_PENDING_FETCH, DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS, + DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS_PER_PEER, }; /// Configuration for managing transactions within the network. @@ -46,6 +47,11 @@ pub struct TransactionFetcherConfig { /// [`PooledTransactions`](reth_eth_wire::PooledTransactions) response on packing a /// [`GetPooledTransactions`](reth_eth_wire::GetPooledTransactions) request with hashes. pub soft_limit_byte_size_pooled_transactions_response_on_pack_request: usize, + /// Max capacity of the cache of transaction hashes, for transactions that weren't yet fetched. + /// A transaction is pending fetch if its hash didn't fit into a + /// [`GetPooledTransactions`](reth_eth_wire::GetPooledTransactions) yet, or it wasn't returned + /// upon request to peers. + pub max_capacity_cache_txns_pending_fetch: u32, } impl Default for TransactionFetcherConfig { @@ -56,7 +62,8 @@ impl Default for TransactionFetcherConfig { 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 + DEFAULT_SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESP_ON_PACK_GET_POOLED_TRANSACTIONS_REQ, + max_capacity_cache_txns_pending_fetch: DEFAULT_MAX_CAPACITY_CACHE_PENDING_FETCH, } } } diff --git a/crates/net/network/src/transactions/fetcher.rs b/crates/net/network/src/transactions/fetcher.rs index 8a5b2fbad..f553cfbfd 100644 --- a/crates/net/network/src/transactions/fetcher.rs +++ b/crates/net/network/src/transactions/fetcher.rs @@ -134,6 +134,8 @@ impl TransactionFetcher { .metrics .capacity_inflight_requests .increment(tx_fetcher.info.max_inflight_requests as u64); + tx_fetcher.info.max_capacity_cache_txns_pending_fetch = + config.max_capacity_cache_txns_pending_fetch; tx_fetcher } @@ -1291,6 +1293,10 @@ pub struct TransactionFetcherInfo { /// Soft limit for the byte size of a [`PooledTransactions`] response, upon assembling the /// response. Spec'd at 2 MiB, but can be adjusted for research purpose. pub soft_limit_byte_size_pooled_transactions_response: usize, + /// Max capacity of the cache of transaction hashes, for transactions that weren't yet fetched. + /// A transaction is pending fetch if its hash didn't fit into a [`GetPooledTransactions`] yet, + /// or it wasn't returned upon request to peers. + pub max_capacity_cache_txns_pending_fetch: u32, } impl TransactionFetcherInfo { @@ -1299,11 +1305,13 @@ impl TransactionFetcherInfo { max_inflight_requests: usize, soft_limit_byte_size_pooled_transactions_response_on_pack_request: usize, soft_limit_byte_size_pooled_transactions_response: usize, + max_capacity_cache_txns_pending_fetch: u32, ) -> Self { Self { max_inflight_requests, soft_limit_byte_size_pooled_transactions_response_on_pack_request, soft_limit_byte_size_pooled_transactions_response, + max_capacity_cache_txns_pending_fetch, } } } @@ -1313,7 +1321,8 @@ impl Default for TransactionFetcherInfo { Self::new( DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS as usize * DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS_PER_PEER as usize, DEFAULT_SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESP_ON_PACK_GET_POOLED_TRANSACTIONS_REQ, - SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESPONSE + SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESPONSE, + DEFAULT_MAX_CAPACITY_CACHE_PENDING_FETCH, ) } } diff --git a/crates/node/core/src/args/network.rs b/crates/node/core/src/args/network.rs index 53891ff0b..45aef0b2b 100644 --- a/crates/node/core/src/args/network.rs +++ b/crates/node/core/src/args/network.rs @@ -20,7 +20,7 @@ use reth_network::{ transactions::{ constants::{ tx_fetcher::{ - DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS, + DEFAULT_MAX_CAPACITY_CACHE_PENDING_FETCH, DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS, DEFAULT_MAX_COUNT_CONCURRENT_REQUESTS_PER_PEER, }, tx_manager::{ @@ -144,6 +144,10 @@ pub struct NetworkArgs { /// Default is 128 KiB. #[arg(long = "pooled-tx-pack-soft-limit", value_name = "BYTES", default_value_t = DEFAULT_SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESP_ON_PACK_GET_POOLED_TRANSACTIONS_REQ, verbatim_doc_comment)] pub soft_limit_byte_size_pooled_transactions_response_on_pack_request: usize, + + /// Max capacity of cache of hashes for transactions pending fetch. + #[arg(long = "max-tx-pending-fetch", value_name = "COUNT", default_value_t = DEFAULT_MAX_CAPACITY_CACHE_PENDING_FETCH, verbatim_doc_comment)] + pub max_capacity_cache_txns_pending_fetch: u32, } impl NetworkArgs { @@ -191,6 +195,7 @@ impl NetworkArgs { 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, + self.max_capacity_cache_txns_pending_fetch, ), max_transactions_seen_by_peer_history: self.max_seen_tx_history, }; @@ -297,6 +302,7 @@ impl Default for NetworkArgs { soft_limit_byte_size_pooled_transactions_response_on_pack_request: DEFAULT_SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESP_ON_PACK_GET_POOLED_TRANSACTIONS_REQ, max_pending_pool_imports: DEFAULT_MAX_COUNT_PENDING_POOL_IMPORTS, max_seen_tx_history: DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER, + max_capacity_cache_txns_pending_fetch: DEFAULT_MAX_CAPACITY_CACHE_PENDING_FETCH, } } }