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
10 changes: 10 additions & 0 deletions crates/op-rbuilder/src/args/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ pub struct FlashblocksArgs {
default_value = "256"
)]
pub ws_subscriber_limit: Option<u16>,

/// Enable continuous building between scheduler triggers.
/// When enabled, the builder runs continuously on a blocking thread and
/// scheduler triggers interrupt the build to seal and publish.
#[arg(
long = "flashblocks.continuous-build",
env = "FLASHBLOCKS_CONTINUOUS_BUILD",
default_value = "false"
)]
pub flashblocks_continuous_build: bool,
}

impl Default for FlashblocksArgs {
Expand Down
2 changes: 1 addition & 1 deletion crates/op-rbuilder/src/builder/best_txs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::tx::MaybeFlashblockFilter;
/// - Reverted txs aren't re-simulated (would waste work).
///
/// A fresh instance is created per block, so exclusions do not leak between blocks.
#[derive(Debug, Default)]
#[derive(Debug, Default, Clone)]
pub(super) struct FlashblockTxTracker {
/// Transactions already committed to state.
committed: HashSet<TxHash>,
Expand Down
2 changes: 1 addition & 1 deletion crates/op-rbuilder/src/builder/builder_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ pub fn get_balance(

/// Adjust batch gas/DA/uncompressed limits to reserve capacity for bottom-of-block builder txs.
/// Returns the adjusted `max_uncompressed_block_size`.
pub(super) fn reserve_builder_tx_budget(
pub(crate) fn reserve_builder_tx_budget(
builder_txs: &[BuilderTransactionCtx],
target_gas: &mut u64,
target_da: &mut Option<u64>,
Expand Down
5 changes: 5 additions & 0 deletions crates/op-rbuilder/src/builder/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ pub struct FlashblocksConfig {

/// Maximum number of concurrent WebSocket subscribers
pub ws_subscriber_limit: Option<u16>,

/// Enable continuous building between scheduler triggers.
pub continuous_build: bool,
}

impl Default for FlashblocksConfig {
Expand All @@ -79,6 +82,7 @@ impl Default for FlashblocksConfig {
p2p_known_peers: None,
p2p_max_peer_count: 50,
ws_subscriber_limit: None,
continuous_build: false,
}
}
}
Expand Down Expand Up @@ -123,6 +127,7 @@ impl TryFrom<OpRbuilderArgs> for FlashblocksConfig {
p2p_known_peers: args.flashblocks.p2p.p2p_known_peers,
p2p_max_peer_count: args.flashblocks.p2p.p2p_max_peer_count,
ws_subscriber_limit: args.flashblocks.ws_subscriber_limit,
continuous_build: args.flashblocks.flashblocks_continuous_build,
})
}
}
Expand Down
26 changes: 21 additions & 5 deletions crates/op-rbuilder/src/builder/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use crate::{
/// `BuilderConfig`) or is itself an `Arc`/handle whose backing data lives
/// outside the per-job context (e.g. metrics registry, global backrun pool,
/// per-address gas limiter buckets).
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct OpPayloadBuilderCtx {
/// EVM configuration used to build a per-job [`OpBlockEvmFactory`].
pub evm_config: OpEvmConfig,
Expand Down Expand Up @@ -81,7 +81,7 @@ pub struct OpPayloadBuilderCtx {

/// Container type that holds all necessities to build a new payload.
/// This struct is constructed once per payload job.
#[derive(derive_more::Constructor, derive_more::Deref)]
#[derive(Clone, derive_more::Constructor, derive_more::Deref)]
#[allow(clippy::too_many_arguments)]
pub struct OpPayloadJobCtx {
/// Builder-lifetime configuration shared with all other in-flight jobs.
Expand All @@ -101,10 +101,14 @@ pub struct OpPayloadJobCtx {
backrun_pool: Option<BackrunBundlePayloadPool>,
/// Per-build guard onto the canonical [`AddressLimiter`] held by
/// `builder_ctx`. Charges accumulate privately here and auto-commit back
/// into the canonical when this ctx is dropped. Shadows the
/// into the canonical when the last [`Arc`] is dropped. Shadows the
/// `address_limiter` field reached via `Deref` to `OpPayloadBuilderCtx`,
/// so `self.address_limiter` inside this ctx always hits the guard.
address_limiter: AddressLimiterGuard,
///
/// Wrapped in [`Arc`] so the continuous build path can clone this ctx
/// across flashblock intervals while every clone still drives a single
/// shared guard. The guard auto-commits when the last clone is dropped.
address_limiter: Arc<AddressLimiterGuard>,
}

impl OpPayloadJobCtx {
Expand Down Expand Up @@ -135,10 +139,22 @@ impl OpPayloadJobCtx {
}

/// Returns the builder attributes.
pub(super) const fn attributes(&self) -> &OpPayloadBuilderAttributes<OpTransactionSigned> {
pub(crate) const fn attributes(&self) -> &OpPayloadBuilderAttributes<OpTransactionSigned> {
&self.config.attributes
}

/// Returns this job's cancellation handle.
pub(crate) fn cancel(&self) -> &FlashblockJobCancellation {
&self.cancel
}

/// Returns this job's per-build [`AddressLimiterGuard`]. All clones of this
/// ctx share the same guard via [`Arc`]; the canonical commit fires when
/// the last clone drops.
pub(crate) fn address_limiter(&self) -> &AddressLimiterGuard {
&self.address_limiter
}

/// Returns the block gas limit to target.
pub fn block_gas_limit(&self) -> u64 {
match self.gas_limit_config.gas_limit() {
Expand Down
Loading
Loading