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

WIP: stATOM, KREAd proposal tests #3

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ ENV THIS_NAME=agoric-upgrade-10 USE_JS=1

WORKDIR /usr/src/agoric-sdk/
COPY ./env_setup.sh ./start_to_to.sh ./package.json ./*.js ./upgrade-test-scripts/
COPY ./lib/ ./upgrade-test-scripts/lib/
RUN cd upgrade-test-scripts && yarn
RUN echo '. /usr/src/agoric-sdk/upgrade-test-scripts/env_setup.sh' >> ~/.bashrc

Expand Down Expand Up @@ -104,6 +105,7 @@ ENV THIS_NAME=agoric-upgrade-11 USE_JS=1
# start-chain boilerplate
WORKDIR /usr/src/agoric-sdk/
COPY ./env_setup.sh ./start_to_to.sh ./package.json ./*.js ./upgrade-test-scripts/
COPY ./lib/ ./upgrade-test-scripts/lib/
RUN cd upgrade-test-scripts && yarn
RUN echo '. /usr/src/agoric-sdk/upgrade-test-scripts/env_setup.sh' >> ~/.bashrc

Expand Down Expand Up @@ -138,6 +140,7 @@ COPY --from=propose-agoric-upgrade-12 /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/
COPY ./lib/ ./upgrade-test-scripts/lib/
RUN cd upgrade-test-scripts && yarn
RUN echo '. /usr/src/agoric-sdk/upgrade-test-scripts/env_setup.sh' >> ~/.bashrc

Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ DEBUG ?= SwingSet:ls,SwingSet:vat
RUN = docker run --rm -it \
-p 26656:26656 -p 26657:26657 -p 1317:1317 \
-v "$${PWD}:/workspace" \
-v "$${MN2}:/mn2" \
dckc marked this conversation as resolved.
Show resolved Hide resolved
-e "DEBUG=$(DEBUG)"

run:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ To make the wallet ui talk to your local chain, set the network config to
2. Duplicate the last pair of UPGRADE and TEST blocks
3. Update their number from the UPGRADE / DEST block at the end
4. Make directory for tests (e.g. `agoric-upgrade-12`)
4. Make directory for ugprade (e.g. `propose-agoric-upgrade-12` with a `.keep`)
5. Update the UPGRADE/DEST pair to be your new upgrade (THIS_NAME matching the upgrade handler string in app.go)
6. Update the `Makefile`
5. Make directory for ugprade (e.g. `propose-agoric-upgrade-12` with a `.keep`)
6. Update the UPGRADE/DEST pair to be your new upgrade (THIS_NAME matching the upgrade handler string in app.go)
7. Update the `Makefile`
- the two targets to `Makefile` (e.g. `propose-agoric-upgrade-12` and `agoric-upgrade-12`)
- set the default TARGET (e.g. `agoric-upgrade-12`)
- add the DEST target to the `.phony` in `Makefile`
Expand Down
61 changes: 17 additions & 44 deletions upgrade-test-scripts/agoric-upgrade-10/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@ import assert from 'assert';

import {
agd,
agoric,
agops,
agopsLocation,
executeCommand,
} from '../cliHelper.js';
smallCapsContext,
wellKnownIdentities,
} from '../lib/cliHelper.js';
import {
HOME,
ATOM_DENOM,
GOV1ADDR,
GOV2ADDR,
GOV3ADDR,
} from '../constants.js';
} from '../lib/constants.js';
import {
waitForBlock,
executeOffer,
getUser,
provisionSmartWallet,
} from '../commonUpgradeHelpers.js';
} from '../lib/commonUpgradeHelpers.js';

const govAccounts = [GOV1ADDR, GOV2ADDR, GOV3ADDR];

Expand Down Expand Up @@ -122,50 +123,23 @@ const paramChangeOfferGeneration = async (
previousOfferId,
voteDur,
debtLimit,
io = {},
) => {
const { now = Date.now, agoricNames = await wellKnownIdentities(io) } = io;
const { brand, instance } = agoricNames;
assert(instance.VaultFactory);
assert(brand.IST);
assert(brand.ATOM);

const ISTunit = 1_000_000n; // aka displayInfo: { decimalPlaces: 6 }
const voteDurSec = BigInt(voteDur);
const debtLimitValue = BigInt(debtLimit) * ISTunit;
const toSec = ms => BigInt(Math.round(ms / 1000));

const id = `propose-${Date.now()}`;
const deadline = toSec(Date.now()) + voteDurSec;
const id = `propose-${now()}`;
const deadline = toSec(now()) + voteDurSec;

const zip = (xs, ys) => xs.map((x, i) => [x, ys[i]]);
const fromSmallCapsEntries = txt => {
const { body, slots } = JSON.parse(txt);
const theEntries = zip(JSON.parse(body.slice(1)), slots).map(
([[name, ref], boardID]) => {
const iface = ref.replace(/^\$\d+\./, '');
return [name, { iface, boardID }];
},
);
return Object.fromEntries(theEntries);
};

const slots = []; // XXX global mutable state
const smallCaps = {
Nat: n => `+${n}`,
// XXX mutates obj
ref: obj => {
if (obj.ix) return obj.ix;
const ix = slots.length;
slots.push(obj.boardID);
obj.ix = `$${ix}.Alleged: ${obj.iface}`;
return obj.ix;
},
};

const instance = fromSmallCapsEntries(
await agoric.follow('-lF', ':published.agoricNames.instance', '-o', 'text'),
);
assert(instance.VaultFactory);

const brand = fromSmallCapsEntries(
await agoric.follow('-lF', ':published.agoricNames.brand', '-o', 'text'),
);
assert(brand.IST);
assert(brand.ATOM);
const { smallCaps, toCapData } = smallCapsContext();

const body = {
method: 'executeOffer',
Expand Down Expand Up @@ -197,8 +171,7 @@ const paramChangeOfferGeneration = async (
},
};

const capData = { body: `#${JSON.stringify(body)}`, slots };
return JSON.stringify(capData);
return toCapData(body);
};

export const provisionWallet = async user => {
Expand Down Expand Up @@ -251,7 +224,7 @@ export const proposeNewDebtCeiling = async address => {

return executeOffer(
address,
paramChangeOfferGeneration(charterAcceptOfferId, 30, 123000000),
paramChangeOfferGeneration(charterAcceptOfferId, 30, 123_000_000),
);
};

Expand Down
12 changes: 8 additions & 4 deletions upgrade-test-scripts/agoric-upgrade-10/actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import {
raiseDebtCeiling,
pushPrice,
} from './actions.js';
import { agd, agoric, agops } from '../cliHelper.js';
import { GOV1ADDR, GOV2ADDR } from '../constants.js';
import { getUser, newOfferId, waitForBlock } from '../commonUpgradeHelpers.js';
import { agd, agoric, agops } from '../lib/cliHelper.js';
import { GOV1ADDR, GOV2ADDR } from '../lib/constants.js';
import {
getUser,
newOfferId,
waitForBlock,
} from '../lib/commonUpgradeHelpers.js';
import { submitDeliverInbound } from './upgradeHelpers.js';
import { openVault, adjustVault, closeVault } from '../econHelpers.js';
import { openVault, adjustVault, closeVault } from '../lib/econHelpers.js';

const START_FREQUENCY = 600; // StartFrequency: 600s (auction runs every 10m)
const CLOCK_STEP = 20; // ClockStep: 20s (ensures auction completes in time)
Expand Down
6 changes: 3 additions & 3 deletions upgrade-test-scripts/agoric-upgrade-10/post.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from 'ava';

import { agd, agoric } from '../cliHelper.js';
import { GOV1ADDR, GOV2ADDR, GOV3ADDR, USER1ADDR } from '../constants.js';
import { calculateWalletState } from '../commonUpgradeHelpers.js';
import { agd, agoric } from '../lib/cliHelper.js';
import { GOV1ADDR, GOV2ADDR, GOV3ADDR, USER1ADDR } from '../lib/constants.js';
import { calculateWalletState } from '../lib/commonUpgradeHelpers.js';

test('DeliverInbound from un-provisioned account is discarded', async t => {
const result = await agd.query('swingset', 'mailbox', USER1ADDR);
Expand Down
8 changes: 4 additions & 4 deletions upgrade-test-scripts/agoric-upgrade-10/pre.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import test from 'ava';

import { promises as fs } from 'fs';

import { agd, agoric, agops } from '../cliHelper.js';
import { agd, agoric, agops } from '../lib/cliHelper.js';

import {
GOV1ADDR,
GOV2ADDR,
GOV3ADDR,
PSM_PAIR,
} from '../constants.js';
import { openVault } from '../econHelpers.js';
import { getUser, waitForBlock } from '../commonUpgradeHelpers.js';
} from '../lib/constants.js';
import { openVault } from '../lib/econHelpers.js';
import { getUser, waitForBlock } from '../lib/commonUpgradeHelpers.js';

test.before(async () => {
console.log('Wait for upgrade to settle');
Expand Down
6 changes: 3 additions & 3 deletions upgrade-test-scripts/agoric-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 '../constants.js';
} from '../lib/constants.js';

import { agd } from '../cliHelper.js';
import { getUser } from '../commonUpgradeHelpers.js';
import { agd } from '../lib/cliHelper.js';
import { getUser } from '../lib/commonUpgradeHelpers.js';

export const printKeys = async () => {
console.log('========== GOVERNANCE KEYS ==========');
Expand Down
92 changes: 92 additions & 0 deletions upgrade-test-scripts/agoric-upgrade-11/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Upgrade 11

1. upgrade-handler
2. 11wf with walletFactory
3. 11kr with kreadKit

# Testing 11kr

Related: https://github.com/agoric-labs/KREAd/releases/tag/gryo-rc0

It has to be built with these specific addresses, using this one really long command:
```sh
KREAD_COMMITTEE_ADDRESSES='{"krgov1": "agoric1890064p6j3xhzzdf8daknd6kpvhw766ds8flgw", "krgov2": "agoric1vqm5x5sj4lxmj2kem7x92tuhaum0k2yzyj6mgu"}' \
KREAD_COMMITTEE_NAME=kread-gov \
KREAD_ROYALTY_ADDRESS=agoric1yjc8llu3fugm7tgqye4rd5n92l9x2dhe30dazp \
KREAD_PLATFORM_ADDRESS=agoric1enwuyn2hzyyvt39x87tk9rhlkpqtyv9haj7mgs \
make clean build-proposals
```

Build the images if you haven't lately,
```sh
make build
```


Then with MN2 set to the repo you build the above from:
```sh
TARGET=agoric-upgrade-11 MN2=/opt/agoric/KREAd/ make run
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MN2= is vestigial

```

That will run:
```sh
docker run --rm -it -p 26656:26656 -p 26657:26657 -p 1317:1317 -v "${PWD}:/workspace" -v "${MN2}:/mn2" -e "DEBUG=SwingSet:ls,SwingSet:vat" -e "DEST=1" -e "TMUX_USE_CC=0" \
--entrypoint /usr/src/agoric-sdk/upgrade-test-scripts/start_to_to.sh \
agoric/upgrade-test:agoric-upgrade-11
```

Then in a new shell do the following.
(TODO integrate these into the layers)
```sh
# Replace its `upgrade-test-scripts` with a symlink:
rm -rf upgrade-test-scripts
ln -s /workspace/upgrade-test-scripts

# Patch agoric-cli
cp upgrade-test-scripts/agoric-upgrade-11/gov-cmd packages/agoric-cli/src/commands/gov.js
cp upgrade-test-scripts/agoric-upgrade-11/agops-bin packages/agoric-cli/src/bin-agops.js
## this should be docker-u11
agops --version

# patch agd so it doesn't try to rebuild
#sed --in-place=.backup '93,$ d' /usr/src/agoric-sdk/bin/agd
#- find `$BUILD_ONLY || exec 1>&2` (line 94?)
#- put this in above it: `${NO_BUILD:-false} && exit 0`
vi /usr/src/agoric-sdk/bin/agd


# Run the test using the `/mn2` that `make run` mounted:
cd /usr/src/agoric-sdk/upgrade-test-scripts

NO_BUILD=true \
MN2_PROPOSAL_INFO=/mn2/agoric/dist/ \
MN2_INSTANCE=kread \
yarn ava /usr/src/agoric-sdk/upgrade-test-scripts/agoric-upgrade-11/mn2-start.test.js
```

Test governance
TODO put into JS
```sh
# should have two invitations in balances
agoric wallet show --keyring-backend=test --from krgov1

agops gov committee --name kreadCommittee --send-from krgov1
agops gov charter --name kreadCommitteeCharter --send-from krgov1

# now should have two used invitations
agoric wallet show --keyring-backend=test --from krgov1

# propose to pause offers
agops gov proposePauseOffers --instance kread --send-from krgov1 --substring foo

# verify it's there
agd query vstorage data published.committees.kread-gov.latestQuestion

agops gov vote --instance kreadCommittee --pathname kread-gov --forPosition 0 --send-from krgov1

# after a minute the chain output should report the question resolving in the affirmative
agd query vstorage data published.committees.kread-gov.latestOutcome
# TODO a way to read capdata out of vstorage
# this should say "win" for the strings you specified
agd query vstorage data --output json published.committees.kread-gov.latestOutcome | jq -r .value | jq -r .values[0] | jq
```
6 changes: 3 additions & 3 deletions upgrade-test-scripts/agoric-upgrade-11/actions.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from 'ava';

import { agoric, agops } from '../cliHelper.js';
import { GOV1ADDR } from '../constants.js';
import { openVault, adjustVault, closeVault } from '../econHelpers.js';
import { agoric, agops } from '../lib/cliHelper.js';
import { GOV1ADDR } from '../lib/constants.js';
import { openVault, adjustVault, closeVault } from '../lib/econHelpers.js';

test.serial('Open Vaults', async t => {
const currentVaults = await agops.vaults('list', '--from', GOV1ADDR);
Expand Down
Loading
Loading