diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-11-16 07:46:40 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-11-16 07:46:40 +0800 |
commit | 64359c9417244c7a824ea90b39a20b06f702bc08 (patch) | |
tree | eb0618e0afbbf7364884d1ce9ce23266fc56de94 | |
parent | 5a3853f83f931b6a68353cb1f3611f1db345e340 (diff) | |
download | go-tangerine-64359c9417244c7a824ea90b39a20b06f702bc08.tar.gz go-tangerine-64359c9417244c7a824ea90b39a20b06f702bc08.tar.zst go-tangerine-64359c9417244c7a824ea90b39a20b06f702bc08.zip |
cmd/utils, mobile, params: set the correct field on testnet EIP 155 (#3272)
-rw-r--r-- | cmd/utils/flags.go | 77 | ||||
-rw-r--r-- | mobile/geth.go | 1 | ||||
-rw-r--r-- | mobile/params.go | 5 | ||||
-rw-r--r-- | params/config.go | 2 |
4 files changed, 35 insertions, 50 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index cac8773e2..dd18fd78c 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -847,61 +847,40 @@ func MakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *params.ChainCon (genesis.Hash() == params.MainNetGenesisHash && !ctx.GlobalBool(TestNetFlag.Name)) || (genesis.Hash() == params.TestNetGenesisHash && ctx.GlobalBool(TestNetFlag.Name)) - // Set any missing chainConfig fields due to them being unset or system upgrade if defaults { - if config.HomesteadBlock == nil { - if ctx.GlobalBool(TestNetFlag.Name) { - config.HomesteadBlock = params.TestNetHomesteadBlock - } else { - config.HomesteadBlock = params.MainNetHomesteadBlock - } - } - if config.DAOForkBlock == nil { - if ctx.GlobalBool(TestNetFlag.Name) { - config.DAOForkBlock = params.TestNetDAOForkBlock - } else { - config.DAOForkBlock = params.MainNetDAOForkBlock - } - config.DAOForkSupport = true - } - if config.EIP150Block == nil { - if ctx.GlobalBool(TestNetFlag.Name) { - config.EIP150Block = params.TestNetHomesteadGasRepriceBlock - } else { - config.EIP150Block = params.MainNetHomesteadGasRepriceBlock - } - } - if config.EIP150Hash == (common.Hash{}) { - if ctx.GlobalBool(TestNetFlag.Name) { - config.EIP150Hash = params.TestNetHomesteadGasRepriceHash - } else { - config.EIP150Hash = params.MainNetHomesteadGasRepriceHash - } + // Homestead fork + if ctx.GlobalBool(TestNetFlag.Name) { + config.HomesteadBlock = params.TestNetHomesteadBlock + } else { + config.HomesteadBlock = params.MainNetHomesteadBlock } - if config.EIP155Block == nil { - if ctx.GlobalBool(TestNetFlag.Name) { - config.EIP150Block = params.TestNetSpuriousDragon - } else { - config.EIP155Block = params.MainNetSpuriousDragon - } + // DAO fork + if ctx.GlobalBool(TestNetFlag.Name) { + config.DAOForkBlock = params.TestNetDAOForkBlock + } else { + config.DAOForkBlock = params.MainNetDAOForkBlock } - if config.EIP158Block == nil { - if ctx.GlobalBool(TestNetFlag.Name) { - config.EIP158Block = params.TestNetSpuriousDragon - } else { - config.EIP158Block = params.MainNetSpuriousDragon - } + config.DAOForkSupport = true + + // DoS reprice fork + if ctx.GlobalBool(TestNetFlag.Name) { + config.EIP150Block = params.TestNetHomesteadGasRepriceBlock + config.EIP150Hash = params.TestNetHomesteadGasRepriceHash + } else { + config.EIP150Block = params.MainNetHomesteadGasRepriceBlock + config.EIP150Hash = params.MainNetHomesteadGasRepriceHash } - if config.ChainId.BitLen() == 0 { - if ctx.GlobalBool(TestNetFlag.Name) { - config.ChainId = params.TestNetChainID - } else { - config.ChainId = params.MainNetChainID - } + // 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.EIP158Block = params.MainNetSpuriousDragon + config.ChainId = params.MainNetChainID } - config.DAOForkSupport = true } - // Force override any existing configs if explicitly requested switch { case ctx.GlobalBool(SupportDAOFork.Name): diff --git a/mobile/geth.go b/mobile/geth.go index d7f0800e0..e209b667c 100644 --- a/mobile/geth.go +++ b/mobile/geth.go @@ -130,6 +130,7 @@ func NewNode(datadir string, config *NodeConfig) (*Node, error) { if config.EthereumEnabled { ethConf := ð.Config{ ChainConfig: ¶ms.ChainConfig{ + ChainId: big.NewInt(config.EthereumChainConfig.ChainID), HomesteadBlock: big.NewInt(config.EthereumChainConfig.HomesteadBlock), DAOForkBlock: big.NewInt(config.EthereumChainConfig.DAOForkBlock), DAOForkSupport: config.EthereumChainConfig.DAOForkSupport, diff --git a/mobile/params.go b/mobile/params.go index 48344a538..1b9f124b4 100644 --- a/mobile/params.go +++ b/mobile/params.go @@ -27,6 +27,7 @@ import ( // MainnetChainConfig returns the chain configurations for the main Ethereum network. func MainnetChainConfig() *ChainConfig { return &ChainConfig{ + ChainID: params.MainNetChainID.Int64(), HomesteadBlock: params.MainNetHomesteadBlock.Int64(), DAOForkBlock: params.MainNetDAOForkBlock.Int64(), DAOForkSupport: true, @@ -46,9 +47,10 @@ func MainnetGenesis() string { // TestnetChainConfig returns the chain configurations for the Ethereum test network. func TestnetChainConfig() *ChainConfig { return &ChainConfig{ + ChainID: params.TestNetChainID.Int64(), HomesteadBlock: params.TestNetHomesteadBlock.Int64(), DAOForkBlock: 0, - DAOForkSupport: false, + DAOForkSupport: true, EIP150Block: params.TestNetHomesteadGasRepriceBlock.Int64(), EIP150Hash: Hash{params.TestNetHomesteadGasRepriceHash}, EIP155Block: params.TestNetSpuriousDragon.Int64(), @@ -63,6 +65,7 @@ func TestnetGenesis() string { // ChainConfig is the core config which determines the blockchain settings. type ChainConfig struct { + ChainID int64 // Chain ID for replay protection HomesteadBlock int64 // Homestead switch block DAOForkBlock int64 // TheDAO hard-fork switch block DAOForkSupport bool // Whether the nodes supports or opposes the DAO hard-fork diff --git a/params/config.go b/params/config.go index d27973a32..6d8d73a9b 100644 --- a/params/config.go +++ b/params/config.go @@ -24,6 +24,7 @@ import ( // MainnetChainConfig is the chain parameters to run a node on the main network. var MainnetChainConfig = &ChainConfig{ + ChainId: MainNetChainID, HomesteadBlock: MainNetHomesteadBlock, DAOForkBlock: MainNetDAOForkBlock, DAOForkSupport: true, @@ -35,6 +36,7 @@ var MainnetChainConfig = &ChainConfig{ // TestnetChainConfig is the chain parameters to run a node on the test network. var TestnetChainConfig = &ChainConfig{ + ChainId: TestNetChainID, HomesteadBlock: TestNetHomesteadBlock, DAOForkBlock: TestNetDAOForkBlock, DAOForkSupport: false, |