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>
|
--max-inbound-peers <MAX_INBOUND_PEERS>
|
||||||
Maximum number of inbound requests. default: 30
|
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>
|
--pooled-tx-response-soft-limit <BYTES>
|
||||||
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||||
to pack in one response.
|
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>
|
--max-inbound-peers <MAX_INBOUND_PEERS>
|
||||||
Maximum number of inbound requests. default: 30
|
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>
|
--pooled-tx-response-soft-limit <BYTES>
|
||||||
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||||
to pack in one response.
|
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>
|
--max-inbound-peers <MAX_INBOUND_PEERS>
|
||||||
Maximum number of inbound requests. default: 30
|
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>
|
--pooled-tx-response-soft-limit <BYTES>
|
||||||
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||||
to pack in one response.
|
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>
|
--max-inbound-peers <MAX_INBOUND_PEERS>
|
||||||
Maximum number of inbound requests. default: 30
|
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>
|
--pooled-tx-response-soft-limit <BYTES>
|
||||||
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||||
to pack in one response.
|
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>
|
--max-inbound-peers <MAX_INBOUND_PEERS>
|
||||||
Maximum number of inbound requests. default: 30
|
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>
|
--pooled-tx-response-soft-limit <BYTES>
|
||||||
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||||
to pack in one response.
|
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>
|
--max-inbound-peers <MAX_INBOUND_PEERS>
|
||||||
Maximum number of inbound requests. default: 30
|
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>
|
--pooled-tx-response-soft-limit <BYTES>
|
||||||
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||||
to pack in one response.
|
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>
|
--max-inbound-peers <MAX_INBOUND_PEERS>
|
||||||
Maximum number of inbound requests. default: 30
|
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>
|
--pooled-tx-response-soft-limit <BYTES>
|
||||||
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||||
to pack in one response.
|
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>
|
--max-inbound-peers <MAX_INBOUND_PEERS>
|
||||||
Maximum number of inbound requests. default: 30
|
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>
|
--pooled-tx-response-soft-limit <BYTES>
|
||||||
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||||
to pack in one response.
|
to pack in one response.
|
||||||
|
|||||||
@ -1,16 +1,28 @@
|
|||||||
use derive_more::Constructor;
|
use derive_more::Constructor;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER,
|
||||||
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,
|
||||||
SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESPONSE,
|
SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESPONSE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Configuration for managing transactions within the network.
|
/// Configuration for managing transactions within the network.
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub struct TransactionsManagerConfig {
|
pub struct TransactionsManagerConfig {
|
||||||
/// Configuration for fetching transactions.
|
/// Configuration for fetching transactions.
|
||||||
pub transaction_fetcher_config: TransactionFetcherConfig,
|
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.
|
/// 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 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;
|
pub const DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER: u32 = 10 * 1024 / 32;
|
||||||
|
|
||||||
/// Default maximum pending pool imports to tolerate.
|
/// Default maximum pending pool imports to tolerate.
|
||||||
|
|||||||
@ -245,6 +245,8 @@ pub struct TransactionsManager<Pool> {
|
|||||||
pending_transactions: ReceiverStream<TxHash>,
|
pending_transactions: ReceiverStream<TxHash>,
|
||||||
/// Incoming events from the [`NetworkManager`](crate::NetworkManager).
|
/// Incoming events from the [`NetworkManager`](crate::NetworkManager).
|
||||||
transaction_events: UnboundedMeteredReceiver<NetworkTransactionEvent>,
|
transaction_events: UnboundedMeteredReceiver<NetworkTransactionEvent>,
|
||||||
|
/// Max number of seen transactions to store for each peer.
|
||||||
|
max_transactions_seen_by_peer_history: u32,
|
||||||
/// `TransactionsManager` metrics
|
/// `TransactionsManager` metrics
|
||||||
metrics: TransactionsManagerMetrics,
|
metrics: TransactionsManagerMetrics,
|
||||||
}
|
}
|
||||||
@ -295,6 +297,8 @@ impl<Pool: TransactionPool> TransactionsManager<Pool> {
|
|||||||
from_network,
|
from_network,
|
||||||
NETWORK_POOL_TRANSACTIONS_SCOPE,
|
NETWORK_POOL_TRANSACTIONS_SCOPE,
|
||||||
),
|
),
|
||||||
|
max_transactions_seen_by_peer_history: transactions_manager_config
|
||||||
|
.max_transactions_seen_by_peer_history,
|
||||||
metrics,
|
metrics,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -904,7 +908,12 @@ where
|
|||||||
peer_id, client_version, messages, version, ..
|
peer_id, client_version, messages, version, ..
|
||||||
} => {
|
} => {
|
||||||
// Insert a new peer into the peerset.
|
// 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) {
|
let peer = match self.peers.entry(peer_id) {
|
||||||
Entry::Occupied(mut entry) => {
|
Entry::Occupied(mut entry) => {
|
||||||
entry.insert(peer);
|
entry.insert(peer);
|
||||||
@ -1613,9 +1622,14 @@ pub struct PeerMetadata {
|
|||||||
|
|
||||||
impl PeerMetadata {
|
impl PeerMetadata {
|
||||||
/// Returns a new instance of [`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 {
|
Self {
|
||||||
seen_transactions: LruCache::new(DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER),
|
seen_transactions: LruCache::new(max_transactions_seen_by_peer),
|
||||||
request_tx,
|
request_tx,
|
||||||
version,
|
version,
|
||||||
client_version,
|
client_version,
|
||||||
@ -1782,6 +1796,7 @@ mod tests {
|
|||||||
PeerRequestSender::new(peer_id, to_mock_session_tx),
|
PeerRequestSender::new(peer_id, to_mock_session_tx),
|
||||||
version,
|
version,
|
||||||
Arc::from(""),
|
Arc::from(""),
|
||||||
|
DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER,
|
||||||
),
|
),
|
||||||
to_mock_session_rx,
|
to_mock_session_rx,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -12,6 +12,7 @@ use reth_discv5::{
|
|||||||
use reth_net_nat::NatResolver;
|
use reth_net_nat::NatResolver;
|
||||||
use reth_network::{
|
use reth_network::{
|
||||||
transactions::{
|
transactions::{
|
||||||
|
constants::tx_manager::DEFAULT_MAX_COUNT_TRANSACTIONS_SEEN_BY_PEER,
|
||||||
TransactionFetcherConfig, TransactionsManagerConfig,
|
TransactionFetcherConfig, TransactionsManagerConfig,
|
||||||
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,
|
||||||
SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESPONSE,
|
SOFT_LIMIT_BYTE_SIZE_POOLED_TRANSACTIONS_RESPONSE,
|
||||||
@ -96,6 +97,12 @@ pub struct NetworkArgs {
|
|||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub max_inbound_peers: Option<usize>,
|
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
|
/// Experimental, for usage in research. Sets the max accumulated byte size of transactions
|
||||||
/// to pack in one response.
|
/// to pack in one response.
|
||||||
/// Spec'd at 2MiB.
|
/// 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,
|
||||||
self.soft_limit_byte_size_pooled_transactions_response_on_pack_request,
|
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
|
// 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,
|
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,
|
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