diff --git a/.github/workflows/deployment-test.yml b/.github/workflows/deployment-test.yml index 5f97ecfa019..17c80392aa6 100644 --- a/.github/workflows/deployment-test.yml +++ b/.github/workflows/deployment-test.yml @@ -34,7 +34,7 @@ jobs: path: ./agoric-sdk - uses: ./agoric-sdk/.github/actions/restore-node with: - node-version: 18.x + node-version: 18.18 path: ./agoric-sdk # Forces xsnap to initialize all memory to random data, which increases # the chances the content of snapshots may deviate between validators diff --git a/packages/deployment/upgrade-test/Dockerfile b/packages/deployment/upgrade-test/Dockerfile index 12120ca898b..10666811894 100644 --- a/packages/deployment/upgrade-test/Dockerfile +++ b/packages/deployment/upgrade-test/Dockerfile @@ -1,25 +1,23 @@ # Defaults -ARG BASE_IMAGE=ghcr.io/agoric/agoric-3-proposals:pr-33 +# Use a stable base image to prevent this test from breaking when +# new upgrade proposals are added to a3p. +# https://github.com/Agoric/agoric-3-proposals/pull/47 adds upgrade-13 to the base a3p image +# TODO: When https://github.com/Agoric/agoric-3-proposals/issues/25 is resolved, +# use a tagged upgrade-13 layer instead +ARG BASE_IMAGE=ghcr.io/agoric/agoric-3-proposals:pr-47 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-agoric-upgrade-13 -ARG UPGRADE_INFO -ENV THIS_NAME= UPGRADE_TO="agoric-upgrade-13" 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 +# BASE stage for the `COPY --from` below +FROM ${BASE_IMAGE} as base-wallet-factory-upgrade # DEST (TEST) -#this is agoric-upgrade-13 +#this is wallet-factory-upgrade ARG DEST_IMAGE -FROM ${DEST_IMAGE} as agoric-upgrade-13 -ENV THIS_NAME=agoric-upgrade-13 USE_JS=1 -COPY --from=propose-agoric-upgrade-13 /root/.agoric /root/.agoric +FROM ${DEST_IMAGE} as wallet-factory-upgrade +ENV THIS_NAME=wallet-factory-upgrade USE_JS=1 +COPY --from=base-wallet-factory-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/ diff --git a/packages/deployment/upgrade-test/Makefile b/packages/deployment/upgrade-test/Makefile index 9f85b6881a1..5a6092f543a 100644 --- a/packages/deployment/upgrade-test/Makefile +++ b/packages/deployment/upgrade-test/Makefile @@ -1,7 +1,7 @@ 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?=agoric-upgrade-13 +TARGET?=wallet-factory-upgrade dockerLabel?=$(TARGET) @echo target: $(TARGET) @@ -12,11 +12,8 @@ BUILD = docker build --progress=plain $(BUILD_OPTS) \ --build-arg DEST_IMAGE=$(DEST_IMAGE) \ -f Dockerfile upgrade-test-scripts -propose-agoric-upgrade-13: - $(BUILD) --target propose-agoric-upgrade-13 -t $(REPOSITORY):propose-agoric-upgrade-13 - -agoric-upgrade-13: propose-agoric-upgrade-13 - $(BUILD) --target agoric-upgrade-13 -t $(REPOSITORY):agoric-upgrade-13 +wallet-factory-upgrade: + $(BUILD) -t $(REPOSITORY):wallet-factory-upgrade # build main bootstrap build: $(TARGET) @@ -38,4 +35,4 @@ run_test: shell: docker exec -it `docker ps --latest --format '{{json .}}' | jq -r .Names` bash -.PHONY: local_sdk agoric-upgrade-13 build build_test run +.PHONY: local_sdk wallet-factory-upgrade build build_test run diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/actions.test.js b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/actions.test.js deleted file mode 100644 index 3ebc09f7f10..00000000000 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/actions.test.js +++ /dev/null @@ -1,45 +0,0 @@ -import test from 'ava'; - -import { agd } from '../cliHelper.js'; -import { ATOM_DENOM, CHAINID, GOV1ADDR } from '../constants.js'; -import { addUser, getISTBalance } from './actions.js'; -import { mintIST, openVault } from '../econHelpers.js'; -import { waitForBlock } from '../commonUpgradeHelpers.js'; - -test.before(async t => { - await mintIST(GOV1ADDR, 12340000000, 10000, 2000); - - await waitForBlock(2); - const userAddress = await addUser('user-auto'); - await agd.tx( - 'bank', - 'send', - 'gov1', - userAddress, - `1000000uist,2100000000${ATOM_DENOM}`, - '--from', - GOV1ADDR, - '--chain-id', - CHAINID, - '--keyring-backend', - 'test', - '--yes', - ); - t.context = { userAddress }; - await waitForBlock(2); -}); - -test('Open Vaults with auto-provisioned wallet', async t => { - const { userAddress } = /** @type {{userAddress: string}} */ (t.context); - t.is(await getISTBalance(userAddress), 1); - - const ATOMGiven = 2000; - const ISTWanted = 400; - await openVault(userAddress, ISTWanted, ATOMGiven); - - await waitForBlock(2); - - const newISTBalance = await getISTBalance(userAddress); - console.log('New IST Balance in u13 account:', newISTBalance); - t.true(newISTBalance >= ISTWanted, 'Got the wanted IST'); -}); diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/post.test.js b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/post.test.js deleted file mode 100644 index 8c8d4b3bbde..00000000000 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/post.test.js +++ /dev/null @@ -1 +0,0 @@ -import test from 'ava'; diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/tools/vat-status.js b/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/tools/vat-status.js deleted file mode 100644 index 81518a53609..00000000000 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/tools/vat-status.js +++ /dev/null @@ -1,92 +0,0 @@ -// @ts-check -import dbOpenAmbient from 'better-sqlite3'; -import { HOME } from '../../constants.js'; - -/** - * @file look up vat incarnation from kernel DB - * @see {getIncarnation} - */ - -const swingstorePath = '~/.agoric/data/agoric/swingstore.sqlite'; - -/** - * SQL short-hand - * - * @param {import('better-sqlite3').Database} db - */ -const dbTool = db => { - const prepare = (strings, ...params) => { - const dml = strings.join('?'); - return { stmt: db.prepare(dml), params }; - }; - const sql = (strings, ...args) => { - const { stmt, params } = prepare(strings, ...args); - return stmt.all(...params); - }; - sql.get = (strings, ...args) => { - const { stmt, params } = prepare(strings, ...args); - return stmt.get(...params); - }; - return sql; -}; - -/** - * @param {import('better-sqlite3').Database} db - */ -const makeSwingstore = db => { - const sql = dbTool(db); - - /** @param {string} key */ - const kvGet = key => sql.get`select * from kvStore where key = ${key}`.value; - /** @param {string} key */ - const kvGetJSON = key => JSON.parse(kvGet(key)); - - /** @param {string} vatID */ - const lookupVat = vatID => { - return Object.freeze({ - source: () => kvGetJSON(`${vatID}.source`), - options: () => kvGetJSON(`${vatID}.options`), - currentSpan: () => - sql.get`select * from transcriptSpans where isCurrent = 1 and vatID = ${vatID}`, - }); - }; - - return Object.freeze({ - /** @param {string} vatName */ - findVat: vatName => { - /** @type {string[]} */ - const dynamicIDs = kvGetJSON('vat.dynamicIDs'); - const targetVat = dynamicIDs.find( - vatID => lookupVat(vatID).options().name === vatName, - ); - if (!targetVat) throw Error(vatName); - return targetVat; - }, - lookupVat, - }); -}; - -/** @type {(val: T | undefined) => T} */ -const NonNullish = val => { - if (!val) throw Error('required'); - return val; -}; - -/** - * @param {string} vatName - */ -export const getIncarnation = async vatName => { - const fullPath = swingstorePath.replace(/^~/, NonNullish(HOME)); - const kStore = makeSwingstore(dbOpenAmbient(fullPath, { readonly: true })); - - const vatID = kStore.findVat(vatName); - const vatInfo = kStore.lookupVat(vatID); - - const source = vatInfo.source(); - const { incarnation } = vatInfo.currentSpan(); - - // misc info to stderr - console.error(JSON.stringify({ vatName, vatID, incarnation, ...source })); - - return incarnation; -}; diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/package.json b/packages/deployment/upgrade-test/upgrade-test-scripts/package.json index 4f88c0a290a..bdb3c510ef8 100644 --- a/packages/deployment/upgrade-test/upgrade-test-scripts/package.json +++ b/packages/deployment/upgrade-test/upgrade-test-scripts/package.json @@ -8,7 +8,7 @@ }, "scripts": { "agops": "yarn --cwd /usr/src/agoric-sdk/ --silent agops", - "upgrade-tests": "ava --serial agoric-upgrade*/**/pre.test.js agoric-upgrade*/**/actions.test.js agoric-upgrade*/**/post.test.js" + "upgrade-tests": "ava --serial */**/pre.test.js */**/actions.test.js */**/post.test.js" }, "ava": { "files": [ diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/.gitignore b/packages/deployment/upgrade-test/upgrade-test-scripts/wallet-factory-upgrade/.gitignore similarity index 100% rename from packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/.gitignore rename to packages/deployment/upgrade-test/upgrade-test-scripts/wallet-factory-upgrade/.gitignore diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/actions.js b/packages/deployment/upgrade-test/upgrade-test-scripts/wallet-factory-upgrade/actions.js similarity index 100% rename from packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/actions.js rename to packages/deployment/upgrade-test/upgrade-test-scripts/wallet-factory-upgrade/actions.js diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/wallet-factory-upgrade/post.test.js b/packages/deployment/upgrade-test/upgrade-test-scripts/wallet-factory-upgrade/post.test.js new file mode 100644 index 00000000000..f23ad804b90 --- /dev/null +++ b/packages/deployment/upgrade-test/upgrade-test-scripts/wallet-factory-upgrade/post.test.js @@ -0,0 +1,5 @@ +import test from 'ava'; + +test.skip('Wallet factory upgrade 2', async () => { + // Nothing to test yet +}); diff --git a/packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/pre.test.js b/packages/deployment/upgrade-test/upgrade-test-scripts/wallet-factory-upgrade/pre.test.js similarity index 100% rename from packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-13/pre.test.js rename to packages/deployment/upgrade-test/upgrade-test-scripts/wallet-factory-upgrade/pre.test.js