From abf21686a833c996e78724839bd712107448b11a Mon Sep 17 00:00:00 2001 From: Chris Hibbert Date: Mon, 26 Aug 2024 19:50:44 -0700 Subject: [PATCH 1/2] feat: update auction in agoricNames, test that the boardId changed --- .../proposals/a:vaults-auctions/agd-tools.js | 15 ++++++++++++ .../proposals/a:vaults-auctions/eval.sh | 9 ++++++++ .../a:vaults-auctions/{use.sh => prepare.sh} | 2 ++ .../a:vaults-auctions/saveAuctionInstance.js | 14 +++++++++++ .../a:vaults-auctions/upgradeVaults.test.js | 23 +++++++++++++++++++ .../src/proposals/add-auction.js | 12 ++++++++++ 6 files changed, 75 insertions(+) create mode 100755 a3p-integration/proposals/a:vaults-auctions/eval.sh rename a3p-integration/proposals/a:vaults-auctions/{use.sh => prepare.sh} (92%) create mode 100644 a3p-integration/proposals/a:vaults-auctions/saveAuctionInstance.js diff --git a/a3p-integration/proposals/a:vaults-auctions/agd-tools.js b/a3p-integration/proposals/a:vaults-auctions/agd-tools.js index b133a96f410..0655a3a2808 100644 --- a/a3p-integration/proposals/a:vaults-auctions/agd-tools.js +++ b/a3p-integration/proposals/a:vaults-auctions/agd-tools.js @@ -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; +}; diff --git a/a3p-integration/proposals/a:vaults-auctions/eval.sh b/a3p-integration/proposals/a:vaults-auctions/eval.sh new file mode 100755 index 00000000000..e9563fa7801 --- /dev/null +++ b/a3p-integration/proposals/a:vaults-auctions/eval.sh @@ -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 diff --git a/a3p-integration/proposals/a:vaults-auctions/use.sh b/a3p-integration/proposals/a:vaults-auctions/prepare.sh similarity index 92% rename from a3p-integration/proposals/a:vaults-auctions/use.sh rename to a3p-integration/proposals/a:vaults-auctions/prepare.sh index 094b3f7f881..d1c774cc83d 100755 --- a/a3p-integration/proposals/a:vaults-auctions/use.sh +++ b/a3p-integration/proposals/a:vaults-auctions/prepare.sh @@ -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 diff --git a/a3p-integration/proposals/a:vaults-auctions/saveAuctionInstance.js b/a3p-integration/proposals/a:vaults-auctions/saveAuctionInstance.js new file mode 100644 index 00000000000..132c3c5a834 --- /dev/null +++ b/a3p-integration/proposals/a:vaults-auctions/saveAuctionInstance.js @@ -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, +); diff --git a/a3p-integration/proposals/a:vaults-auctions/upgradeVaults.test.js b/a3p-integration/proposals/a:vaults-auctions/upgradeVaults.test.js index ceb07eee31b..a262e4066fb 100644 --- a/a3p-integration/proposals/a:vaults-auctions/upgradeVaults.test.js +++ b/a3p-integration/proposals/a:vaults-auctions/upgradeVaults.test.js @@ -7,6 +7,7 @@ import { openVault, USER1ADDR, } from '@agoric/synthetic-chain'; +import { readFile } from 'fs/promises'; import { bankSend, @@ -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; @@ -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'); @@ -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); }); diff --git a/packages/inter-protocol/src/proposals/add-auction.js b/packages/inter-protocol/src/proposals/add-auction.js index 77196fd37f5..1dfe91432a5 100644 --- a/packages/inter-protocol/src/proposals/add-auction.js +++ b/packages/inter-protocol/src/proposals/add-auction.js @@ -20,6 +20,7 @@ const trace = makeTracer('NewAuction', true); export const addAuction = async ( { consume: { + agoricNamesAdmin, auctioneerKit: legacyKitP, board, chainStorage, @@ -31,6 +32,7 @@ export const addAuction = async ( produce: { auctioneerKit: produceAuctioneerKit, auctionUpgradeNewInstance }, instance: { consume: { reserve: reserveInstance }, + produce: { auctioneer: auctionInstance }, }, installation: { consume: { contractGovernor: contractGovernorInstallation }, @@ -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, @@ -186,6 +197,7 @@ export const ADD_AUCTION_MANIFEST = harden({ }, instance: { consume: { reserve: true }, + produce: { auctioneer: true }, }, installation: { consume: { From 87b945d9190ee658f8bf90ba1aa7d417ffbeb294 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Mon, 26 Aug 2024 23:15:35 -0500 Subject: [PATCH 2/2] chore: introduce economic committee charter to new auctioneer --- .../src/proposals/add-auction.js | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/packages/inter-protocol/src/proposals/add-auction.js b/packages/inter-protocol/src/proposals/add-auction.js index 1dfe91432a5..ca5bb004759 100644 --- a/packages/inter-protocol/src/proposals/add-auction.js +++ b/packages/inter-protocol/src/proposals/add-auction.js @@ -26,6 +26,7 @@ export const addAuction = async ( chainStorage, chainTimerService, economicCommitteeCreatorFacet: electorateCreatorFacet, + econCharterKit, priceAuthority, zoe, }, @@ -153,19 +154,26 @@ export const addAuction = async ( ), ); + const kit = harden({ + label: 'auctioneer', + creatorFacet: governedCreatorFacet, + adminFacet: governorStartResult.adminFacet, + publicFacet: governedPublicFacet, + instance: governedInstance, + + governor: governorStartResult.instance, + governorCreatorFacet: governorStartResult.creatorFacet, + governorAdminFacet: governorStartResult.adminFacet, + }); produceAuctioneerKit.reset(); - produceAuctioneerKit.resolve( - harden({ - label: 'auctioneer', - creatorFacet: governedCreatorFacet, - adminFacet: governorStartResult.adminFacet, - publicFacet: governedPublicFacet, - instance: governedInstance, - - governor: governorStartResult.instance, - governorCreatorFacet: governorStartResult.creatorFacet, - governorAdminFacet: governorStartResult.adminFacet, - }), + produceAuctioneerKit.resolve(kit); + + // introduce economic committee charter to new auctioneer + // cf addGovernorsToEconCharter() in committee-proposal.js + await E(E.get(econCharterKit).creatorFacet).addInstance( + kit.instance, + kit.governorCreatorFacet, + kit.label, ); auctionInstance.reset(); @@ -187,6 +195,7 @@ export const ADD_AUCTION_MANIFEST = harden({ board: true, chainStorage: true, chainTimerService: true, + econCharterKit: true, economicCommitteeCreatorFacet: true, priceAuthority: true, zoe: true,