Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.
Merged
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
39 changes: 24 additions & 15 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,12 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
// If sealing is running resubmit a new work cycle periodically to pull in
// higher priced transactions. Disable this overhead for pending blocks.
if w.isRunning() && (w.chainConfig.Clique == nil || w.chainConfig.Clique.Period > 0) {
// flashbots: disable this because there can be new bundles
// Short circuit if no new transaction arrives.
if atomic.LoadInt32(&w.newTxs) == 0 {
timer.Reset(recommit)
continue
}
//if atomic.LoadInt32(&w.newTxs) == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this necessary?
I'm not sure if anything depends on this in PoS.
There's been a recent change that allows "no tx" blocks to be built

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is a good thing to have, otherwise to commit bundles you must have txs around and that makes some type of testing more hard. Also its more correct because this code does not know about bundles and assumes that if there are no txs then there is no way to create a non-empty block.

I don't think that this matters in PoS.

  1. It may matter only if people use our builder as a primary node for CL + EL setup. If we use this node as a builder this code is never called.
  2. Even then I don't think this matters because this is only short-circuit, meaning that in the absence of bugs in the sealing code the same output should happen but after some steps. E.g. if its prohibited by consensus to a real empty block then it should error in another place.

// timer.Reset(recommit)
// continue
//}
commit(true, commitInterruptResubmit)
}

Expand Down Expand Up @@ -1289,6 +1290,23 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) {
return env, nil
}

func (w *worker) fillTransactionsSelectAlgo(interrupt *int32, env *environment) (error, []types.SimulatedBundle, []types.SimulatedBundle) {
var (
blockBundles []types.SimulatedBundle
allBundles []types.SimulatedBundle
err error
)
switch w.flashbots.algoType {
case ALGO_GREEDY:
err, blockBundles, allBundles = w.fillTransactionsAlgoWorker(interrupt, env)
case ALGO_MEV_GETH:
err, blockBundles, allBundles = w.fillTransactions(interrupt, env)
default:
err, blockBundles, allBundles = w.fillTransactions(interrupt, env)
}
return err, blockBundles, allBundles
}

// fillTransactions retrieves the pending transactions from the txpool and fills them
// into the given sealing block. The transaction selection and ordering strategy can
// be customized with the plugin in the future.
Expand Down Expand Up @@ -1420,17 +1438,8 @@ func (w *worker) generateWork(params *generateParams) (*types.Block, error) {
return nil, err
}

var blockBundles []types.SimulatedBundle
var allBundles []types.SimulatedBundle
orderCloseTime := time.Now()
switch w.flashbots.algoType {
case ALGO_GREEDY:
err, blockBundles, allBundles = w.fillTransactionsAlgoWorker(nil, work)
case ALGO_MEV_GETH:
err, blockBundles, allBundles = w.fillTransactions(nil, work)
default:
err, blockBundles, allBundles = w.fillTransactions(nil, work)
}
err, blockBundles, allBundles := w.fillTransactionsSelectAlgo(nil, work)

if err != nil {
return nil, err
Expand Down Expand Up @@ -1524,7 +1533,7 @@ func (w *worker) commitWork(interrupt *int32, noempty bool, timestamp int64) {
}

// Fill pending transactions from the txpool
err, _, _ = w.fillTransactions(interrupt, work)
err, _, _ = w.fillTransactionsSelectAlgo(interrupt, work)
if err != nil && !errors.Is(err, errBlockInterruptedByRecommit) {
work.discard()
return
Expand Down