Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions miner/bid_simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,14 +670,17 @@ func (b *bidSimulator) simBid(interruptCh chan int32, bidRuntime *BidRuntime) {

// if enable greedy merge, fill bid env with transactions from mempool
if b.config.GreedyMergeTx {
delay := b.engine.Delay(b.chain, bidRuntime.env.header, &b.delayLeftOver)
endingBidsExtra := 20 * time.Millisecond // Add a buffer to ensure ending bids before `delayLeftOver`
minTimeLeftForEndingBids := b.delayLeftOver + endingBidsExtra
delay := b.engine.Delay(b.chain, bidRuntime.env.header, &minTimeLeftForEndingBids)
if delay != nil && *delay > 0 {
bidTxsSet := mapset.NewThreadUnsafeSetWithSize[common.Hash](len(bidRuntime.bid.Txs))
for _, tx := range bidRuntime.bid.Txs {
bidTxsSet.Add(tx.Hash())
}

fillErr := b.bidWorker.fillTransactions(interruptCh, bidRuntime.env, nil, bidTxsSet)
stopTimer := time.NewTimer(*delay)
defer stopTimer.Stop()
fillErr := b.bidWorker.fillTransactions(interruptCh, bidRuntime.env, stopTimer, 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)

Expand Down
16 changes: 2 additions & 14 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ const (
// 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

// Reserve block size for the following 3 components:
// a. System transactions at the end of the block
// b. Seal in the block header
Expand Down Expand Up @@ -1403,8 +1400,8 @@ LOOP:
// We want to start sealing the block as late as possible here if mev is enabled, so we could give builder the chance to send their final bid.
// Time left till sealing the block.
tillSealingTime := time.Until(time.Unix(int64(bestWork.header.Time), 0)) - w.config.DelayLeftOver
if tillSealingTime > max(100*time.Millisecond, w.config.DelayLeftOver) {
// Still a lot of time left, wait for the best bid.
if tillSealingTime > 0 {
// Still some time left, wait for the best bid.
// This happens during the peak time of the network, the local block building LOOP would break earlier than
// the final sealing time by meeting the errBlockInterruptedByOutOfGas criteria.

Expand All @@ -1418,15 +1415,6 @@ LOOP:
}
}

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 {
Expand Down