Skip to content

Commit

Permalink
fix: update genesis commands (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-vagabond authored Nov 16, 2024
1 parent 0836907 commit 54f837b
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 4 deletions.
14 changes: 14 additions & 0 deletions cmd/chaininit/chain-init-cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ import (
"github.com/elys-network/post-upgrade-snapshot-generator/utils"
)

// chain-init command does the following:
// 1. download and run old binary
// 2. init nodes
// 3. update config files to enable api and cors
// 4. query node 1 id
// 5. add peers
// 6. add validator keys to node 1
// 7. add validator keys to node 2
// 8. add genesis accounts
// 9. generate genesis tx
// 10. collect genesis txs
// 11. validate genesis
// 12. backup genesis init file
// 13. update genesis
func ChainInitCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "chain-init [old_binary_url] [flags]",
Expand Down
6 changes: 6 additions & 0 deletions cmd/chainsnapshotexport/chain-snapshot-export-cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import (
"github.com/elys-network/post-upgrade-snapshot-generator/utils"
)

// chain-snapshot-export command does the following:
// 1. download and run old binary
// 2. init nodes
// 3. update config files to enable api and cors
// 4. retrieve the snapshot
// 5. export genesis file
func ChainSnapshotExportCmd() *cobra.Command {
return &cobra.Command{
Use: "chain-snapshot-export [snapshot_url] [old_binary_url] [flags]",
Expand Down
8 changes: 8 additions & 0 deletions cmd/createsecondvalidator/create-second-validator-cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ import (
"github.com/elys-network/post-upgrade-snapshot-generator/utils"
)

// create-second-validator command does the following:
// 1. download and run old binary
// 2. start node 1
// 3. wait for rpc to start
// 4. wait for next block
// 5. create validator node 2
// 6. wait for next block
// 7. stop old binary
func CreateSecondValidatorCmd() *cobra.Command {
return &cobra.Command{
Use: "create-second-validator [old_binary_url] [flags]",
Expand Down
2 changes: 2 additions & 0 deletions cmd/deletesnapshot/delete-snapshot-cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"github.com/elys-network/post-upgrade-snapshot-generator/types"
)

// delete-snapshot command does the following:
// 1. delete an existing snapshot file from R2 bucket
func DeleteSnapshotCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "delete-snapshot [branch_name] [flags]",
Expand Down
4 changes: 4 additions & 0 deletions cmd/preparevalidatordata/prepare-validator-data-cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import (
"github.com/elys-network/post-upgrade-snapshot-generator/utils"
)

// prepare-validator-data command does the following:
// 1. restore genesis init file
// 2. copy data from node 1 to node 2
// 3. generate priv_validator_state.json file for node 2
func PrepareValidatorDataCmd() *cobra.Command {
return &cobra.Command{
Use: "prepare-validator-data",
Expand Down
10 changes: 10 additions & 0 deletions cmd/submitnewproposal/submit-new-proposal-cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ import (
"github.com/elys-network/post-upgrade-snapshot-generator/utils"
)

// submit-new-proposal command does the following:
// 1. download and run old binary
// 2. download and run new binary
// 3. start node 1 and 2
// 4. query and calculate upgrade block height
// 5. query next proposal id
// 6. submit upgrade proposal
// 7. vote on upgrade proposal
// 8. wait for upgrade block height
// 9. stop old binaries
func SubmitNewProposalCmd() *cobra.Command {
return &cobra.Command{
Use: "submit-new-proposal [old_binary_url] [new_binary_url] [flags]",
Expand Down
9 changes: 9 additions & 0 deletions cmd/upgradetonewbinary/upgrade-to-new-binary-cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ import (
"github.com/elys-network/post-upgrade-snapshot-generator/utils"
)

// upgrade-to-new-binary command does the following:
// 1. download and run new binary
// 2. start node 1 and 2
// 3. wait for rpc to start
// 4. wait for next block
// 5. query upgrade applied
// 6. unbond validator
// 7. wait for next block
// 8. stop new binaries
func UpgradeToNewBinaryCmd() *cobra.Command {
return &cobra.Command{
Use: "upgrade-to-new-binary [new_binary_url] [flags]",
Expand Down
2 changes: 2 additions & 0 deletions cmd/uploadsnapshot/upload-snapshot-cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"github.com/elys-network/post-upgrade-snapshot-generator/types"
)

// upload-snapshot command does the following:
// 1. upload snapshot file to R2
func UploadSnapshotCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "upload-snapshot [file_path] [flags]",
Expand Down
1 change: 1 addition & 0 deletions cmd/version/version-cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/spf13/cobra"
)

// version command shows the version of the application
func VersionCmd() *cobra.Command {
return &cobra.Command{
Use: "version",
Expand Down
2 changes: 1 addition & 1 deletion utils/add-genesis-account.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func AddGenesisAccount(cmdPath, address, balance, homePath string) {
// Command and arguments
args := []string{"add-genesis-account", address, balance + "uelys," + balance + "ibc/2180E84E20F5679FCC760D8C165B60F42065DEF7F46A72B447CFF1B7DC6C0A65," + balance + "ibc/E2D2F6ADCC68AA3384B2F5DFACCA437923D137C14E86FB8A10207CF3BED0C8D4," + balance + "ibc/B4314D0E670CB43C88A5DCA09F76E5E812BD831CC2FEC6E434C9E5A9D1F57953", "--home", homePath}
args := []string{"genesis", "add-genesis-account", address, balance + "uelys," + balance + "ibc/2180E84E20F5679FCC760D8C165B60F42065DEF7F46A72B447CFF1B7DC6C0A65," + balance + "ibc/E2D2F6ADCC68AA3384B2F5DFACCA437923D137C14E86FB8A10207CF3BED0C8D4," + balance + "ibc/B4314D0E670CB43C88A5DCA09F76E5E812BD831CC2FEC6E434C9E5A9D1F57953", "--home", homePath}

// Execute the command
if err := exec.Command(cmdPath, args...).Run(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion utils/collect-gentxs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func CollectGentxs(cmdPath, homePath string) {
// Command and arguments
args := []string{"collect-gentxs", "--home", homePath}
args := []string{"genesis", "collect-gentxs", "--home", homePath}

// Execute the command
if err := exec.Command(cmdPath, args...).Run(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion utils/gen-tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func GenTx(cmdPath, name, amount, chainId, homePath, keyringBackend string) {
// Command and arguments
args := []string{"gentx", name, amount + "uelys", "--chain-id", chainId, "--home", homePath, "--keyring-backend", keyringBackend, "--gas", "1000000"}
args := []string{"genesis", "gentx", name, amount + "uelys", "--chain-id", chainId, "--home", homePath, "--keyring-backend", keyringBackend, "--gas", "1000000"}

// Execute the command
if err := exec.Command(cmdPath, args...).Run(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion utils/validate-genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func ValidateGenesis(cmdPath, homePath string) {
// Command and arguments
args := []string{"validate-genesis", "--home", homePath}
args := []string{"genesis", "validate-genesis", "--home", homePath}

// Execute the command
if err := exec.Command(cmdPath, args...).Run(); err != nil {
Expand Down

0 comments on commit 54f837b

Please sign in to comment.