Skip to content

Commit 7991456

Browse files
committed
fix tests
1 parent dd46eb1 commit 7991456

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

crates/op-rbuilder/src/builders/builder_tx.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub trait BuilderTransactions<ExtraCtx: Debug + Default = ()>: Debug {
8383
info: &mut ExecutionInfo<Extra>,
8484
builder_ctx: &OpPayloadBuilderCtx<ExtraCtx>,
8585
db: &mut State<impl Database>,
86-
) -> Result<(), BuilderTransactionError> {
86+
) -> Result<Vec<BuilderTransactionCtx>, BuilderTransactionError> {
8787
{
8888
let mut evm = builder_ctx
8989
.evm_config
@@ -93,7 +93,7 @@ pub trait BuilderTransactions<ExtraCtx: Debug + Default = ()>: Debug {
9393

9494
let builder_txs =
9595
self.simulate_builder_txs(state_provider, info, builder_ctx, evm.db_mut())?;
96-
for builder_tx in builder_txs {
96+
for builder_tx in builder_txs.iter() {
9797
if invalid.contains(&builder_tx.signed_tx.signer()) {
9898
debug!(target: "payload_builder", tx_hash = ?builder_tx.signed_tx.tx_hash(), "builder signer invalid as previous builder tx reverted");
9999
continue;
@@ -128,13 +128,13 @@ pub trait BuilderTransactions<ExtraCtx: Debug + Default = ()>: Debug {
128128
// Append sender and transaction to the respective lists
129129
info.executed_senders.push(builder_tx.signed_tx.signer());
130130
info.executed_transactions
131-
.push(builder_tx.signed_tx.into_inner());
131+
.push(builder_tx.signed_tx.clone().into_inner());
132132
}
133133

134134
// Release the db reference by dropping evm
135135
drop(evm);
136136

137-
Ok(())
137+
Ok(builder_txs)
138138
}
139139
}
140140

crates/op-rbuilder/src/builders/flashblocks/payload.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,11 @@ where
282282
ctx.metrics.sequencer_tx_gauge.set(sequencer_tx_time);
283283

284284
// If we have payload with txpool we add first builder tx right after deposits
285-
self.builder_tx
286-
.add_builder_txs(&state_provider, &mut info, &ctx, &mut db)?;
285+
let builder_txs =
286+
self.builder_tx
287+
.add_builder_txs(&state_provider, &mut info, &ctx, &mut db)?;
287288

288289
// We subtract gas limit and da limit for builder transaction from the whole limit
289-
let builder_txs = self
290-
.builder_tx
291-
.simulate_builder_txs(&state_provider, &mut info, &ctx, &mut db)
292-
.map_err(|err| PayloadBuilderError::Other(Box::new(err)))?;
293290
let builder_tx_gas = builder_txs.iter().fold(0, |acc, tx| acc + tx.gas_used);
294291
let builder_tx_da_size: u64 = builder_txs.iter().fold(0, |acc, tx| acc + tx.da_size);
295292

@@ -430,19 +427,28 @@ where
430427
);
431428
let flashblock_build_start_time = Instant::now();
432429
let state = StateProviderDatabase::new(&state_provider);
430+
let mut db = State::builder()
431+
.with_database(state)
432+
.with_bundle_update()
433+
.with_bundle_prestate(bundle_state.clone())
434+
.build();
435+
436+
let builder_txs = self.builder_tx.simulate_builder_txs(
437+
&state_provider,
438+
&mut info,
439+
&ctx,
440+
&mut db,
441+
)?;
442+
let builder_tx_gas = builder_txs.iter().fold(0, |acc, tx| acc + tx.gas_used);
443+
let builder_tx_da_size: u64 =
444+
builder_txs.iter().fold(0, |acc, tx| acc + tx.da_size);
433445

434446
total_gas_per_batch = total_gas_per_batch.saturating_sub(builder_tx_gas);
435447
// saturating sub just in case, we will log an error if da_limit too small for builder_tx_da_size
436448
if let Some(da_limit) = total_da_per_batch.as_mut() {
437449
*da_limit = da_limit.saturating_sub(builder_tx_da_size);
438450
}
439451

440-
let mut db = State::builder()
441-
.with_database(state)
442-
.with_bundle_update()
443-
.with_bundle_prestate(bundle_state.clone())
444-
.build();
445-
446452
let best_txs_start_time = Instant::now();
447453
let best_txs = BestPayloadTransactions::new(
448454
// We are not using without_updates in here, so arriving transaction could target the current block

0 commit comments

Comments
 (0)