Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bin/reth/src/args/txpool_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use clap::Args;
use reth_transaction_pool::{
PoolConfig, SubPoolLimit, TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER,
PoolConfig, SubPoolLimit, DEFAULT_PRICE_BUMP, TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER,
TXPOOL_SUBPOOL_MAX_SIZE_MB_DEFAULT, TXPOOL_SUBPOOL_MAX_TXS_DEFAULT,
};

Expand Down Expand Up @@ -33,6 +33,10 @@ pub struct TxPoolArgs {
/// Max number of executable transaction slots guaranteed per account
#[arg(long = "txpool.max_account_slots", help_heading = "TxPool", default_value_t = TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER)]
pub max_account_slots: usize,

/// Price bump (in %) for the transaction pool underpriced check.
#[arg(long = "txpool.price_bump", help_heading = "TxPool", default_value_t = DEFAULT_PRICE_BUMP)]
pub price_bump: u128,
Comment on lines +36 to +39
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

}

impl TxPoolArgs {
Expand All @@ -52,6 +56,7 @@ impl TxPoolArgs {
max_size: self.queued_max_size * 1024 * 1024,
},
max_account_slots: self.max_account_slots,
price_bump: self.price_bump,
}
}
}
27 changes: 27 additions & 0 deletions crates/transaction-pool/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ pub const TXPOOL_SUBPOOL_MAX_TXS_DEFAULT: usize = 10_000;
/// The default maximum allowed size of the given subpool.
pub const TXPOOL_SUBPOOL_MAX_SIZE_MB_DEFAULT: usize = 20;

/// Default price bump (in %) for the transaction pool underpriced check.
pub const DEFAULT_PRICE_BUMP: u128 = 10;

/// Replace blob price bump (in %) for the transaction pool underpriced check.
pub const REPLACE_BLOB_PRICE_BUMP: u128 = 100;

/// Configuration options for the Transaction pool.
#[derive(Debug, Clone)]
pub struct PoolConfig {
Expand All @@ -18,6 +24,8 @@ pub struct PoolConfig {
pub queued_limit: SubPoolLimit,
/// Max number of executable transaction slots guaranteed per account
pub max_account_slots: usize,
/// Price bump (in %) for the transaction pool underpriced check.
pub price_bump: u128,
}

impl Default for PoolConfig {
Expand All @@ -27,6 +35,7 @@ impl Default for PoolConfig {
basefee_limit: Default::default(),
queued_limit: Default::default(),
max_account_slots: TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER,
price_bump: PriceBumpConfig::default().default_price_bump,
}
}
}
Expand Down Expand Up @@ -57,3 +66,21 @@ impl Default for SubPoolLimit {
}
}
}

/// Price bump config (in %) for the transaction pool underpriced check.
#[derive(Debug, Clone)]
pub struct PriceBumpConfig {
/// Default price bump (in %) for the transaction pool underpriced check.
pub default_price_bump: u128,
/// Replace blob price bump (in %) for the transaction pool underpriced check.
pub replace_blob_tx_price_bump: u128,
}

impl Default for PriceBumpConfig {
fn default() -> Self {
Self {
default_price_bump: DEFAULT_PRICE_BUMP,
replace_blob_tx_price_bump: REPLACE_BLOB_PRICE_BUMP,
}
}
}
8 changes: 3 additions & 5 deletions crates/transaction-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,9 @@ use tracing::{instrument, trace};

pub use crate::{
config::{
PoolConfig, SubPoolLimit, TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER,
TXPOOL_SUBPOOL_MAX_SIZE_MB_DEFAULT, TXPOOL_SUBPOOL_MAX_TXS_DEFAULT,
PoolConfig, PriceBumpConfig, SubPoolLimit, DEFAULT_PRICE_BUMP, REPLACE_BLOB_PRICE_BUMP,
TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER, TXPOOL_SUBPOOL_MAX_SIZE_MB_DEFAULT,
TXPOOL_SUBPOOL_MAX_TXS_DEFAULT,
},
error::PoolResult,
ordering::{GasCostOrdering, TransactionOrdering},
Expand Down Expand Up @@ -208,9 +209,6 @@ pub(crate) const MAX_CODE_SIZE: usize = 24576;
// Maximum initcode to permit in a creation transaction and create instructions
pub(crate) const MAX_INIT_CODE_SIZE: usize = 2 * MAX_CODE_SIZE;

// Price bump (in %) for the transaction pool underpriced check
pub(crate) const PRICE_BUMP: u128 = 10;

/// A shareable, generic, customizable `TransactionPool` implementation.
#[derive(Debug)]
pub struct Pool<V: TransactionValidator, T: TransactionOrdering> {
Expand Down
5 changes: 2 additions & 3 deletions crates/transaction-pool/src/pool/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use crate::{
AddedPendingTransaction, AddedTransaction, OnNewCanonicalStateOutcome,
},
traits::{BlockInfo, PoolSize},
PoolConfig, PoolResult, PoolTransaction, TransactionOrdering, ValidPoolTransaction, PRICE_BUMP,
U256,
PoolConfig, PoolResult, PoolTransaction, TransactionOrdering, ValidPoolTransaction, U256,
};
use fnv::FnvHashMap;
use reth_primitives::{
Expand Down Expand Up @@ -1105,7 +1104,7 @@ impl<T: PoolTransaction> AllTransactions<T> {
if Self::is_underpriced(
transaction.as_ref(),
entry.get().transaction.as_ref(),
PRICE_BUMP,
PoolConfig::default().price_bump,
) {
return Err(InsertErr::Underpriced {
transaction: pool_tx.transaction,
Expand Down