mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: add PoolBuilderConfigOverrides (#11507)
This commit is contained in:
@ -1,8 +1,8 @@
|
|||||||
//! Pool component for the node builder.
|
//! Pool component for the node builder.
|
||||||
|
|
||||||
use std::future::Future;
|
use alloy_primitives::Address;
|
||||||
|
use reth_transaction_pool::{PoolConfig, SubPoolLimit, TransactionPool};
|
||||||
use reth_transaction_pool::TransactionPool;
|
use std::{collections::HashSet, future::Future};
|
||||||
|
|
||||||
use crate::{BuilderContext, FullNodeTypes};
|
use crate::{BuilderContext, FullNodeTypes};
|
||||||
|
|
||||||
@ -34,3 +34,59 @@ where
|
|||||||
self(ctx)
|
self(ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convenience type to override cli or default pool configuration during build.
|
||||||
|
#[derive(Debug, Clone, Default)]
|
||||||
|
pub struct PoolBuilderConfigOverrides {
|
||||||
|
/// Max number of transaction in the pending sub-pool
|
||||||
|
pub pending_limit: Option<SubPoolLimit>,
|
||||||
|
/// Max number of transaction in the basefee sub-pool
|
||||||
|
pub basefee_limit: Option<SubPoolLimit>,
|
||||||
|
/// Max number of transaction in the queued sub-pool
|
||||||
|
pub queued_limit: Option<SubPoolLimit>,
|
||||||
|
/// Max number of transactions in the blob sub-pool
|
||||||
|
pub blob_limit: Option<SubPoolLimit>,
|
||||||
|
/// Max number of executable transaction slots guaranteed per account
|
||||||
|
pub max_account_slots: Option<usize>,
|
||||||
|
/// Minimum base fee required by the protocol.
|
||||||
|
pub minimal_protocol_basefee: Option<u64>,
|
||||||
|
/// Addresses that will be considered as local. Above exemptions apply.
|
||||||
|
pub local_addresses: HashSet<Address>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PoolBuilderConfigOverrides {
|
||||||
|
/// Applies the configured overrides to the given [`PoolConfig`].
|
||||||
|
pub fn apply(self, mut config: PoolConfig) -> PoolConfig {
|
||||||
|
let Self {
|
||||||
|
pending_limit,
|
||||||
|
basefee_limit,
|
||||||
|
queued_limit,
|
||||||
|
blob_limit,
|
||||||
|
max_account_slots,
|
||||||
|
minimal_protocol_basefee,
|
||||||
|
local_addresses,
|
||||||
|
} = self;
|
||||||
|
|
||||||
|
if let Some(pending_limit) = pending_limit {
|
||||||
|
config.pending_limit = pending_limit;
|
||||||
|
}
|
||||||
|
if let Some(basefee_limit) = basefee_limit {
|
||||||
|
config.basefee_limit = basefee_limit;
|
||||||
|
}
|
||||||
|
if let Some(queued_limit) = queued_limit {
|
||||||
|
config.queued_limit = queued_limit;
|
||||||
|
}
|
||||||
|
if let Some(blob_limit) = blob_limit {
|
||||||
|
config.blob_limit = blob_limit;
|
||||||
|
}
|
||||||
|
if let Some(max_account_slots) = max_account_slots {
|
||||||
|
config.max_account_slots = max_account_slots;
|
||||||
|
}
|
||||||
|
if let Some(minimal_protocol_basefee) = minimal_protocol_basefee {
|
||||||
|
config.minimal_protocol_basefee = minimal_protocol_basefee;
|
||||||
|
}
|
||||||
|
config.local_transactions_config.local_addresses.extend(local_addresses);
|
||||||
|
|
||||||
|
config
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ use reth_node_api::{EngineValidator, FullNodeComponents, NodeAddOns};
|
|||||||
use reth_node_builder::{
|
use reth_node_builder::{
|
||||||
components::{
|
components::{
|
||||||
ComponentsBuilder, ConsensusBuilder, EngineValidatorBuilder, ExecutorBuilder,
|
ComponentsBuilder, ConsensusBuilder, EngineValidatorBuilder, ExecutorBuilder,
|
||||||
NetworkBuilder, PayloadServiceBuilder, PoolBuilder,
|
NetworkBuilder, PayloadServiceBuilder, PoolBuilder, PoolBuilderConfigOverrides,
|
||||||
},
|
},
|
||||||
node::{FullNodeTypes, NodeTypes, NodeTypesWithEngine},
|
node::{FullNodeTypes, NodeTypes, NodeTypesWithEngine},
|
||||||
BuilderContext, Node, PayloadBuilderConfig,
|
BuilderContext, Node, PayloadBuilderConfig,
|
||||||
@ -166,9 +166,11 @@ where
|
|||||||
///
|
///
|
||||||
/// This contains various settings that can be configured and take precedence over the node's
|
/// This contains various settings that can be configured and take precedence over the node's
|
||||||
/// config.
|
/// config.
|
||||||
#[derive(Debug, Default, Clone, Copy)]
|
#[derive(Debug, Default, Clone)]
|
||||||
#[non_exhaustive]
|
pub struct OptimismPoolBuilder {
|
||||||
pub struct OptimismPoolBuilder;
|
/// Enforced overrides that are applied to the pool config.
|
||||||
|
pub pool_config_overrides: PoolBuilderConfigOverrides,
|
||||||
|
}
|
||||||
|
|
||||||
impl<Node> PoolBuilder<Node> for OptimismPoolBuilder
|
impl<Node> PoolBuilder<Node> for OptimismPoolBuilder
|
||||||
where
|
where
|
||||||
@ -177,6 +179,7 @@ where
|
|||||||
type Pool = OpTransactionPool<Node::Provider, DiskFileBlobStore>;
|
type Pool = OpTransactionPool<Node::Provider, DiskFileBlobStore>;
|
||||||
|
|
||||||
async fn build_pool(self, ctx: &BuilderContext<Node>) -> eyre::Result<Self::Pool> {
|
async fn build_pool(self, ctx: &BuilderContext<Node>) -> eyre::Result<Self::Pool> {
|
||||||
|
let Self { pool_config_overrides } = self;
|
||||||
let data_dir = ctx.config().datadir();
|
let data_dir = ctx.config().datadir();
|
||||||
let blob_store = DiskFileBlobStore::open(data_dir.blobstore(), Default::default())?;
|
let blob_store = DiskFileBlobStore::open(data_dir.blobstore(), Default::default())?;
|
||||||
|
|
||||||
@ -198,7 +201,7 @@ where
|
|||||||
validator,
|
validator,
|
||||||
CoinbaseTipOrdering::default(),
|
CoinbaseTipOrdering::default(),
|
||||||
blob_store,
|
blob_store,
|
||||||
ctx.pool_config(),
|
pool_config_overrides.apply(ctx.pool_config()),
|
||||||
);
|
);
|
||||||
info!(target: "reth::cli", "Transaction pool initialized");
|
info!(target: "reth::cli", "Transaction pool initialized");
|
||||||
let transactions_path = data_dir.txpool_transactions();
|
let transactions_path = data_dir.txpool_transactions();
|
||||||
|
|||||||
@ -157,7 +157,7 @@ pub struct LocalTransactionConfig {
|
|||||||
/// - no price exemptions
|
/// - no price exemptions
|
||||||
/// - no eviction exemptions
|
/// - no eviction exemptions
|
||||||
pub no_exemptions: bool,
|
pub no_exemptions: bool,
|
||||||
/// Addresses that will be considered as local . Above exemptions apply
|
/// Addresses that will be considered as local. Above exemptions apply.
|
||||||
pub local_addresses: HashSet<Address>,
|
pub local_addresses: HashSet<Address>,
|
||||||
/// Flag indicating whether local transactions should be propagated.
|
/// Flag indicating whether local transactions should be propagated.
|
||||||
pub propagate_local_transactions: bool,
|
pub propagate_local_transactions: bool,
|
||||||
|
|||||||
Reference in New Issue
Block a user