From 767dfde1dac732c8822660e308b46e4d67ddb167 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 31 May 2023 16:03:31 +1000 Subject: [PATCH] add v2 config into genesis wizard (#273) --- cmd/puppeth/wizard.go | 2 +- cmd/puppeth/wizard_genesis.go | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/cmd/puppeth/wizard.go b/cmd/puppeth/wizard.go index c4ac5d9094..9958771f95 100644 --- a/cmd/puppeth/wizard.go +++ b/cmd/puppeth/wizard.go @@ -62,7 +62,7 @@ func (c config) servers() []string { func (c config) flush() { os.MkdirAll(filepath.Dir(c.path), 0755) - out, _ := json.MarshalIndent(c, "", " ") + out, _ := json.MarshalIndent(c.Genesis, "", " ") if err := ioutil.WriteFile(c.path, out, 0644); err != nil { log.Warn("Failed to save puppeth configs", "file", c.path, "err", err) } diff --git a/cmd/puppeth/wizard_genesis.go b/cmd/puppeth/wizard_genesis.go index d4fb9e8f46..de8d243853 100644 --- a/cmd/puppeth/wizard_genesis.go +++ b/cmd/puppeth/wizard_genesis.go @@ -116,15 +116,41 @@ func (w *wizard) makeGenesis() { Period: 15, Epoch: 30000, Reward: 0, + V2: ¶ms.V2{ + SwitchBlock: big.NewInt(0), + CurrentConfig: ¶ms.V2Config{}, + AllConfigs: make(map[uint64]*params.V2Config), + }, } fmt.Println() fmt.Println("How many seconds should blocks take? (default = 2)") genesis.Config.XDPoS.Period = uint64(w.readDefaultInt(2)) + genesis.Config.XDPoS.V2.CurrentConfig.WaitPeriod = int(genesis.Config.XDPoS.Period) + genesis.Config.XDPoS.V2.CurrentConfig.MinePeriod = int(genesis.Config.XDPoS.Period) fmt.Println() fmt.Println("How many Ethers should be rewarded to masternode? (default = 10)") genesis.Config.XDPoS.Reward = uint64(w.readDefaultInt(10)) + fmt.Println() + fmt.Println("Which block number start v2 consesus? (default = 0)") + genesis.Config.XDPoS.V2.SwitchBlock = w.readDefaultBigInt(genesis.Config.XDPoS.V2.SwitchBlock) + genesis.Config.XDPoS.V2.CurrentConfig.SwitchRound = 0 + + fmt.Println() + fmt.Println("How long is the v2 timeout period? (default = 10)") + genesis.Config.XDPoS.V2.CurrentConfig.TimeoutPeriod = w.readDefaultInt(10) + + fmt.Println() + fmt.Println("How many v2 timeout reach to send Synchronize message? (default = 3)") + genesis.Config.XDPoS.V2.CurrentConfig.TimeoutSyncThreshold = w.readDefaultInt(3) + + fmt.Println() + fmt.Printf("How many v2 vote collection to generate a QC, should be two thirds of masternodes? (default = %d)\n", common.MaxMasternodesV2/3*2+1) + genesis.Config.XDPoS.V2.CurrentConfig.CertThreshold = w.readDefaultInt(common.MaxMasternodesV2)/3*2 + 1 + + genesis.Config.XDPoS.V2.AllConfigs[0] = genesis.Config.XDPoS.V2.CurrentConfig + fmt.Println() fmt.Println("Who own the first masternodes? (mandatory)") owner := *w.readAddress()