@@ -27,17 +27,10 @@ import (
2727 "net/http"
2828 "os"
2929 "path/filepath"
30- "strings"
3130 "time"
3231
33- "github.com/ethereum/go-ethereum/accounts/abi"
3432 "github.com/ethereum/go-ethereum/common"
35- "github.com/ethereum/go-ethereum/common/math"
36- "github.com/ethereum/go-ethereum/contracts/registrar/contract"
3733 "github.com/ethereum/go-ethereum/core"
38- "github.com/ethereum/go-ethereum/core/rawdb"
39- "github.com/ethereum/go-ethereum/core/state"
40- "github.com/ethereum/go-ethereum/core/vm/runtime"
4134 "github.com/ethereum/go-ethereum/log"
4235 "github.com/ethereum/go-ethereum/params"
4336)
@@ -140,65 +133,6 @@ func (w *wizard) makeGenesis() {
140133 fmt .Println ("Specify your chain/network ID if you want an explicit one (default = random)" )
141134 genesis .Config .ChainID = new (big.Int ).SetUint64 (uint64 (w .readDefaultInt (rand .Intn (65536 ))))
142135
143- // Query the user for checkpoint contract config
144- fmt .Println ()
145- fmt .Println ("Should a checkpoint contract be deployed (y/n)? (default = no)" )
146- if w .readDefaultYesNo (false ) {
147- // Read the addresses of the trusted signers
148- fmt .Println ("Which accounts should be trusted signers? (mandatory at least one)" )
149- var (
150- signers []common.Address
151- threshold uint64
152- )
153- // Get trusted signer addresses
154- for {
155- if address := w .readAddress (); address != nil {
156- signers = append (signers , * address )
157- continue
158- }
159- if len (signers ) == 0 {
160- continue
161- }
162- break
163- }
164- // Read the checkpoint signature threshold
165- for {
166- fmt .Printf ("What is the minimal approval threshold (maximum %d)?\n " , len (signers ))
167- threshold = uint64 (w .readInt ())
168- if threshold <= 0 || threshold > uint64 (len (signers )) {
169- log .Error (fmt .Sprintf ("Invalid approval threshold, please enter in range [1, %d]\n " , len (signers )))
170- continue
171- }
172- break
173- }
174- parsed , err := abi .JSON (strings .NewReader (contract .ContractABI ))
175- if err != nil {
176- log .Crit ("Parse contract ABI failed" , "err" , err )
177- }
178- input , err := parsed .Pack ("" , signers , big .NewInt (params .CheckpointFrequency ), big .NewInt (params .CheckpointProcessConfirmations ), new (big.Int ).SetUint64 (threshold ))
179- if err != nil {
180- log .Crit ("Pack contract constructor arguments failed" , "err" , err )
181- }
182- config := & runtime.Config {GasLimit : math .MaxInt64 }
183- config .State , _ = state .New (common.Hash {}, state .NewDatabase (rawdb .NewMemoryDatabase ()))
184- code , address , _ , err := runtime .Create (append (common .FromHex (contract .ContractBin ), input ... ), config )
185- if err != nil {
186- log .Crit ("Execute contract constructor failed" , "err" , err )
187- }
188- config .State .Commit (true )
189- genesis .Alloc [address ] = core.GenesisAccount {Code : code , Storage : make (map [common.Hash ]common.Hash ), Balance : big .NewInt (1 )}
190- if err = config .State .ForEachStorage (address , func (key , value common.Hash ) bool {
191- genesis .Alloc [address ].Storage [key ] = value
192- return true
193- }); err != nil {
194- log .Crit ("Failed to iterate contract storage" , "err" , err )
195- }
196- genesis .Config .CheckpointConfig = & params.CheckpointContractConfig {
197- Address : address ,
198- Signers : signers ,
199- Threshold : threshold ,
200- }
201- }
202136 // All done, store the genesis and flush to disk
203137 log .Info ("Configured new genesis block" )
204138
@@ -296,77 +230,6 @@ func (w *wizard) manageGenesis() {
296230 fmt .Printf ("Which block should Petersburg come into effect? (default = %v)\n " , w .conf .Genesis .Config .PetersburgBlock )
297231 w .conf .Genesis .Config .PetersburgBlock = w .readDefaultBigInt (w .conf .Genesis .Config .PetersburgBlock )
298232
299- // The registrar contract might have been deployed
300- fmt .Println ()
301- fmt .Printf ("Should a checkpoint contract be active (y/n)? (default = %v)\n " , w .conf .Genesis .Config .CheckpointConfig != nil )
302- if ! w .readDefaultYesNo (w .conf .Genesis .Config .CheckpointConfig != nil ) {
303- w .conf .Genesis .Config .CheckpointConfig = nil
304- } else {
305- // Make sure we have a checkpoint config to fill out
306- checkpoint := w .conf .Genesis .Config .CheckpointConfig
307- if checkpoint == nil {
308- checkpoint = new (params.CheckpointContractConfig )
309- }
310- // Read the Ethereum address of the deployed contract
311- fmt .Println ()
312- if checkpoint .Address == (common.Address {}) {
313- fmt .Printf ("Which address does the checkpoint contract reside at?\n " )
314- for checkpoint .Address == (common.Address {}) {
315- if address := w .readAddress (); address != nil {
316- checkpoint .Address = * address
317- }
318- }
319- } else {
320- fmt .Printf ("Which address does the checkpoint contract reside at? (default = %s)\n " , checkpoint .Address .Hex ())
321- checkpoint .Address = w .readDefaultAddress (checkpoint .Address )
322- }
323- // Read the addresses of the trusted signers
324- if len (checkpoint .Signers ) > 0 {
325- signers := make ([]string , len (checkpoint .Signers ))
326- for i , signer := range checkpoint .Signers {
327- signers [i ] = signer .Hex ()
328- }
329- fmt .Println ()
330- fmt .Printf ("Keep existing list of authorized signers %s? (default = yes)\n " , strings .Join (signers , "," ))
331- if ! w .readDefaultYesNo (true ) {
332- checkpoint .Signers = nil
333- }
334- }
335- if len (checkpoint .Signers ) == 0 {
336- fmt .Println ()
337- fmt .Println ("Which accounts should be trusted signers? (mandatory at least one)" )
338- for {
339- if address := w .readAddress (); address != nil {
340- checkpoint .Signers = append (checkpoint .Signers , * address )
341- continue
342- }
343- if len (checkpoint .Signers ) == 0 {
344- continue
345- }
346- break
347- }
348- }
349- // Read the checkpoint signature threshold
350- fmt .Println ()
351- if checkpoint .Threshold == 0 {
352- fmt .Printf ("What is the minimal approval threshold (maximum %d)?\n " , len (checkpoint .Signers ))
353- } else {
354- fmt .Printf ("What is the minimal approval threshold (maximum %d)? (default = %d)\n " , len (checkpoint .Signers ), checkpoint .Threshold )
355- }
356- for {
357- if checkpoint .Threshold == 0 {
358- checkpoint .Threshold = uint64 (w .readInt ())
359- } else {
360- checkpoint .Threshold = uint64 (w .readDefaultInt (int (checkpoint .Threshold )))
361- }
362- if checkpoint .Threshold <= 0 || checkpoint .Threshold > uint64 (len (checkpoint .Signers )) {
363- log .Error (fmt .Sprintf ("Invalid approval threshold, please enter in range [1, %d]\n " , len (checkpoint .Signers )))
364- continue
365- }
366- break
367- }
368- w .conf .Genesis .Config .CheckpointConfig = checkpoint
369- }
370233 out , _ := json .MarshalIndent (w .conf .Genesis .Config , "" , " " )
371234 fmt .Printf ("Chain configuration updated:\n \n %s\n " , out )
372235
0 commit comments