Skip to content

Commit

Permalink
fix: start_to_to.sh for backwards compat (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg authored Feb 7, 2024
1 parent 954b5a0 commit e303fd0
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/synthetic-chain/src/cli/dockerfileGen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ ENV UPGRADE_TO=${planName} UPGRADE_INFO=${JSON.stringify(
encodeUpgradeInfo(upgradeInfo),
)}
COPY --link --chmod=755 ./upgrade-test-scripts/env_setup.sh ./upgrade-test-scripts/run_prepare.sh /usr/src/upgrade-test-scripts/
COPY --link --chmod=755 ./upgrade-test-scripts/env_setup.sh ./upgrade-test-scripts/run_prepare.sh ./upgrade-test-scripts/start_to_to.sh /usr/src/upgrade-test-scripts/
WORKDIR /usr/src/upgrade-test-scripts
SHELL ["/bin/bash", "-c"]
RUN ./run_prepare.sh
Expand All @@ -89,7 +89,7 @@ WORKDIR /usr/src/upgrade-test-scripts
# base is a fresh sdk image so set up the proposal and its dependencies
COPY --link --chmod=755 ./proposals/${proposalIdentifier}:${proposalName} /usr/src/proposals/${proposalIdentifier}:${proposalName}
COPY --link --chmod=755 ./upgrade-test-scripts/env_setup.sh ./upgrade-test-scripts/run_execute.sh ./upgrade-test-scripts/install_deps.sh /usr/src/upgrade-test-scripts/
COPY --link --chmod=755 ./upgrade-test-scripts/env_setup.sh ./upgrade-test-scripts/run_execute.sh ./upgrade-test-scripts/start_to_to.sh ./upgrade-test-scripts/install_deps.sh /usr/src/upgrade-test-scripts/
RUN --mount=type=cache,target=/root/.yarn ./install_deps.sh ${proposalIdentifier}:${proposalName}
COPY --link --from=prepare-${proposalName} /root/.agoric /root/.agoric
Expand Down
56 changes: 56 additions & 0 deletions packages/synthetic-chain/upgrade-test-scripts/start_to_to.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
# Prepare or execute an upgrade
# XXX retained for backwards compatibility

echo "DEPRECATED start_to_to; migrate start to @agoric/synthetic-chain 0.0.5 or later"

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

startAgd

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

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"

0 comments on commit e303fd0

Please sign in to comment.