Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions crates/op-rbuilder/src/args/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ pub struct OpRbuilderArgs {
)]
pub chain_block_time: u64,

/// max gas a transaction can use
#[arg(long = "builder.max-gas-usage", default_value = "25000")]
pub max_gas_per_txn: u64,

/// Signals whether to log pool transaction events
#[arg(long = "builder.log-pool-transactions", default_value = "false")]
pub log_pool_transactions: bool,
Expand Down
6 changes: 6 additions & 0 deletions crates/op-rbuilder/src/builders/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ pub struct OpPayloadBuilderCtx<ExtraCtx: Debug + Default = ()> {
pub metrics: Arc<OpRBuilderMetrics>,
/// Extra context for the payload builder
pub extra_ctx: ExtraCtx,
/// Max gas that can be used by a transaction.
pub max_gas_per_txn: u64,
}

impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
Expand Down Expand Up @@ -566,6 +568,10 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {

// Add gas used by the transaction to cumulative gas used, before creating the receipt
let gas_used = result.gas_used();
if gas_used > self.max_gas_per_txn {
info!("builder txn took execessive gas. not included in block");
return Ok(());
Copy link
Collaborator

@SozinM SozinM Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is out builder transaction, not needed here
We should implement this logic inside execute_best_transactions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh thank you for clarifying

}
info.cumulative_gas_used += gas_used;

let ctx = ReceiptBuilderCtx {
Expand Down
1 change: 1 addition & 0 deletions crates/op-rbuilder/src/builders/flashblocks/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ where
flashblock_index: 0,
target_flashblock_count: self.config.flashblocks_per_block(),
},
max_gas_per_txn: self.config.max_gas_per_txn,
};

let state_provider = self.client.state_by_block_hash(ctx.parent().hash())?;
Expand Down
4 changes: 4 additions & 0 deletions crates/op-rbuilder/src/builders/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ pub struct BuilderConfig<Specific: Clone> {

/// Configuration values that are specific to the block builder implementation used.
pub specific: Specific,
/// Maximum gas a transaction can use before being excluded.
pub max_gas_per_txn: u64,
}

impl<S: Debug + Clone> core::fmt::Debug for BuilderConfig<S> {
Expand Down Expand Up @@ -145,6 +147,7 @@ impl<S: Default + Clone> Default for BuilderConfig<S> {
da_config: OpDAConfig::default(),
specific: S::default(),
sampling_ratio: 100,
max_gas_per_txn: 25_000,
}
}
}
Expand All @@ -164,6 +167,7 @@ where
block_time_leeway: Duration::from_secs(args.extra_block_deadline_secs),
da_config: Default::default(),
sampling_ratio: args.telemetry.sampling_ratio,
max_gas_per_txn: args.max_gas_per_txn,
specific: S::try_from(args)?,
})
}
Expand Down
1 change: 1 addition & 0 deletions crates/op-rbuilder/src/builders/standard/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ where
builder_signer: self.config.builder_signer,
metrics: self.metrics.clone(),
extra_ctx: Default::default(),
max_gas_per_txn: self.config.max_gas_per_txn,
};

let builder = OpBuilder::new(best);
Expand Down