Skip to content

Commit

Permalink
WIP stATOM proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Nov 1, 2023
1 parent b76aace commit 5344a3f
Show file tree
Hide file tree
Showing 16 changed files with 131 additions and 52 deletions.
1 change: 1 addition & 0 deletions buildTestImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ProposalCommon = {

export type SoftwareUpgradeProposal = ProposalCommon & {
sdkVersion: string;
planName?: string;
planName: string;
type: 'Software Upgrade Proposal';
};

Expand Down
49 changes: 38 additions & 11 deletions makeDockerfile.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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}
Expand All @@ -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}/
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions proposals/34:upgrade-10/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
13 changes: 10 additions & 3 deletions proposals/34:upgrade-10/performActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions proposals/34:upgrade-10/post.test.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
10 changes: 7 additions & 3 deletions proposals/34:upgrade-10/pre.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
6 changes: 3 additions & 3 deletions proposals/34:upgrade-10/upgradeHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ==========');
Expand Down
4 changes: 2 additions & 2 deletions proposals/43:upgrade-11/performActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions proposals/43:upgrade-11/pre.test.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
30 changes: 13 additions & 17 deletions proposals/55:stATOM-vaults/add-collateral.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<ReturnType<typeof makeTestContext>>} TestContext */
/** @type {import('ava').TestFn<TestContext>}} */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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');
12 changes: 8 additions & 4 deletions proposals/55:stATOM-vaults/core-eval-support.js
Original file line number Diff line number Diff line change
@@ -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 = () => {
Expand Down
3 changes: 3 additions & 0 deletions proposals/55:statom-vaults/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "/agoric.swingset.CoreEvalProposal"
}
12 changes: 12 additions & 0 deletions proposals/55:statom-vaults/eval.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions proposals/55:statom-vaults/test.sh
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions upgrade-test-scripts/run_eval.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5344a3f

Please sign in to comment.