Skip to content

Commit d3ab38b

Browse files
committed
fix metrics
1 parent ebe3850 commit d3ab38b

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

crates/op-rbuilder/src/payload_builder.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -398,17 +398,17 @@ where
398398
.build();
399399

400400
let mut info = execute_pre_steps(&mut db, &ctx)?;
401-
ctx.metrics
401+
self.metrics
402402
.sequencer_tx_duration
403403
.record(sequencer_tx_start_time.elapsed());
404404

405-
let (payload, fb_payload, mut bundle_state) = build_block(db, &ctx, &mut info)?;
405+
let (payload, fb_payload, mut bundle_state) = build_block(db, &ctx, &mut info, &self.metrics)?;
406406

407407
best_payload.set(payload.clone());
408408
let _ = self.send_message(serde_json::to_string(&fb_payload).unwrap_or_default());
409409

410410
tracing::info!(target: "payload_builder", "Fallback block built");
411-
ctx.metrics
411+
self.metrics
412412
.payload_num_tx
413413
.record(info.executed_transactions.len() as f64);
414414

@@ -517,7 +517,7 @@ where
517517
self.pool
518518
.best_transactions_with_attributes(ctx.best_transaction_attributes()),
519519
);
520-
ctx.metrics
520+
self.metrics
521521
.transaction_pool_fetch_duration
522522
.record(best_txs_start_time.elapsed());
523523

@@ -528,7 +528,7 @@ where
528528
best_txs,
529529
total_gas_per_batch.min(ctx.block_gas_limit()),
530530
)?;
531-
ctx.metrics
531+
self.metrics
532532
.payload_tx_simulation_duration
533533
.record(tx_execution_start_time.elapsed());
534534

@@ -542,8 +542,8 @@ where
542542
}
543543

544544
let total_block_built_duration = Instant::now();
545-
let build_result = build_block(db, &ctx, &mut info);
546-
ctx.metrics
545+
let build_result = build_block(db, &ctx, &mut info, &self.metrics);
546+
self.metrics
547547
.total_block_built_duration
548548
.record(total_block_built_duration.elapsed());
549549

@@ -570,10 +570,10 @@ where
570570
self.metrics
571571
.flashblock_build_duration
572572
.record(flashblock_build_start_time.elapsed());
573-
ctx.metrics
573+
self.metrics
574574
.payload_byte_size
575575
.record(new_payload.block().size() as f64);
576-
ctx.metrics
576+
self.metrics
577577
.payload_num_tx
578578
.record(info.executed_transactions.len() as f64);
579579

@@ -620,6 +620,7 @@ pub fn build_block<ChainSpec, DB, P>(
620620
mut state: State<DB>,
621621
ctx: &OpPayloadBuilderCtx<ChainSpec>,
622622
info: &mut ExecutionInfo<OpPrimitives>,
623+
metrics: &OpRBuilderMetrics,
623624
) -> Result<(OpBuiltPayload, FlashblocksPayloadV1, BundleState), PayloadBuilderError>
624625
where
625626
ChainSpec: EthChainSpec + OpHardforks,
@@ -631,7 +632,7 @@ where
631632
// and 4788 contract call
632633
let state_merge_start_time = Instant::now();
633634
state.merge_transitions(BundleRetention::Reverts);
634-
ctx.metrics
635+
metrics
635636
.state_transition_merge_duration
636637
.record(state_merge_start_time.elapsed());
637638

@@ -677,7 +678,7 @@ where
677678
);
678679
})?
679680
};
680-
ctx.metrics
681+
metrics
681682
.state_root_calculation_duration
682683
.record(state_root_start_time.elapsed());
683684

0 commit comments

Comments
 (0)