diff --git a/.github/workflows/software-upgrade-test.yml b/.github/workflows/software-upgrade-test.yml index 21993723d..6c8a67111 100644 --- a/.github/workflows/software-upgrade-test.yml +++ b/.github/workflows/software-upgrade-test.yml @@ -150,7 +150,6 @@ jobs: - name: Save up space run: | - rm -rf /tmp/genesis.json rm -rf ~/.elys/config/genesis.json - name: Prepare second validator data diff --git a/cmd/upgrade-assure/backup-genesis-init-file.go b/cmd/upgrade-assure/backup-genesis-init-file.go new file mode 100644 index 000000000..74e0fba21 --- /dev/null +++ b/cmd/upgrade-assure/backup-genesis-init-file.go @@ -0,0 +1,21 @@ +package main + +import ( + "log" + "os/exec" +) + +func backupGenesisInitFile(homePath string) { + // Copy genesis.json to genesis_init.json + args := []string{ + homePath + "/config/genesis.json", + homePath + "/config/genesis_init.json", + } + + if err := exec.Command("cp", args...).Run(); err != nil { + log.Fatalf(ColorRed+"Failed to copy genesis.json to genesis_init.json: %v", err) + } + + // If execution reaches here, the command was successful + log.Printf(ColorYellow + "Genesis file copied to genesis_init.json") +} diff --git a/cmd/upgrade-assure/restore-genesis-init-file.go b/cmd/upgrade-assure/restore-genesis-init-file.go new file mode 100644 index 000000000..e61a0963b --- /dev/null +++ b/cmd/upgrade-assure/restore-genesis-init-file.go @@ -0,0 +1,21 @@ +package main + +import ( + "log" + "os/exec" +) + +func restoreGenesisInitFile(homePath string) { + // Copy genesis_init.json to genesis.json + args := []string{ + homePath + "/config/genesis_init.json", + homePath + "/config/genesis.json", + } + + if err := exec.Command("cp", args...).Run(); err != nil { + log.Fatalf(ColorRed+"Failed to copy genesis_init.json to genesis.json: %v", err) + } + + // If execution reaches here, the command was successful + log.Printf(ColorYellow + "Genesis file copied to genesis.json") +} diff --git a/cmd/upgrade-assure/upgrade-assure.go b/cmd/upgrade-assure/upgrade-assure.go index 60e0d6a51..9eb136a57 100644 --- a/cmd/upgrade-assure/upgrade-assure.go +++ b/cmd/upgrade-assure/upgrade-assure.go @@ -118,6 +118,9 @@ func main() { // validate genesis validateGenesis(oldBinaryPath, homePath) + // backup genesis init file + backupGenesisInitFile(homePath) + // update genesis updateGenesis(validatorBalance, homePath, genesisFilePath) } @@ -153,6 +156,9 @@ func main() { } if !skipPrepareValidatorData { + // restore genesis init file + restoreGenesisInitFile(homePath) + // copy data from node 1 to node 2 copyDataFromNodeToNode(homePath, homePath2)