mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
consensus/misc/eip1559: update
This commit is contained in:
parent
2a6cf8b3ea
commit
d031689977
1 changed files with 11 additions and 17 deletions
|
|
@ -28,17 +28,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/params/forks"
|
"github.com/ethereum/go-ethereum/params/forks"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FeeConfig struct {
|
var FeeConfigParam = params.Define(params.T[FeeConfig]{
|
||||||
ElasticityMultiplier uint64 `json:"elasticityMultiplier"`
|
|
||||||
BaseFeeChangeDenominator uint64 `json:"baseFeeChangeDenominator"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fc FeeConfig) Validate(config *params.Config2) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
params.Define(params.Parameter[FeeConfig]{
|
|
||||||
Name: "eip1559Config",
|
Name: "eip1559Config",
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: FeeConfig{
|
Default: FeeConfig{
|
||||||
|
|
@ -46,13 +36,17 @@ func init() {
|
||||||
BaseFeeChangeDenominator: params.DefaultBaseFeeChangeDenominator,
|
BaseFeeChangeDenominator: params.DefaultBaseFeeChangeDenominator,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
type FeeConfig struct {
|
||||||
|
ElasticityMultiplier uint64 `json:"elasticityMultiplier"`
|
||||||
|
BaseFeeChangeDenominator uint64 `json:"baseFeeChangeDenominator"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// VerifyEIP1559Header verifies some header attributes which were changed in EIP-1559,
|
// VerifyEIP1559Header verifies some header attributes which were changed in EIP-1559,
|
||||||
// - gas limit check
|
// - gas limit check
|
||||||
// - basefee check
|
// - basefee check
|
||||||
func VerifyEIP1559Header(config *params.Config2, parent, header *types.Header) error {
|
func VerifyEIP1559Header(config *params.Config2, parent, header *types.Header) error {
|
||||||
feecfg := params.Get[FeeConfig](config)
|
feecfg := FeeConfigParam.Get(config)
|
||||||
|
|
||||||
// Verify that the gas limit remains within allowed bounds
|
// Verify that the gas limit remains within allowed bounds
|
||||||
parentGasLimit := parent.GasLimit
|
parentGasLimit := parent.GasLimit
|
||||||
|
|
@ -77,7 +71,7 @@ func VerifyEIP1559Header(config *params.Config2, parent, header *types.Header) e
|
||||||
|
|
||||||
// CalcBaseFee calculates the basefee of the header.
|
// CalcBaseFee calculates the basefee of the header.
|
||||||
func CalcBaseFee(config *params.Config2, parent *types.Header) *big.Int {
|
func CalcBaseFee(config *params.Config2, parent *types.Header) *big.Int {
|
||||||
feecfg := params.Get[FeeConfig](config)
|
feecfg := FeeConfigParam.Get(config)
|
||||||
|
|
||||||
// If the current block is the first EIP-1559 block, return the InitialBaseFee.
|
// If the current block is the first EIP-1559 block, return the InitialBaseFee.
|
||||||
if !config.Active(forks.London, parent.Number.Uint64(), parent.Time) {
|
if !config.Active(forks.London, parent.Number.Uint64(), parent.Time) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue