Skip to content

Commit

Permalink
Merge branch 'fix/multi-geth-config-schema-ecip1017'
Browse files Browse the repository at this point in the history
  • Loading branch information
meowsbits committed Aug 3, 2020
2 parents 4bbe6b4 + 326d6e0 commit 6700427
Show file tree
Hide file tree
Showing 13 changed files with 320 additions and 376 deletions.
4 changes: 2 additions & 2 deletions cmd/echainspec/main.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/genesisT"
"github.com/ethereum/go-ethereum/params/types/goethereum"
"github.com/ethereum/go-ethereum/params/types/multigethv0"
"github.com/ethereum/go-ethereum/params/types/multigeth"
"github.com/ethereum/go-ethereum/params/types/parity"
"gopkg.in/urfave/cli.v1"
)
Expand All @@ -27,7 +27,7 @@ var (
Config: &coregeth.CoreGethChainConfig{},
},
"multigeth": &genesisT.Genesis{
Config: &multigethv0.ChainConfig{},
Config: &multigeth.ChainConfig{},
},
"geth": &genesisT.Genesis{
Config: &goethereum.ChainConfig{},
Expand Down
49 changes: 23 additions & 26 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/coregeth"
"github.com/ethereum/go-ethereum/params/types/ctypes"
"github.com/ethereum/go-ethereum/params/types/multigethv0"
"github.com/ethereum/go-ethereum/params/types/multigeth"
)

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

