core: implemented new ropsten testnet

This commit is contained in:
Jeffrey Wilcke 2016-11-20 22:32:31 +01:00
parent aad4890082
commit a8ca75738a
8 changed files with 42 additions and 66 deletions

View File

@ -191,14 +191,15 @@ func testDAOForkBlockNewChain(t *testing.T, testnet bool, genesis string, votes
genesisHash := common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") genesisHash := common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")
if testnet { if testnet {
genesisHash = common.HexToHash("0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303") genesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d")
} }
if genesis != "" { if genesis != "" {
genesisHash = daoGenesisHash genesisHash = daoGenesisHash
} }
config, err := core.GetChainConfig(db, genesisHash) config, err := core.GetChainConfig(db, genesisHash)
if err != nil { if err != nil {
t.Fatalf("failed to retrieve chain config: %v", err) t.Errorf("failed to retrieve chain config: %v", err)
return // we want to return here, the other checks can't make it past this point (nil panic).
} }
// Validate the DAO hard-fork block number against the expected value // Validate the DAO hard-fork block number against the expected value
if config.DAOForkBlock == nil { if config.DAOForkBlock == nil {

View File

@ -750,9 +750,9 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
case ctx.GlobalBool(TestNetFlag.Name): case ctx.GlobalBool(TestNetFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) { if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
ethConf.NetworkId = 2 ethConf.NetworkId = 3
} }
ethConf.Genesis = core.TestNetGenesisBlock() ethConf.Genesis = core.DefaultTestnetGenesisBlock()
case ctx.GlobalBool(DevModeFlag.Name): case ctx.GlobalBool(DevModeFlag.Name):
ethConf.Genesis = core.OlympicGenesisBlock() ethConf.Genesis = core.OlympicGenesisBlock()
@ -845,34 +845,20 @@ func MakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *params.ChainCon
(genesis.Hash() == params.TestNetGenesisHash && ctx.GlobalBool(TestNetFlag.Name)) (genesis.Hash() == params.TestNetGenesisHash && ctx.GlobalBool(TestNetFlag.Name))
if defaults { if defaults {
// Homestead fork
if ctx.GlobalBool(TestNetFlag.Name) { if ctx.GlobalBool(TestNetFlag.Name) {
config.HomesteadBlock = params.TestNetHomesteadBlock config = params.TestnetChainConfig
} else { } else {
// Homestead fork
config.HomesteadBlock = params.MainNetHomesteadBlock config.HomesteadBlock = params.MainNetHomesteadBlock
} // DAO fork
// DAO fork
if ctx.GlobalBool(TestNetFlag.Name) {
config.DAOForkBlock = params.TestNetDAOForkBlock
} else {
config.DAOForkBlock = params.MainNetDAOForkBlock config.DAOForkBlock = params.MainNetDAOForkBlock
} config.DAOForkSupport = true
config.DAOForkSupport = true
// DoS reprice fork // DoS reprice fork
if ctx.GlobalBool(TestNetFlag.Name) {
config.EIP150Block = params.TestNetHomesteadGasRepriceBlock
config.EIP150Hash = params.TestNetHomesteadGasRepriceHash
} else {
config.EIP150Block = params.MainNetHomesteadGasRepriceBlock config.EIP150Block = params.MainNetHomesteadGasRepriceBlock
config.EIP150Hash = params.MainNetHomesteadGasRepriceHash config.EIP150Hash = params.MainNetHomesteadGasRepriceHash
}
// DoS state cleanup fork // DoS state cleanup fork
if ctx.GlobalBool(TestNetFlag.Name) {
config.EIP155Block = params.TestNetSpuriousDragon
config.EIP158Block = params.TestNetSpuriousDragon
config.ChainId = params.TestNetChainID
} else {
config.EIP155Block = params.MainNetSpuriousDragon config.EIP155Block = params.MainNetSpuriousDragon
config.EIP158Block = params.MainNetSpuriousDragon config.EIP158Block = params.MainNetSpuriousDragon
config.ChainId = params.MainNetChainID config.ChainId = params.MainNetChainID

File diff suppressed because one or more lines are too long

View File

@ -17,6 +17,7 @@
package core package core
import ( import (
"compress/bzip2"
"compress/gzip" "compress/gzip"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
@ -43,7 +44,7 @@ func WriteGenesisBlock(chainDb ethdb.Database, reader io.Reader) (*types.Block,
} }
var genesis struct { var genesis struct {
ChainConfig params.ChainConfig `json:"config"` ChainConfig *params.ChainConfig `json:"config"`
Nonce string Nonce string
Timestamp string Timestamp string
ParentHash string ParentHash string
@ -115,7 +116,7 @@ func WriteGenesisBlock(chainDb ethdb.Database, reader io.Reader) (*types.Block,
if err := WriteHeadBlockHash(chainDb, block.Hash()); err != nil { if err := WriteHeadBlockHash(chainDb, block.Hash()); err != nil {
return nil, err return nil, err
} }
if err := WriteChainConfig(chainDb, block.Hash(), &genesis.ChainConfig); err != nil { if err := WriteChainConfig(chainDb, block.Hash(), genesis.ChainConfig); err != nil {
return nil, err return nil, err
} }
@ -174,7 +175,7 @@ func WriteDefaultGenesisBlock(chainDb ethdb.Database) (*types.Block, error) {
// WriteTestNetGenesisBlock assembles the Morden test network genesis block and // WriteTestNetGenesisBlock assembles the Morden test network genesis block and
// writes it - along with all associated state - into a chain database. // writes it - along with all associated state - into a chain database.
func WriteTestNetGenesisBlock(chainDb ethdb.Database) (*types.Block, error) { func WriteTestNetGenesisBlock(chainDb ethdb.Database) (*types.Block, error) {
return WriteGenesisBlock(chainDb, strings.NewReader(TestNetGenesisBlock())) return WriteGenesisBlock(chainDb, strings.NewReader(DefaultTestnetGenesisBlock()))
} }
// WriteOlympicGenesisBlock assembles the Olympic genesis block and writes it // WriteOlympicGenesisBlock assembles the Olympic genesis block and writes it
@ -197,6 +198,15 @@ func DefaultGenesisBlock() string {
return string(blob) return string(blob)
} }
func DefaultTestnetGenesisBlock() string {
reader := bzip2.NewReader(base64.NewDecoder(base64.StdEncoding, strings.NewReader(defaultTestnetGenesisBlock)))
blob, err := ioutil.ReadAll(reader)
if err != nil {
panic(fmt.Sprintf("failed to load default genesis: %v", err))
}
return string(blob)
}
// OlympicGenesisBlock assembles a JSON string representing the Olympic genesis // OlympicGenesisBlock assembles a JSON string representing the Olympic genesis
// block. // block.
func OlympicGenesisBlock() string { func OlympicGenesisBlock() string {
@ -220,25 +230,3 @@ func OlympicGenesisBlock() string {
} }
}`, types.EncodeNonce(42), params.GenesisGasLimit.Bytes(), params.GenesisDifficulty.Bytes()) }`, types.EncodeNonce(42), params.GenesisGasLimit.Bytes(), params.GenesisDifficulty.Bytes())
} }
// TestNetGenesisBlock assembles a JSON string representing the Morden test net
// genenis block.
func TestNetGenesisBlock() string {
return fmt.Sprintf(`{
"nonce": "0x%x",
"difficulty": "0x20000",
"mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
"coinbase": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
"gasLimit": "0x2FEFD8",
"alloc": {
"0000000000000000000000000000000000000001": { "balance": "1" },
"0000000000000000000000000000000000000002": { "balance": "1" },
"0000000000000000000000000000000000000003": { "balance": "1" },
"0000000000000000000000000000000000000004": { "balance": "1" },
"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376" }
}
}`, types.EncodeNonce(0x6d6f7264656e))
}

View File

@ -235,7 +235,6 @@ func (self *LightState) newStateObject(addr common.Address) *StateObject {
} }
stateObject := NewStateObject(addr, self.odr) stateObject := NewStateObject(addr, self.odr)
stateObject.SetNonce(0)
self.stateObjects[addr.Str()] = stateObject self.stateObjects[addr.Str()] = stateObject
return stateObject return stateObject

View File

@ -60,7 +60,7 @@ func TestnetChainConfig() *ChainConfig {
// TestnetGenesis returns the JSON spec to use for the Ethereum test network. // TestnetGenesis returns the JSON spec to use for the Ethereum test network.
func TestnetGenesis() string { func TestnetGenesis() string {
return core.TestNetGenesisBlock() return core.DefaultTestnetGenesisBlock()
} }
// ChainConfig is the core config which determines the blockchain settings. // ChainConfig is the core config which determines the blockchain settings.

View File

@ -36,14 +36,14 @@ var MainnetChainConfig = &ChainConfig{
// TestnetChainConfig is the chain parameters to run a node on the test network. // TestnetChainConfig is the chain parameters to run a node on the test network.
var TestnetChainConfig = &ChainConfig{ var TestnetChainConfig = &ChainConfig{
ChainId: TestNetChainID, ChainId: big.NewInt(3),
HomesteadBlock: TestNetHomesteadBlock, HomesteadBlock: big.NewInt(0),
DAOForkBlock: TestNetDAOForkBlock, DAOForkBlock: nil,
DAOForkSupport: false, DAOForkSupport: true,
EIP150Block: TestNetHomesteadGasRepriceBlock, EIP150Block: big.NewInt(0),
EIP150Hash: TestNetHomesteadGasRepriceHash, EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"),
EIP155Block: TestNetSpuriousDragon, EIP155Block: big.NewInt(10),
EIP158Block: TestNetSpuriousDragon, EIP158Block: big.NewInt(10),
} }
// ChainConfig is the core config which determines the blockchain settings. // ChainConfig is the core config which determines the blockchain settings.

View File

@ -23,21 +23,21 @@ import (
) )
var ( var (
TestNetGenesisHash = common.HexToHash("0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303") // Testnet genesis hash to enforce below configs on TestNetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") // Testnet genesis hash to enforce below configs on
MainNetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") // Mainnet genesis hash to enforce below configs on MainNetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") // Mainnet genesis hash to enforce below configs on
TestNetHomesteadBlock = big.NewInt(494000) // Testnet homestead block TestNetHomesteadBlock = big.NewInt(0) // Testnet homestead block
MainNetHomesteadBlock = big.NewInt(1150000) // Mainnet homestead block MainNetHomesteadBlock = big.NewInt(1150000) // Mainnet homestead block
TestNetHomesteadGasRepriceBlock = big.NewInt(1783000) // Testnet gas reprice block TestNetHomesteadGasRepriceBlock = big.NewInt(0) // Testnet gas reprice block
MainNetHomesteadGasRepriceBlock = big.NewInt(2463000) // Mainnet gas reprice block MainNetHomesteadGasRepriceBlock = big.NewInt(2463000) // Mainnet gas reprice block
TestNetHomesteadGasRepriceHash = common.HexToHash("0xf376243aeff1f256d970714c3de9fd78fa4e63cf63e32a51fe1169e375d98145") // Testnet gas reprice block hash (used by fast sync) TestNetHomesteadGasRepriceHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") // Testnet gas reprice block hash (used by fast sync)
MainNetHomesteadGasRepriceHash = common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0") // Mainnet gas reprice block hash (used by fast sync) MainNetHomesteadGasRepriceHash = common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0") // Mainnet gas reprice block hash (used by fast sync)
TestNetSpuriousDragon = big.NewInt(1885000) TestNetSpuriousDragon = big.NewInt(10)
MainNetSpuriousDragon = big.NewInt(2675000) MainNetSpuriousDragon = big.NewInt(2675000)
TestNetChainID = big.NewInt(2) // Test net default chain ID TestNetChainID = big.NewInt(3) // Test net default chain ID
MainNetChainID = big.NewInt(1) // main net default chain ID MainNetChainID = big.NewInt(1) // main net default chain ID
) )