Skip to content

Commit

Permalink
Merge pull request ethereum#36 from etclabscore/fix/eip2200-sload-gas…
Browse files Browse the repository at this point in the history
…-again

Fix/eip2200 sload gas again (and ECIP1086 nullified)
  • Loading branch information
meowsbits authored Feb 27, 2020
2 parents 93d8581 + db2e8c5 commit 7cd60ae
Show file tree
Hide file tree
Showing 14 changed files with 3 additions and 169 deletions.
12 changes: 1 addition & 11 deletions core/vm/eips.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ func enableSelfBalance(jt *JumpTable) {
// - Define SELFBALANCE, with cost GasFastStep (5)
func enable1884(jt *JumpTable) {
// Gas cost changes
jt[SLOAD].constantGas = vars.SloadGasEIP1884
jt[BALANCE].constantGas = vars.BalanceGasEIP1884
jt[EXTCODEHASH].constantGas = vars.ExtcodeHashGasEIP1884
jt[SLOAD].constantGas = vars.SloadGasEIP1884

// New opcode
enableSelfBalance(jt)
Expand Down Expand Up @@ -90,17 +90,7 @@ func opChainID(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memo
return nil, nil
}

// enable2200Sloppy applies EIP-2200 (Rebalance net-metered SSTORE)
// WITHOUT IMPLEMENTING THE GAS REPRICING FOR SLOAD OPCODE.
func enable2200Sloppy(jt *JumpTable) {
// This value is wrong on purpose; it makes the "sloppiness" explicit.
jt[SLOAD].constantGas = vars.SloadGasEIP150 // 200

jt[SSTORE].dynamicGas = gasSStoreEIP2200
}

// enable2200 applies EIP-2200 (Rebalance net-metered SSTORE)
func enable2200(jt *JumpTable) {
jt[SLOAD].constantGas = vars.SloadGasEIP2200
jt[SSTORE].dynamicGas = gasSStoreEIP2200
}
1 change: 1 addition & 0 deletions core/vm/gas_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func TestEIP2200(t *testing.T) {
CanTransfer: func(StateDB, common.Address, *big.Int) bool { return true },
Transfer: func(StateDB, common.Address, common.Address, *big.Int) {},
}

vmenv := NewEVM(vmctx, statedb, params.AllEthashProtocolChanges, Config{ExtraEips: []int{2200}})

_, gas, err := vmenv.Call(AccountRef(common.Address{}), address, nil, tt.gaspool, new(big.Int))
Expand Down
11 changes: 1 addition & 10 deletions core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,7 @@ func instructionSetForConfig(config ctypes.ChainConfigurator, bn *big.Int) JumpT
enableSelfBalance(&instructionSet)
}

// EIP2200 was originally implemented incorrectly (not meeting specifications) by ethereum/go-ethereum, multi-geth, and Parity
// clients.
// ECIP1086 is a specification to allow this "bad" implementation, which is useful for ETC testnets Kotti and Mordor.
//
is2200enabled := config.IsEnabled(config.GetEIP2200Transition, bn) && !config.IsEnabled(config.GetEIP2200DisableTransition, bn)
if is2200enabled &&
config.IsEnabled(config.GetECIP1086Transition, bn) &&
!config.IsEnabled(config.GetEIP1884Transition, bn) {
enable2200Sloppy(&instructionSet)
} else if is2200enabled {
if config.IsEnabled(config.GetEIP2200Transition, bn) && !config.IsEnabled(config.GetEIP2200DisableTransition, bn) {
enable2200(&instructionSet) // Net metered SSTORE - https://eips.ethereum.org/EIPS/eip-2200
}
return instructionSet
Expand Down
88 changes: 0 additions & 88 deletions core/vm/jump_table_test.go

This file was deleted.

2 changes: 0 additions & 2 deletions params/config_kotti.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ var (
EIP2028FBlock: big.NewInt(2058191),
EIP2200FBlock: big.NewInt(2058191), // RePetersburg (== re-1283)

ECIP1086FBlock: big.NewInt(2058191),

// ECIP-1078, aka Phoenix Fix
EIP2200DisableFBlock: big.NewInt(2_208_203),
EIP1283FBlock: big.NewInt(2_208_203),
Expand Down
2 changes: 0 additions & 2 deletions params/config_mordor.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ var (
EIP2028FBlock: big.NewInt(778507),
EIP2200FBlock: big.NewInt(778507), // RePetersburg (== re-1283)

ECIP1086FBlock: big.NewInt(778507),

// ECIP-1078, aka Phoenix Fix
EIP2200DisableFBlock: big.NewInt(976_231),
EIP1283FBlock: big.NewInt(976_231),
Expand Down
3 changes: 0 additions & 3 deletions params/types/ctypes/configurator_iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ type ProtocolSpecifier interface {
SetECIP1080Transition(n *uint64) error
GetEIP1706Transition() *uint64
SetEIP1706Transition(n *uint64) error

GetECIP1086Transition() *uint64
SetECIP1086Transition(n *uint64) error
}

type Forker interface {
Expand Down
8 changes: 0 additions & 8 deletions params/types/genesisT/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,14 +536,6 @@ func (g Genesis) SetEIP1706Transition(n *uint64) error {
return g.Config.SetEIP1706Transition(n)
}

func (g Genesis) GetECIP1086Transition() *uint64 {
return g.Config.GetECIP1086Transition()
}

func (g Genesis) SetECIP1086Transition(n *uint64) error {
return g.Config.SetECIP1086Transition(n)
}

func (g *Genesis) IsEnabled(fn func() *uint64, n *big.Int) bool {
return g.Config.IsEnabled(fn, n)
}
Expand Down
11 changes: 0 additions & 11 deletions params/types/goethereum/goethereum_configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,17 +382,6 @@ func (c *ChainConfig) SetEIP1706Transition(n *uint64) error {
return nil
}

func (c *ChainConfig) GetECIP1086Transition() *uint64 {
return nil
}

func (c *ChainConfig) SetECIP1086Transition(n *uint64) error {
if n == nil {
return nil
}
return ctypes.ErrUnsupportedConfigFatal
}

func (c *ChainConfig) IsEnabled(fn func() *uint64, n *big.Int) bool {
f := fn()
if f == nil || n == nil {
Expand Down
2 changes: 0 additions & 2 deletions params/types/multigeth/chain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ type MultiGethChainConfig struct {
ECIP1017EraRounds *big.Int `json:"ecip1017EraRounds,omitempty"` // ECIP1017 era rounds
ECIP1080FBlock *big.Int `json:"ecip1080FBlock,omitempty"`

ECIP1086FBlock *big.Int `json:"ecip1086FBlock,omitempty"`

DisposalBlock *big.Int `json:"disposalBlock,omitempty"` // Bomb disposal HF block
SocialBlock *big.Int `json:"socialBlock,omitempty"` // Ethereum Social Reward block
EthersocialBlock *big.Int `json:"ethersocialBlock,omitempty"` // Ethersocial Reward block
Expand Down
9 changes: 0 additions & 9 deletions params/types/multigeth/chain_config_configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,6 @@ func (c *MultiGethChainConfig) SetEIP1706Transition(n *uint64) error {
return nil
}

func (c *MultiGethChainConfig) GetECIP1086Transition() *uint64 {
return bigNewU64(c.ECIP1086FBlock)
}

func (c *MultiGethChainConfig) SetECIP1086Transition(n *uint64) error {
c.ECIP1086FBlock = setBig(c.ECIP1086FBlock, n)
return nil
}

func (c *MultiGethChainConfig) IsEnabled(fn func() *uint64, n *big.Int) bool {
f := fn()
if f == nil || n == nil {
Expand Down
11 changes: 0 additions & 11 deletions params/types/multigethv0/multigethv0_chain_config_configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,17 +385,6 @@ func (c *ChainConfig) SetEIP1706Transition(n *uint64) error {
return ctypes.ErrUnsupportedConfigFatal
}

func (c *ChainConfig) GetECIP1086Transition() *uint64 {
return nil
}

func (c *ChainConfig) SetECIP1086Transition(n *uint64) error {
if n == nil {
return nil
}
return ctypes.ErrUnsupportedConfigFatal
}

func (c *ChainConfig) IsEnabled(fn func() *uint64, n *big.Int) bool {
f := fn()
if f == nil || n == nil {
Expand Down
11 changes: 0 additions & 11 deletions params/types/parity/parity_configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,17 +477,6 @@ func (c *ParityChainSpec) SetEIP1706Transition(n *uint64) error {
return nil
}

func (c *ParityChainSpec) GetECIP1086Transition() *uint64 {
return nil
}

func (c *ParityChainSpec) SetECIP1086Transition(n *uint64) error {
if n == nil {
return nil
}
return ctypes.ErrUnsupportedConfigFatal
}

func (spec *ParityChainSpec) IsEnabled(fn func() *uint64, n *big.Int) bool {
f := fn()
if f == nil || n == nil {
Expand Down
1 change: 0 additions & 1 deletion params/vars/protocol_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ var (
SloadGasFrontier uint64 = 50
SloadGasEIP150 uint64 = 200
SloadGasEIP1884 uint64 = 800 // Cost of SLOAD after EIP 1884 (part of Istanbul)
SloadGasEIP2200 uint64 = 800 // Cost of SLOAD after EIP 2200 (part of Istanbul)
ExtcodeHashGasConstantinople uint64 = 400 // Cost of EXTCODEHASH (introduced in Constantinople)
ExtcodeHashGasEIP1884 uint64 = 700 // Cost of EXTCODEHASH after EIP 1884 (part in Istanbul)
SelfdestructGasEIP150 uint64 = 5000 // Cost of SELFDESTRUCT post EIP 150 (Tangerine)
Expand Down

0 comments on commit 7cd60ae

Please sign in to comment.