Skip to content

Commit

Permalink
consensus/misc, core, core/vm: disabled EIP-1559 & EIP-3198, fixed --…
Browse files Browse the repository at this point in the history
…override.london option to include berlin as well
  • Loading branch information
sadoci committed Feb 25, 2022
1 parent 579c759 commit 892bb78
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions consensus/misc/eip1559.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core/types"
metaminer "github.com/ethereum/go-ethereum/metadium/miner"
"github.com/ethereum/go-ethereum/params"
)

// VerifyEip1559Header verifies some header attributes which were changed in EIP-1559,
// - gas limit check
// - basefee check
func VerifyEip1559Header(config *params.ChainConfig, parent, header *types.Header) error {
// Metadium: eip-1559 is inactive
if !metaminer.IsPoW() {
return nil
}
// Verify that the gas limit remains within allowed bounds
parentGasLimit := parent.GasLimit
if !config.IsLondon(parent.Number) {
Expand All @@ -53,6 +58,10 @@ func VerifyEip1559Header(config *params.ChainConfig, parent, header *types.Heade

// CalcBaseFee calculates the basefee of the header.
func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
// Metadium: eip-1559 is inactive
if !metaminer.IsPoW() {
return new(big.Int).SetUint64(0)
}
// If the current block is the first EIP-1559 block, return the InitialBaseFee.
if !config.IsLondon(parent.Number) {
return new(big.Int).SetUint64(params.InitialBaseFee)
Expand Down
5 changes: 5 additions & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, override
// Get the existing chain configuration.
newcfg := genesis.configOrDefault(stored)
if overrideLondon != nil {
newcfg.BerlinBlock = overrideLondon
newcfg.LondonBlock = overrideLondon
}
if err := newcfg.CheckConfigForkOrder(); err != nil {
Expand All @@ -218,6 +219,10 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, override
rawdb.WriteChainConfig(db, stored, newcfg)
return newcfg, stored, nil
}
if overrideLondon != nil {
storedcfg.BerlinBlock = overrideLondon
storedcfg.LondonBlock = overrideLondon
}
// Special case: don't change the existing config of a non-mainnet chain if no new
// config is supplied. These chains would get AllProtocolChanges (and a compat error)
// if we just continued here.
Expand Down
6 changes: 5 additions & 1 deletion core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package vm

import (
metaminer "github.com/ethereum/go-ethereum/metadium/miner"
"github.com/ethereum/go-ethereum/params"
)

Expand Down Expand Up @@ -68,7 +69,10 @@ type JumpTable [256]*operation
func newLondonInstructionSet() JumpTable {
instructionSet := newBerlinInstructionSet()
enable3529(&instructionSet) // EIP-3529: Reduction in refunds https://eips.ethereum.org/EIPS/eip-3529
enable3198(&instructionSet) // Base fee opcode https://eips.ethereum.org/EIPS/eip-3198
// Metadium: eip-3198 is inactive
if metaminer.IsPoW() {
enable3198(&instructionSet) // Base fee opcode https://eips.ethereum.org/EIPS/eip-3198
}
return instructionSet
}

Expand Down

0 comments on commit 892bb78

Please sign in to comment.