Skip to content

Comments

metrics: optimize mev metrics#3082

Merged
zzzckck merged 1 commit intobnb-chain:developfrom
zzzckck:mev_metrics
May 12, 2025
Merged

metrics: optimize mev metrics#3082
zzzckck merged 1 commit intobnb-chain:developfrom
zzzckck:mev_metrics

Conversation

@zzzckck
Copy link
Collaborator

@zzzckck zzzckck commented May 12, 2025

Description

1.for metrics: "bid/err/<...>"

// reportIssue reports the issue to the mev-sentry
func (b *bidSimulator) reportIssue(bidRuntime *BidRuntime, err error) {
	metrics.GetOrRegisterCounter(fmt.Sprintf("bid/err/%v", bidRuntime.bid.Builder), nil).Inc(1)
        ...
}
image

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/<...>"

metrics.GetOrRegisterCounter(fmt.Sprintf("block/from/%v", from), nil).Inc(1)
image

a.it is inaccurate, as blocks that are committed in commitWork() does not mean it is a valid one, it could be rejected later in taskLoop() as block seal failed, like:

"Block sealing failed" err="unauthorized validator:<...>"

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

@zzzckck zzzckck requested a review from Copilot May 12, 2025 06:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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")

@zzzckck zzzckck merged commit 25da4b0 into bnb-chain:develop May 12, 2025
7 checks passed
@zzzckck zzzckck deleted the mev_metrics branch May 12, 2025 06:47
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
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.

4 participants