add metrics to track gas used by reverting txs#273
Conversation
| if result.is_success() { | ||
| log_txn(TxnExecutionResult::Success); | ||
| num_txs_simulated_success += 1; | ||
| self.metrics.successful_tx_gas_used.record(gas_used as f64); |
There was a problem hiding this comment.
does this not need reverted_gas_used += gas_used?
There was a problem hiding this comment.
no i'm only tracking reverted gas when the tx reverts
There was a problem hiding this comment.
sorry I meant successful_tx_gas_used += gas_used
There was a problem hiding this comment.
that would calculate the cumulative gas used by successful txs in a block. reth already tracks this in the reth_sync_execution_gas_processed_total metrics. successful_tx_gas_used is a histogram metric so it will tell us what the distribution of gas looks like used by each tx
| } | ||
|
|
||
| impl OpRBuilderMetrics { | ||
| #[expect(clippy::too_many_arguments)] |
There was a problem hiding this comment.
can group these metrics as a struct instead of adding more args
There was a problem hiding this comment.
do you mean a type where each field is one of these args? i'm not sure that's a good idea it would introduce more complexity than just having the directive to ignore the lint here
📝 Summary
So we have a good idea of how much execution resources is taken up by reverting txs
💡 Motivation and Context
Unfortunately reth only tracks gas used by blocks, which isn't accurate for us since we don't include reverting txs in the block: https://github.com/paradigmxyz/reth/blob/main/crates/evm/evm/src/metrics.rs
✅ I have completed the following steps:
make lintmake test