From f4df38c965a69269ee67c86ed984cc5eb9167d3a Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Mon, 6 Jan 2025 13:38:27 -0500 Subject: [PATCH 1/9] feat(scripts): Rewrite gen-upgrade-proposal.sh (#10590) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #8784 ## Description * script arguments for target release/tag/commit and Cosmos upgrade name, plus pass-through of arbitrary `agd tx` arguments * automatic selection of upgrade name from gen-github-release.sh release contents, with interactive disambiguation (where possible) of multiple candidates * reasonable defaults for title and description from gen-github-release.sh release contents * script option `--send` to invoke `agd tx` rather than just printing it out (but successfully invocation additionally requires `--from` etc.) * readable output of the `agd tx` command and data affecting it, whether or not it is to be invoked directly * argument checking with readable error messages and usage details * use of GitHub requests and https://main.agoric.net/network-config, overridable by environment variables Sample use: ```console $ scripts/gen-upgrade-proposal.sh --send agoric-upgrade-18-rc2 Checking https://api.github.com/repos/Agoric/agoric-sdk for agoric-upgrade-18-rc2... Verifying archive at https://github.com/Agoric/agoric-sdk/archive/431b36a49f8574ce49c29d152bf0ace03eb5a348.zip... Generating SHA-256 checksum... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 10.1M 0 10.1M 0 0 4421k 0 --:--:-- 0:00:02 --:--:-- 5292k Found upgrade names: * agoric-upgrade-18-basic-2 * agoric-upgrade-18-devnet * agoric-upgrade-18-mainnet upgrade name (agoric-upgrade-18-mainnet): typo use unknown upgrade name typo (y/n)? n upgrade name (agoric-upgrade-18-mainnet): agd tx gov submit-proposal software-upgrade agoric-upgrade-18-mainnet \ --upgrade-info '{"binaries":{"any":"https://github.com/Agoric/agoric-sdk/archive/431b36a49f8574ce49c29d152bf0ace03eb5a348.zip//agoric-sdk-431b36a49f8574ce49c29d152bf0ace03eb5a348?checksum=sha256:6d8d7b444e28c52dc15731bfc42955d3bb78d135bc6569c290261f278a587046"},"source":"https://github.com/Agoric/agoric-sdk/archive/431b36a49f8574ce49c29d152bf0ace03eb5a348.zip?checksum=sha256:6d8d7b444e28c52dc15731bfc42955d3bb78d135bc6569c290261f278a587046"}' \ --title 'Upgrade to agoric-upgrade-18-rc2' \ --description https://github.com/Agoric/agoric-sdk/releases/tag/agoric-upgrade-18-rc2 \ --chain-id "$(curl -sSL https://main.agoric.net/network-config | jq -r .chainName)" \ --from '' \ --upgrade-height "$(agoric-estimator -date '' -rpc https://main.rpc.agoric.net:443 | tee /dev/stderr | sed -n '$s/.* //p')" \ --help Executing... scripts/gen-upgrade-proposal.sh: line 286: agoric-estimator: command not found Error: invalid argument "" for "--upgrade-height" flag: strconv.ParseInt: parsing "": invalid syntax Usage: agd tx gov submit-proposal software-upgrade [name] (--upgrade-height [height]) (--upgrade-info [info]) [flags] … ``` ### Security Considerations This script is not directly on a security-critical path, but it is important for it to remain transparent for operators. ### Scaling Considerations n/a ### Documentation Considerations Includes embedded usage information, and also remains backwards-compatible in a zero-argument form that uses git HEAD as the target ref (although we should consider instead making target ref a required argument). I'd also like to incorporate https://github.com/Agoric/estimator into `agd` itself, for something better than `--upgrade-height "$(agoric-estimator -date '' -rpc https://main.rpc.agoric.net:443 | tee /dev/stderr | sed -n '$s/.* //p')"`, but haven't done so in this PR. ### Testing Considerations Tested manually, although I'm open to ideas. ### Upgrade Considerations None in particular. --- scripts/gen-upgrade-proposal.sh | 315 ++++++++++++++++++++++++++++---- 1 file changed, 282 insertions(+), 33 deletions(-) diff --git a/scripts/gen-upgrade-proposal.sh b/scripts/gen-upgrade-proposal.sh index dab5a576e9a2..fdc802177de8 100755 --- a/scripts/gen-upgrade-proposal.sh +++ b/scripts/gen-upgrade-proposal.sh @@ -1,46 +1,295 @@ #! /bin/bash set -ueo pipefail +# shellcheck disable=SC2016 # intentionally escape `agd tx` +declare -r USAGE="Usage: $0"' \ + [