metrics: optimize mev metrics#3082
Merged
zzzckck merged 1 commit intobnb-chain:developfrom May 12, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes MEV metrics reporting by refining error metrics in the bid simulation and disabling an inexact block metric counter.
- Removes the "block/from" metric incrementation in worker.go to avoid inaccurate block origin counts.
- Introduces a dedicated error (errBetterBid) in bid_simulator.go to prevent misreporting benign bid aborts.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| miner/worker.go | Removed unused variable "from" and the unreliable "block/from" metric incrementation line. |
| miner/bid_simulator.go | Added errBetterBid error and adjusted error handling to prevent spurious error reporting for better bids. |
Comments suppressed due to low confidence (2)
miner/worker.go:1450
- Removing this metric counter improves accuracy as discussed, but ensure that alternative on-chain metrics tracking is in place for monitoring block origins.
metrics.GetOrRegisterCounter(fmt.Sprintf("block/from/%v", from), nil).Inc(1)
miner/bid_simulator.go:57
- [nitpick] Consider rephrasing the error message for clarity, for example, 'simulation aborted due to a superior bid arriving'.
errBetterBid = errors.New("simulation abort due to better bid arrived")
galaio
approved these changes
May 12, 2025
zlacfzy
approved these changes
May 12, 2025
buddh0
approved these changes
May 12, 2025
This was referenced May 16, 2025
Merged
galaio
pushed a commit
to galaio/bsc
that referenced
this pull request
May 29, 2025
galaio
pushed a commit
to galaio/bsc
that referenced
this pull request
May 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
1.for metrics:
"bid/err/<...>"The error of "simulation abort due to better bid arrived" should not be taken as bid error, otherwise the metrics would be useless, as there would be lots of such kind of errors(hundreds per hour)
2.for metrics:
"block/from/<...>"a.it is inaccurate, as blocks that are committed in
commitWork()does not mean it is a valid one, it could be rejected later intaskLoop()as block seal failed, like:The most common case, would be it is triggered by the recommit timer, even unauthorized or recently signed validator could commitWork(), but failed to be failed.
b.it can be capture on chain
see: https://dune.com/bnbchain/bnb-smart-chain-mev-stats
Rationale
NA
Example
NA
Changes
NA