From 442e71de72386a7510b18496808ffa935c2070f1 Mon Sep 17 00:00:00 2001 From: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com> Date: Wed, 17 Apr 2024 07:08:06 +0200 Subject: [PATCH] ci: wait for tx confirmation --- scripts/upgrade-assure/upgrade-assure.go | 10 ++-------- scripts/upgrade-assure/wait-for-tx-confirmation.go | 13 +++++++------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/scripts/upgrade-assure/upgrade-assure.go b/scripts/upgrade-assure/upgrade-assure.go index 70eae2518..8426f9443 100644 --- a/scripts/upgrade-assure/upgrade-assure.go +++ b/scripts/upgrade-assure/upgrade-assure.go @@ -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) diff --git a/scripts/upgrade-assure/wait-for-tx-confirmation.go b/scripts/upgrade-assure/wait-for-tx-confirmation.go index 4d9e18dc4..24ac5ca43 100644 --- a/scripts/upgrade-assure/wait-for-tx-confirmation.go +++ b/scripts/upgrade-assure/wait-for-tx-confirmation.go @@ -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) }