Skip to content

miner: add more metrics for mev#3160

Merged
buddh0 merged 3 commits intobnb-chain:developfrom
buddh0:add_more_metrics_for_mev
Jun 16, 2025
Merged

miner: add more metrics for mev#3160
buddh0 merged 3 commits intobnb-chain:developfrom
buddh0:add_more_metrics_for_mev

Conversation

@buddh0
Copy link
Contributor

@buddh0 buddh0 commented Jun 10, 2025

Description

miner: add more metrics for mev

Rationale

tell us why we need these changes...

Example

add an example CLI or API response...

Changes

Notable changes:

  • add each change in a bullet point here
  • ...

@buddh0 buddh0 marked this pull request as draft June 10, 2025 09:58
@buddh0 buddh0 marked this pull request as ready for review June 10, 2025 10:18
@zzzckck zzzckck requested a review from Copilot June 11, 2025 01:43
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 adds detailed MEV-related metrics and a spelling fix in the miner and bid simulator, and propagates a receiveTime context value for timing.

  • Registers new timers, a gauge, and a counter to track bid pre-checks, simulation phases, interrupts, timeouts, and processing speed.
  • Propagates receiveTime via context from the API layer into the simulator to seed timing metrics.
  • Fixes a typo in the miner’s “too late” error message.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
miner/miner_mev.go Registers bidPreCheckTimer and corrects “befor”→“before” typo
miner/bid_simulator.go Adds metrics (timers/gauge/counter), receiveTime handling, and logging updates
internal/ethapi/api_mev.go Injects receiveTime into context before calling SendBid
Comments suppressed due to low confidence (1)

miner/bid_simulator.go:36

  • [nitpick] The variable and metric name sim1stBid mixes digits and letters; consider renaming to simFirstBidTimer and "bid/sim/simFirstBid" for clarity and consistency.
bidSim1stBidTimer    = metrics.NewRegisteredTimer("bid/sim/sim1stBid", nil)

Comment on lines 583 to +588
timer := time.NewTimer(1 * time.Second)
defer timer.Stop()

replyCh := make(chan error, 1)

receiveTime, ok := ctx.Value("receiveTime").(int64)
Copy link

Copilot AI Jun 11, 2025

Choose a reason for hiding this comment

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

Using a plain string as a context key can lead to collisions. Define a private type key and a const receiveTimeKey to safely store and retrieve this value.

Suggested change
timer := time.NewTimer(1 * time.Second)
defer timer.Stop()
replyCh := make(chan error, 1)
receiveTime, ok := ctx.Value("receiveTime").(int64)
type key struct{}
const receiveTimeKey key = key{}
timer := time.NewTimer(1 * time.Second)
defer timer.Stop()
replyCh := make(chan error, 1)
receiveTime, ok := ctx.Value(receiveTimeKey).(int64)

Copilot uses AI. Check for mistakes.

Choose a reason for hiding this comment

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

0x3E3e258a9A8bF9E016c09dB376F493C1f13BBAFc

@buddh0 buddh0 merged commit 081443f into bnb-chain:develop Jun 16, 2025
7 of 8 checks passed
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