Skip to content

Commit

Permalink
ci: wait for tx confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-vagabond committed Apr 17, 2024
1 parent 5abcf03 commit 442e71d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
10 changes: 2 additions & 8 deletions scripts/upgrade-assure/upgrade-assure.go
Original file line number Diff line number Diff line change
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 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)
}

0 comments on commit 442e71d

Please sign in to comment.