diff --git a/miner/worker_builder.go b/miner/worker_builder.go index 83cbed01a8..54eb9f20bc 100644 --- a/miner/worker_builder.go +++ b/miner/worker_builder.go @@ -28,6 +28,8 @@ var ( // fillTransactions retrieves the pending bundles and transactions from the txpool and fills them // into the given sealing block. The selection and ordering strategy can be extended in the future. func (w *worker) fillTransactionsAndBundles(interruptCh chan int32, env *environment, stopTimer *time.Timer) error { + env.state.StopPrefetcher() // no need to prefetch txs for a builder + var ( localPlainTxs map[common.Address][]*txpool.LazyTransaction remotePlainTxs map[common.Address][]*txpool.LazyTransaction @@ -35,6 +37,31 @@ func (w *worker) fillTransactionsAndBundles(interruptCh chan int32, env *environ remoteBlobTxs map[common.Address][]*txpool.LazyTransaction bundles []*types.Bundle ) + + { + bundles = w.eth.TxPool().PendingBundles(env.header.Number.Uint64(), env.header.Time) + + // if no bundles, not necessary to fill transactions + if len(bundles) == 0 { + return errors.New("no bundles in bundle pool") + } + + log.Info("fill bundles and transactions", "bundles_count", len(bundles)) + + txs, bundle, err := w.generateOrderedBundles(env, bundles) + if err != nil { + log.Error("fail to generate ordered bundles", "err", err) + return err + } + + if err = w.commitBundles(env, txs, interruptCh, stopTimer); err != nil { + log.Error("fail to commit bundles", "err", err) + return err + } + + env.profit.Add(env.profit, bundle.EthSentToSystem) + } + { w.mu.RLock() tip := w.tip @@ -71,34 +98,8 @@ func (w *worker) fillTransactionsAndBundles(interruptCh chan int32, env *environ localBlobTxs[account] = txs } } - - bundles = w.eth.TxPool().PendingBundles(env.header.Number.Uint64(), env.header.Time) - - log.Info("fill bundles and transactions", "bundles_count", len(bundles), "plain_tx_count", len(localPlainTxs)+len(remotePlainTxs), "blob_tx_count", len(localBlobTxs)+len(remoteBlobTxs)) - - // if no bundles, not necessary to fill transactions - if len(bundles) == 0 { - return errors.New("no bundles in bundle pool") - } } - { - txs, bundle, err := w.generateOrderedBundles(env, bundles) - if err != nil { - log.Error("fail to generate ordered bundles", "err", err) - return err - } - - if err = w.commitBundles(env, txs, interruptCh, stopTimer); err != nil { - log.Error("fail to commit bundles", "err", err) - return err - } - - env.profit.Add(env.profit, bundle.EthSentToSystem) - } - - env.state.StopPrefetcher() // no need to prefetch txs for a builder - // Fill the block with all available pending transactions. // we will abort when: // 1.new block was imported @@ -107,6 +108,7 @@ func (w *worker) fillTransactionsAndBundles(interruptCh chan int32, env *environ // 4.interrupted resubmit timer, which is by default 10s. // resubmit is for PoW only, can be deleted for PoS consensus later if len(localPlainTxs) > 0 || len(localBlobTxs) > 0 { + log.Info("fill local transactions", "plain", len(localPlainTxs), "blob", len(localBlobTxs)) plainTxs := newTransactionsByPriceAndNonce(env.signer, localPlainTxs, env.header.BaseFee) blobTxs := newTransactionsByPriceAndNonce(env.signer, localBlobTxs, env.header.BaseFee) @@ -115,6 +117,7 @@ func (w *worker) fillTransactionsAndBundles(interruptCh chan int32, env *environ } } if len(remotePlainTxs) > 0 || len(remoteBlobTxs) > 0 { + log.Info("fill remote transactions", "plain", len(remotePlainTxs), "blob", len(remoteBlobTxs)) plainTxs := newTransactionsByPriceAndNonce(env.signer, remotePlainTxs, env.header.BaseFee) blobTxs := newTransactionsByPriceAndNonce(env.signer, remoteBlobTxs, env.header.BaseFee)