diff --git a/cmd/puppeth/genesis.go b/cmd/puppeth/genesis.go index ae7675cd9b..1e283ec1b6 100644 --- a/cmd/puppeth/genesis.go +++ b/cmd/puppeth/genesis.go @@ -36,25 +36,27 @@ import ( type alethGenesisSpec struct { SealEngine string `json:"sealEngine"` Params struct { - AccountStartNonce math2.HexOrDecimal64 `json:"accountStartNonce"` - MaximumExtraDataSize hexutil.Uint64 `json:"maximumExtraDataSize"` - HomesteadForkBlock hexutil.Uint64 `json:"homesteadForkBlock"` - DaoHardforkBlock math2.HexOrDecimal64 `json:"daoHardforkBlock"` - EIP150ForkBlock hexutil.Uint64 `json:"EIP150ForkBlock"` - EIP158ForkBlock hexutil.Uint64 `json:"EIP158ForkBlock"` - ByzantiumForkBlock hexutil.Uint64 `json:"byzantiumForkBlock"` - ConstantinopleForkBlock hexutil.Uint64 `json:"constantinopleForkBlock"` - MinGasLimit hexutil.Uint64 `json:"minGasLimit"` - MaxGasLimit hexutil.Uint64 `json:"maxGasLimit"` - TieBreakingGas bool `json:"tieBreakingGas"` - GasLimitBoundDivisor math2.HexOrDecimal64 `json:"gasLimitBoundDivisor"` - MinimumDifficulty *hexutil.Big `json:"minimumDifficulty"` - DifficultyBoundDivisor *math2.HexOrDecimal256 `json:"difficultyBoundDivisor"` - DurationLimit *math2.HexOrDecimal256 `json:"durationLimit"` - BlockReward *hexutil.Big `json:"blockReward"` - NetworkID hexutil.Uint64 `json:"networkID"` - ChainID hexutil.Uint64 `json:"chainID"` - AllowFutureBlocks bool `json:"allowFutureBlocks"` + AccountStartNonce math2.HexOrDecimal64 `json:"accountStartNonce"` + MaximumExtraDataSize hexutil.Uint64 `json:"maximumExtraDataSize"` + HomesteadForkBlock hexutil.Uint64 `json:"homesteadForkBlock"` + DaoHardforkBlock math2.HexOrDecimal64 `json:"daoHardforkBlock"` + EIP150ForkBlock hexutil.Uint64 `json:"EIP150ForkBlock"` + EIP158ForkBlock hexutil.Uint64 `json:"EIP158ForkBlock"` + ByzantiumForkBlock hexutil.Uint64 `json:"byzantiumForkBlock"` + ConstantinopleForkBlock hexutil.Uint64 `json:"constantinopleForkBlock"` + ConstantinopleFixForkBlock hexutil.Uint64 `json:"constantinopleFixForkBlock"` + IstanbulForkBlock hexutil.Uint64 `json:"IstanbulForkBlock"` + MinGasLimit hexutil.Uint64 `json:"minGasLimit"` + MaxGasLimit hexutil.Uint64 `json:"maxGasLimit"` + TieBreakingGas bool `json:"tieBreakingGas"` + GasLimitBoundDivisor math2.HexOrDecimal64 `json:"gasLimitBoundDivisor"` + MinimumDifficulty *hexutil.Big `json:"minimumDifficulty"` + DifficultyBoundDivisor *math2.HexOrDecimal256 `json:"difficultyBoundDivisor"` + DurationLimit *math2.HexOrDecimal256 `json:"durationLimit"` + BlockReward *hexutil.Big `json:"blockReward"` + NetworkID hexutil.Uint64 `json:"networkID"` + ChainID hexutil.Uint64 `json:"chainID"` + AllowFutureBlocks bool `json:"allowFutureBlocks"` } `json:"params"` Genesis struct { @@ -112,15 +114,27 @@ func newAlethGenesisSpec(network string, genesis *core.Genesis) (*alethGenesisSp spec.Params.EIP150ForkBlock = (hexutil.Uint64)(genesis.Config.EIP150Block.Uint64()) spec.Params.EIP158ForkBlock = (hexutil.Uint64)(genesis.Config.EIP158Block.Uint64()) - // Byzantium + if num := genesis.Config.HomesteadBlock; num != nil { + spec.Params.HomesteadForkBlock = hexutil.Uint64(num.Uint64()) + } + if num := genesis.Config.EIP150Block; num != nil { + spec.Params.EIP150ForkBlock = hexutil.Uint64(num.Uint64()) + } + if num := genesis.Config.EIP158Block; num != nil { + spec.Params.EIP158ForkBlock = hexutil.Uint64(num.Uint64()) + } if num := genesis.Config.ByzantiumBlock; num != nil { - spec.setByzantium(num) + spec.Params.ByzantiumForkBlock = hexutil.Uint64(num.Uint64()) } - // Constantinople if num := genesis.Config.ConstantinopleBlock; num != nil { - spec.setConstantinople(num) + spec.Params.ConstantinopleForkBlock = hexutil.Uint64(num.Uint64()) + } + if num := genesis.Config.PetersburgBlock; num != nil { + spec.Params.ConstantinopleFixForkBlock = hexutil.Uint64(num.Uint64()) + } + if num := genesis.Config.IstanbulBlock; num != nil { + spec.Params.IstanbulForkBlock = hexutil.Uint64(num.Uint64()) } - spec.Params.NetworkID = (hexutil.Uint64)(genesis.Config.ChainID.Uint64()) spec.Params.ChainID = (hexutil.Uint64)(genesis.Config.ChainID.Uint64()) spec.Params.MaximumExtraDataSize = (hexutil.Uint64)(params.MaximumExtraDataSize) @@ -196,14 +210,6 @@ func (spec *alethGenesisSpec) setAccount(address common.Address, account core.Ge } -func (spec *alethGenesisSpec) setByzantium(num *big.Int) { - spec.Params.ByzantiumForkBlock = hexutil.Uint64(num.Uint64()) -} - -func (spec *alethGenesisSpec) setConstantinople(num *big.Int) { - spec.Params.ConstantinopleForkBlock = hexutil.Uint64(num.Uint64()) -} - // parityChainSpec is the chain specification format used by Parity. type parityChainSpec struct { Name string `json:"name"` diff --git a/cmd/puppeth/wizard_genesis.go b/cmd/puppeth/wizard_genesis.go index 499f320f64..44b607ce86 100644 --- a/cmd/puppeth/wizard_genesis.go +++ b/cmd/puppeth/wizard_genesis.go @@ -51,6 +51,7 @@ func (w *wizard) makeGenesis() { ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), }, } // Figure out which consensus engine to choose @@ -230,6 +231,10 @@ func (w *wizard) manageGenesis() { fmt.Printf("Which block should Petersburg come into effect? (default = %v)\n", w.conf.Genesis.Config.PetersburgBlock) w.conf.Genesis.Config.PetersburgBlock = w.readDefaultBigInt(w.conf.Genesis.Config.PetersburgBlock) + fmt.Println() + fmt.Printf("Which block should Istanbul come into effect? (default = %v)\n", w.conf.Genesis.Config.IstanbulBlock) + w.conf.Genesis.Config.IstanbulBlock = w.readDefaultBigInt(w.conf.Genesis.Config.IstanbulBlock) + out, _ := json.MarshalIndent(w.conf.Genesis.Config, "", " ") fmt.Printf("Chain configuration updated:\n\n%s\n", out) @@ -268,7 +273,7 @@ func (w *wizard) manageGenesis() { } else { saveGenesis(folder, w.network, "parity", spec) } - // Export the genesis spec used by Harmony (formerly EthereumJ + // Export the genesis spec used by Harmony (formerly EthereumJ) saveGenesis(folder, w.network, "harmony", w.conf.Genesis) case "3":