Skip to content

Commit

Permalink
Merge pull request ethereum#140 from etclabscore/fix/rename-oldmultig…
Browse files Browse the repository at this point in the history
…eth-pkg

Fix/rename oldmultigeth pkg
  • Loading branch information
meowsbits authored Feb 6, 2020
2 parents e3831ee + ba5afc9 commit 25ef332
Show file tree
Hide file tree
Showing 22 changed files with 131 additions and 47 deletions.
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,20 @@ sync-clients:

test-multigeth: test-multigeth-features test-multigeth-chainspecs ## Runs all tests specific to multi-geth.

test-multigeth-features: test-multigeth-features-parity test-multigeth-features-multigeth ## Runs tests specific to multi-geth using Fork/Feature configs.
test-multigeth-features: test-multigeth-features-parity test-multigeth-features-multigeth test-multigeth-features-multigethv0 ## Runs tests specific to multi-geth using Fork/Feature configs.

test-multigeth-features-multigeth:
test-multigeth-features-parity:
@echo "Testing fork/feature/datatype implementation; equivalence - PARITY."
env MULTIGETH_TESTS_CHAINCONFIG_FEATURE_EQUIVALENCE_PARITY=on go test -count=1 ./tests

test-multigeth-features-parity:
test-multigeth-features-multigeth:
@echo "Testing fork/feature/datatype implementation; equivalence - MULTIGETH."
env MULTIGETH_TESTS_CHAINCONFIG_FEATURE_EQUIVALENCE_MULTIGETH=on go test -count=1 ./tests

test-multigeth-features-multigethv0:
@echo "Testing fork/feature/datatype implementation; equivalence - MULTIGETHv0."
env MULTIGETH_TESTS_CHAINCONFIG_FEATURE_EQUIVALENCE_MULTIGETHV0=on go test -count=1 ./tests

