diff --git a/miner/bid_simulator.go b/miner/bid_simulator.go index baa2c9c1c5..50d74e576d 100644 --- a/miner/bid_simulator.go +++ b/miner/bid_simulator.go @@ -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) diff --git a/miner/worker.go b/miner/worker.go index 6a32188484..261596ad09 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -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 @@ -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. @@ -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 {