Skip to content

feat(metrics): Add labels to tx simulation metrics#492

Open
avalonche wants to merge 2 commits into
mainfrom
feat/tx-simulation-metrics
Open

feat(metrics): Add labels to tx simulation metrics#492
avalonche wants to merge 2 commits into
mainfrom
feat/tx-simulation-metrics

Conversation

@avalonche
Copy link
Copy Markdown
Collaborator

Summary

Replaces the unlabeled op_rbuilder_tx_simulation_duration histogram with a labeled version under the same metric name, so we can break
down per-tx EVM simulation latency along the dimensions that matter for tuning the builder hot path:

  • source — bundle | mempool
  • result — success | revert
  • revert_protected — true | false (always false for mempool txs; for bundles, true when the tx hash isn't in the bundle's
    allowed-revert list)

Compatibility

The metric name is unchanged (op_rbuilder_tx_simulation_duration), but it now carries three labels.

@akundaz
Copy link
Copy Markdown
Contributor

akundaz commented May 5, 2026

Can you change source to differentiate backruns from bundles?

Also, can you do the same thing for gas used?

You can deprecate some metrics if you do this:

  • successful_tx_gas_used
  • reverted_tx_gas_used
    and maybe others that I'm not thinking of

@avalonche avalonche force-pushed the feat/tx-simulation-metrics branch from 516a5ee to 35f35fc Compare May 7, 2026 06:16
TxSource::Mempool => match tx_result {
TxResult::Revert => num_mempool_txs_simulated_revert += 1,
TxResult::Halt => num_mempool_txs_simulated_halt += 1,
TxResult::Success => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i think you can avoid the unreachable! invocations if you matched on TxResult instead of branching on result.is_success() above

let mut num_txs_simulated_success = 0;
let mut num_txs_simulated_fail = 0;
let mut num_bundles_reverted = 0;
let mut num_mempool_txs_simulated_success = 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just store all these in a hashmap or something so you just have one mutable variable for recording metrics. you wouldn't have so much repetitive code in set_payload_builder_metrics then either

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants