Skip to content

Commit

Permalink
feat: update auction in agoricNames, test that the boardId changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Aug 27, 2024
1 parent 7296b47 commit afe0522
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
15 changes: 15 additions & 0 deletions a3p-integration/proposals/a:vaults-auctions/agd-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,18 @@ export const getProvisionPoolMetrics = async () => {
const path = `published.provisionPool.metrics`;
return getQuoteBody(path);
};

export const getAuctionInstance = async price => {
const instanceRec = await queryVstorage(`published.agoricNames.instance`);

const value = JSON.parse(instanceRec.value);
const body = JSON.parse(value.values.at(-1));

const feeds = JSON.parse(body.body.substring(1));

const key = Object.keys(feeds).find(k => feeds[k][0] === 'auctioneer');
if (key) {
return body.slots[key];
}
return null;
};
9 changes: 9 additions & 0 deletions a3p-integration/proposals/a:vaults-auctions/eval.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# we have an eval.sh so we can run prepare.sh before the rest

echo "[$PROPOSAL] Running prepare.sh"
./prepare.sh

echo "[$PROPOSAL] Running proposal declared in package.json"
# copy to run in the proposal package so the dependencies can be resolved
cp /usr/src/upgrade-test-scripts/eval_submission.js .
./eval_submission.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
# actions are executed in the upgraded chain software and the effects are
# persisted in the generated image for the upgrade, so they can be used in
# later steps, such as the "test" step, or further proposal layers.

./saveAuctionInstance.js
14 changes: 14 additions & 0 deletions a3p-integration/proposals/a:vaults-auctions/saveAuctionInstance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env node

import { writeFile } from 'fs/promises';
import { getAuctionInstance } from './agd-tools.js';

const { env } = process;

const oldAuctionInstance = await getAuctionInstance();
console.log('old auction instance ', oldAuctionInstance, env.HOME);

await writeFile(
`${env.HOME}/.agoric/previousInstance.json`,
oldAuctionInstance,
);
23 changes: 23 additions & 0 deletions a3p-integration/proposals/a:vaults-auctions/upgradeVaults.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
openVault,
USER1ADDR,
} from '@agoric/synthetic-chain';
import { readFile } from 'fs/promises';

import {
bankSend,
Expand All @@ -16,9 +17,12 @@ import {
getVaultPrices,
pushPrices,
addPreexistingOracles,
getAuctionInstance,
} from './agd-tools.js';
import { getDetailsMatchingVats } from './vatDetails.js';

const { env } = process;

const oraclesByBrand = new Map();

let roundId = 2;
Expand Down Expand Up @@ -103,6 +107,22 @@ const verifyVaultPriceUpdate = async t => {
t.is(quote.value[0].amountOut.value, '+5200000');
};

const verifyAuctionInstance = async t => {
const newAuctionInstance = await getAuctionInstance();
const oldInstance = await readFile(
`${env.HOME}/.agoric/previousInstance.json`,
'utf-8',
);

console.log(
`new: ${newAuctionInstance} should be different from ${oldInstance}`,
);
t.true(
newAuctionInstance !== oldInstance,
`new: ${newAuctionInstance} should be different from ${oldInstance}`,
);
};

// test.serial() isn't guaranteed to run tests in order, so we run the intended tests here
test('liquidation post upgrade', async t => {
t.log('setup Oracles');
Expand All @@ -125,4 +145,7 @@ test('liquidation post upgrade', async t => {

t.log('vault price updated');
await verifyVaultPriceUpdate(t);

t.log('auction instance changed in agoricNames');
await verifyAuctionInstance(t);
});
12 changes: 12 additions & 0 deletions packages/inter-protocol/src/proposals/add-auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const trace = makeTracer('NewAuction', true);
export const addAuction = async (
{
consume: {
agoricNamesAdmin,
auctioneerKit: legacyKitP,
board,
chainStorage,
Expand All @@ -31,6 +32,7 @@ export const addAuction = async (
produce: { auctioneerKit: produceAuctioneerKit, auctionUpgradeNewInstance },
instance: {
consume: { reserve: reserveInstance },
produce: { auctioneer: auctionInstance },
},
installation: {
consume: { contractGovernor: contractGovernorInstallation },
Expand Down Expand Up @@ -166,12 +168,21 @@ export const addAuction = async (
}),
);

auctionInstance.reset();
await auctionInstance.resolve(governedInstance);
// belt and suspenders; the above is supposed to also do this
await E(E(agoricNamesAdmin).lookupAdmin('instance')).update(
'auctioneer',
governedInstance,
);

auctionUpgradeNewInstance.resolve(governedInstance);
};

export const ADD_AUCTION_MANIFEST = harden({
[addAuction.name]: {
consume: {
agoricNamesAdmin: true,
auctioneerKit: true,
board: true,
chainStorage: true,
Expand All @@ -186,6 +197,7 @@ export const ADD_AUCTION_MANIFEST = harden({
},
instance: {
consume: { reserve: true },
produce: { auctioneer: true },
},
installation: {
consume: {
Expand Down

0 comments on commit afe0522

Please sign in to comment.