mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
save
This commit is contained in:
parent
f2ecd7a833
commit
0e200edf9b
4 changed files with 63 additions and 7 deletions
|
|
@ -117,6 +117,10 @@ var (
|
||||||
utils.MaxPendingPeersFlag,
|
utils.MaxPendingPeersFlag,
|
||||||
utils.MiningEnabledFlag, // deprecated
|
utils.MiningEnabledFlag, // deprecated
|
||||||
utils.MinerGasLimitFlag,
|
utils.MinerGasLimitFlag,
|
||||||
|
utils.MinerEIP7783BlockNumStartFlag,
|
||||||
|
utils.MinerEIP7783GasLimitCapFlag,
|
||||||
|
utils.MinerEIP7783IncreaseRateFlag,
|
||||||
|
utils.MinerEIP7783InitialGasLimitFlag,
|
||||||
utils.MinerGasPriceFlag,
|
utils.MinerGasPriceFlag,
|
||||||
utils.MinerEtherbaseFlag, // deprecated
|
utils.MinerEtherbaseFlag, // deprecated
|
||||||
utils.MinerExtraDataFlag,
|
utils.MinerExtraDataFlag,
|
||||||
|
|
|
||||||
|
|
@ -478,7 +478,30 @@ var (
|
||||||
MinerGasLimitFlag = &cli.Uint64Flag{
|
MinerGasLimitFlag = &cli.Uint64Flag{
|
||||||
Name: "miner.gaslimit",
|
Name: "miner.gaslimit",
|
||||||
Usage: "Target gas ceiling for mined blocks",
|
Usage: "Target gas ceiling for mined blocks",
|
||||||
Value: ethconfig.Defaults.Miner.GasCeil,
|
Category: flags.MinerCategory,
|
||||||
|
}
|
||||||
|
MinerEIP7783BlockNumStartFlag = &flags.BigFlag{
|
||||||
|
Name: "miner.eip7783.blocknumstart",
|
||||||
|
Usage: "The block number to start using EIP-7783 gas limit calculation",
|
||||||
|
Value: ethconfig.Defaults.Miner.EIP7783BlockNumStart,
|
||||||
|
Category: flags.MinerCategory,
|
||||||
|
}
|
||||||
|
MinerEIP7783InitialGasLimitFlag = &cli.Uint64Flag{
|
||||||
|
Name: "miner.eip7783.initialgaslimit",
|
||||||
|
Usage: "The initial gas limit to use before EIP-7783 calculation",
|
||||||
|
Value: ethconfig.Defaults.Miner.EIP7783InitialGasLimit,
|
||||||
|
Category: flags.MinerCategory,
|
||||||
|
}
|
||||||
|
MinerEIP7783IncreaseRateFlag = &cli.Uint64Flag{
|
||||||
|
Name: "miner.eip7783.increaserate",
|
||||||
|
Usage: "The rate of gas limit increase per block",
|
||||||
|
Value: ethconfig.Defaults.Miner.Eip7783IncreaseRate,
|
||||||
|
Category: flags.MinerCategory,
|
||||||
|
}
|
||||||
|
MinerEIP7783GasLimitCapFlag = &cli.Uint64Flag{
|
||||||
|
Name: "miner.eip7783.gaslimitcap",
|
||||||
|
Usage: "The maximum gas limit to use after EIP-7783 calculation",
|
||||||
|
Value: ethconfig.Defaults.Miner.EIP7783GasLimitCap,
|
||||||
Category: flags.MinerCategory,
|
Category: flags.MinerCategory,
|
||||||
}
|
}
|
||||||
MinerGasPriceFlag = &flags.BigFlag{
|
MinerGasPriceFlag = &flags.BigFlag{
|
||||||
|
|
@ -1553,8 +1576,22 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
|
||||||
cfg.ExtraData = []byte(ctx.String(MinerExtraDataFlag.Name))
|
cfg.ExtraData = []byte(ctx.String(MinerExtraDataFlag.Name))
|
||||||
}
|
}
|
||||||
if ctx.IsSet(MinerGasLimitFlag.Name) {
|
if ctx.IsSet(MinerGasLimitFlag.Name) {
|
||||||
cfg.GasCeil = ctx.Uint64(MinerGasLimitFlag.Name)
|
cfg.GasCeil = new(uint64)
|
||||||
|
*cfg.GasCeil = ctx.Uint64(MinerGasLimitFlag.Name)
|
||||||
}
|
}
|
||||||
|
if ctx.IsSet(MinerEIP7783BlockNumStartFlag.Name) {
|
||||||
|
cfg.EIP7783BlockNumStart = flags.GlobalBig(ctx, MinerEIP7783BlockNumStartFlag.Name)
|
||||||
|
}
|
||||||
|
if ctx.IsSet(MinerEIP7783GasLimitCapFlag.Name) {
|
||||||
|
cfg.EIP7783GasLimitCap = ctx.Uint64(MinerEIP7783GasLimitCapFlag.Name)
|
||||||
|
}
|
||||||
|
if ctx.IsSet(MinerEIP7783IncreaseRateFlag.Name) {
|
||||||
|
cfg.Eip7783IncreaseRate = ctx.Uint64(MinerEIP7783IncreaseRateFlag.Name)
|
||||||
|
}
|
||||||
|
if ctx.IsSet(MinerEIP7783InitialGasLimitFlag.Name) {
|
||||||
|
cfg.EIP7783InitialGasLimit = ctx.Uint64(MinerEIP7783InitialGasLimitFlag.Name)
|
||||||
|
}
|
||||||
|
|
||||||
if ctx.IsSet(MinerGasPriceFlag.Name) {
|
if ctx.IsSet(MinerGasPriceFlag.Name) {
|
||||||
cfg.GasPrice = flags.GlobalBig(ctx, MinerGasPriceFlag.Name)
|
cfg.GasPrice = flags.GlobalBig(ctx, MinerGasPriceFlag.Name)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,14 +45,20 @@ type Config struct {
|
||||||
Etherbase common.Address `toml:"-"` // Deprecated
|
Etherbase common.Address `toml:"-"` // Deprecated
|
||||||
PendingFeeRecipient common.Address `toml:"-"` // Address for pending block rewards.
|
PendingFeeRecipient common.Address `toml:"-"` // Address for pending block rewards.
|
||||||
ExtraData hexutil.Bytes `toml:",omitempty"` // Block extra data set by the miner
|
ExtraData hexutil.Bytes `toml:",omitempty"` // Block extra data set by the miner
|
||||||
GasCeil uint64 // Target gas ceiling for mined blocks.
|
GasCeil *uint64 // Target gas ceiling for mined blocks.
|
||||||
GasPrice *big.Int // Minimum gas price for mining a transaction
|
GasPrice *big.Int // Minimum gas price for mining a transaction
|
||||||
Recommit time.Duration // The time interval for miner to re-create mining work.
|
Recommit time.Duration // The time interval for miner to re-create mining work.
|
||||||
|
|
||||||
|
// EIP-7783 parameters
|
||||||
|
EIP7783BlockNumStart *big.Int // The block number to start using EIP-7783 gas limit calculation
|
||||||
|
EIP7783InitialGasLimit uint64 // The initial gas limit to use before EIP-7783 calculation
|
||||||
|
Eip7783IncreaseRate uint64 // The rate of gas limit increase per block
|
||||||
|
EIP7783GasLimitCap uint64 // The maximum gas limit to use after EIP-7783 calculation
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultConfig contains default settings for miner.
|
// DefaultConfig contains default settings for miner.
|
||||||
var DefaultConfig = Config{
|
var DefaultConfig = Config{
|
||||||
GasCeil: 30_000_000,
|
//GasCeil: 30_000_000,
|
||||||
GasPrice: big.NewInt(params.GWei / 1000),
|
GasPrice: big.NewInt(params.GWei / 1000),
|
||||||
|
|
||||||
// The default recommit time is chosen as two seconds since
|
// The default recommit time is chosen as two seconds since
|
||||||
|
|
@ -113,7 +119,8 @@ func (miner *Miner) SetExtra(extra []byte) error {
|
||||||
// For pre-1559 blocks, it sets the ceiling.
|
// For pre-1559 blocks, it sets the ceiling.
|
||||||
func (miner *Miner) SetGasCeil(ceil uint64) {
|
func (miner *Miner) SetGasCeil(ceil uint64) {
|
||||||
miner.confMu.Lock()
|
miner.confMu.Lock()
|
||||||
miner.config.GasCeil = ceil
|
miner.config.GasCeil = new(uint64)
|
||||||
|
*miner.config.GasCeil = ceil
|
||||||
miner.confMu.Unlock()
|
miner.confMu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
|
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
|
||||||
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
|
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
|
||||||
|
"github.com/ethereum/go-ethereum/consensus/misc/eip7783"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/core/stateless"
|
"github.com/ethereum/go-ethereum/core/stateless"
|
||||||
|
|
@ -171,11 +172,18 @@ func (miner *Miner) prepareWork(genParams *generateParams, witness bool) (*envir
|
||||||
}
|
}
|
||||||
timestamp = parent.Time + 1
|
timestamp = parent.Time + 1
|
||||||
}
|
}
|
||||||
|
useEip7783 := miner.config.GasCeil == nil
|
||||||
|
var gasLimit uint64
|
||||||
|
if useEip7783 {
|
||||||
|
gasLimit = eip7783.CalcGasLimitEIP7783(parent.Number, miner.config.EIP7783BlockNumStart, miner.config.EIP7783InitialGasLimit, miner.config.Eip7783IncreaseRate, miner.config.EIP7783GasLimitCap)
|
||||||
|
} else {
|
||||||
|
gasLimit = core.CalcGasLimit(parent.GasLimit, *miner.config.GasCeil)
|
||||||
|
}
|
||||||
// Construct the sealing block header.
|
// Construct the sealing block header.
|
||||||
header := &types.Header{
|
header := &types.Header{
|
||||||
ParentHash: parent.Hash(),
|
ParentHash: parent.Hash(),
|
||||||
Number: new(big.Int).Add(parent.Number, common.Big1),
|
Number: new(big.Int).Add(parent.Number, common.Big1),
|
||||||
GasLimit: core.CalcGasLimit(parent.GasLimit, miner.config.GasCeil),
|
GasLimit: gasLimit,
|
||||||
Time: timestamp,
|
Time: timestamp,
|
||||||
Coinbase: genParams.coinbase,
|
Coinbase: genParams.coinbase,
|
||||||
}
|
}
|
||||||
|
|
@ -192,7 +200,7 @@ func (miner *Miner) prepareWork(genParams *generateParams, witness bool) (*envir
|
||||||
header.BaseFee = eip1559.CalcBaseFee(miner.chainConfig, parent)
|
header.BaseFee = eip1559.CalcBaseFee(miner.chainConfig, parent)
|
||||||
if !miner.chainConfig.IsLondon(parent.Number) {
|
if !miner.chainConfig.IsLondon(parent.Number) {
|
||||||
parentGasLimit := parent.GasLimit * miner.chainConfig.ElasticityMultiplier()
|
parentGasLimit := parent.GasLimit * miner.chainConfig.ElasticityMultiplier()
|
||||||
header.GasLimit = core.CalcGasLimit(parentGasLimit, miner.config.GasCeil)
|
header.GasLimit = core.CalcGasLimit(parentGasLimit, gasLimit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Run the consensus preparation with the default or customized consensus engine.
|
// Run the consensus preparation with the default or customized consensus engine.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue