Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
23 changes: 22 additions & 1 deletion cmd/ethrex/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use std::{

use clap::{ArgAction, Parser as ClapParser, Subcommand as ClapSubcommand};
use ethrex_blockchain::{
BlockchainOptions, BlockchainType, L2Config,
BlockchainOptions, BlockchainType, DEFAULT_BLOB_PRICE_BUMP_PERCENT, DEFAULT_PRICE_BUMP_PERCENT,
L2Config,
error::{ChainError, InvalidBlockError},
};
use ethrex_common::types::{Block, DEFAULT_BUILDER_GAS_CEIL, Genesis, validate_block_body};
Expand Down Expand Up @@ -183,6 +184,24 @@ pub struct Options {
env = "ETHREX_MEMPOOL_MAX_SIZE"
)]
pub mempool_max_size: usize,
#[arg(
help = "Minimum fee bump (in percent) required to replace a non-blob pooled transaction at the same (sender, nonce).",
long = "mempool.price-bump",
default_value_t = DEFAULT_PRICE_BUMP_PERCENT,
value_name = "PERCENT",
help_heading = "Node options",
env = "ETHREX_MEMPOOL_PRICE_BUMP"
)]
pub mempool_price_bump: u64,
#[arg(
help = "Minimum fee bump (in percent) required to replace an EIP-4844 blob pooled transaction.",
long = "mempool.blob-price-bump",
default_value_t = DEFAULT_BLOB_PRICE_BUMP_PERCENT,
value_name = "PERCENT",
help_heading = "Node options",
env = "ETHREX_MEMPOOL_BLOB_PRICE_BUMP"
)]
pub mempool_blob_price_bump: u64,
#[arg(
long = "http.addr",
default_value = "0.0.0.0",
Expand Down Expand Up @@ -450,6 +469,8 @@ impl Default for Options {
dev: Default::default(),
force: false,
mempool_max_size: Default::default(),
mempool_price_bump: DEFAULT_PRICE_BUMP_PERCENT,
mempool_blob_price_bump: DEFAULT_BLOB_PRICE_BUMP_PERCENT,
tx_broadcasting_time_interval: Default::default(),
target_peers: Default::default(),
lookup_interval: Default::default(),
Expand Down
2 changes: 2 additions & 0 deletions cmd/ethrex/initializers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ pub async fn init_l1(
max_blobs_per_block: opts.max_blobs_per_block,
precompute_witnesses: opts.precompute_witnesses,
precompile_cache_enabled: !opts.no_precompile_cache,
price_bump_percent: opts.mempool_price_bump,
blob_price_bump_percent: opts.mempool_blob_price_bump,
},
);

Expand Down
2 changes: 2 additions & 0 deletions cmd/ethrex/l2/initializers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ pub async fn init_l2(
max_blobs_per_block: None, // L2 doesn't support blob transactions
precompute_witnesses: opts.node_opts.precompute_witnesses,
precompile_cache_enabled: true,
price_bump_percent: opts.node_opts.mempool_price_bump,
blob_price_bump_percent: opts.node_opts.mempool_blob_price_bump,
};

let blockchain = init_blockchain(store.clone(), blockchain_opts.clone());
Expand Down
28 changes: 27 additions & 1 deletion crates/blockchain/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,15 @@ pub struct BlockchainOptions {
/// warmer thread and the executor. Set to false (via `--no-precompile-cache`) to
/// disable the cache for benchmarking purposes.
pub precompile_cache_enabled: bool,
/// Minimum fee-field bump (in percent) required to replace a non-blob
/// transaction at the same `(sender, nonce)`. Matches the 10%
/// default of every peer EL client.
pub price_bump_percent: u64,
/// Minimum fee-field bump (in percent) required to replace an EIP-4844
/// blob transaction at the same `(sender, nonce)`. Matches the 100%
/// default of every peer EL client. Blob replacements are deliberately
/// expensive because blob sidecars are large to re-propagate.
pub blob_price_bump_percent: u64,
}

impl Default for BlockchainOptions {
Expand All @@ -242,10 +251,21 @@ impl Default for BlockchainOptions {
max_blobs_per_block: None,
precompute_witnesses: false,
precompile_cache_enabled: true,
price_bump_percent: DEFAULT_PRICE_BUMP_PERCENT,
blob_price_bump_percent: DEFAULT_BLOB_PRICE_BUMP_PERCENT,
}
}
}

/// Default 10% bump required for non-blob RBF replacements (matches geth
/// `PriceBump`, reth `default_price_bump`, nethermind `PriceBump`,
/// erigon `PriceBump`, besu `DEFAULT_PRICE_BUMP`).
pub const DEFAULT_PRICE_BUMP_PERCENT: u64 = 10;
/// Default 100% bump required for blob RBF replacements (matches geth
/// `blobpool.PriceBump`, reth `replace_blob_tx_price_bump`, nethermind
/// blob comparison, erigon `BlobPriceBump`, besu `DEFAULT_BLOB_PRICE_BUMP`).
pub const DEFAULT_BLOB_PRICE_BUMP_PERCENT: u64 = 100;

#[derive(Debug, Clone)]
pub struct BatchBlockProcessingFailure {
pub last_valid_hash: H256,
Expand Down Expand Up @@ -2505,7 +2525,13 @@ impl Blockchain {

// Check the nonce of pendings TXs in the mempool from the same sender
// If it exists check if the new tx has higher fees
let tx_to_replace_hash = self.mempool.find_tx_to_replace(sender, nonce, tx)?;
let tx_to_replace_hash = self.mempool.find_tx_to_replace(
sender,
nonce,
tx,
self.options.price_bump_percent,
self.options.blob_price_bump_percent,
)?;

if tx
.chain_id()
Expand Down
Loading
Loading