Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(scripts): Rewrite gen-upgrade-proposal.sh #10590

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

gibson042
Copy link
Member

@gibson042 gibson042 commented Dec 1, 2024

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:

$ 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 '<WALLET>' \
  --upgrade-height "$(agoric-estimator -date '<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 '<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.

Fixes #8784

* 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
@gibson042 gibson042 requested a review from a team as a code owner December 1, 2024 20:33
Copy link

cloudflare-workers-and-pages bot commented Dec 1, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: fa9e3a1
Status: ✅  Deploy successful!
Preview URL: https://0c9507c8.agoric-sdk.pages.dev
Branch Preview URL: https://gibson-8784-scriptable-gen-u.agoric-sdk.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gen-upgrade-proposal.sh should be scriptable
1 participant