Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft release v1.4.9 #2511

Merged
merged 20 commits into from
Jun 11, 2024
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0c0958f
eth/handler: check lists in body before broadcast blocks (#2461)
NathanBSC May 15, 2024
86e3a02
cmd/utils: add a flag to change breathe block interval for testing (#…
NathanBSC May 15, 2024
b230a02
cmd: fix memory leak when big dataset (#2455)
fynnss May 15, 2024
5ea2ada
utils: add check_blobtx.js (#2463)
setunapo May 15, 2024
6b8cbbe
sync: fix some sync issues caused by prune-block. (#2466)
galaio May 16, 2024
5edd032
internal/ethapi: add optional parameter for blobSidecars (#2467)
zlacfzy May 16, 2024
c856d21
fix: move mev op to MinerAPI & add command to console (#2475)
Jolly23 May 20, 2024
c77bb11
fix: limit the gas price of the mev bid (#2473)
irrun May 20, 2024
08769ea
dev: ensure consistency in BPS bundle result (#2479)
Jolly23 May 21, 2024
d7b9866
Merge pull request #2487 from bnb-chain/master
brilliant-lx May 22, 2024
b014626
jsutils: faucet successful requests within blocks (#2470)
emailtovamos May 23, 2024
05543e5
fix: fix inspect database error (#2484)
jingjunLi May 27, 2024
63e7eac
fix: keep 9W blocks in ancient db when prune block (#2481)
jingjunLi May 29, 2024
8b9558b
params/config: add Bohr hardfork (#2497)
NathanBSC May 30, 2024
6b02ac7
doc: update url linker (#2498)
zzzckck May 30, 2024
35e71a7
doc: update url linker (#2499)
zzzckck May 30, 2024
9bb4fed
fix: add an empty freeze db (#2495)
sysvm Jun 4, 2024
1047f0e
chore: fix function name (#2501)
zoupingshi Jun 5, 2024
af7e9b9
fix: waiting for the last simulation before pick best bid (#2507)
irrun Jun 7, 2024
aab4b88
release: prepare for release v1.4.9 (#2510)
zzzckck Jun 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: waiting for the last simulation before pick best bid (#2507)
irrun authored Jun 7, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit af7e9b95bda2fb90faead2db2d5c728529c4d7eb
40 changes: 13 additions & 27 deletions miner/bid_simulator.go
Original file line number Diff line number Diff line change
@@ -29,11 +29,6 @@ import (
const (
// maxBidPerBuilderPerBlock is the max bid number per builder
maxBidPerBuilderPerBlock = 3

// leftOverTimeRate is the rate of left over time to simulate a bid
leftOverTimeRate = 11
// leftOverTimeScale is the scale of left over time to simulate a bid
leftOverTimeScale = 10
)

var (
@@ -318,18 +313,6 @@ func (b *bidSimulator) newBidLoop() {

// commit aborts in-flight bid execution with given signal and resubmits a new one.
commit := func(reason int32, bidRuntime *BidRuntime) {
// if the left time is not enough to do simulation, return
var simDuration time.Duration
if lastBid := b.GetBestBid(bidRuntime.bid.ParentHash); lastBid != nil && lastBid.duration != 0 {
simDuration = lastBid.duration
}

if time.Until(b.bidMustBefore(bidRuntime.bid.ParentHash)) <= simDuration*leftOverTimeRate/leftOverTimeScale {
log.Debug("BidSimulator: abort commit, not enough time to simulate",
"builder", bidRuntime.bid.Builder, "bidHash", bidRuntime.bid.Hash().Hex())
return
}

if interruptCh != nil {
// each commit work will have its own interruptCh to stop work with a reason
interruptCh <- reason
@@ -370,6 +353,7 @@ func (b *bidSimulator) newBidLoop() {
expectedValidatorReward: expectedValidatorReward,
packedBlockReward: big.NewInt(0),
packedValidatorReward: big.NewInt(0),
finished: make(chan struct{}),
}

simulatingBid := b.GetSimulatingBid(newBid.ParentHash)
@@ -410,11 +394,6 @@ func (b *bidSimulator) newBidLoop() {
}
}

func (b *bidSimulator) bidMustBefore(parentHash common.Hash) time.Time {
parentHeader := b.chain.GetHeaderByHash(parentHash)
return bidutil.BidMustBefore(parentHeader, b.chainConfig.Parlia.Period, b.delayLeftOver)
}

func (b *bidSimulator) bidBetterBefore(parentHash common.Hash) time.Time {
parentHeader := b.chain.GetHeaderByHash(parentHash)
return bidutil.BidBetterBefore(parentHeader, b.chainConfig.Parlia.Period, b.delayLeftOver, b.config.BidSimulationLeftOver)
@@ -530,7 +509,6 @@ func (b *bidSimulator) simBid(interruptCh chan int32, bidRuntime *BidRuntime) {

// ensure simulation exited then start next simulation
b.SetSimulatingBid(parentHash, bidRuntime)
start := time.Now()

defer func(simStart time.Time) {
logCtx := []any{
@@ -556,10 +534,11 @@ func (b *bidSimulator) simBid(interruptCh chan int32, bidRuntime *BidRuntime) {
}

b.RemoveSimulatingBid(parentHash)
bidSimTimer.UpdateSince(start)
close(bidRuntime.finished)

if success {
bidRuntime.duration = time.Since(simStart)
bidSimTimer.UpdateSince(simStart)

// only recommit self bid when newBidCh is empty
if len(b.newBidCh) > 0 {
@@ -583,6 +562,14 @@ func (b *bidSimulator) simBid(interruptCh chan int32, bidRuntime *BidRuntime) {
return
}

// if the left time is not enough to do simulation, return
delay := b.engine.Delay(b.chain, bidRuntime.env.header, &b.delayLeftOver)
if delay == nil || *delay <= 0 {
log.Info("BidSimulator: abort commit, not enough time to simulate",
"builder", bidRuntime.bid.Builder, "bidHash", bidRuntime.bid.Hash().Hex())
return
}

gasLimit := bidRuntime.env.header.GasLimit
if bidRuntime.env.gasPool == nil {
bidRuntime.env.gasPool = new(core.GasPool).AddGas(gasLimit)
@@ -650,14 +637,12 @@ func (b *bidSimulator) simBid(interruptCh chan int32, bidRuntime *BidRuntime) {
if b.config.GreedyMergeTx {
delay := b.engine.Delay(b.chain, bidRuntime.env.header, &b.delayLeftOver)
if delay != nil && *delay > 0 {
stopTimer := time.NewTimer(*delay)

bidTxsSet := mapset.NewSet[common.Hash]()
for _, tx := range bidRuntime.bid.Txs {
bidTxsSet.Add(tx.Hash())
}

fillErr := b.bidWorker.fillTransactions(interruptCh, bidRuntime.env, stopTimer, bidTxsSet)
fillErr := b.bidWorker.fillTransactions(interruptCh, bidRuntime.env, nil, bidTxsSet)
log.Trace("BidSimulator: greedy merge stopped", "block", bidRuntime.env.header.Number,
"builder", bidRuntime.bid.Builder, "tx count", bidRuntime.env.tcount-bidTxLen+1, "err", fillErr)

@@ -733,6 +718,7 @@ type BidRuntime struct {
packedBlockReward *big.Int
packedValidatorReward *big.Int

finished chan struct{}
duration time.Duration
}

13 changes: 13 additions & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
@@ -67,6 +67,9 @@ const (
// the current 4 mining loops could have asynchronous risk of mining block with
// save height, keep recently mined blocks to avoid double sign for safety,
recentMinedCacheLimit = 20

// the default to wait for the mev miner to finish
waitMEVMinerEndTimeLimit = 50 * time.Millisecond
)

var (
@@ -171,6 +174,7 @@ type getWorkReq struct {

type bidFetcher interface {
GetBestBid(parentHash common.Hash) *BidRuntime
GetSimulatingBid(prevBlockHash common.Hash) *BidRuntime
}

// worker is the main object which takes care of submitting new work to consensus engine
@@ -1336,6 +1340,15 @@ LOOP:
// when in-turn, compare with remote work.
from := bestWork.coinbase
if w.bidFetcher != nil && bestWork.header.Difficulty.Cmp(diffInTurn) == 0 {
if pendingBid := w.bidFetcher.GetSimulatingBid(bestWork.header.ParentHash); pendingBid != nil {
waitBidTimer := time.NewTimer(waitMEVMinerEndTimeLimit)
defer waitBidTimer.Stop()
select {
case <-waitBidTimer.C:
case <-pendingBid.finished:
}
}

bestBid := w.bidFetcher.GetBestBid(bestWork.header.ParentHash)

if bestBid != nil {