Skip to content
Closed
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
20 changes: 0 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ anyhow = "1"
url = "2.5.7"
lru = "0.16.3"
rand = "0.9.2"
serde_yaml = "0.9"
shellexpand = "3.1"
strum = "0.27.2"
backon = "1.6.0"
Expand Down
1 change: 0 additions & 1 deletion crates/builder/op-rbuilder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ tokio-tungstenite.workspace = true
rand.workspace = true
tracing-subscriber = { workspace = true, features = ["env-filter", "json"] }
shellexpand.workspace = true
serde_yaml.workspace = true
moka.workspace = true
http.workspace = true
sha3.workspace = true
Expand Down
83 changes: 32 additions & 51 deletions crates/builder/op-rbuilder/src/flashblocks/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,45 +49,6 @@ use crate::{
tx_data_store::{TxData, TxDataStore},
};

#[derive(Debug, Default, Clone)]
pub struct FlashblocksExtraCtx {
/// Current flashblock index
pub flashblock_index: u64,
/// Target flashblock count per block
pub target_flashblock_count: u64,
/// Total gas left for the current flashblock
pub target_gas_for_batch: u64,
/// Total DA bytes left for the current flashblock
pub target_da_for_batch: Option<u64>,
/// Total DA footprint left for the current flashblock
pub target_da_footprint_for_batch: Option<u64>,
/// Gas limit per flashblock
pub gas_per_batch: u64,
/// DA bytes limit per flashblock
pub da_per_batch: Option<u64>,
/// DA footprint limit per flashblock
pub da_footprint_per_batch: Option<u64>,
/// Whether to disable state root calculation for each flashblock
pub disable_state_root: bool,
}

impl FlashblocksExtraCtx {
pub const fn next(
self,
target_gas_for_batch: u64,
target_da_for_batch: Option<u64>,
target_da_footprint_for_batch: Option<u64>,
) -> Self {
Self {
flashblock_index: self.flashblock_index + 1,
target_gas_for_batch,
target_da_for_batch,
target_da_footprint_for_batch,
..self
}
}
}

/// Container type that holds all necessities to build a new payload.
#[derive(Debug)]
pub struct OpPayloadBuilderCtx {
Expand All @@ -109,8 +70,24 @@ pub struct OpPayloadBuilderCtx {
pub cancel: CancellationToken,
/// The metrics for the builder
pub metrics: Arc<OpRBuilderMetrics>,
/// Extra context for the payload builder
pub extra: FlashblocksExtraCtx,
/// Current flashblock index
pub flashblock_index: u64,
/// Target flashblock count per block
pub target_flashblock_count: u64,
/// Total gas left for the current flashblock
pub target_gas_for_batch: u64,
/// Total DA bytes left for the current flashblock
pub target_da_for_batch: Option<u64>,
/// Total DA footprint left for the current flashblock
pub target_da_footprint_for_batch: Option<u64>,
/// Gas limit per flashblock
pub gas_per_batch: u64,
/// DA bytes limit per flashblock
pub da_per_batch: Option<u64>,
/// DA footprint limit per flashblock
pub da_footprint_per_batch: Option<u64>,
/// Whether to disable state root calculation for each flashblock
pub disable_state_root: bool,
/// Max gas that can be used by a transaction.
pub max_gas_per_txn: Option<u64>,
/// Rate limiting based on gas. This is an optional feature.
Expand All @@ -124,16 +101,20 @@ impl OpPayloadBuilderCtx {
Self { cancel, ..self }
}

pub(super) fn with_extra_ctx(self, extra: FlashblocksExtraCtx) -> Self {
Self { extra, ..self }
}

pub(crate) const fn flashblock_index(&self) -> u64 {
self.extra.flashblock_index
}

pub(crate) const fn target_flashblock_count(&self) -> u64 {
self.extra.target_flashblock_count
/// Updates the target fields for the next flashblock iteration.
pub(super) fn with_next_targets(
self,
target_gas_for_batch: u64,
target_da_for_batch: Option<u64>,
target_da_footprint_for_batch: Option<u64>,
) -> Self {
Self {
flashblock_index: self.flashblock_index + 1,
target_gas_for_batch,
target_da_for_batch,
target_da_footprint_for_batch,
..self
}
}

/// Returns the parent block the payload will be build on.
Expand Down
12 changes: 10 additions & 2 deletions crates/builder/op-rbuilder/src/flashblocks/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use reth_optimism_primitives::OpTransactionSigned;
use tokio_util::sync::CancellationToken;

use crate::{
flashblocks::{BuilderConfig, FlashblocksExtraCtx, OpPayloadBuilderCtx},
flashblocks::{BuilderConfig, OpPayloadBuilderCtx},
gas_limiter::AddressGasLimiter,
metrics::OpRBuilderMetrics,
traits::ClientBounds,
Expand Down Expand Up @@ -85,7 +85,15 @@ impl OpPayloadSyncerCtx {
block_env_attributes,
cancel,
metrics: self.metrics,
extra: FlashblocksExtraCtx::default(),
flashblock_index: 0,
target_flashblock_count: 0,
target_gas_for_batch: 0,
target_da_for_batch: None,
target_da_footprint_for_batch: None,
gas_per_batch: 0,
da_per_batch: None,
da_footprint_per_batch: None,
disable_state_root: false,
max_gas_per_txn: self.max_gas_per_txn,
address_gas_limiter: AddressGasLimiter::new(GasLimiterArgs::default()),
tx_data_store: self.tx_data_store,
Expand Down
2 changes: 1 addition & 1 deletion crates/builder/op-rbuilder/src/flashblocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(crate) mod service;
pub(crate) mod wspub;

pub use config::FlashblocksConfig;
pub use context::{FlashblocksExtraCtx, OpPayloadBuilderCtx};
pub use context::OpPayloadBuilderCtx;
pub use payload::FlashblocksExecutionInfo;
pub use service::FlashblocksServiceBuilder;

Expand Down
Loading
Loading