test-multigeth-chainspecs: ## Run tests specific to multi-geth using chainspec file configs.
@echo "Testing Parity JSON chainspec equivalence."
env MULTIGETH_TESTS_CHAINCONFIG_PARITY_SPECS=on go test -count=1 ./tests
Expand Down
10 changes: 2 additions & 8 deletions consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,8 @@ func CalcDifficulty(config ctypes.ChainConfigurator, time uint64, parent *types.
exPeriodRef.Set(fakeBlockNumber)

} else if config.IsForked(config.GetEthashEIP2384Transition, next) {
// calcDifficultyEIP1234 is the difficulty adjustment algorithm for Constantinople.
// The calculation uses the Byzantium rules, but with bomb offset 5M.
// Specification EIP-1234: https://eips.ethereum.org/EIPS/eip-1234
// Note, the calculations below looks at the parent number, which is 1 below
// the block number. Thus we remove one from the delay given

// calculate a fake block number for the ice-age delay
// Specification: https://eips.ethereum.org/EIPS/eip-1234
// calcDifficultyEIP2384 is the difficulty adjustment algorithm for Muir Glacier.
// The calculation uses the Byzantium rules, but with bomb offset 9M.
fakeBlockNumber := new(big.Int)
delayWithOffset := new(big.Int).Sub(vars.EIP2384DifficultyBombDelay, common.Big1)
if parent.Number.Cmp(delayWithOffset) >= 0 {
Expand Down
6 changes: 3 additions & 3 deletions core/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/ethereum/go-ethereum/params/confp"
"github.com/ethereum/go-ethereum/params/types/ctypes"
"github.com/ethereum/go-ethereum/params/types/multigeth"
"github.com/ethereum/go-ethereum/params/types/oldmultigeth"
"github.com/ethereum/go-ethereum/params/types/multigethv0"
)

func TestSetupGenesisBlock(t *testing.T) {
Expand Down Expand Up @@ -71,7 +71,7 @@ func TestSetupGenesisBlockOldVsNewMultigeth(t *testing.T) {

// Setup a genesis mocking <=v1.9.6, aka "old".
genA := params.DefaultGenesisBlock()
genA.Config = &oldmultigeth.ChainConfig{
genA.Config = &multigethv0.ChainConfig{
ChainID: big.NewInt(61),
HomesteadBlock: big.NewInt(1150000),
DAOForkBlock: big.NewInt(1920000),
Expand Down Expand Up @@ -256,7 +256,7 @@ func TestSetupGenesisBlock2(t *testing.T) {
if storedConf == nil {
t.Fatal("nil stored conf")
}
wantType := reflect.TypeOf(&oldmultigeth.ChainConfig{})
wantType := reflect.TypeOf(&multigethv0.ChainConfig{})
if reflect.TypeOf(storedConf) != wantType {
t.Fatalf("mismatch, want: %v, got: %v", wantType, reflect.TypeOf(storedConf))
}
Expand Down
2 changes: 1 addition & 1 deletion core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func instructionSetForConfig(config ctypes.ChainConfigurator, bn *big.Int) JumpT
if config.IsForked(config.GetECIP1080Transition, bn) {
enableSelfBalance(&instructionSet)
}
if config.IsForked(config.GetEIP2200Transition, bn) {
if config.IsForked(config.GetEIP2200Transition, bn) && !config.IsForked(config.GetEIP2200DisableTransition, bn) {
enable2200(&instructionSet) // Net metered SSTORE - https://eips.ethereum.org/EIPS/eip-2200
}
return instructionSet
Expand Down
6 changes: 3 additions & 3 deletions params/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/ethereum/go-ethereum/params/types/ctypes"
"github.com/ethereum/go-ethereum/params/types/goethereum"
"github.com/ethereum/go-ethereum/params/types/multigeth"
"github.com/ethereum/go-ethereum/params/types/oldmultigeth"
"github.com/ethereum/go-ethereum/params/types/multigethv0"
)

func uint64P(n uint64) *uint64 {
Expand Down Expand Up @@ -219,7 +219,7 @@ func TestCheckCompatible(t *testing.T) {
{
stored: func() ctypes.ChainConfigurator {
// ClassicChainConfig is the chain parameters to run a node on the Classic main network.
c := &oldmultigeth.ChainConfig{
c := &multigethv0.ChainConfig{
ChainID: big.NewInt(61),
HomesteadBlock: big.NewInt(1150000),
DAOForkBlock: big.NewInt(1920000),
Expand Down Expand Up @@ -252,7 +252,7 @@ func TestCheckCompatible(t *testing.T) {
{
stored: func() ctypes.ChainConfigurator {
// ClassicChainConfig is the chain parameters to run a node on the Classic main network.
c := &oldmultigeth.ChainConfig{
c := &multigethv0.ChainConfig{
ChainID: big.NewInt(61),
HomesteadBlock: big.NewInt(1150000),
DAOForkBlock: big.NewInt(1920000),
Expand Down
6 changes: 3 additions & 3 deletions params/confp/generic/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/ethereum/go-ethereum/params/types/ctypes"
"github.com/ethereum/go-ethereum/params/types/goethereum"
"github.com/ethereum/go-ethereum/params/types/multigeth"
"github.com/ethereum/go-ethereum/params/types/oldmultigeth"
"github.com/ethereum/go-ethereum/params/types/multigethv0"
"github.com/ethereum/go-ethereum/params/types/parity"
"github.com/ethereum/go-ethereum/params/vars"
"github.com/tidwall/gjson"
Expand All @@ -47,7 +47,7 @@ func (c GenericCC) DAOSupport() bool {
if gc, ok := c.ChainConfigurator.(*goethereum.ChainConfig); ok {
return gc.DAOForkSupport
}
if omg, ok := c.ChainConfigurator.(*oldmultigeth.ChainConfig); ok {
if omg, ok := c.ChainConfigurator.(*multigethv0.ChainConfig); ok {
return omg.DAOForkSupport
}
if mg, ok := c.ChainConfigurator.(*multigeth.MultiGethChainConfig); ok {
Expand Down Expand Up @@ -114,7 +114,7 @@ func UnmarshalChainConfigurator(input []byte) (ctypes.ChainConfigurator, error)
}{
{&parity.ParityChainSpec{}, paritySchemaKeysSuffice, paritySchemaKeysMustNot},
{&multigeth.MultiGethChainConfig{}, multigethSchemaSuffice, multigethSchemaMustNot},
{&oldmultigeth.ChainConfig{}, oldmultigethSchemaSuffice, oldmultigethSchemaMustNot},
{&multigethv0.ChainConfig{}, oldmultigethSchemaSuffice, oldmultigethSchemaMustNot},
{&goethereum.ChainConfig{}, goethereumSchemaSuffice, goethereumSchemaMustNot},
}
for _, c := range cases {
Expand Down
12 changes: 6 additions & 6 deletions params/confp/generic/generic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/ethereum/go-ethereum/params/types/ctypes"
"github.com/ethereum/go-ethereum/params/types/goethereum"
"github.com/ethereum/go-ethereum/params/types/multigeth"
"github.com/ethereum/go-ethereum/params/types/oldmultigeth"
"github.com/ethereum/go-ethereum/params/types/multigethv0"
"github.com/ethereum/go-ethereum/params/types/parity"
)

Expand Down Expand Up @@ -68,7 +68,7 @@ result:
}
}

om := &oldmultigeth.ChainConfig{
om := &multigethv0.ChainConfig{
ChainID: big.NewInt(61),
HomesteadBlock: big.NewInt(1150000),
DAOForkBlock: big.NewInt(1920000),
Expand Down Expand Up @@ -101,8 +101,8 @@ result:
if err != nil {
t.Fatal(err)
}
if reflect.TypeOf(got) != reflect.TypeOf(&oldmultigeth.ChainConfig{}) {
t.Fatalf("mismatch, want: %v, got: %v", reflect.TypeOf(&oldmultigeth.ChainConfig{}), reflect.TypeOf(got))
if reflect.TypeOf(got) != reflect.TypeOf(&multigethv0.ChainConfig{}) {
t.Fatalf("mismatch, want: %v, got: %v", reflect.TypeOf(&multigethv0.ChainConfig{}), reflect.TypeOf(got))
}

if tr := got.GetEIP7Transition(); tr == nil || *tr != 1150000 {
Expand Down Expand Up @@ -233,12 +233,12 @@ func TestUnmarshalChainConfigurator2(t *testing.T) {
{
versionid: "v196",
raw: cc_v196_a,
wantType: reflect.TypeOf(&oldmultigeth.ChainConfig{}),
wantType: reflect.TypeOf(&multigethv0.ChainConfig{}),
},
{
versionid: "v197",
raw: cc_v197_a,
wantType: reflect.TypeOf(&oldmultigeth.ChainConfig{}),
wantType: reflect.TypeOf(&multigethv0.ChainConfig{}),
},
{
versionid: "v198",
Expand Down
2 changes: 2 additions & 0 deletions params/types/ctypes/configurator_iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ type CatHerder interface {
SetEIP1108Transition(n *uint64) error
GetEIP2200Transition() *uint64
SetEIP2200Transition(n *uint64) error
GetEIP2200DisableTransition() *uint64
SetEIP2200DisableTransition(n *uint64) error
GetEIP1344Transition() *uint64
SetEIP1344Transition(n *uint64) error
GetEIP1884Transition() *uint64
Expand Down
6 changes: 3 additions & 3 deletions params/types/genesisT/gen_genesis.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

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

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

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

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

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

func (c *ChainConfig) GetEIP1344Transition() *uint64 {
return bigNewU64(c.IstanbulBlock)
}
Expand Down
3 changes: 2 additions & 1 deletion params/types/multigeth/chain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ type MultiGethChainConfig struct {
// EIP-2200: Rebalance net-metered SSTORE gas cost with consideration of SLOAD gas cost change
// It's a combined version of EIP-1283 + EIP-1706, with a structured definition so as to make it
// interoperable with other gas changes such as EIP-1884.
EIP2200FBlock *big.Int `json:"eip2200FBlock,omitempty"`
EIP2200FBlock *big.Int `json:"eip2200FBlock,omitempty"`
EIP2200DisableFBlock *big.Int `json:"eip2200DisableFBlock,omitempty"`

// EIP-2384: Difficulty Bomb Delay (Muir Glacier)
eip2384Inferred bool
Expand Down
9 changes: 9 additions & 0 deletions params/types/multigeth/chain_config_configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,15 @@ func (c *MultiGethChainConfig) SetEIP2200Transition(n *uint64) error {
return nil
}

func (c *MultiGethChainConfig) GetEIP2200DisableTransition() *uint64 {
return bigNewU64(c.EIP2200DisableFBlock)
}

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

func (c *MultiGethChainConfig) GetEIP1344Transition() *uint64 {
return bigNewU64(c.EIP1344FBlock)
}
Expand Down
9 changes: 9 additions & 0 deletions params/types/multigethv0/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
Package multigethv0 implements the data type fitting
the original iteration of the multigeth client configuration structure.
It is mostly used for managing upgrades between client versions,
and is not encouraged for real use.
*/

package multigethv0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package oldmultigeth
package multigethv0

import (
"math/big"
Expand Down Expand Up @@ -112,8 +112,9 @@ type ChainConfig struct {

PetersburgBlock *big.Int `json:"petersburgBlock,omitempty"` // Petersburg switch block (nil = same as Constantinople)

IstanbulBlock *big.Int `json:"istanbulBlock,omitempty"` // Istanbul switch block (nil = no fork, 0 = already on istanbul)
EWASMBlock *big.Int `json:"ewasmBlock,omitempty"` // EWASM switch block (nil = no fork, 0 = already activated)
IstanbulBlock *big.Int `json:"istanbulBlock,omitempty"` // Istanbul switch block (nil = no fork, 0 = already on istanbul)
MuirGlacierBlock *big.Int `json:"muirGlacierBlock,omitempty"` // Eip-2384 (bomb delay) switch block (nil = no fork, 0 = already activated)
EWASMBlock *big.Int `json:"ewasmBlock,omitempty"` // EWASM switch block (nil = no fork, 0 = already activated)

ECIP1010PauseBlock *big.Int `json:"ecip1010PauseBlock,omitempty"` // ECIP1010 pause HF block
ECIP1010Length *big.Int `json:"ecip1010Length,omitempty"` // ECIP1010 length
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package oldmultigeth
package multigethv0

import (
"math/big"
Expand Down Expand Up @@ -314,6 +314,17 @@ func (c *ChainConfig) SetEIP2200Transition(n *uint64) error {
return nil
}

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

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

func (c *ChainConfig) GetEIP1344Transition() *uint64 {
return bigNewU64(c.IstanbulBlock)
}
Expand Down Expand Up @@ -526,15 +537,14 @@ func (c *ChainConfig) SetEthashEIP1234Transition(n *uint64) error {
return nil
}

// Muir Glacier difficulty bomb delay
func (c *ChainConfig) GetEthashEIP2384Transition() *uint64 {
return nil
return bigNewU64(c.MuirGlacierBlock)
}

func (c *ChainConfig) SetEthashEIP2384Transition(n *uint64) error {
if n == nil {
return nil
}
return ctypes.ErrUnsupportedConfigFatal
c.MuirGlacierBlock = setBig(c.MuirGlacierBlock, n)
return nil
}

func (c *ChainConfig) GetEthashECIP1010PauseTransition() *uint64 {
Expand Down Expand Up @@ -600,9 +610,11 @@ func (c *ChainConfig) SetEthashECIP1017EraRounds(n *uint64) error {
}

func (c *ChainConfig) GetEthashEIP100BTransition() *uint64 {
x := bigNewU64(bigMax(c.EIP100FBlock, c.ByzantiumBlock))
// Because the Ethereum Foundation network (and client... and tests) assume that if Constantinople
// is activated, then Byzantium must be (have been) as well.
x := bigMax(c.EIP100FBlock, c.ByzantiumBlock)
if x != nil {
return x
return bigNewU64(x)
}
return bigNewU64(bigMax(c.EIP100FBlock, c.ConstantinopleBlock))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package oldmultigeth
package multigethv0

import (
"math/big"
Expand Down
11 changes: 11 additions & 0 deletions params/types/parity/parity_configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,17 @@ func (spec *ParityChainSpec) SetEIP2200Transition(i *uint64) error {
return nil
}

func (spec *ParityChainSpec) GetEIP2200DisableTransition() *uint64 {
return nil
}

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

func (spec *ParityChainSpec) GetEIP1344Transition() *uint64 {
return spec.Params.EIP1344Transition.Uint64P()
}
Expand Down
3 changes: 2 additions & 1 deletion tests/difficulty_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,11 @@ func (test *DifficultyTest) Run(config ctypes.ChainConfigurator) error {
actual := ethash.CalcDifficulty(config, test.CurrentTimestamp, parent)
exp := test.CurrentDifficulty

b, _ := json.Marshal(config)
if actual.Cmp(exp) != 0 {
return fmt.Errorf(`%s got: %v, want: %v
test: %v
config: %s`, test.Name, actual, exp, test, config)
config: %s`, test.Name, actual, exp, test, string(b))
}
return nil

Expand Down
5 changes: 3 additions & 2 deletions tests/init_mgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ var (

// Feature Equivalence tests use convert.Convert to
// run tests using alternating ChainConfig data type implementations.
MG_CHAINCONFIG_FEATURE_EQ_MULTIGETH_KEY = "MULTIGETH_TESTS_CHAINCONFIG_FEATURE_EQUIVALENCE_MULTIGETH"
MG_CHAINCONFIG_FEATURE_EQ_PARITY_KEY = "MULTIGETH_TESTS_CHAINCONFIG_FEATURE_EQUIVALENCE_PARITY"
MG_CHAINCONFIG_FEATURE_EQ_MULTIGETH_KEY = "MULTIGETH_TESTS_CHAINCONFIG_FEATURE_EQUIVALENCE_MULTIGETH"
MG_CHAINCONFIG_FEATURE_EQ_MULTIGETHV0_KEY = "MULTIGETH_TESTS_CHAINCONFIG_FEATURE_EQUIVALENCE_MULTIGETHV0"
MG_CHAINCONFIG_FEATURE_EQ_PARITY_KEY = "MULTIGETH_TESTS_CHAINCONFIG_FEATURE_EQUIVALENCE_PARITY"

// Parity specs tests use Parity JSON config data (in params/parity.json.d/)
// when applicable as equivalent config implementations for the default Go data type
Expand Down
Loading

0 comments on commit 25ef332

Please sign in to comment.