diff --git a/params/config.go b/params/config.go index 1be9134499..6a1cd30168 100644 --- a/params/config.go +++ b/params/config.go @@ -60,6 +60,7 @@ var ( DisposalBlock: big.NewInt(0), ConstantinopleBlock: nil, ECIP1017EraRounds: big.NewInt(10000000), + EIP160Block: big.NewInt(0), Ethash: new(EthashConfig), } @@ -103,16 +104,16 @@ var ( // // This configuration is intentionally not using keyed fields to force anyone // adding flags to the config to also have to set these fields. - AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, new(EthashConfig), nil} + AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, new(EthashConfig), nil} // AllCliqueProtocolChanges contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers into the Clique consensus. // // This configuration is intentionally not using keyed fields to force anyone // adding flags to the config to also have to set these fields. - AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}} + AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}} - TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, new(EthashConfig), nil} + TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, new(EthashConfig), nil} TestRules = TestChainConfig.Rules(new(big.Int)) ) @@ -141,6 +142,7 @@ type ChainConfig struct { ConstantinopleBlock *big.Int `json:"constantinopleBlock,omitempty"` // Constantinople switch block (nil = no fork, 0 = already activated) ECIP1017EraRounds *big.Int `json:"ecip1017EraRounds,omitempty"` // ECIP1017 era rounds + EIP160Block *big.Int `json:"eip160Block,omitempty"` // EIP160 HF block // Various consensus engines Ethash *EthashConfig `json:"ethash,omitempty"` @@ -177,7 +179,7 @@ func (c *ChainConfig) String() string { default: engine = "unknown" } - return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v, Disposal: %v, ECIP1017: %v, Constantinople: %v, Engine: %v}", + return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v, Disposal: %v, ECIP1017: %v, EIP160: %v, Constantinople: %v, Engine: %v}", c.ChainId, c.HomesteadBlock, c.DAOForkBlock, @@ -207,6 +209,11 @@ func (c *ChainConfig) IsHomestead(num *big.Int) bool { return isForked(c.HomesteadBlock, num) } +// IsEIP160 returns whether num is either equal to the EIP160 block or greater. +func (c *ChainConfig) IsEIP160(num *big.Int) bool { + return isForked(c.EIP160Block, num) +} + // IsDAO returns whether num is either equal to the DAO fork block or greater. func (c *ChainConfig) IsDAOFork(num *big.Int) bool { return isForked(c.DAOForkBlock, num) @@ -244,6 +251,8 @@ func (c *ChainConfig) GasTable(num *big.Int) GasTable { return GasTableHomestead } switch { + case c.IsEIP160(num): + return GasTableEIP160 case c.IsEIP158(num): return GasTableEIP158 case c.IsEIP150(num): diff --git a/params/gas_table.go b/params/gas_table.go index 4969382b1b..8e16a01fec 100644 --- a/params/gas_table.go +++ b/params/gas_table.go @@ -61,6 +61,20 @@ var ( CreateBySuicide: 25000, } + // GasTableEIP160 contains the gas re-prices for + // EIP160 hard fork. + GasTableEIP160 = GasTable{ + ExtcodeSize: 700, + ExtcodeCopy: 700, + Balance: 400, + SLoad: 200, + Calls: 700, + Suicide: 5000, + ExpByte: 50, + + CreateBySuicide: 25000, + } + GasTableEIP158 = GasTable{ ExtcodeSize: 700, ExtcodeCopy: 700,