// Setup a genesis mocking <=v1.9.6, aka "old".
genA := params.DefaultGenesisBlock()
genA.Config = &multigethv0.ChainConfig{
ChainID: big.NewInt(61),
HomesteadBlock: big.NewInt(1150000),
DAOForkBlock: big.NewInt(1920000),
DAOForkSupport: false,
EIP150Block: big.NewInt(2500000),
EIP150Hash: common.HexToHash("0xca12c63534f565899681965528d536c52cb05b7c48e269c2a6cb77ad864d878a"),
EIP155Block: big.NewInt(3000000),
EIP158Block: big.NewInt(8772000),
ByzantiumBlock: big.NewInt(8772000),
DisposalBlock: big.NewInt(5900000),
SocialBlock: nil,
EthersocialBlock: nil,
ConstantinopleBlock: big.NewInt(9573000),
PetersburgBlock: big.NewInt(9573000),
IstanbulBlock: big.NewInt(10500839),
EIP1884DisableFBlock: big.NewInt(10500839),
ECIP1017EraRounds: big.NewInt(5000000),
EIP160FBlock: big.NewInt(3000000),
ECIP1010PauseBlock: big.NewInt(3000000),
ECIP1010Length: big.NewInt(2000000),
Ethash: new(ctypes.EthashConfig),
genA.Config = &multigeth.ChainConfig{
NetworkID: 1,
ChainID: big.NewInt(61),
HomesteadBlock: big.NewInt(1150000),
DAOForkBlock: big.NewInt(1920000),
DAOForkSupport: false,
EIP150Block: big.NewInt(2500000),
EIP150Hash: common.HexToHash("0xca12c63534f565899681965528d536c52cb05b7c48e269c2a6cb77ad864d878a"),
EIP155Block: big.NewInt(3000000),
EIP158Block: big.NewInt(8772000),
ByzantiumBlock: big.NewInt(8772000),
DisposalBlock: big.NewInt(5900000),
ConstantinopleBlock: big.NewInt(9573000),
PetersburgBlock: big.NewInt(9573000),
IstanbulBlock: big.NewInt(10500839),
ECIP1017EraBlock: big.NewInt(5000000),
EIP160Block: big.NewInt(3000000),
ECIP1010PauseBlock: big.NewInt(3000000),
ECIP1010Length: big.NewInt(2000000),
Ethash: new(ctypes.EthashConfig),
}

// Set it up.
Expand Down Expand Up @@ -185,8 +183,7 @@ func TestSetupGenesisBlock2(t *testing.T) {
"EIP2200FBlock": null,
"ecip1010PauseBlock": 3000000,
"ecip1010Length": 2000000,
"ecip1017FBlock": 5000000,
"ecip1017EraRounds": 5000000,
"ecip1017EraBlock": 5000000,
"disposalBlock": 5900000
}
`
Expand Down Expand Up @@ -256,7 +253,7 @@ func TestSetupGenesisBlock2(t *testing.T) {
if storedConf == nil {
t.Fatal("nil stored conf")
}
wantType := reflect.TypeOf(&multigethv0.ChainConfig{})
wantType := reflect.TypeOf(&multigeth.ChainConfig{})
if reflect.TypeOf(storedConf) != wantType {
t.Fatalf("mismatch, want: %v, got: %v", wantType, reflect.TypeOf(storedConf))
}
Expand Down
51 changes: 23 additions & 28 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/coregeth"
"github.com/ethereum/go-ethereum/params/types/ctypes"
"github.com/ethereum/go-ethereum/params/types/goethereum"
"github.com/ethereum/go-ethereum/params/types/multigethv0"
"github.com/ethereum/go-ethereum/params/types/multigeth"
)

func uint64P(n uint64) *uint64 {
Expand Down Expand Up @@ -221,7 +221,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 := &multigethv0.ChainConfig{
c := &multigeth.ChainConfig{
ChainID: big.NewInt(61),
HomesteadBlock: big.NewInt(1150000),
DAOForkBlock: big.NewInt(1920000),
Expand All @@ -232,15 +232,13 @@ func TestCheckCompatible(t *testing.T) {
EIP158Block: big.NewInt(8772000),
ByzantiumBlock: big.NewInt(8772000),
DisposalBlock: big.NewInt(5900000),
SocialBlock: nil,
EthersocialBlock: nil,
ConstantinopleBlock: big.NewInt(9573000),
PetersburgBlock: big.NewInt(9573000),
// As if client hasn't upgraded config to latest fork.
//IstanbulBlock: big.NewInt(10500839),
//EIP1884DisableFBlock:big.NewInt(10500839),
ECIP1017EraRounds: big.NewInt(5000000),
EIP160FBlock: big.NewInt(3000000),
ECIP1017EraBlock: big.NewInt(5000000),
EIP160Block: big.NewInt(3000000),
ECIP1010PauseBlock: big.NewInt(3000000),
ECIP1010Length: big.NewInt(2000000),
Ethash: new(ctypes.EthashConfig),
Expand All @@ -254,28 +252,25 @@ func TestCheckCompatible(t *testing.T) {
{
stored: func() ctypes.ChainConfigurator {
// ClassicChainConfig is the chain parameters to run a node on the Classic main network.
c := &multigethv0.ChainConfig{
ChainID: big.NewInt(61),
HomesteadBlock: big.NewInt(1150000),
DAOForkBlock: big.NewInt(1920000),
DAOForkSupport: false,
EIP150Block: big.NewInt(2500000),
EIP150Hash: common.HexToHash("0xca12c63534f565899681965528d536c52cb05b7c48e269c2a6cb77ad864d878a"),
EIP155Block: big.NewInt(3000000),
EIP158Block: big.NewInt(8772000),
ByzantiumBlock: big.NewInt(8772000),
DisposalBlock: big.NewInt(5900000),
SocialBlock: nil,
EthersocialBlock: nil,
ConstantinopleBlock: big.NewInt(9573000),
PetersburgBlock: big.NewInt(9573000),
IstanbulBlock: big.NewInt(10500839),
EIP1884DisableFBlock: big.NewInt(10500839),
ECIP1017EraRounds: big.NewInt(5000000),
EIP160FBlock: big.NewInt(3000000),
ECIP1010PauseBlock: big.NewInt(3000000),
ECIP1010Length: big.NewInt(2000000),
Ethash: new(ctypes.EthashConfig),
c := &multigeth.ChainConfig{
ChainID: big.NewInt(61),
HomesteadBlock: big.NewInt(1150000),
DAOForkBlock: big.NewInt(1920000),
DAOForkSupport: false,
EIP150Block: big.NewInt(2500000),
EIP150Hash: common.HexToHash("0xca12c63534f565899681965528d536c52cb05b7c48e269c2a6cb77ad864d878a"),
EIP155Block: big.NewInt(3000000),
EIP158Block: big.NewInt(8772000),
ByzantiumBlock: big.NewInt(8772000),
DisposalBlock: big.NewInt(5900000),
ConstantinopleBlock: big.NewInt(9573000),
PetersburgBlock: big.NewInt(9573000),
IstanbulBlock: big.NewInt(10500839),
ECIP1017EraBlock: big.NewInt(5000000),
EIP160Block: big.NewInt(3000000),
ECIP1010PauseBlock: big.NewInt(3000000),
ECIP1010Length: big.NewInt(2000000),
Ethash: new(ctypes.EthashConfig),
}
return c
}(),
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/coregeth"
"github.com/ethereum/go-ethereum/params/types/ctypes"
"github.com/ethereum/go-ethereum/params/types/goethereum"
"github.com/ethereum/go-ethereum/params/types/multigethv0"
"github.com/ethereum/go-ethereum/params/types/multigeth"
"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.(*multigethv0.ChainConfig); ok {
if omg, ok := c.ChainConfigurator.(*multigeth.ChainConfig); ok {
return omg.DAOForkSupport
}
if mg, ok := c.ChainConfigurator.(*coregeth.CoreGethChainConfig); ok {
Expand Down Expand Up @@ -114,7 +114,7 @@ func UnmarshalChainConfigurator(input []byte) (ctypes.ChainConfigurator, error)
}{
{&parity.ParityChainSpec{}, paritySchemaKeysSuffice, paritySchemaKeysMustNot},
{&coregeth.CoreGethChainConfig{}, multigethSchemaSuffice, multigethSchemaMustNot},
{&multigethv0.ChainConfig{}, oldmultigethSchemaSuffice, oldmultigethSchemaMustNot},
{&multigeth.ChainConfig{}, oldmultigethSchemaSuffice, oldmultigethSchemaMustNot},
{&goethereum.ChainConfig{}, goethereumSchemaSuffice, goethereumSchemaMustNot},
}
for _, c := range cases {
Expand Down
55 changes: 26 additions & 29 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/coregeth"
"github.com/ethereum/go-ethereum/params/types/ctypes"
"github.com/ethereum/go-ethereum/params/types/goethereum"
"github.com/ethereum/go-ethereum/params/types/multigethv0"
"github.com/ethereum/go-ethereum/params/types/multigeth"
"github.com/ethereum/go-ethereum/params/types/parity"
)

Expand Down Expand Up @@ -68,28 +68,25 @@ result:
}
}

om := &multigethv0.ChainConfig{
ChainID: big.NewInt(61),
HomesteadBlock: big.NewInt(1150000),
DAOForkBlock: big.NewInt(1920000),
DAOForkSupport: false,
EIP150Block: big.NewInt(2500000),
EIP150Hash: common.HexToHash("0xca12c63534f565899681965528d536c52cb05b7c48e269c2a6cb77ad864d878a"),
EIP155Block: big.NewInt(3000000),
EIP158Block: big.NewInt(8772000),
ByzantiumBlock: big.NewInt(8772000),
DisposalBlock: big.NewInt(5900000),
SocialBlock: nil,
EthersocialBlock: nil,
ConstantinopleBlock: big.NewInt(9573000),
PetersburgBlock: big.NewInt(9573000),
IstanbulBlock: big.NewInt(10500839),
EIP1884DisableFBlock: big.NewInt(10500839),
ECIP1017EraRounds: big.NewInt(5000000),
EIP160FBlock: big.NewInt(3000000),
ECIP1010PauseBlock: big.NewInt(3000000),
ECIP1010Length: big.NewInt(2000000),
Ethash: new(ctypes.EthashConfig),
om := &multigeth.ChainConfig{
ChainID: big.NewInt(61),
HomesteadBlock: big.NewInt(1150000),
DAOForkBlock: big.NewInt(1920000),
DAOForkSupport: false,
EIP150Block: big.NewInt(2500000),
EIP150Hash: common.HexToHash("0xca12c63534f565899681965528d536c52cb05b7c48e269c2a6cb77ad864d878a"),
EIP155Block: big.NewInt(3000000),
EIP158Block: big.NewInt(8772000),
ByzantiumBlock: big.NewInt(8772000),
DisposalBlock: big.NewInt(5900000),
ConstantinopleBlock: big.NewInt(9573000),
PetersburgBlock: big.NewInt(9573000),
IstanbulBlock: big.NewInt(10500839),
ECIP1017EraBlock: big.NewInt(5000000),
EIP160Block: big.NewInt(3000000),
ECIP1010PauseBlock: big.NewInt(3000000),
ECIP1010Length: big.NewInt(2000000),
Ethash: new(ctypes.EthashConfig),
}

b, err := json.MarshalIndent(om, "", " ")
Expand All @@ -101,8 +98,8 @@ result:
if err != nil {
t.Fatal(err)
}
if reflect.TypeOf(got) != reflect.TypeOf(&multigethv0.ChainConfig{}) {
t.Fatalf("mismatch, want: %v, got: %v", reflect.TypeOf(&multigethv0.ChainConfig{}), reflect.TypeOf(got))
if reflect.TypeOf(got) != reflect.TypeOf(&multigeth.ChainConfig{}) {
t.Fatalf("mismatch, want: %v, got: %v", reflect.TypeOf(&multigeth.ChainConfig{}), reflect.TypeOf(got))
}

if tr := got.GetEIP7Transition(); tr == nil || *tr != 1150000 {
Expand Down Expand Up @@ -157,7 +154,7 @@ var cc_v196_a = `{
"ecip1010PauseBlock": 3000000,
"ecip1010Length": 2000000,
"ecip1017FBlock": 5000000,
"ecip1017EraRounds": 5000000,
"ecip1017EraBlock": 5000000,
"disposalBlock": 5900000
}
`
Expand All @@ -179,7 +176,7 @@ var cc_v197_a = `{
"istanbulBlock": 10500839,
"ecip1010PauseBlock": 3000000,
"ecip1010Length": 2000000,
"ecip1017EraRounds": 5000000,
"ecip1017EraBlock": 5000000,
"disposalBlock": 5900000,
"ethash": {},
"trustedCheckpoint": null,
Expand Down Expand Up @@ -233,12 +230,12 @@ func TestUnmarshalChainConfigurator2(t *testing.T) {
{
versionid: "v196",
raw: cc_v196_a,
wantType: reflect.TypeOf(&multigethv0.ChainConfig{}),
wantType: reflect.TypeOf(&multigeth.ChainConfig{}),
},
{
versionid: "v197",
raw: cc_v197_a,
wantType: reflect.TypeOf(&multigethv0.ChainConfig{}),
wantType: reflect.TypeOf(&multigeth.ChainConfig{}),
},
{
versionid: "v198",
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.

Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ It is mostly used for managing upgrades between client versions,
and is not encouraged for real use.
*/

package multigethv0
package multigeth
62 changes: 62 additions & 0 deletions params/types/multigeth/multigethv0_chain_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package multigeth

import (
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params/types/ctypes"
)

// ChainConfig is the core config which determines the blockchain settings.
//
// ChainConfig is stored in the database on a per block basis. This means
// that any network, identified by its genesis block, can have its own
// set of configuration options.
type ChainConfig struct {
NetworkID uint64 `json:"-"`
ChainID *big.Int `json:"chainId"` // chainId identifies the current chain and is used for replay protection

HomesteadBlock *big.Int `json:"homesteadBlock,omitempty"` // Homestead switch block (nil = no fork, 0 = already homestead)

DAOForkBlock *big.Int `json:"daoForkBlock,omitempty"` // TheDAO hard-fork switch block (nil = no fork)
DAOForkSupport bool `json:"daoForkSupport,omitempty"` // Whether the nodes supports or opposes the DAO hard-fork

// EIP150 implements the Gas price changes (https://github.com/ethereum/EIPs/issues/150)
EIP150Block *big.Int `json:"eip150Block,omitempty"` // EIP150 HF block (nil = no fork)
EIP150Hash common.Hash `json:"eip150Hash,omitempty"` // EIP150 HF hash (needed for header only clients as only gas pricing changed)

EIP155Block *big.Int `json:"eip155Block,omitempty"` // EIP155 HF block
EIP158Block *big.Int `json:"eip158Block,omitempty"` // EIP158 HF block

ByzantiumBlock *big.Int `json:"byzantiumBlock,omitempty"` // Byzantium switch block (nil = no fork, 0 = already on byzantium)
ConstantinopleBlock *big.Int `json:"constantinopleBlock,omitempty"` // Constantinople switch block (nil = no fork, 0 = already activated)
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)
MuirGlacierBlock *big.Int `json:"muirGlacierBlock,omitempty"` // Eip-2384 (bomb delay) switch block (nil = no fork, 0 = already activated)

YoloV1Block *big.Int `json:"yoloV1Block,omitempty"` // YOLO v1: https://github.com/ethereum/EIPs/pull/2657 (Ephemeral testnet)
EWASMBlock *big.Int `json:"ewasmBlock,omitempty"` // EWASM switch block (nil = no fork, 0 = already activated)

//
// EXP cost increase
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-160.md
// NOTE: this json tag:
// (a.) varies from it's 'siblings', which have 'F's in them
// (b.) without the 'F' will vary from ETH implementations if they choose to accept the proposed changes
// with corresponding refactoring (https://github.com/ethereum/go-ethereum/pull/18401)
EIP160Block *big.Int `json:"eip160Block,omitempty"`
EIP161DisableBlock *big.Int `json:"eip161DisableBlock,omitempty"`
EIP161ReenableBlock *big.Int `json:"eip161ReenableBlock,omitempty"`
ECIP1010PauseBlock *big.Int `json:"ecip1010PauseBlock,omitempty"` // ECIP1010 pause HF block
ECIP1010Length *big.Int `json:"ecip1010Length,omitempty"` // ECIP1010 length
ECIP1017EraBlock *big.Int `json:"ecip1017EraBlock,omitempty"` // ECIP1017 era rounds
DisposalBlock *big.Int `json:"disposalBlock,omitempty"` // Bomb disposal HF block

MCIP0Block *big.Int `json:"mcip0Block,omitempty"` // Musicoin default block; no MCIP, just denotes chain pref
MCIP3Block *big.Int `json:"mcip3Block,omitempty"` // Musicoin 'UBI Fork' block
MCIP8Block *big.Int `json:"mcip8Block,omitempty"` // Musicoin 'QT For' block

// Various consensus engines
Ethash *ctypes.EthashConfig `json:"ethash,omitempty"`
Clique *ctypes.CliqueConfig `json:"clique,omitempty"`
}
Loading

0 comments on commit 6700427

Please sign in to comment.