diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-11-24 16:56:33 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-24 16:56:33 +0800 |
commit | f9569f3cd8a05dff5be5da83a5d8c70c1b23dd3e (patch) | |
tree | fa8b344aedb3d56c2cd904173053a5273ec87a67 /cmd/puppeth/wizard_genesis.go | |
parent | 35801f938e21430f8fb0f2e1c3de5db7dbd21666 (diff) | |
parent | a3a2c6b0d9f963c9377612cae1ed6ded6f216c2d (diff) | |
download | go-tangerine-f9569f3cd8a05dff5be5da83a5d8c70c1b23dd3e.tar go-tangerine-f9569f3cd8a05dff5be5da83a5d8c70c1b23dd3e.tar.gz go-tangerine-f9569f3cd8a05dff5be5da83a5d8c70c1b23dd3e.tar.bz2 go-tangerine-f9569f3cd8a05dff5be5da83a5d8c70c1b23dd3e.tar.lz go-tangerine-f9569f3cd8a05dff5be5da83a5d8c70c1b23dd3e.tar.xz go-tangerine-f9569f3cd8a05dff5be5da83a5d8c70c1b23dd3e.tar.zst go-tangerine-f9569f3cd8a05dff5be5da83a5d8c70c1b23dd3e.zip |
Merge pull request #15390 from karalabe/puppeth-devcon3
cmd/puppeth: new version as presented at devcon3
Diffstat (limited to 'cmd/puppeth/wizard_genesis.go')
-rw-r--r-- | cmd/puppeth/wizard_genesis.go | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/cmd/puppeth/wizard_genesis.go b/cmd/puppeth/wizard_genesis.go index 222fc2a7c..f255ef6e6 100644 --- a/cmd/puppeth/wizard_genesis.go +++ b/cmd/puppeth/wizard_genesis.go @@ -37,7 +37,7 @@ func (w *wizard) makeGenesis() { genesis := &core.Genesis{ Timestamp: uint64(time.Now().Unix()), GasLimit: 4700000, - Difficulty: big.NewInt(1048576), + Difficulty: big.NewInt(524288), Alloc: make(core.GenesisAlloc), Config: ¶ms.ChainConfig{ HomesteadBlock: big.NewInt(1), @@ -118,24 +118,16 @@ func (w *wizard) makeGenesis() { for i := int64(0); i < 256; i++ { genesis.Alloc[common.BigToAddress(big.NewInt(i))] = core.GenesisAccount{Balance: big.NewInt(1)} } - fmt.Println() - // Query the user for some custom extras fmt.Println() fmt.Println("Specify your chain/network ID if you want an explicit one (default = random)") genesis.Config.ChainId = new(big.Int).SetUint64(uint64(w.readDefaultInt(rand.Intn(65536)))) - fmt.Println() - fmt.Println("Anything fun to embed into the genesis block? (max 32 bytes)") - - extra := w.read() - if len(extra) > 32 { - extra = extra[:32] - } - genesis.ExtraData = append([]byte(extra), genesis.ExtraData[len(extra):]...) - // All done, store the genesis and flush to disk - w.conf.genesis = genesis + log.Info("Configured new genesis block") + + w.conf.Genesis = genesis + w.conf.flush() } // manageGenesis permits the modification of chain configuration parameters in @@ -145,44 +137,56 @@ func (w *wizard) manageGenesis() { fmt.Println() fmt.Println(" 1. Modify existing fork rules") fmt.Println(" 2. Export genesis configuration") + fmt.Println(" 3. Remove genesis configuration") choice := w.read() switch { case choice == "1": // Fork rule updating requested, iterate over each fork fmt.Println() - fmt.Printf("Which block should Homestead come into effect? (default = %v)\n", w.conf.genesis.Config.HomesteadBlock) - w.conf.genesis.Config.HomesteadBlock = w.readDefaultBigInt(w.conf.genesis.Config.HomesteadBlock) + fmt.Printf("Which block should Homestead come into effect? (default = %v)\n", w.conf.Genesis.Config.HomesteadBlock) + w.conf.Genesis.Config.HomesteadBlock = w.readDefaultBigInt(w.conf.Genesis.Config.HomesteadBlock) fmt.Println() - fmt.Printf("Which block should EIP150 come into effect? (default = %v)\n", w.conf.genesis.Config.EIP150Block) - w.conf.genesis.Config.EIP150Block = w.readDefaultBigInt(w.conf.genesis.Config.EIP150Block) + fmt.Printf("Which block should EIP150 come into effect? (default = %v)\n", w.conf.Genesis.Config.EIP150Block) + w.conf.Genesis.Config.EIP150Block = w.readDefaultBigInt(w.conf.Genesis.Config.EIP150Block) fmt.Println() - fmt.Printf("Which block should EIP155 come into effect? (default = %v)\n", w.conf.genesis.Config.EIP155Block) - w.conf.genesis.Config.EIP155Block = w.readDefaultBigInt(w.conf.genesis.Config.EIP155Block) + fmt.Printf("Which block should EIP155 come into effect? (default = %v)\n", w.conf.Genesis.Config.EIP155Block) + w.conf.Genesis.Config.EIP155Block = w.readDefaultBigInt(w.conf.Genesis.Config.EIP155Block) fmt.Println() - fmt.Printf("Which block should EIP158 come into effect? (default = %v)\n", w.conf.genesis.Config.EIP158Block) - w.conf.genesis.Config.EIP158Block = w.readDefaultBigInt(w.conf.genesis.Config.EIP158Block) + fmt.Printf("Which block should EIP158 come into effect? (default = %v)\n", w.conf.Genesis.Config.EIP158Block) + w.conf.Genesis.Config.EIP158Block = w.readDefaultBigInt(w.conf.Genesis.Config.EIP158Block) fmt.Println() - fmt.Printf("Which block should Byzantium come into effect? (default = %v)\n", w.conf.genesis.Config.ByzantiumBlock) - w.conf.genesis.Config.ByzantiumBlock = w.readDefaultBigInt(w.conf.genesis.Config.ByzantiumBlock) + fmt.Printf("Which block should Byzantium come into effect? (default = %v)\n", w.conf.Genesis.Config.ByzantiumBlock) + w.conf.Genesis.Config.ByzantiumBlock = w.readDefaultBigInt(w.conf.Genesis.Config.ByzantiumBlock) - out, _ := json.MarshalIndent(w.conf.genesis.Config, "", " ") + out, _ := json.MarshalIndent(w.conf.Genesis.Config, "", " ") fmt.Printf("Chain configuration updated:\n\n%s\n", out) case choice == "2": // Save whatever genesis configuration we currently have fmt.Println() fmt.Printf("Which file to save the genesis into? (default = %s.json)\n", w.network) - out, _ := json.MarshalIndent(w.conf.genesis, "", " ") + out, _ := json.MarshalIndent(w.conf.Genesis, "", " ") if err := ioutil.WriteFile(w.readDefaultString(fmt.Sprintf("%s.json", w.network)), out, 0644); err != nil { log.Error("Failed to save genesis file", "err", err) } log.Info("Exported existing genesis block") + case choice == "3": + // Make sure we don't have any services running + if len(w.conf.servers()) > 0 { + log.Error("Genesis reset requires all services and servers torn down") + return + } + log.Info("Genesis block destroyed") + + w.conf.Genesis = nil + w.conf.flush() + default: log.Error("That's not something I can do") } |