Skip to content

Commit 5c93462

Browse files
authored
Merge pull request #15147 from karalabe/enable-byzantium-ropsten
params: enable Byzantium on Ropsten/tests, fix failures
2 parents 9be07de + 701d60c commit 5c93462

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

core/blockchain_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ func TestReorgSideEvent(t *testing.T) {
928928
replacementBlocks, _ := GenerateChain(gspec.Config, genesis, db, 4, func(i int, gen *BlockGen) {
929929
tx, err := types.SignTx(types.NewContractCreation(gen.TxNonce(addr1), new(big.Int), big.NewInt(1000000), new(big.Int), nil), signer, key1)
930930
if i == 2 {
931-
gen.OffsetTime(-1)
931+
gen.OffsetTime(-9)
932932
}
933933
if err != nil {
934934
t.Fatalf("failed to create tx: %v", err)

core/dao_test.go

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,22 @@ func TestDAOForkRangeExtradata(t *testing.T) {
4040
// Create the concurrent, conflicting two nodes
4141
proDb, _ := ethdb.NewMemDatabase()
4242
gspec.MustCommit(proDb)
43-
proConf := &params.ChainConfig{HomesteadBlock: big.NewInt(0), DAOForkBlock: forkBlock, DAOForkSupport: true}
44-
proBc, _ := NewBlockChain(proDb, proConf, ethash.NewFaker(), vm.Config{})
43+
44+
proConf := *params.TestChainConfig
45+
proConf.DAOForkBlock = forkBlock
46+
proConf.DAOForkSupport = true
47+
48+
proBc, _ := NewBlockChain(proDb, &proConf, ethash.NewFaker(), vm.Config{})
4549
defer proBc.Stop()
4650

4751
conDb, _ := ethdb.NewMemDatabase()
4852
gspec.MustCommit(conDb)
49-
conConf := &params.ChainConfig{HomesteadBlock: big.NewInt(0), DAOForkBlock: forkBlock, DAOForkSupport: false}
50-
conBc, _ := NewBlockChain(conDb, conConf, ethash.NewFaker(), vm.Config{})
53+
54+
conConf := *params.TestChainConfig
55+
conConf.DAOForkBlock = forkBlock
56+
conConf.DAOForkSupport = false
57+
58+
conBc, _ := NewBlockChain(conDb, &conConf, ethash.NewFaker(), vm.Config{})
5159
defer conBc.Stop()
5260

5361
if _, err := proBc.InsertChain(prefix); err != nil {
@@ -61,7 +69,7 @@ func TestDAOForkRangeExtradata(t *testing.T) {
6169
// Create a pro-fork block, and try to feed into the no-fork chain
6270
db, _ = ethdb.NewMemDatabase()
6371
gspec.MustCommit(db)
64-
bc, _ := NewBlockChain(db, conConf, ethash.NewFaker(), vm.Config{})
72+
bc, _ := NewBlockChain(db, &conConf, ethash.NewFaker(), vm.Config{})
6573
defer bc.Stop()
6674

6775
blocks := conBc.GetBlocksFromHash(conBc.CurrentBlock().Hash(), int(conBc.CurrentBlock().NumberU64()))
@@ -71,19 +79,19 @@ func TestDAOForkRangeExtradata(t *testing.T) {
7179
if _, err := bc.InsertChain(blocks); err != nil {
7280
t.Fatalf("failed to import contra-fork chain for expansion: %v", err)
7381
}
74-
blocks, _ = GenerateChain(proConf, conBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
82+
blocks, _ = GenerateChain(&proConf, conBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
7583
if _, err := conBc.InsertChain(blocks); err == nil {
7684
t.Fatalf("contra-fork chain accepted pro-fork block: %v", blocks[0])
7785
}
7886
// Create a proper no-fork block for the contra-forker
79-
blocks, _ = GenerateChain(conConf, conBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
87+
blocks, _ = GenerateChain(&conConf, conBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
8088
if _, err := conBc.InsertChain(blocks); err != nil {
8189
t.Fatalf("contra-fork chain didn't accepted no-fork block: %v", err)
8290
}
8391
// Create a no-fork block, and try to feed into the pro-fork chain
8492
db, _ = ethdb.NewMemDatabase()
8593
gspec.MustCommit(db)
86-
bc, _ = NewBlockChain(db, proConf, ethash.NewFaker(), vm.Config{})
94+
bc, _ = NewBlockChain(db, &proConf, ethash.NewFaker(), vm.Config{})
8795
defer bc.Stop()
8896

8997
blocks = proBc.GetBlocksFromHash(proBc.CurrentBlock().Hash(), int(proBc.CurrentBlock().NumberU64()))
@@ -93,20 +101,20 @@ func TestDAOForkRangeExtradata(t *testing.T) {
93101
if _, err := bc.InsertChain(blocks); err != nil {
94102
t.Fatalf("failed to import pro-fork chain for expansion: %v", err)
95103
}
96-
blocks, _ = GenerateChain(conConf, proBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
104+
blocks, _ = GenerateChain(&conConf, proBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
97105
if _, err := proBc.InsertChain(blocks); err == nil {
98106
t.Fatalf("pro-fork chain accepted contra-fork block: %v", blocks[0])
99107
}
100108
// Create a proper pro-fork block for the pro-forker
101-
blocks, _ = GenerateChain(proConf, proBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
109+
blocks, _ = GenerateChain(&proConf, proBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
102110
if _, err := proBc.InsertChain(blocks); err != nil {
103111
t.Fatalf("pro-fork chain didn't accepted pro-fork block: %v", err)
104112
}
105113
}
106114
// Verify that contra-forkers accept pro-fork extra-datas after forking finishes
107115
db, _ = ethdb.NewMemDatabase()
108116
gspec.MustCommit(db)
109-
bc, _ := NewBlockChain(db, conConf, ethash.NewFaker(), vm.Config{})
117+
bc, _ := NewBlockChain(db, &conConf, ethash.NewFaker(), vm.Config{})
110118
defer bc.Stop()
111119

112120
blocks := conBc.GetBlocksFromHash(conBc.CurrentBlock().Hash(), int(conBc.CurrentBlock().NumberU64()))
@@ -116,14 +124,14 @@ func TestDAOForkRangeExtradata(t *testing.T) {
116124
if _, err := bc.InsertChain(blocks); err != nil {
117125
t.Fatalf("failed to import contra-fork chain for expansion: %v", err)
118126
}
119-
blocks, _ = GenerateChain(proConf, conBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
127+
blocks, _ = GenerateChain(&proConf, conBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
120128
if _, err := conBc.InsertChain(blocks); err != nil {
121129
t.Fatalf("contra-fork chain didn't accept pro-fork block post-fork: %v", err)
122130
}
123131
// Verify that pro-forkers accept contra-fork extra-datas after forking finishes
124132
db, _ = ethdb.NewMemDatabase()
125133
gspec.MustCommit(db)
126-
bc, _ = NewBlockChain(db, proConf, ethash.NewFaker(), vm.Config{})
134+
bc, _ = NewBlockChain(db, &proConf, ethash.NewFaker(), vm.Config{})
127135
defer bc.Stop()
128136

129137
blocks = proBc.GetBlocksFromHash(proBc.CurrentBlock().Hash(), int(proBc.CurrentBlock().NumberU64()))
@@ -133,7 +141,7 @@ func TestDAOForkRangeExtradata(t *testing.T) {
133141
if _, err := bc.InsertChain(blocks); err != nil {
134142
t.Fatalf("failed to import pro-fork chain for expansion: %v", err)
135143
}
136-
blocks, _ = GenerateChain(conConf, proBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
144+
blocks, _ = GenerateChain(&conConf, proBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
137145
if _, err := proBc.InsertChain(blocks); err != nil {
138146
t.Fatalf("pro-fork chain didn't accept contra-fork block post-fork: %v", err)
139147
}

params/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var (
5555
EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"),
5656
EIP155Block: big.NewInt(10),
5757
EIP158Block: big.NewInt(10),
58-
ByzantiumBlock: big.NewInt(math.MaxInt64), // Don't enable yet
58+
ByzantiumBlock: big.NewInt(1700000),
5959

6060
Ethash: new(EthashConfig),
6161
}
@@ -86,8 +86,8 @@ var (
8686
// means that all fields must be set at all times. This forces
8787
// anyone adding flags to the config to also have to set these
8888
// fields.
89-
AllProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(math.MaxInt64) /*disabled*/, new(EthashConfig), nil}
90-
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil}
89+
AllProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), new(EthashConfig), nil}
90+
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), new(EthashConfig), nil}
9191
TestRules = TestChainConfig.Rules(new(big.Int))
9292
)
9393

0 commit comments

Comments
 (0)