From 6501295f1d9662789827114e9eb7516b262c3cf1 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Fri, 8 Dec 2023 14:54:37 -0800 Subject: [PATCH] chore: remove old upgrade-tests --- .eslintrc.cjs | 8 - packages/deployment/upgrade-test/Dockerfile | 34 --- packages/deployment/upgrade-test/Makefile | 44 --- packages/deployment/upgrade-test/Readme.md | 110 ------- .../upgrade-test-scripts/cliHelper.js | 132 -------- .../commonUpgradeHelpers.js | 281 ------------------ .../upgrade-test-scripts/constants.js | 13 - .../upgrade-test-scripts/econHelpers.js | 73 ----- .../upgrade-test-scripts/env_setup.sh | 215 -------------- .../upgrade-test-scripts/package.json | 24 -- .../upgrade-test-scripts/start_to_to.sh | 67 ----- .../unreleased-upgrade/.gitignore | 2 - .../unreleased-upgrade/actions.js | 147 --------- .../unreleased-upgrade/actions.test.js | 97 ------ .../unreleased-upgrade/post.test.js | 7 - .../unreleased-upgrade/pre.test.js | 21 -- .../unreleased-upgrade/tools/vat-status.js | 92 ------ .../zoe-full-upgrade/run-prober-script.js | 95 ------ .../zoe-full-upgrade/run-prober.sh | 20 -- .../zoe-full-upgrade/zcf-upgrade-driver.sh | 25 -- .../zoe-full-upgrade/zcf-upgrade-permit.json | 8 - .../zoe-full-upgrade/zcf-upgrade-script.js | 31 -- 22 files changed, 1546 deletions(-) delete mode 100644 packages/deployment/upgrade-test/Dockerfile delete mode 100644 packages/deployment/upgrade-test/Makefile delete mode 100644 packages/deployment/upgrade-test/Readme.md delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/cliHelper.js delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/commonUpgradeHelpers.js delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/constants.js delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/econHelpers.js delete mode 100755 packages/deployment/upgrade-test/upgrade-test-scripts/env_setup.sh delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/package.json delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/start_to_to.sh delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/unreleased-upgrade/.gitignore delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/unreleased-upgrade/actions.js delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/unreleased-upgrade/actions.test.js delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/unreleased-upgrade/post.test.js delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/unreleased-upgrade/pre.test.js delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/unreleased-upgrade/tools/vat-status.js delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/unreleased-upgrade/zoe-full-upgrade/run-prober-script.js delete mode 100755 packages/deployment/upgrade-test/upgrade-test-scripts/unreleased-upgrade/zoe-full-upgrade/run-prober.sh delete mode 100755 packages/deployment/upgrade-test/upgrade-test-scripts/unreleased-upgrade/zoe-full-upgrade/zcf-upgrade-driver.sh delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/unreleased-upgrade/zoe-full-upgrade/zcf-upgrade-permit.json delete mode 100644 packages/deployment/upgrade-test/upgrade-test-scripts/unreleased-upgrade/zoe-full-upgrade/zcf-upgrade-script.js diff --git a/.eslintrc.cjs b/.eslintrc.cjs index cebbc95e07b4..3e04adce8362 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -157,14 +157,6 @@ module.exports = { project: false, }, }, - { - files: ['packages/**/upgrade-test-scripts/**/*.*js'], - rules: { - // NOTE: This rule is enabled for the repository in general. We turn it - // off for test code for now. - '@jessie.js/safe-await-separator': 'off', - }, - }, { // Types files have no promises to lint and that linter chokes on the .d.ts twin. // Maybe due to https://github.com/typescript-eslint/typescript-eslint/issues/7435 diff --git a/packages/deployment/upgrade-test/Dockerfile b/packages/deployment/upgrade-test/Dockerfile deleted file mode 100644 index 20cf81e1c32e..000000000000 --- a/packages/deployment/upgrade-test/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -# Defaults -ARG BASE_IMAGE=ghcr.io/agoric/agoric-3-proposals:main -ARG DEST_IMAGE=ghcr.io/agoric/agoric-sdk:dev - -# TODO different naming scheme for upgrade handler (in app.go) and the image name - -# UPGRADE -FROM ${BASE_IMAGE} as propose-unreleased-upgrade -# TODO: Replace with actual Zoe core proposal for vat upgrades (MCS, Kread, Zoe, restart-contracts, etc) -ARG UPGRADE_INFO='{"coreProposals":["@agoric/builders/scripts/vats/init-network.js"]}' -ENV THIS_NAME= UPGRADE_TO="UNRELEASED_UPGRADE" UPGRADE_INFO=${UPGRADE_INFO} - -WORKDIR /usr/src/agoric-sdk/ -COPY --chmod=755 ./env_setup.sh ./start_to_to.sh ./upgrade-test-scripts/ -SHELL ["/bin/bash", "-c"] -RUN . ./upgrade-test-scripts/start_to_to.sh - -# DEST (TEST) -#this is unreleased-upgrade -ARG DEST_IMAGE -FROM ${DEST_IMAGE} as unreleased-upgrade -ENV THIS_NAME=unreleased-upgrade USE_JS=1 -COPY --from=propose-unreleased-upgrade /root/.agoric /root/.agoric -# start-chain boilerplate -WORKDIR /usr/src/agoric-sdk/ -COPY ./env_setup.sh ./start_to_to.sh ./package.json ./*.js ./upgrade-test-scripts/ -RUN cd upgrade-test-scripts && yarn -RUN echo '. /usr/src/agoric-sdk/upgrade-test-scripts/env_setup.sh' >> ~/.bashrc - -COPY ./${THIS_NAME} ./upgrade-test-scripts/${THIS_NAME}/ -SHELL ["/bin/bash", "-c"] -RUN chmod +x ./upgrade-test-scripts/*.sh -# enter image in interactive shell -ENTRYPOINT /usr/src/agoric-sdk/upgrade-test-scripts/start_to_to.sh diff --git a/packages/deployment/upgrade-test/Makefile b/packages/deployment/upgrade-test/Makefile deleted file mode 100644 index a5602aca8f92..000000000000 --- a/packages/deployment/upgrade-test/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -REPOSITORY = agoric/upgrade-test -# use :dev (latest prerelease image) unless we build local sdk -DEST_IMAGE ?= $(if $(findstring local_sdk,$(MAKECMDGOALS)),ghcr.io/agoric/agoric-sdk:latest,ghcr.io/agoric/agoric-sdk:dev) -TARGET?=unreleased-upgrade -dockerLabel?=$(TARGET) -@echo target: $(TARGET) - -local_sdk: - (cd ../ && make docker-build-sdk) - -BUILD = docker build --progress=plain $(BUILD_OPTS) \ - --build-arg DEST_IMAGE=$(DEST_IMAGE) \ - -f Dockerfile upgrade-test-scripts - -propose-unreleased-upgrade: - $(BUILD) --target propose-unreleased-upgrade -t $(REPOSITORY):propose-unreleased-upgrade - -unreleased-upgrade: propose-unreleased-upgrade - $(BUILD) --target unreleased-upgrade -t $(REPOSITORY):unreleased-upgrade - -# build main bootstrap -build: $(TARGET) - -DEBUG ?= SwingSet:ls,SwingSet:vat -RUN = docker run --rm -it \ - -p 26656:26656 -p 26657:26657 -p 1317:1317 \ - -v "$${PWD}:/workspace" \ - -e "DEBUG=$(DEBUG)" - -run: - $(RUN) -e "DEST=1" \ - --entrypoint /usr/src/agoric-sdk/upgrade-test-scripts/start_to_to.sh \ - $(REPOSITORY):$(dockerLabel) - -run_test: - $(RUN) -e "DEST=0" $(REPOSITORY):$(dockerLabel) - -run_bash: - $(RUN) --entrypoint /bin/bash $(REPOSITORY):$(dockerLabel) - -shell: - docker exec -it `docker ps --latest --format '{{json .}}' | jq -r .Names` bash - -.PHONY: local_sdk unreleased-upgrade build build_test run diff --git a/packages/deployment/upgrade-test/Readme.md b/packages/deployment/upgrade-test/Readme.md deleted file mode 100644 index 731e0f710c11..000000000000 --- a/packages/deployment/upgrade-test/Readme.md +++ /dev/null @@ -1,110 +0,0 @@ -# Dockerized Chain Upgrade Tester - -This will build an image upgrade of [agoric-3-proposals](https://github.com/Agoric/agoric-3-proposals), a Docker based environment simulating the agoric-3 mainnet chain, using the latest agoric-sdk. - -## Testing - -**To build the upgrade image** - -```shell -make build -``` - -By default pre-releases use the lastest image tagged `dev` in our [container repository](https://github.com/agoric/agoric-sdk/pkgs/container/agoric-sdk). To use -a specific build: - -```shell -DEST_IMAGE=ghcr.io/agoric/agoric-sdk:20230515033839-e56ae7 -``` -To use a build based on local changes: -```shell -# build ghcr.io/agoric/agoric-sdk:latest -make local_sdk build -# or DEST_IMAGE=ghcr.io/agoric/agoric-sdk:latest make build -``` - -**To run the upgrade interactively** - -```shell -make run -``` - -This will start a container with the output of chain start. - -To get a shell: `make shell` - - For more info: https://phase2.github.io/devtools/common-tasks/ssh-into-a-container/ - -The container and chain will halt once you detach from the session. - -### Troubleshooting -If you get an error about port 26656 already in use, you have a local chain running on your OS. - -If you run into other problems, you might have a local `agoric-sdk:latest` that -is stale. Either `make local_sdk` or delete your local image so Docker pulls -from the repository instead. - -If you lose the connection and want to get back, -```sh -# find the container id -docker ps -# reattach using the auto-generated goofy name -docker attach sweet_edison -``` - -**To pass specific `software-upgrade --upgrade-info`** - -```shell -json='{"some":"json","here":123}' -make build BUILD_OPTS="--build-arg UPGRADE_INFO='$json'" -``` - -Search this directory for `UPGRADE_INFO` if you want to see how it is plumbed -through. - -**To test CLI** - -You can point your local CLI tools to the chain running in Docker. Our Docker config binds on the same port (26656) as running a local chain. So you can use the agoric-cli commands on the Docker chain the same way. But note that the Cosmos account keys will be different from in your dev keyring. - -If when reattaching you get a log tail, you need to start a new TTY (with the container name). -```sh -docker exec -it sweet_edison bash -``` - -or just use this helper, -``` -make shell -``` - - -**To test GUI** - -To make the wallet ui talk to your local chain, set the network config to -`https://local.agoric.net/network-config` - -## Development - -When you exit and run again, the container will be a fresh state. - -By default targets that use "agoric-sdk:latest" will source from CI builds. To use your local checkout of agoric-sdk inside Docker run, - -```shell -make local_sdk -``` -Builds an image: ghcr.io/agoric/agoric-sdk:latest that will be used by all your builds. - -That will produce an image tagged agoric-sdk:latest in your local resolution. (Then run `make build run` again.) - -For more details about the docker upgrade test framework, refer to the [agoric-3-proposals](https://github.com/Agoric/agoric-3-proposals) repository. - -### IDE - -Some IDEs support connecting to a running container. For VS Code you can use [Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) to connect to a run above. Then you can edit the filesystem using the IDE. Once the workspace opens, you have to add a folder. E.g. `/usr/src/agoric-sdk/packages/agoric-cli/` for tweaking agoric-cli (without a rebuild of SDK). -Note that whatever changes you make within the running container will be lost when you terminate it. Use this just for iterating and be sure to copy any changes you want back to your real workspace. - -# TODO -- [X] make the Docker test environment log verbosely (agd start is just printing "block N" begin, commit) -- [ ] a target like `local_sdk` that just copies the local filesystem, without a full rebuild -- [ ] alternately, mount the local agoric-sdk in the container -- [ ] provide a utility to import the Docker's GOV123 keys into a local keyring - diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/cliHelper.js b/packages/deployment/upgrade-test/upgrade-test-scripts/cliHelper.js deleted file mode 100644 index 8a89a19241a5..000000000000 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/cliHelper.js +++ /dev/null @@ -1,132 +0,0 @@ -/* eslint-disable @jessie.js/safe-await-separator */ -import { $, execaCommand } from 'execa'; - -const BINARY = 'agd'; - -export const executeCommand = async (command, params, options = {}) => { - const { stdout } = await execaCommand( - `${command} ${params.join(' ')}`, - options, - ); - return stdout; -}; - -export const agd = { - query: async (...params) => { - const newParams = ['query', ...params, '-o json']; - const data = await executeCommand(BINARY, newParams); - return JSON.parse(data); - }, - tx: async (...params) => { - const newParams = ['tx', ...params, '-o json']; - const data = await executeCommand(BINARY, newParams, { shell: true }); - return JSON.parse(data); - }, - keys: async (...params) => { - let newParams = ['keys', ...params]; - let shouldParse = true; - - if (params.includes('show')) { - if (params.includes('-a') || params.includes('-address')) { - shouldParse = false; - } - } - - if (shouldParse) { - newParams = [...newParams, '--output json']; - } - - const data = await executeCommand(BINARY, newParams, { input: 'Y' }); - if (!shouldParse) { - return data; - } - - return JSON.parse(data); - }, - export: async (...params) => { - const newParams = ['export', ...params]; - const data = await executeCommand(BINARY, newParams); - return JSON.parse(data); - }, -}; - -export const agoric = { - follow: async (...params) => { - let newParams = ['follow', ...params]; - let parseJson = false; - - if (!params.includes('-o')) { - newParams = [...newParams, '-o json']; - parseJson = true; - } - const data = await executeCommand('agoric', newParams); - - if (parseJson) { - return JSON.parse(data); - } - - return data; - }, - wallet: async (...params) => { - const newParams = ['wallet', ...params]; - return executeCommand('agoric', newParams); - }, - run: async (...params) => { - const newParams = ['run', ...params]; - return executeCommand('agoric', newParams); - }, -}; - -export const { stdout: agopsLocation } = await $({ - shell: true, - cwd: '/usr/src/agoric-sdk', -})`yarn bin agops`; - -export const agops = { - vaults: async (...params) => { - const newParams = ['vaults', ...params]; - - const result = await executeCommand(agopsLocation, newParams); - - if (params[0] === 'list') { - if (result === '') return []; - - return result.split('\n'); - } - - return result; - }, - ec: async (...params) => { - const newParams = ['ec', ...params]; - return executeCommand(agopsLocation, newParams); - }, - oracle: async (...params) => { - const newParams = ['oracle', ...params]; - return executeCommand(agopsLocation, newParams); - }, - perf: async (...params) => { - const newParams = ['perf', ...params]; - return executeCommand(agopsLocation, newParams); - }, - auctioneer: async (...params) => { - const newParams = ['auctioneer', ...params]; - return executeCommand(agopsLocation, newParams); - }, -}; - -export const { stdout: bundleSourceLocation } = await $({ - shell: true, - cwd: '/usr/src/agoric-sdk', -})`yarn bin bundle-source`; - -/** - * @param {string} filePath - * @param {string} bundleName - * @returns {Promise} Returns the filepath of the bundle - */ -export const bundleSource = async (filePath, bundleName) => { - const output = - await $`${bundleSourceLocation} --cache-json /tmp ${filePath} ${bundleName}`; - console.log(output.stderr); - return `/tmp/bundle-${bundleName}.json`; -}; diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/commonUpgradeHelpers.js b/packages/deployment/upgrade-test/upgrade-test-scripts/commonUpgradeHelpers.js deleted file mode 100644 index 2c7945d520ae..000000000000 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/commonUpgradeHelpers.js +++ /dev/null @@ -1,281 +0,0 @@ -/* eslint-disable @jessie.js/safe-await-separator */ -import { $ } from 'execa'; -import { promises as fs } from 'fs'; -import * as path from 'path'; -import { agd, agoric, agops } from './cliHelper.js'; -import { CHAINID, VALIDATORADDR } from './constants.js'; - -const waitForBootstrap = async () => { - const endpoint = 'localhost'; - // eslint-disable-next-line no-constant-condition - while (true) { - const { stdout: json } = await $({ - reject: false, - })`curl -s --fail -m 15 ${`${endpoint}:26657/status`}`; - - if (json.length === 0) { - continue; - } - - const data = JSON.parse(json); - - if (data.jsonrpc !== '2.0') { - continue; - } - - const lastHeight = data.result.sync_info.latest_block_height; - - if (lastHeight !== '1') { - return lastHeight; - } - - // eslint-disable-next-line no-undef - await new Promise(r => setTimeout(r, 2000)); - } -}; - -export const waitForBlock = async (times = 1) => { - console.log(times); - let time = 0; - while (time < times) { - const block1 = await waitForBootstrap(); - // eslint-disable-next-line no-constant-condition - while (true) { - const block2 = await waitForBootstrap(); - - if (block1 !== block2) { - console.log('block produced'); - break; - } - - // eslint-disable-next-line no-undef - await new Promise(r => setTimeout(r, 1000)); - } - time += 1; - } -}; - -export const provisionSmartWallet = async (address, amount) => { - console.log(`funding ${address}`); - await agd.tx( - 'bank', - 'send', - 'validator', - address, - amount, - '-y', - '--keyring-backend=test', - `--chain-id="${CHAINID}"`, - ); - await waitForBlock(); - - console.log(`provisioning ${address}`); - await agd.tx( - 'swingset', - 'provision-one', - 'my-wallet', - address, - 'SMART_WALLET', - '--keyring-backend=test', - '-y', - `--chain-id="${CHAINID}"`, - `--from="${address}"`, - ); - - await waitForBlock(2); - console.log(await agoric.wallet('show', `--from ${address}`)); -}; - -export const newOfferId = async () => { - const { stdout: date } = await $`date +${'%s%3M'}`; - // eslint-disable-next-line no-undef - await new Promise(r => setTimeout(r, 1000)); - - return date; -}; - -export const mkTemp = async template => { - const { stdout: data } = await $({ - shell: true, - })`mktemp -t ${template}`; - return data; -}; - -export const calculateWalletState = async addr => { - const result = await agoric.follow( - '-lF', - `:published.wallet.${addr}`, - '-o', - 'text', - ); - - const body = JSON.parse(result).body; - let state = body; - - if (body.includes('@qclass')) { - state = 'old'; - } else if (body.includes('#{}')) { - state = 'upgraded'; - } else if (body.includes('#')) { - state = 'revived'; - } - - return state; -}; - -export const executeOffer = async (address, offerPromise) => { - const offerPath = await mkTemp('agops.XXX'); - const offer = await offerPromise; - await fs.writeFile(offerPath, offer); - - await agops.perf( - 'satisfaction', - '--from', - address, - '--executeOffer', - offerPath, - '--keyring-backend=test', - ); -}; - -export const getUser = async user => { - return agd.keys('show', user, '-a', '--keyring-backend=test'); -}; - -export const voteLatestProposalAndWait = async () => { - await waitForBlock(); - const proposalsData = await agd.query('gov', 'proposals'); - const lastProposalId = proposalsData.proposals.at(-1).proposal_id; - - await waitForBlock(); - - await agd.tx( - 'gov', - 'deposit', - lastProposalId, - '50000000ubld', - '--from', - VALIDATORADDR, - `--chain-id=${CHAINID}`, - '--yes', - '--keyring-backend', - 'test', - ); - - await waitForBlock(); - - await agd.tx( - 'gov', - 'vote', - lastProposalId, - 'yes', - '--from', - VALIDATORADDR, - `--chain-id=${CHAINID}`, - '--yes', - '--keyring-backend', - 'test', - ); - - let info = {}; - for ( - ; - info.status !== 'PROPOSAL_STATUS_REJECTED' && - info.status !== 'PROPOSAL_STATUS_PASSED'; - await waitForBlock() - ) { - info = await agd.query('gov', 'proposal', lastProposalId); - console.log( - `Waiting for proposal ${lastProposalId} to pass (status=${info.status})`, - ); - } - return info; -}; - -const Fail = (template, ...args) => { - throw Error(String.raw(template, ...args.map(val => String(val)))); -}; - -/** - * Parse output of `agoric run proposal-builder.js` - * - * @param {string} txt - * - * adapted from packages/boot/test/bootstrapTests/supports.js - */ -const parseProposalParts = txt => { - const evals = [ - ...txt.matchAll(/swingset-core-eval (?\S+) (?