diff --git a/core/block_validator.go b/core/block_validator.go index b82965a99d..6a2c7d0a83 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -262,3 +262,8 @@ func CalcGasLimit(parentGasLimit, desiredLimit uint64) uint64 { } return limit } + +// CalcGasLimitForBuilder computes the gas limit of the next block. +func CalcGasLimitForBuilder(parentGasLimit, desiredLimit uint64) uint64 { + return CalcGasLimit(parentGasLimit, desiredLimit) / 2 +} diff --git a/miner/bidder.go b/miner/bidder.go index 3469775448..8c8da93fe3 100644 --- a/miner/bidder.go +++ b/miner/bidder.go @@ -119,11 +119,7 @@ func (b *Bidder) mainLoop() { betterBidBefore = bidutil.BidBetterBefore(parentHeader, b.chain.Config().Parlia.Period, b.delayLeftOver, bidSimulationLeftOver) - if time.Now().After(betterBidBefore) { - timer.Reset(0) - } else { - timer.Reset(time.Until(betterBidBefore) / time.Duration(maxBid)) - } + timer.Reset(0) } if bidNum < maxBid && b.isBestWork(work) { // update the bestWork and do bid diff --git a/miner/miner.go b/miner/miner.go index a6474bb694..f4d91c57e0 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -358,7 +358,7 @@ func (miner *Miner) prepareSimulationEnv(parent *types.Header, state *state.Stat header := &types.Header{ ParentHash: parent.Hash(), Number: new(big.Int).Add(parent.Number, common.Big1), - GasLimit: core.CalcGasLimit(parent.GasLimit, miner.worker.config.GasCeil), + GasLimit: core.CalcGasLimitForBuilder(parent.GasLimit, miner.worker.config.GasCeil), Extra: miner.worker.extra, Time: uint64(timestamp), Coinbase: miner.worker.etherbase(), diff --git a/miner/worker.go b/miner/worker.go index 884453b721..4818ca414d 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1017,7 +1017,7 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) { header := &types.Header{ ParentHash: parent.Hash(), Number: new(big.Int).Add(parent.Number, common.Big1), - GasLimit: core.CalcGasLimit(parent.GasLimit, w.config.GasCeil), + GasLimit: core.CalcGasLimitForBuilder(parent.GasLimit, w.config.GasCeil), Time: timestamp, Coinbase: genParams.coinbase, } @@ -1034,7 +1034,7 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) { header.BaseFee = eip1559.CalcBaseFee(w.chainConfig, parent) if w.chainConfig.Parlia == nil && !w.chainConfig.IsLondon(parent.Number) { parentGasLimit := parent.GasLimit * w.chainConfig.ElasticityMultiplier() - header.GasLimit = core.CalcGasLimit(parentGasLimit, w.config.GasCeil) + header.GasLimit = core.CalcGasLimitForBuilder(parentGasLimit, w.config.GasCeil) } } // Run the consensus preparation with the default or customized consensus engine. diff --git a/miner/worker_builder.go b/miner/worker_builder.go index fdd41752c9..e8d0d7711f 100644 --- a/miner/worker_builder.go +++ b/miner/worker_builder.go @@ -20,6 +20,8 @@ import ( "github.com/ethereum/go-ethereum/params" ) +const smallBundleGas = 10 * params.TxGas + var ( errNonRevertingTxInBundleFailed = errors.New("non-reverting tx in bundle failed") errBundlePriceTooLow = errors.New("bundle price too low") @@ -349,6 +351,11 @@ func (w *worker) mergeBundles( } for _, bundle := range bundles { + // if we don't have enough gas for any further transactions then we're done + if gasPool.Gas() < smallBundleGas { + break + } + prevState := currentState.Copy() prevGasPool := new(core.GasPool).AddGas(gasPool.Gas())