eip 1559 in miner (#2773)

This commit is contained in:
Alex Sharov 2021-10-04 19:47:52 +07:00 committed by GitHub
parent de16cb9e23
commit 044aa6748c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,7 @@ import (
"github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/common/debug"
"github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/consensus"
"github.com/ledgerwatch/erigon/consensus/misc"
"github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core"
"github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/types"
@ -210,11 +211,19 @@ func SpawnMiningCreateBlockStage(s *StageState, tx kv.RwTx, cfg MiningCreateBloc
header := &types.Header{ header := &types.Header{
ParentHash: parent.Hash(), ParentHash: parent.Hash(),
Number: num.Add(num, common.Big1), Number: num.Add(num, common.Big1),
GasLimit: core.CalcGasLimit(parent.GasUsed, parent.GasLimit, cfg.miner.MiningConfig.GasFloor, cfg.miner.MiningConfig.GasCeil),
Extra: cfg.miner.MiningConfig.ExtraData, Extra: cfg.miner.MiningConfig.ExtraData,
Time: uint64(timestamp), Time: uint64(timestamp),
} }
// Set baseFee and GasLimit if we are on an EIP-1559 chain
if cfg.chainConfig.IsLondon(header.Number.Uint64()) {
header.BaseFee = misc.CalcBaseFee(&cfg.chainConfig, parent)
if !cfg.chainConfig.IsLondon(parent.Number.Uint64()) {
parentGasLimit := parent.GasLimit * params.ElasticityMultiplier
header.GasLimit = core.CalcGasLimit(parent.GasUsed, parentGasLimit, cfg.miner.MiningConfig.GasFloor, cfg.miner.MiningConfig.GasCeil)
}
}
// Only set the coinbase if our consensus engine is running (avoid spurious block rewards) // Only set the coinbase if our consensus engine is running (avoid spurious block rewards)
//if w.isRunning() { //if w.isRunning() {
header.Coinbase = coinbase header.Coinbase = coinbase