Skip to content

Commit a8ca757

Browse files
committed
core: implemented new ropsten testnet
1 parent aad4890 commit a8ca757

File tree

8 files changed

+42
-66
lines changed

8 files changed

+42
-66
lines changed

cmd/geth/dao_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,15 @@ func testDAOForkBlockNewChain(t *testing.T, testnet bool, genesis string, votes
191191

192192
genesisHash := common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")
193193
if testnet {
194-
genesisHash = common.HexToHash("0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303")
194+
genesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d")
195195
}
196196
if genesis != "" {
197197
genesisHash = daoGenesisHash
198198
}
199199
config, err := core.GetChainConfig(db, genesisHash)
200200
if err != nil {
201-
t.Fatalf("failed to retrieve chain config: %v", err)
201+
t.Errorf("failed to retrieve chain config: %v", err)
202+
return // we want to return here, the other checks can't make it past this point (nil panic).
202203
}
203204
// Validate the DAO hard-fork block number against the expected value
204205
if config.DAOForkBlock == nil {

cmd/utils/flags.go

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -750,9 +750,9 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
750750

751751
case ctx.GlobalBool(TestNetFlag.Name):
752752
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
753-
ethConf.NetworkId = 2
753+
ethConf.NetworkId = 3
754754
}
755-
ethConf.Genesis = core.TestNetGenesisBlock()
755+
ethConf.Genesis = core.DefaultTestnetGenesisBlock()
756756

757757
case ctx.GlobalBool(DevModeFlag.Name):
758758
ethConf.Genesis = core.OlympicGenesisBlock()
@@ -845,34 +845,20 @@ func MakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *params.ChainCon
845845
(genesis.Hash() == params.TestNetGenesisHash && ctx.GlobalBool(TestNetFlag.Name))
846846

847847
if defaults {
848-
// Homestead fork
849848
if ctx.GlobalBool(TestNetFlag.Name) {
850-
config.HomesteadBlock = params.TestNetHomesteadBlock
849+
config = params.TestnetChainConfig
851850
} else {
851+
// Homestead fork
852852
config.HomesteadBlock = params.MainNetHomesteadBlock
853-
}
854-
// DAO fork
855-
if ctx.GlobalBool(TestNetFlag.Name) {
856-
config.DAOForkBlock = params.TestNetDAOForkBlock
857-
} else {
853+
// DAO fork
858854
config.DAOForkBlock = params.MainNetDAOForkBlock
859-
}
860-
config.DAOForkSupport = true
855+
config.DAOForkSupport = true
861856

862-
// DoS reprice fork
863-
if ctx.GlobalBool(TestNetFlag.Name) {
864-
config.EIP150Block = params.TestNetHomesteadGasRepriceBlock
865-
config.EIP150Hash = params.TestNetHomesteadGasRepriceHash
866-
} else {
857+
// DoS reprice fork
867858
config.EIP150Block = params.MainNetHomesteadGasRepriceBlock
868859
config.EIP150Hash = params.MainNetHomesteadGasRepriceHash
869-
}
870-
// DoS state cleanup fork
871-
if ctx.GlobalBool(TestNetFlag.Name) {
872-
config.EIP155Block = params.TestNetSpuriousDragon
873-
config.EIP158Block = params.TestNetSpuriousDragon
874-
config.ChainId = params.TestNetChainID
875-
} else {
860+
861+
// DoS state cleanup fork
876862
config.EIP155Block = params.MainNetSpuriousDragon
877863
config.EIP158Block = params.MainNetSpuriousDragon
878864
config.ChainId = params.MainNetChainID

core/default_genesis.go

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.

core/genesis.go

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package core
1818

1919
import (
20+
"compress/bzip2"
2021
"compress/gzip"
2122
"encoding/base64"
2223
"encoding/json"
@@ -43,7 +44,7 @@ func WriteGenesisBlock(chainDb ethdb.Database, reader io.Reader) (*types.Block,
4344
}
4445

4546
var genesis struct {
46-
ChainConfig params.ChainConfig `json:"config"`
47+
ChainConfig *params.ChainConfig `json:"config"`
4748
Nonce string
4849
Timestamp string
4950
ParentHash string
@@ -115,7 +116,7 @@ func WriteGenesisBlock(chainDb ethdb.Database, reader io.Reader) (*types.Block,
115116
if err := WriteHeadBlockHash(chainDb, block.Hash()); err != nil {
116117
return nil, err
117118
}
118-
if err := WriteChainConfig(chainDb, block.Hash(), &genesis.ChainConfig); err != nil {
119+
if err := WriteChainConfig(chainDb, block.Hash(), genesis.ChainConfig); err != nil {
119120
return nil, err
120121
}
121122

@@ -174,7 +175,7 @@ func WriteDefaultGenesisBlock(chainDb ethdb.Database) (*types.Block, error) {
174175
// WriteTestNetGenesisBlock assembles the Morden test network genesis block and
175176
// writes it - along with all associated state - into a chain database.
176177
func WriteTestNetGenesisBlock(chainDb ethdb.Database) (*types.Block, error) {
177-
return WriteGenesisBlock(chainDb, strings.NewReader(TestNetGenesisBlock()))
178+
return WriteGenesisBlock(chainDb, strings.NewReader(DefaultTestnetGenesisBlock()))
178179
}
179180

180181
// WriteOlympicGenesisBlock assembles the Olympic genesis block and writes it
@@ -197,6 +198,15 @@ func DefaultGenesisBlock() string {
197198
return string(blob)
198199
}
199200

201+
func DefaultTestnetGenesisBlock() string {
202+
reader := bzip2.NewReader(base64.NewDecoder(base64.StdEncoding, strings.NewReader(defaultTestnetGenesisBlock)))
203+
blob, err := ioutil.ReadAll(reader)
204+
if err != nil {
205+
panic(fmt.Sprintf("failed to load default genesis: %v", err))
206+
}
207+
return string(blob)
208+
}
209+
200210
// OlympicGenesisBlock assembles a JSON string representing the Olympic genesis
201211
// block.
202212
func OlympicGenesisBlock() string {
@@ -220,25 +230,3 @@ func OlympicGenesisBlock() string {
220230
}
221231
}`, types.EncodeNonce(42), params.GenesisGasLimit.Bytes(), params.GenesisDifficulty.Bytes())
222232
}
223-
224-
// TestNetGenesisBlock assembles a JSON string representing the Morden test net
225-
// genenis block.
226-
func TestNetGenesisBlock() string {
227-
return fmt.Sprintf(`{
228-
"nonce": "0x%x",
229-
"difficulty": "0x20000",
230-
"mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
231-
"coinbase": "0x0000000000000000000000000000000000000000",
232-
"timestamp": "0x00",
233-
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
234-
"extraData": "0x",
235-
"gasLimit": "0x2FEFD8",
236-
"alloc": {
237-
"0000000000000000000000000000000000000001": { "balance": "1" },
238-
"0000000000000000000000000000000000000002": { "balance": "1" },
239-
"0000000000000000000000000000000000000003": { "balance": "1" },
240-
"0000000000000000000000000000000000000004": { "balance": "1" },
241-
"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376" }
242-
}
243-
}`, types.EncodeNonce(0x6d6f7264656e))
244-
}

light/state.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ func (self *LightState) newStateObject(addr common.Address) *StateObject {
235235
}
236236

237237
stateObject := NewStateObject(addr, self.odr)
238-
stateObject.SetNonce(0)
239238
self.stateObjects[addr.Str()] = stateObject
240239

241240
return stateObject

mobile/params.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func TestnetChainConfig() *ChainConfig {
6060

6161
// TestnetGenesis returns the JSON spec to use for the Ethereum test network.
6262
func TestnetGenesis() string {
63-
return core.TestNetGenesisBlock()
63+
return core.DefaultTestnetGenesisBlock()
6464
}
6565

6666
// ChainConfig is the core config which determines the blockchain settings.

params/config.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ var MainnetChainConfig = &ChainConfig{
3636

3737
// TestnetChainConfig is the chain parameters to run a node on the test network.
3838
var TestnetChainConfig = &ChainConfig{
39-
ChainId: TestNetChainID,
40-
HomesteadBlock: TestNetHomesteadBlock,
41-
DAOForkBlock: TestNetDAOForkBlock,
42-
DAOForkSupport: false,
43-
EIP150Block: TestNetHomesteadGasRepriceBlock,
44-
EIP150Hash: TestNetHomesteadGasRepriceHash,
45-
EIP155Block: TestNetSpuriousDragon,
46-
EIP158Block: TestNetSpuriousDragon,
39+
ChainId: big.NewInt(3),
40+
HomesteadBlock: big.NewInt(0),
41+
DAOForkBlock: nil,
42+
DAOForkSupport: true,
43+
EIP150Block: big.NewInt(0),
44+
EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"),
45+
EIP155Block: big.NewInt(10),
46+
EIP158Block: big.NewInt(10),
4747
}
4848

4949
// ChainConfig is the core config which determines the blockchain settings.

params/util.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ import (
2323
)
2424

2525
var (
26-
TestNetGenesisHash = common.HexToHash("0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303") // Testnet genesis hash to enforce below configs on
26+
TestNetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") // Testnet genesis hash to enforce below configs on
2727
MainNetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") // Mainnet genesis hash to enforce below configs on
2828

29-
TestNetHomesteadBlock = big.NewInt(494000) // Testnet homestead block
29+
TestNetHomesteadBlock = big.NewInt(0) // Testnet homestead block
3030
MainNetHomesteadBlock = big.NewInt(1150000) // Mainnet homestead block
3131

32-
TestNetHomesteadGasRepriceBlock = big.NewInt(1783000) // Testnet gas reprice block
32+
TestNetHomesteadGasRepriceBlock = big.NewInt(0) // Testnet gas reprice block
3333
MainNetHomesteadGasRepriceBlock = big.NewInt(2463000) // Mainnet gas reprice block
3434

35-
TestNetHomesteadGasRepriceHash = common.HexToHash("0xf376243aeff1f256d970714c3de9fd78fa4e63cf63e32a51fe1169e375d98145") // Testnet gas reprice block hash (used by fast sync)
35+
TestNetHomesteadGasRepriceHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") // Testnet gas reprice block hash (used by fast sync)
3636
MainNetHomesteadGasRepriceHash = common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0") // Mainnet gas reprice block hash (used by fast sync)
3737

38-
TestNetSpuriousDragon = big.NewInt(1885000)
38+
TestNetSpuriousDragon = big.NewInt(10)
3939
MainNetSpuriousDragon = big.NewInt(2675000)
4040

41-
TestNetChainID = big.NewInt(2) // Test net default chain ID
41+
TestNetChainID = big.NewInt(3) // Test net default chain ID
4242
MainNetChainID = big.NewInt(1) // main net default chain ID
4343
)

0 commit comments

Comments
 (0)