Skip to content

Commit

Permalink
feat: extend pool configuration (#10985)
Browse files Browse the repository at this point in the history
  • Loading branch information
greged93 authored Sep 18, 2024
1 parent 2ee1416 commit 6d49dc1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
10 changes: 10 additions & 0 deletions book/cli/reth/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,16 @@ TxPool:
[default: 10]
--txpool.minimal-protocol-fee <MINIMAL_PROTOCOL_BASEFEE>
Minimum base fee required by the protocol
[default: 7]
--txpool.gas-limit <GAS_LIMIT>
The default enforced gas limit for transactions entering the pool
[default: 30000000]
--blobpool.pricebump <BLOB_TRANSACTION_PRICE_BUMP>
Price bump percentage to replace an already existing blob transaction
Expand Down
13 changes: 13 additions & 0 deletions crates/node/core/src/args/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use crate::cli::config::RethTransactionPoolConfig;
use alloy_primitives::Address;
use clap::Args;
use reth_primitives::constants::{ETHEREUM_BLOCK_GAS_LIMIT, MIN_PROTOCOL_BASE_FEE};
use reth_transaction_pool::{
blobstore::disk::DEFAULT_MAX_CACHED_BLOBS,
pool::{NEW_TX_LISTENER_BUFFER_SIZE, PENDING_TX_LISTENER_BUFFER_SIZE},
Expand Down Expand Up @@ -45,6 +46,14 @@ pub struct TxPoolArgs {
#[arg(long = "txpool.pricebump", default_value_t = DEFAULT_PRICE_BUMP)]
pub price_bump: u128,

/// Minimum base fee required by the protocol.
#[arg(long = "txpool.minimal-protocol-fee", default_value_t = MIN_PROTOCOL_BASE_FEE)]
pub minimal_protocol_basefee: u64,

/// The default enforced gas limit for transactions entering the pool
#[arg(long = "txpool.gas-limit", default_value_t = ETHEREUM_BLOCK_GAS_LIMIT)]
pub gas_limit: u64,

/// Price bump percentage to replace an already existing blob transaction
#[arg(long = "blobpool.pricebump", default_value_t = REPLACE_BLOB_PRICE_BUMP)]
pub blob_transaction_price_bump: u128,
Expand Down Expand Up @@ -90,6 +99,8 @@ impl Default for TxPoolArgs {
queued_max_size: TXPOOL_SUBPOOL_MAX_SIZE_MB_DEFAULT,
max_account_slots: TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER,
price_bump: DEFAULT_PRICE_BUMP,
minimal_protocol_basefee: MIN_PROTOCOL_BASE_FEE,
gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
blob_transaction_price_bump: REPLACE_BLOB_PRICE_BUMP,
max_tx_input_bytes: DEFAULT_MAX_TX_INPUT_BYTES,
max_cached_entries: DEFAULT_MAX_CACHED_BLOBS,
Expand Down Expand Up @@ -133,6 +144,8 @@ impl RethTransactionPoolConfig for TxPoolArgs {
default_price_bump: self.price_bump,
replace_blob_tx_price_bump: self.blob_transaction_price_bump,
},
minimal_protocol_basefee: self.minimal_protocol_basefee,
gas_limit: self.gas_limit,
pending_tx_listener_buffer_size: self.pending_tx_listener_buffer_size,
new_tx_listener_buffer_size: self.new_tx_listener_buffer_size,
}
Expand Down
17 changes: 13 additions & 4 deletions crates/transaction-pool/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use crate::{
PoolSize, TransactionOrigin,
};
use alloy_primitives::Address;
use reth_primitives::EIP4844_TX_TYPE_ID;
use reth_primitives::{
constants::{ETHEREUM_BLOCK_GAS_LIMIT, MIN_PROTOCOL_BASE_FEE},
EIP4844_TX_TYPE_ID,
};
use std::collections::HashSet;
/// Guarantees max transactions for one sender, compatible with geth/erigon
pub const TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER: usize = 16;
Expand Down Expand Up @@ -40,8 +43,12 @@ pub struct PoolConfig {
pub max_account_slots: usize,
/// Price bump (in %) for the transaction pool underpriced check.
pub price_bumps: PriceBumpConfig,
/// Minimum base fee required by the protocol.
pub minimal_protocol_basefee: u64,
/// The max gas limit for transactions in the pool
pub gas_limit: u64,
/// How to handle locally received transactions:
/// [`TransactionOrigin::Local`](crate::TransactionOrigin).
/// [`TransactionOrigin::Local`](TransactionOrigin).
pub local_transactions_config: LocalTransactionConfig,
/// Bound on number of pending transactions from `reth_network::TransactionsManager` to buffer.
pub pending_tx_listener_buffer_size: usize,
Expand All @@ -50,7 +57,7 @@ pub struct PoolConfig {
}

impl PoolConfig {
/// Returns whether or not the size and amount constraints in any sub-pools are exceeded.
/// Returns whether the size and amount constraints in any sub-pools are exceeded.
#[inline]
pub const fn is_exceeded(&self, pool_size: PoolSize) -> bool {
self.blob_limit.is_exceeded(pool_size.blob, pool_size.blob_size) ||
Expand All @@ -69,6 +76,8 @@ impl Default for PoolConfig {
blob_limit: Default::default(),
max_account_slots: TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER,
price_bumps: Default::default(),
minimal_protocol_basefee: MIN_PROTOCOL_BASE_FEE,
gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
local_transactions_config: Default::default(),
pending_tx_listener_buffer_size: PENDING_TX_LISTENER_BUFFER_SIZE,
new_tx_listener_buffer_size: NEW_TX_LISTENER_BUFFER_SIZE,
Expand Down Expand Up @@ -138,7 +147,7 @@ impl Default for PriceBumpConfig {
}

/// Configuration options for the locally received transactions:
/// [`TransactionOrigin::Local`](crate::TransactionOrigin)
/// [`TransactionOrigin::Local`](TransactionOrigin)
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct LocalTransactionConfig {
/// Apply no exemptions to the locally received transactions.
Expand Down
2 changes: 2 additions & 0 deletions crates/transaction-pool/src/pool/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,8 @@ impl<T: PoolTransaction> AllTransactions<T> {
max_account_slots: config.max_account_slots,
price_bumps: config.price_bumps,
local_transactions_config: config.local_transactions_config.clone(),
minimal_protocol_basefee: config.minimal_protocol_basefee,
block_gas_limit: config.gas_limit,
..Default::default()
}
}
Expand Down

0 comments on commit 6d49dc1

Please sign in to comment.