Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: temporarily reduce gaslimit when fill txs for builder block #64

Merged
merged 1 commit into from
Jan 7, 2025
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
5 changes: 0 additions & 5 deletions core/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,3 @@ 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
}
2 changes: 1 addition & 1 deletion miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,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.CalcGasLimitForBuilder(parent.GasLimit, miner.worker.config.GasCeil),
GasLimit: core.CalcGasLimit(parent.GasLimit, miner.worker.config.GasCeil),
Extra: miner.worker.extra,
Time: uint64(timestamp),
Coinbase: coinbase,
Expand Down
5 changes: 3 additions & 2 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1033,10 +1033,11 @@ 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.CalcGasLimitForBuilder(parent.GasLimit, w.config.GasCeil),
GasLimit: core.CalcGasLimit(parent.GasLimit, w.config.GasCeil),
Time: timestamp,
Coinbase: genParams.coinbase,
}

// Set the extra field.
if len(w.extra) != 0 {
header.Extra = w.extra
Expand All @@ -1050,7 +1051,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.CalcGasLimitForBuilder(parentGasLimit, w.config.GasCeil)
header.GasLimit = core.CalcGasLimit(parentGasLimit, w.config.GasCeil)
}
}
// Run the consensus preparation with the default or customized consensus engine.
Expand Down
8 changes: 8 additions & 0 deletions miner/worker_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ var (
func (w *worker) fillTransactionsAndBundles(interruptCh chan int32, env *environment, stopTimer *time.Timer) error {
env.state.StopPrefetcher() // no need to prefetch txs for a builder

// reduce gas limit for builder block
fullGasLimit := env.header.GasLimit
env.header.GasLimit /= 2

defer func() {
env.header.GasLimit = fullGasLimit
}()

var (
localPlainTxs map[common.Address][]*txpool.LazyTransaction
remotePlainTxs map[common.Address][]*txpool.LazyTransaction
Expand Down
Loading