Add price bump config (#3967)

This commit is contained in:
Altuğ Bakan
2023-07-28 11:47:15 +02:00
committed by GitHub
parent 4d31b3ae61
commit d2cdd10ed2
4 changed files with 38 additions and 9 deletions

View File

@@ -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,
};
@@ -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,
}
impl TxPoolArgs {
@@ -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,
}
}
}

View File

@@ -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 {
@@ -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 {
@@ -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,
}
}
}
@@ -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,
}
}
}

View File

@@ -153,8 +153,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::{CoinbaseTipOrdering, Priority, TransactionOrdering},
@@ -207,9 +208,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> {

View File

@@ -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::{
@@ -1111,7 +1110,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,