From 5344a3f8d7ca8c43b55a61612423e87ff903dad0 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Wed, 1 Nov 2023 15:46:29 -0700 Subject: [PATCH] WIP stATOM proposal --- buildTestImages.ts | 1 + common.ts | 2 +- makeDockerfile.ts | 49 ++++++++++++++----- proposals/34:upgrade-10/actions.js | 6 +-- proposals/34:upgrade-10/performActions.js | 13 +++-- proposals/34:upgrade-10/post.test.js | 6 +-- proposals/34:upgrade-10/pre.test.js | 10 ++-- proposals/34:upgrade-10/upgradeHelpers.js | 6 +-- proposals/43:upgrade-11/performActions.js | 4 +- proposals/43:upgrade-11/pre.test.js | 4 +- .../55:stATOM-vaults/add-collateral.test.js | 30 +++++------- .../55:stATOM-vaults/core-eval-support.js | 12 +++-- proposals/55:statom-vaults/config.json | 3 ++ proposals/55:statom-vaults/eval.sh | 12 +++++ proposals/55:statom-vaults/test.sh | 4 ++ upgrade-test-scripts/run_eval.sh | 21 ++++++++ 16 files changed, 131 insertions(+), 52 deletions(-) create mode 100644 proposals/55:statom-vaults/config.json create mode 100644 proposals/55:statom-vaults/eval.sh create mode 100644 proposals/55:statom-vaults/test.sh create mode 100644 upgrade-test-scripts/run_eval.sh diff --git a/buildTestImages.ts b/buildTestImages.ts index 223d85ad..aae6bb00 100755 --- a/buildTestImages.ts +++ b/buildTestImages.ts @@ -9,5 +9,6 @@ for (const proposal of readProposals()) { const { name, target } = imageNameForProposalTest(proposal); const cmd = `docker build --tag ${name} --target ${target} .`; console.log(cmd); + // TODO stream the output execSync(cmd); } diff --git a/common.ts b/common.ts index b0b5cdeb..5efd1f7b 100644 --- a/common.ts +++ b/common.ts @@ -13,7 +13,7 @@ type ProposalCommon = { export type SoftwareUpgradeProposal = ProposalCommon & { sdkVersion: string; - planName?: string; + planName: string; type: 'Software Upgrade Proposal'; }; diff --git a/makeDockerfile.ts b/makeDockerfile.ts index 78e9f4c8..c409a91f 100755 --- a/makeDockerfile.ts +++ b/makeDockerfile.ts @@ -1,9 +1,14 @@ #!/usr/bin/env tsx // @ts-check +import assert from 'node:assert'; import fs from 'node:fs'; import { readProposals } from './common'; -import type { ProposalInfo, SoftwareUpgradeProposal } from './common'; +import type { + ProposalInfo, + SoftwareUpgradeProposal, + CoreEvalProposal, +} from './common'; const agZeroUpgrade = 'agoric-upgrade-7-2'; @@ -51,6 +56,9 @@ SHELL ["/bin/bash", "-c"] RUN . ./upgrade-test-scripts/start_to_to.sh `; }, + /** + * Execute a prepared upgrade + */ EXECUTE({ proposalName, planName, sdkVersion }: SoftwareUpgradeProposal) { return ` # EXECUTE ${proposalName} @@ -66,10 +74,27 @@ SHELL ["/bin/bash", "-c"] RUN . ./upgrade-test-scripts/start_to_to.sh `; }, - USE({ proposalName, proposalIdentifier }: ProposalInfo) { + /** + * Run a core-eval proposal + */ + EVAL( + { proposalIdentifier, proposalName }: CoreEvalProposal, + lastProposal: ProposalInfo, + ) { + return ` +# EVAL ${proposalName} +FROM use-${lastProposal.proposalName} as eval-${proposalName} + +WORKDIR /usr/src/agoric-sdk/upgrade-test-scripts/ +RUN ./run_eval.sh ${proposalIdentifier}:${proposalName} +`; + }, + USE({ proposalName, proposalIdentifier, type }: ProposalInfo) { + const previousStage = + type === 'Software Upgrade Proposal' ? 'execute' : 'eval'; return ` # USE ${proposalName} -FROM execute-${proposalName} as use-${proposalName} +FROM ${previousStage}-${proposalName} as use-${proposalName} COPY ./proposals/package.json /usr/src/proposals/ COPY --chmod=755 ./proposals/${proposalIdentifier}:${proposalName}/* /usr/src/proposals/${proposalIdentifier}:${proposalName}/ @@ -110,16 +135,18 @@ for (const proposal of readProposals()) { `#----------------\n# ${proposal.proposalName}\n#----------------`, ); - // handle the first proposal specially - if (previousProposal) { - blocks.push(stage.PREPARE(proposal, previousProposal)); - } else { - if (!proposal.planName) { - throw new Error('first proposal must have a planName'); + if (proposal.type === '/agoric.swingset.CoreEvalProposal') { + blocks.push(stage.EVAL(proposal, previousProposal!)); + } else if (proposal.type === 'Software Upgrade Proposal') { + // handle the first proposal specially + if (previousProposal) { + blocks.push(stage.PREPARE(proposal, previousProposal)); + } else { + blocks.push(stage.START(proposal.proposalName, proposal.planName)); } - blocks.push(stage.START(proposal.proposalName, proposal.planName)); + blocks.push(stage.EXECUTE(proposal)); } - blocks.push(stage.EXECUTE(proposal)); + blocks.push(stage.USE(proposal)); blocks.push(stage.TEST(proposal)); previousProposal = proposal; diff --git a/proposals/34:upgrade-10/actions.js b/proposals/34:upgrade-10/actions.js index 96452abf..2ec871e8 100644 --- a/proposals/34:upgrade-10/actions.js +++ b/proposals/34:upgrade-10/actions.js @@ -7,20 +7,20 @@ import { agops, agopsLocation, executeCommand, -} from '../../upgrade-test-scripts/cliHelper.js'; +} from '../../upgrade-test-scripts/lib/cliHelper.js'; import { HOME, ATOM_DENOM, GOV1ADDR, GOV2ADDR, GOV3ADDR, -} from '../../upgrade-test-scripts/constants.js'; +} from '../../upgrade-test-scripts/lib/constants.js'; import { waitForBlock, executeOffer, getUser, provisionSmartWallet, -} from '../../upgrade-test-scripts/commonUpgradeHelpers.js'; +} from '../../upgrade-test-scripts/lib/commonUpgradeHelpers.js'; const govAccounts = [GOV1ADDR, GOV2ADDR, GOV3ADDR]; diff --git a/proposals/34:upgrade-10/performActions.js b/proposals/34:upgrade-10/performActions.js index 5cc8e4a9..75d8b663 100644 --- a/proposals/34:upgrade-10/performActions.js +++ b/proposals/34:upgrade-10/performActions.js @@ -8,13 +8,20 @@ import { raiseDebtCeiling, pushPrice, } from './actions.js'; -import { agd, agoric, agops } from '../../upgrade-test-scripts/cliHelper.js'; -import { GOV1ADDR, GOV2ADDR } from '../../upgrade-test-scripts/constants.js'; +import { + agd, + agoric, + agops, +} from '../../upgrade-test-scripts/lib/cliHelper.js'; +import { + GOV1ADDR, + GOV2ADDR, +} from '../../upgrade-test-scripts/lib/constants.js'; import { getUser, newOfferId, waitForBlock, -} from '../../upgrade-test-scripts/commonUpgradeHelpers.js'; +} from '../../upgrade-test-scripts/lib/commonUpgradeHelpers.js'; import { submitDeliverInbound } from './upgradeHelpers.js'; import { openVault, diff --git a/proposals/34:upgrade-10/post.test.js b/proposals/34:upgrade-10/post.test.js index 3a914b9e..873cf394 100644 --- a/proposals/34:upgrade-10/post.test.js +++ b/proposals/34:upgrade-10/post.test.js @@ -1,13 +1,13 @@ import test from 'ava'; -import { agd, agoric } from '../../upgrade-test-scripts/cliHelper.js'; +import { agd, agoric } from '../../upgrade-test-scripts/lib/cliHelper.js'; import { GOV1ADDR, GOV2ADDR, GOV3ADDR, USER1ADDR, -} from '../../upgrade-test-scripts/constants.js'; -import { calculateWalletState } from '../../upgrade-test-scripts/commonUpgradeHelpers.js'; +} from '../../upgrade-test-scripts/lib/constants.js'; +import { calculateWalletState } from '../../upgrade-test-scripts/lib/commonUpgradeHelpers.js'; test('DeliverInbound from un-provisioned account is discarded', async t => { const result = await agd.query('swingset', 'mailbox', USER1ADDR); diff --git a/proposals/34:upgrade-10/pre.test.js b/proposals/34:upgrade-10/pre.test.js index 2ad0cc25..0e17e943 100644 --- a/proposals/34:upgrade-10/pre.test.js +++ b/proposals/34:upgrade-10/pre.test.js @@ -2,19 +2,23 @@ import test from 'ava'; import { promises as fs } from 'fs'; -import { agd, agoric, agops } from '../../upgrade-test-scripts/cliHelper.js'; +import { + agd, + agoric, + agops, +} from '../../upgrade-test-scripts/lib/cliHelper.js'; import { GOV1ADDR, GOV2ADDR, GOV3ADDR, PSM_PAIR, -} from '../../upgrade-test-scripts/constants.js'; +} from '../../upgrade-test-scripts/lib/constants.js'; import { openVault } from '../../upgrade-test-scripts/econHelpers.js'; import { getUser, waitForBlock, -} from '../../upgrade-test-scripts/commonUpgradeHelpers.js'; +} from '../../upgrade-test-scripts/lib/commonUpgradeHelpers.js'; test.before(async () => { console.log('Wait for upgrade to settle'); diff --git a/proposals/34:upgrade-10/upgradeHelpers.js b/proposals/34:upgrade-10/upgradeHelpers.js index daeb2916..14817083 100644 --- a/proposals/34:upgrade-10/upgradeHelpers.js +++ b/proposals/34:upgrade-10/upgradeHelpers.js @@ -8,10 +8,10 @@ import { VALIDATORADDR, USER1ADDR, CHAINID, -} from '../../upgrade-test-scripts/constants.js'; +} from '../../upgrade-test-scripts/lib/constants.js'; -import { agd } from '../../upgrade-test-scripts/cliHelper.js'; -import { getUser } from '../../upgrade-test-scripts/commonUpgradeHelpers.js'; +import { agd } from '../../upgrade-test-scripts/lib/cliHelper.js'; +import { getUser } from '../../upgrade-test-scripts/lib/commonUpgradeHelpers.js'; export const printKeys = async () => { console.log('========== GOVERNANCE KEYS =========='); diff --git a/proposals/43:upgrade-11/performActions.js b/proposals/43:upgrade-11/performActions.js index 6b4782a8..2c389fb6 100644 --- a/proposals/43:upgrade-11/performActions.js +++ b/proposals/43:upgrade-11/performActions.js @@ -3,8 +3,8 @@ // FIXME get TypeScript to resolve these, probably with lib:ES2022 import assert from 'node:assert/strict'; -import { agoric, agops } from '../../upgrade-test-scripts/cliHelper.js'; -import { GOV1ADDR } from '../../upgrade-test-scripts/constants.js'; +import { agoric, agops } from '../../upgrade-test-scripts/lib/cliHelper.js'; +import { GOV1ADDR } from '../../upgrade-test-scripts/lib/constants.js'; import { openVault, adjustVault, diff --git a/proposals/43:upgrade-11/pre.test.js b/proposals/43:upgrade-11/pre.test.js index 3dc9f3a2..9b704134 100644 --- a/proposals/43:upgrade-11/pre.test.js +++ b/proposals/43:upgrade-11/pre.test.js @@ -1,7 +1,7 @@ import test from 'ava'; -import { agd, agoric } from '../../upgrade-test-scripts/cliHelper.js'; -import { waitForBlock } from '../../upgrade-test-scripts/commonUpgradeHelpers.js'; +import { agd, agoric } from '../../upgrade-test-scripts/lib/cliHelper.js'; +import { waitForBlock } from '../../upgrade-test-scripts/lib/commonUpgradeHelpers.js'; test.before(async () => { console.log('Wait for upgrade to settle'); diff --git a/proposals/55:stATOM-vaults/add-collateral.test.js b/proposals/55:stATOM-vaults/add-collateral.test.js index 06225faa..3a385a02 100644 --- a/proposals/55:stATOM-vaults/add-collateral.test.js +++ b/proposals/55:stATOM-vaults/add-collateral.test.js @@ -9,10 +9,14 @@ import dbOpenAmbient from 'better-sqlite3'; import { tmpName as tmpNameAmbient } from 'tmp'; import { ZipReader } from '@endo/zip'; -import { makeFileRW, makeWebCache, makeWebRd } from '../lib/webAsset.js'; -import { makeAgd } from '../lib/agd-lib.js'; -import { dbTool } from '../lib/vat-status.js'; -import { voteLatestProposalAndWait } from '../lib/commonUpgradeHelpers.js'; +import { + makeFileRW, + makeWebCache, + makeWebRd, +} from '../../upgrade-test-scripts/lib/webAsset.js'; +import { makeAgd } from '../../upgrade-test-scripts/lib/agd-lib.js'; +import { dbTool } from '../../upgrade-test-scripts/lib/vat-status.js'; +import { voteLatestProposalAndWait } from '../../upgrade-test-scripts/lib/commonUpgradeHelpers.js'; import { bundleDetail, ensureISTForInstall, @@ -22,7 +26,10 @@ import { testIncludes, txAbbr, } from './core-eval-support.js'; -import { agoric, wellKnownIdentities } from '../lib/cliHelper.js'; +import { + agoric, + wellKnownIdentities, +} from '../../upgrade-test-scripts/lib/cliHelper.js'; /** @typedef {Awaited>} TestContext */ /** @type {import('ava').TestFn}} */ @@ -222,7 +229,7 @@ test.serial('core eval not permitted to add/replace installations', async t => { } }); -test.serial('save installations before the poposal', async t => { +test.serial('save installations before the proposal', async t => { const { agoric, before } = t.context; const { installation } = await wellKnownIdentities({ agoric }); t.log(installation.priceAggregator); @@ -332,14 +339,3 @@ test.serial('priceAuthority installation was not changed', async t => { t.log({ expected, actual }); t.deepEqual(actual, expected); }); - -// needs synchronization -test.skip('stATOM-USD price feed instance in agoricNames', async t => { - const { agoric } = t.context; - const { instance } = await wellKnownIdentities({ agoric }); - testIncludes(t, 'stATOM-USD price feed', Object.keys(instance), 'instance'); -}); - -test.todo('manager in vstorage'); -test.todo('price feed in vstorage - after setting prices'); -test.todo('create a vault as dapp-inter does'); diff --git a/proposals/55:stATOM-vaults/core-eval-support.js b/proposals/55:stATOM-vaults/core-eval-support.js index 48ebac20..61910552 100644 --- a/proposals/55:stATOM-vaults/core-eval-support.js +++ b/proposals/55:stATOM-vaults/core-eval-support.js @@ -1,11 +1,15 @@ // @ts-check -import { Far, makeMarshal, makeTranslationTable } from '../lib/unmarshal.js'; -import { Fail, NonNullish } from '../lib/assert.js'; +import { + Far, + makeMarshal, + makeTranslationTable, +} from '../../upgrade-test-scripts/lib/unmarshal.js'; +import { Fail, NonNullish } from '../../upgrade-test-scripts/lib/assert.js'; // TODO: factor out ambient authority from these // or at least allow caller to supply authority. -import { mintIST } from '../lib/econHelpers.js'; -import { agoric } from '../lib/cliHelper.js'; +import { mintIST } from '../../upgrade-test-scripts/lib/econHelpers.js'; +import { agoric } from '../../upgrade-test-scripts/lib/cliHelper.js'; // move to unmarshal.js? const makeBoardUnmarshal = () => { diff --git a/proposals/55:statom-vaults/config.json b/proposals/55:statom-vaults/config.json new file mode 100644 index 00000000..8acfb07d --- /dev/null +++ b/proposals/55:statom-vaults/config.json @@ -0,0 +1,3 @@ +{ + "type": "/agoric.swingset.CoreEvalProposal" +} diff --git a/proposals/55:statom-vaults/eval.sh b/proposals/55:statom-vaults/eval.sh new file mode 100644 index 00000000..f3427c88 --- /dev/null +++ b/proposals/55:statom-vaults/eval.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Exit when any command fails +set -e + +source /usr/src/agoric-sdk/upgrade-test-scripts/env_setup.sh + +ls -al + +yarn install + +yarn ava 55:stATOM-vaults/add-collateral.test.js diff --git a/proposals/55:statom-vaults/test.sh b/proposals/55:statom-vaults/test.sh new file mode 100644 index 00000000..76a8c694 --- /dev/null +++ b/proposals/55:statom-vaults/test.sh @@ -0,0 +1,4 @@ +# TODO stATOM-USD price feed instance in agoricNames +# TODO manager in vstorage +# TODO price feed in vstorage - after setting prices +# TODO create a vault as dapp-inter does diff --git a/upgrade-test-scripts/run_eval.sh b/upgrade-test-scripts/run_eval.sh new file mode 100644 index 00000000..685691cc --- /dev/null +++ b/upgrade-test-scripts/run_eval.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Starts agd in the background and runs eval.sh against it in the foreground +# Note that STDOUT mixes the two. TODO separate them cleanly with log output. + +set -e +set -x + +source ./env_setup.sh + +export SLOGFILE=slog.slog + +PROPOSAL_PATH=$1 + +startAgd + +echo "Agd started. Running eval.sh." +cd /usr/src/proposals/"$PROPOSAL_PATH/" || exit +./eval.sh + +echo "Eval completed. Running 10 blocks and exiting." +waitForBlock 10