From ca3070faaeb203b04fb2280ad569ba78be3f1b2a Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Fri, 3 Nov 2023 15:35:41 -0700 Subject: [PATCH] refactor: split start_agd from start_to_to --- upgrade-test-scripts/start_agd.sh | 11 ++++ upgrade-test-scripts/start_to_to.sh | 83 ++++++++++++++--------------- 2 files changed, 50 insertions(+), 44 deletions(-) create mode 100644 upgrade-test-scripts/start_agd.sh diff --git a/upgrade-test-scripts/start_agd.sh b/upgrade-test-scripts/start_agd.sh new file mode 100644 index 00000000..5f620344 --- /dev/null +++ b/upgrade-test-scripts/start_agd.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Start and leave agd running + +grep -qF 'env_setup.sh' /root/.bashrc || echo "source /usr/src/upgrade-test-scripts/env_setup.sh" >>/root/.bashrc +grep -qF 'printKeys' /root/.bashrc || echo "printKeys" >>/root/.bashrc + +source ./env_setup.sh + +export SLOGFILE=slog.slog + +startAgd diff --git a/upgrade-test-scripts/start_to_to.sh b/upgrade-test-scripts/start_to_to.sh index d5b83da5..a58d64ee 100644 --- a/upgrade-test-scripts/start_to_to.sh +++ b/upgrade-test-scripts/start_to_to.sh @@ -1,4 +1,5 @@ #!/bin/bash +# Prepare or execute an upgrade grep -qF 'env_setup.sh' /root/.bashrc || echo "source /usr/src/upgrade-test-scripts/env_setup.sh" >>/root/.bashrc grep -qF 'printKeys' /root/.bashrc || echo "printKeys" >>/root/.bashrc @@ -9,52 +10,46 @@ export SLOGFILE=slog.slog startAgd -if [[ "$DEST" != "1" ]]; then - #Destined for an upgrade - if [[ -z "${UPGRADE_TO}" ]]; then - echo "no upgrade set. running for a few blocks and exiting" - waitForBlock 5 - exit 0 - fi +if [[ -z "${UPGRADE_TO}" ]]; then + echo "no upgrade set. running for a few blocks and exiting" + waitForBlock 5 + exit 0 +fi + +voting_period_s=10 +latest_height=$(agd status | jq -r .SyncInfo.latest_block_height) +height=$((latest_height + voting_period_s + 10)) +info=${UPGRADE_INFO-"{}"} +if echo "$info" | jq .; then + echo "upgrade-info: $info" +else + status=$? + echo "Upgrade info is not valid JSON: $info" + exit $status +fi +agd tx gov submit-proposal software-upgrade "$UPGRADE_TO" \ + --upgrade-height="$height" --upgrade-info="$info" \ + --title="Upgrade to ${UPGRADE_TO}" --description="upgrades" \ + --from=validator --chain-id="$CHAINID" \ + --yes --keyring-backend=test +waitForBlock - voting_period_s=10 +voteLatestProposalAndWait + +echo "Chain in to-be-upgraded state for $UPGRADE_TO" + +while true; do latest_height=$(agd status | jq -r .SyncInfo.latest_block_height) - height=$((latest_height + voting_period_s + 10)) - info=${UPGRADE_INFO-"{}"} - if echo "$info" | jq .; then - echo "upgrade-info: $info" + if [ "$latest_height" != "$height" ]; then + echo "Waiting for upgrade height for $UPGRADE_TO to be reached (need $height, have $latest_height)" + sleep 1 else - status=$? - echo "Upgrade info is not valid JSON: $info" - exit $status + echo "Upgrade height for $UPGRADE_TO reached. Killing agd" + echo "(CONSENSUS FAILURE above for height $height is expected)" + break fi - agd tx gov submit-proposal software-upgrade "$UPGRADE_TO" \ - --upgrade-height="$height" --upgrade-info="$info" \ - --title="Upgrade to ${UPGRADE_TO}" --description="upgrades" \ - --from=validator --chain-id="$CHAINID" \ - --yes --keyring-backend=test - waitForBlock - - voteLatestProposalAndWait - - echo "Chain in to-be-upgraded state for $UPGRADE_TO" - - while true; do - latest_height=$(agd status | jq -r .SyncInfo.latest_block_height) - if [ "$latest_height" != "$height" ]; then - echo "Waiting for upgrade height for $UPGRADE_TO to be reached (need $height, have $latest_height)" - sleep 1 - else - echo "Upgrade height for $UPGRADE_TO reached. Killing agd" - echo "(CONSENSUS FAILURE above for height $height is expected)" - break - fi - done - - sleep 2 - killAgd - echo "state directory $HOME/.agoric ready for upgrade to $UPGRADE_TO" -else +done - waitAgd -fi +sleep 2 +killAgd +echo "state directory $HOME/.agoric ready for upgrade to $UPGRADE_TO"