mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(net): Expose max seen transactions history size as cli arg (#10327)
Co-authored-by: Oliver <onbjerg@users.noreply.github.com>
This commit is contained in:
7
book/cli/reth/debug/execution.md
vendored
7
book/cli/reth/debug/execution.md
vendored
@ -177,6 +177,13 @@ Networking:
|
||||
--max-inbound-peers <MAX_INBOUND_PEERS>
|
||||
Maximum number of inbound requests. default: 30
|
||||
|
||||
--max-seen-tx-history <MAX_SEEN_TX_HISTORY>
|
||||
Max number of seen transactions to remember per peer.
|
||||
|
||||
Default is 320 transaction hashes.
|
||||
|
||||
[default: 320]
|
||||
|
||||
--pooled-tx-response-soft-limit <BYTES>
|
||||
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||
to pack in one response.
|
||||
|
||||
7
book/cli/reth/debug/in-memory-merkle.md
vendored
7
book/cli/reth/debug/in-memory-merkle.md
vendored
@ -177,6 +177,13 @@ Networking:
|
||||
--max-inbound-peers <MAX_INBOUND_PEERS>
|
||||
Maximum number of inbound requests. default: 30
|
||||
|
||||
--max-seen-tx-history <MAX_SEEN_TX_HISTORY>
|
||||
Max number of seen transactions to remember per peer.
|
||||
|
||||
Default is 320 transaction hashes.
|
||||
|
||||
[default: 320]
|
||||
|
||||
--pooled-tx-response-soft-limit <BYTES>
|
||||
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||
to pack in one response.
|
||||
|
||||
7
book/cli/reth/debug/merkle.md
vendored
7
book/cli/reth/debug/merkle.md
vendored
@ -177,6 +177,13 @@ Networking:
|
||||
--max-inbound-peers <MAX_INBOUND_PEERS>
|
||||
Maximum number of inbound requests. default: 30
|
||||
|
||||
--max-seen-tx-history <MAX_SEEN_TX_HISTORY>
|
||||
Max number of seen transactions to remember per peer.
|
||||
|
||||
Default is 320 transaction hashes.
|
||||
|
||||
[default: 320]
|
||||
|
||||
--pooled-tx-response-soft-limit <BYTES>
|
||||
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||
to pack in one response.
|
||||
|
||||
7
book/cli/reth/debug/replay-engine.md
vendored
7
book/cli/reth/debug/replay-engine.md
vendored
@ -177,6 +177,13 @@ Networking:
|
||||
--max-inbound-peers <MAX_INBOUND_PEERS>
|
||||
Maximum number of inbound requests. default: 30
|
||||
|
||||
--max-seen-tx-history <MAX_SEEN_TX_HISTORY>
|
||||
Max number of seen transactions to remember per peer.
|
||||
|
||||
Default is 320 transaction hashes.
|
||||
|
||||
[default: 320]
|
||||
|
||||
--pooled-tx-response-soft-limit <BYTES>
|
||||
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||
to pack in one response.
|
||||
|
||||
7
book/cli/reth/node.md
vendored
7
book/cli/reth/node.md
vendored
@ -169,6 +169,13 @@ Networking:
|
||||
--max-inbound-peers <MAX_INBOUND_PEERS>
|
||||
Maximum number of inbound requests. default: 30
|
||||
|
||||
--max-seen-tx-history <MAX_SEEN_TX_HISTORY>
|
||||
Max number of seen transactions to remember per peer.
|
||||
|
||||
Default is 320 transaction hashes.
|
||||
|
||||
[default: 320]
|
||||
|
||||
--pooled-tx-response-soft-limit <BYTES>
|
||||
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||
to pack in one response.
|
||||
|
||||
7
book/cli/reth/p2p.md
vendored
7
book/cli/reth/p2p.md
vendored
@ -154,6 +154,13 @@ Networking:
|
||||
--max-inbound-peers <MAX_INBOUND_PEERS>
|
||||
Maximum number of inbound requests. default: 30
|
||||
|
||||
--max-seen-tx-history <MAX_SEEN_TX_HISTORY>
|
||||
Max number of seen transactions to remember per peer.
|
||||
|
||||
Default is 320 transaction hashes.
|
||||
|
||||
[default: 320]
|
||||
|
||||
--pooled-tx-response-soft-limit <BYTES>
|
||||
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||
to pack in one response.
|
||||
|
||||
7
book/cli/reth/stage/run.md
vendored
7
book/cli/reth/stage/run.md
vendored
@ -220,6 +220,13 @@ Networking:
|
||||
--max-inbound-peers <MAX_INBOUND_PEERS>
|
||||
Maximum number of inbound requests. default: 30
|
||||
|
||||
--max-seen-tx-history <MAX_SEEN_TX_HISTORY>
|
||||
Max number of seen transactions to remember per peer.
|
||||
|
||||
Default is 320 transaction hashes.
|
||||
|
||||
[default: 320]
|
||||
|
||||
--pooled-tx-response-soft-limit <BYTES>
|
||||
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||
to pack in one response.
|
||||
|
||||
7
book/cli/reth/stage/unwind.md
vendored
7
book/cli/reth/stage/unwind.md
vendored
@ -182,6 +182,13 @@ Networking:
|
||||
--max-inbound-peers <MAX_INBOUND_PEERS>
|
||||
Maximum number of inbound requests. default: 30
|
||||
|
||||
--max-seen-tx-history <MAX_SEEN_TX_HISTORY>
|
||||
Max number of seen transactions to remember per peer.
|
||||
|
||||
Default is 320 transaction hashes.
|
||||
|
||||
[default: 320]
|
||||
|
||||
--pooled-tx-response-soft-limit <BYTES>
|
||||
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||
to pack in one response.
|
||||
|
||||
@ -1,16 +1,28 @@
|
||||
use derive_more::Constructor;
|
||||
|
||||
use super::{
|
||||
DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER,
|
||||
DEFAULT_SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESP_ON_PACK_GET_POOLED_TRANSACTIONS_REQ,
|
||||
SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESPONSE,
|
||||
};
|
||||
|
||||
/// Configuration for managing transactions within the network.
|
||||
#[derive(Debug, Default, Clone)]
|
||||
#[derive(Debug, Clone)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct TransactionsManagerConfig {
|
||||
/// Configuration for fetching transactions.
|
||||
pub transaction_fetcher_config: TransactionFetcherConfig,
|
||||
/// Max number of seen transactions to store for each peer.
|
||||
pub max_transactions_seen_by_peer_history: u32,
|
||||
}
|
||||
|
||||
impl Default for TransactionsManagerConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
transaction_fetcher_config: TransactionFetcherConfig::default(),
|
||||
max_transactions_seen_by_peer_history: DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuration for fetching transactions.
|
||||
|
||||
@ -39,7 +39,7 @@ pub mod tx_manager {
|
||||
|
||||
/// Default limit for number of transactions to keep track of for a single peer.
|
||||
///
|
||||
/// Default is 10 KiB, i.e. 320 transaction hashes.
|
||||
/// Default is 320 transaction hashes.
|
||||
pub const DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER: u32 = 10 * 1024 / 32;
|
||||
|
||||
/// Default maximum pending pool imports to tolerate.
|
||||
|
||||
@ -245,6 +245,8 @@ pub struct TransactionsManager<Pool> {
|
||||
pending_transactions: ReceiverStream<TxHash>,
|
||||
/// Incoming events from the [`NetworkManager`](crate::NetworkManager).
|
||||
transaction_events: UnboundedMeteredReceiver<NetworkTransactionEvent>,
|
||||
/// Max number of seen transactions to store for each peer.
|
||||
max_transactions_seen_by_peer_history: u32,
|
||||
/// `TransactionsManager` metrics
|
||||
metrics: TransactionsManagerMetrics,
|
||||
}
|
||||
@ -295,6 +297,8 @@ impl<Pool: TransactionPool> TransactionsManager<Pool> {
|
||||
from_network,
|
||||
NETWORK_POOL_TRANSACTIONS_SCOPE,
|
||||
),
|
||||
max_transactions_seen_by_peer_history: transactions_manager_config
|
||||
.max_transactions_seen_by_peer_history,
|
||||
metrics,
|
||||
}
|
||||
}
|
||||
@ -904,7 +908,12 @@ where
|
||||
peer_id, client_version, messages, version, ..
|
||||
} => {
|
||||
// Insert a new peer into the peerset.
|
||||
let peer = PeerMetadata::new(messages, version, client_version);
|
||||
let peer = PeerMetadata::new(
|
||||
messages,
|
||||
version,
|
||||
client_version,
|
||||
self.max_transactions_seen_by_peer_history,
|
||||
);
|
||||
let peer = match self.peers.entry(peer_id) {
|
||||
Entry::Occupied(mut entry) => {
|
||||
entry.insert(peer);
|
||||
@ -1613,9 +1622,14 @@ pub struct PeerMetadata {
|
||||
|
||||
impl PeerMetadata {
|
||||
/// Returns a new instance of [`PeerMetadata`].
|
||||
fn new(request_tx: PeerRequestSender, version: EthVersion, client_version: Arc<str>) -> Self {
|
||||
fn new(
|
||||
request_tx: PeerRequestSender,
|
||||
version: EthVersion,
|
||||
client_version: Arc<str>,
|
||||
max_transactions_seen_by_peer: u32,
|
||||
) -> Self {
|
||||
Self {
|
||||
seen_transactions: LruCache::new(DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER),
|
||||
seen_transactions: LruCache::new(max_transactions_seen_by_peer),
|
||||
request_tx,
|
||||
version,
|
||||
client_version,
|
||||
@ -1782,6 +1796,7 @@ mod tests {
|
||||
PeerRequestSender::new(peer_id, to_mock_session_tx),
|
||||
version,
|
||||
Arc::from(""),
|
||||
DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER,
|
||||
),
|
||||
to_mock_session_rx,
|
||||
)
|
||||
|
||||
@ -12,6 +12,7 @@ use reth_discv5::{
|
||||
use reth_net_nat::NatResolver;
|
||||
use reth_network::{
|
||||
transactions::{
|
||||
constants::tx_manager::DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER,
|
||||
TransactionFetcherConfig, TransactionsManagerConfig,
|
||||
DEFAULT_SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESP_ON_PACK_GET_POOLED_TRANSACTIONS_REQ,
|
||||
SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESPONSE,
|
||||
@ -96,6 +97,12 @@ pub struct NetworkArgs {
|
||||
#[arg(long)]
|
||||
pub max_inbound_peers: Option<usize>,
|
||||
|
||||
/// 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)]
|
||||
pub max_seen_tx_history: u32,
|
||||
|
||||
/// Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||
/// to pack in one response.
|
||||
/// Spec'd at 2MiB.
|
||||
@ -161,6 +168,7 @@ impl NetworkArgs {
|
||||
self.soft_limit_byte_size_pooled_transactions_response,
|
||||
self.soft_limit_byte_size_pooled_transactions_response_on_pack_request,
|
||||
),
|
||||
max_transactions_seen_by_peer_history: self.max_seen_tx_history,
|
||||
};
|
||||
|
||||
// Configure basic network stack
|
||||
@ -261,6 +269,7 @@ impl Default for NetworkArgs {
|
||||
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,
|
||||
max_seen_tx_history: DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user