Skip to content

mev: no interrupt if it is too later#2971

Merged
zzzckck merged 9 commits intobnb-chain:develop_for_v1.5.8from
zzzckck:develop_for_v1.5.8_bid_interrupt
Mar 22, 2025
Merged

mev: no interrupt if it is too later#2971
zzzckck merged 9 commits intobnb-chain:develop_for_v1.5.8from
zzzckck:develop_for_v1.5.8_bid_interrupt

Conversation

@zzzckck
Copy link
Collaborator

@zzzckck zzzckck commented Mar 22, 2025

Description

This is an improvement to the current MEV logic, especially on large traffic to avoid too frequent bid interrupt that could lead to no bid can be simulated.

with 3s block interval, if there is a simulating bid and with a short time left for simulate, then don't interrupt the current simulating bid. The new bid will be pending and can still run once the current simulating bid completes

Rationale

NA

Example

NA

Changes

NA

zzzckck added 2 commits March 22, 2025 08:53
with 3s block interval, if there is a simulating bid and with a short time
left for simulate, then don't interrupt the current simulating bid. The new bid
will be pending and can still run once the current simulating bid completes
zzzckck added 2 commits March 22, 2025 15:12
no replyError if the bid has no time to interrupt
buddh0
buddh0 previously approved these changes Mar 22, 2025
@buddh0
Copy link
Contributor

buddh0 commented Mar 22, 2025

LGTM

@zzzckck zzzckck merged commit 0d07985 into bnb-chain:develop_for_v1.5.8 Mar 22, 2025
1 check passed
GasUsed uint64
GasFee *big.Int
BuilderFee *big.Int
Committed bool // whether the bid has been committed to simulate or not
Copy link
Contributor

@unclezoro unclezoro Mar 22, 2025

Choose a reason for hiding this comment

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

I strongly suggest that Committed to be lower case just like the rawBid, just to prevent that the external component inject a value to Committed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

accept, can be improved

const (
// maxBidPerBuilderPerBlock is the max bid number per builder
maxBidPerBuilderPerBlock = 3
NoInterruptTimeLeft = 400 * time.Millisecond
Copy link
Contributor

@unclezoro unclezoro Mar 22, 2025

Choose a reason for hiding this comment

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

This is not good to be a const, prefer it to be a config, but with default value with 400 * time.Millisecond. This will provider more flexability.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

accept, can be improved

replyErr = genDiscardedReply(simulatingBid)
// new bid will be discarded, as it is useless now.
toCommit = false
replyErr = genDiscardedReply(bidRuntime)
Copy link
Contributor

@unclezoro unclezoro Mar 22, 2025

Choose a reason for hiding this comment

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

seems generate a wrong reply to builders, as bidRuntime here is not a better bid, I mean the input should not be bidRuntime

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

accept, will update

func (b *bidSimulator) canBeInterrupted(targetTime uint64) bool {
if targetTime == 0 {
// invalid targetTime, disable the interrupt check
return true
Copy link
Contributor

@unclezoro unclezoro Mar 22, 2025

Choose a reason for hiding this comment

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

I think should return false here, this is the case where block header can not be find

} else {
replyErr = genDiscardedReply(simulatingBid)
// new bid will be discarded, as it is useless now.
toCommit = false
Copy link
Contributor

Choose a reason for hiding this comment

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

this will break the recommit logic, for a recommit bid, you will not do delBestBidToRun, the bidRuntime.isExpectedBetterThan(bestBidRuntime) will return false, bestBidToRun.Committed is ture, so code goes here, validator will report false issue to builder, and recommit wont work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the bidRuntime.isExpectedBetterThan(bestBidRuntime) will return false
== why? I think it will return true if recommit the same bid

@zzzckck zzzckck deleted the develop_for_v1.5.8_bid_interrupt branch May 14, 2025 06:11
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