Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: delete old proposals breaking commitment refactoring #464

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
m "github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
Expand All @@ -22,6 +23,12 @@ func setUpgradeHandler(app *ElysApp) {
app.Logger().Info("Running upgrade handler for " + version.Version)

if version.Version == "v0.29.32" {
app.Logger().Info("Deleting proposals with ID <= 185")
store := ctx.KVStore(app.keys[govtypes.StoreKey])
for i := uint64(1); i <= 185; i++ {
store.Delete(govtypes.ProposalKey(i))
}

// update the signing info for the validators
signers := []string{
"elysvalcons1j7047ewlfa75dv0q93lnqkctr9afgfayyvmhc4", // euphoria
Expand Down
1 change: 1 addition & 0 deletions scripts/upgrade-assure/submit-upgrade-proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func submitUpgradeProposal(cmdPath, name, newVersion, upgradeHeight, homePath, k
"--gas", "1000000",
"--deposit", "10000000uelys",
"--home", homePath,
"--output", "json",
"--yes",
}

Expand Down
3 changes: 3 additions & 0 deletions scripts/upgrade-assure/update-genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func updateGenesis(validatorBalance, homePath, genesisFilePath string) {
// add localhost as allowed client
genesis.AppState.Ibc.ClientGenesis.Params.AllowedClients = append(genesis.AppState.Ibc.ClientGenesis.Params.AllowedClients, "09-localhost")

// reset gov as there are broken proposoals
genesis.AppState.Gov = genesisInit.AppState.Gov

// update voting period
genesis.AppState.Gov.Params.VotingPeriod = "20s"
genesis.AppState.Gov.Params.MaxDepositPeriod = "20s"
Expand Down
18 changes: 6 additions & 12 deletions scripts/upgrade-assure/upgrade-assure.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func main() {
waitForServiceToStart(rpc, moniker)

// wait for next block
waitForNextBlock(oldBinaryPath, rpc, moniker)
waitForNextBlock(oldBinaryPath, rpc, moniker, 5*time.Minute)

if skipProposal {
// listen for signals
Expand All @@ -129,7 +129,7 @@ func main() {
createValidator(oldBinaryPath, validatorKeyName2, validatorSelfDelegation2, moniker2, validatorPubkey2, homePath, keyringBackend, chainId, rpc, broadcastMode)

// wait for next block
waitForNextBlock(oldBinaryPath, rpc, moniker)
waitForNextBlock(oldBinaryPath, rpc, moniker, 2*time.Minute)

// stop old binary
stop(oldBinaryCmd)
Expand Down Expand Up @@ -162,18 +162,12 @@ func main() {
// submit upgrade proposal
txHash := submitUpgradeProposal(oldBinaryPath, validatorKeyName, newVersion, upgradeBlockHeight, homePath, keyringBackend, chainId, rpc, broadcastMode)

err = waitForTxConfirmation(oldBinaryPath, rpc, txHash, 5*time.Minute)
if err != nil {
log.Fatalf("upgrade proposal not confirmed: %v", err)
}
waitForTxConfirmation(oldBinaryPath, rpc, txHash, 5*time.Minute)

// vote on upgrade proposal
txHash = voteOnUpgradeProposal(oldBinaryPath, validatorKeyName, proposalId, homePath, keyringBackend, chainId, rpc, broadcastMode)

err = waitForTxConfirmation(oldBinaryPath, rpc, txHash, 5*time.Minute)
if err != nil {
log.Fatalf("voting on upgrade proposal not confirmed: %v", err)
}
waitForTxConfirmation(oldBinaryPath, rpc, txHash, 5*time.Minute)

// wait for upgrade block height
waitForBlockHeight(oldBinaryPath, rpc, upgradeBlockHeight)
Expand All @@ -196,8 +190,8 @@ func main() {
waitForServiceToStart(rpc2, moniker2)

// wait for next block
waitForNextBlock(newBinaryPath, rpc, moniker)
waitForNextBlock(newBinaryPath, rpc2, moniker2)
waitForNextBlock(newBinaryPath, rpc, moniker, 5*time.Minute)
waitForNextBlock(newBinaryPath, rpc2, moniker2, 5*time.Minute)

// check if the upgrade was successful
queryUpgradeApplied(newBinaryPath, rpc, newVersion)
Expand Down
1 change: 1 addition & 0 deletions scripts/upgrade-assure/vote-on-upgrade-proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func voteOnUpgradeProposal(cmdPath, name, proposalId, homePath, keyringBackend,
"--fees", "100000uelys",
"--gas", "1000000",
"--home", homePath,
"--output", "json",
"--yes",
}

Expand Down
3 changes: 1 addition & 2 deletions scripts/upgrade-assure/wait-for-next-block.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import (
"time"
)

func waitForNextBlock(cmdPath, node, moniker string) {
func waitForNextBlock(cmdPath, node, moniker string, timeout time.Duration) {
var currentBlockHeight, newBlockHeight int
var err error

timeout := 120 * time.Second
start := time.Now()

// First, get the current block height
Expand Down
13 changes: 7 additions & 6 deletions scripts/upgrade-assure/wait-for-tx-confirmation.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
package main

import (
"fmt"
"log"
"time"
)

func waitForTxConfirmation(cmdPath, node, txHash string, timeout time.Duration) error {
func waitForTxConfirmation(cmdPath, node, txHash string, timeout time.Duration) {
start := time.Now()
for {
if time.Since(start) > timeout {
return fmt.Errorf("timeout reached while waiting for tx confirmation")
log.Fatalf(ColorRed + "timeout reached while waiting for tx confirmation")
}
success, err := checkTxStatus(cmdPath, node, txHash)
if err != nil {
log.Printf("error checking tx status: %v", err)
log.Printf(ColorRed+"error checking tx status, retrying in 5 seconds: %v", err)
time.Sleep(5 * time.Second)
continue
}
if success {
return nil
break
}
time.Sleep(10 * time.Second)
log.Printf(ColorYellow+"waiting for tx confirmation %s", txHash)
time.Sleep(5 * time.Second)
}
log.Printf(ColorGreen+"tx %s confirmed", txHash)
}
Loading