Skip to content

Commit

Permalink
feat: specify a bundle to use when upgrading auctions
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Aug 21, 2024
1 parent dfc7a48 commit b6e0739
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 32 deletions.
15 changes: 15 additions & 0 deletions a3p-integration/proposals/a:vaults-auctions/upgradeVaults.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,24 @@ const triggerAuction = async t => {
t.is(atomOut, '+5200000');
};

function newAuctioneerFromNewBundle(details) {
for (const detail of details) {
// contract vat names are based on bundleID
const originalAuctionVatName = 'zcf-b1-a5683-auctioneer';
if (
!detail.vatName.includes('governor') &&
detail.vatName !== originalAuctionVatName
) {
return true;
}
}
return false;
}

const checkAuctionVat = async t => {
const details = await getDetailsMatchingVats('auctioneer');

t.true(newAuctioneerFromNewBundle(details));
// This query matches both the auction and its governor, so double the count
t.true(Object.keys(details).length > 2);
};
Expand Down
14 changes: 12 additions & 2 deletions packages/builders/scripts/vats/add-auction.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { makeHelpers } from '@agoric/deploy-script-support';

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
export const defaultProposalBuilder = async () => {
export const defaultProposalBuilder = async ({ publishRef, install }) => {
return harden({
sourceSpec: '@agoric/inter-protocol/src/proposals/add-auction.js',
getManifestCall: ['getManifestForAddAuction'],
getManifestCall: [
'getManifestForAddAuction',
{
auctionsRef: publishRef(
install(
'@agoric/inter-protocol/src/auction/auctioneer.js',
'../../inter-protocol/bundles/bundle-auctioneer.js',
),
),
},
],
});
};

Expand Down
85 changes: 58 additions & 27 deletions packages/inter-protocol/src/proposals/add-auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,45 @@ const trace = makeTracer('NewAuction', true);
/**
* @param {import('./econ-behaviors.js').EconomyBootstrapPowers &
* interlockPowers} powers
* @param {{ options: { auctionsRef: { bundleID: string } } }} options
*/
export const addAuction = async ({
consume: {
zoe,
board,
chainTimerService,
priceAuthority,
chainStorage,
economicCommitteeCreatorFacet: electorateCreatorFacet,
auctioneerKit: legacyKitP,
},
produce: { newAuctioneerKit, auctionsUpgradeComplete },
instance: {
consume: { reserve: reserveInstance },
},
installation: {
export const addAuction = async (
{
consume: {
auctioneer: auctionInstallation,
contractGovernor: contractGovernorInstallation,
zoe,
board,
chainTimerService,
priceAuthority,
chainStorage,
economicCommitteeCreatorFacet: electorateCreatorFacet,
agoricNamesAdmin,
auctioneerKit: legacyKitP,
},
produce: { newAuctioneerKit, auctionsUpgradeComplete },
instance: {
consume: { reserve: reserveInstance },
},
installation: {
consume: { contractGovernor: contractGovernorInstallation },
},
issuer: {
consume: { [Stable.symbol]: stableIssuerP },
},
},
issuer: {
consume: { [Stable.symbol]: stableIssuerP },
},
}) => {
trace('addAuction start');
{ options },
) => {
trace('addAuction start', options);
const STORAGE_PATH = 'auction';
const { auctionsRef } = options;

const poserInvitationP = E(electorateCreatorFacet).getPoserInvitation();
const bundleID = auctionsRef.bundleID;
/**
* @type {Promise<
* Installation<import('../../src/auction/auctioneer.js')['start']>
* >}
*/
const installationP = E(zoe).installBundleID(bundleID);

const [
initialPoserInvitation,
Expand All @@ -57,6 +67,16 @@ export const addAuction = async ({
legacyKitP,
]);

await E.when(
installationP,
installation =>
E(E(agoricNamesAdmin).lookupAdmin('installation')).update(
'auctioneer',
installation,
),
err => console.error(`🚨 failed to update vaultFactory installation`, err),
);

// Each field has an extra layer of type + value:
// AuctionStartDelay: { type: 'relativeTime', value: { relValue: 2n, timerBrand: Object [Alleged: timerBrand] {} } }
/** @type {any} */
Expand Down Expand Up @@ -89,10 +109,12 @@ export const addAuction = async ({
},
);

const installation = await installationP;

const governorTerms = await deeplyFulfilledObject(
harden({
timer: chainTimerService,
governedContractInstallation: auctionInstallation,
governedContractInstallation: installation,
governed: {
terms: auctionTerms,
issuerKeywordRecord: { Bid: stableIssuer },
Expand All @@ -103,7 +125,7 @@ export const addAuction = async ({
}),
);

/** @type {GovernorStartedInstallationKit<typeof auctionInstallation>} */
/** @type {GovernorStartedInstallationKit<typeof installationP>} */
const governorStartResult = await E(zoe).startInstance(
contractGovernorInstallation,
undefined,
Expand Down Expand Up @@ -165,6 +187,7 @@ export const ADD_AUCTION_MANIFEST = harden({
priceAuthority: true,
chainStorage: true,
economicCommitteeCreatorFacet: true,
agoricNamesAdmin: true,
auctioneerKit: true,
},
produce: {
Expand All @@ -186,7 +209,15 @@ export const ADD_AUCTION_MANIFEST = harden({
},
});

/* Add a new auction to a chain that already has one. */
export const getManifestForAddAuction = async () => {
return { manifest: ADD_AUCTION_MANIFEST };
/**
* Add a new auction to a chain that already has one.
*
* @param {object} _ign
* @param {any} addAuctionOptions
*/
export const getManifestForAddAuction = async (_ign, addAuctionOptions) => {
return {
manifest: ADD_AUCTION_MANIFEST,
options: addAuctionOptions,
};
};
8 changes: 5 additions & 3 deletions packages/inter-protocol/src/proposals/upgrade-vaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const any = promises =>
* interlockPowers} powers
* @param {{ options: { vaultsRef: { bundleID: string } } }} options
*/
export const upgradeVaults = async (powers, { options }) => {
const {
export const upgradeVaults = async (
{
consume: {
agoricNamesAdmin,
newAuctioneerKit: auctioneerKitP,
Expand All @@ -61,7 +61,9 @@ export const upgradeVaults = async (powers, { options }) => {
instance: {
produce: { auctioneer: auctioneerProducer },
},
} = powers;
},
{ options },
) => {
const { vaultsRef } = options;
const kit = await vaultFactoryKit;
const auctioneerKit = await auctioneerKitP;
Expand Down

0 comments on commit b6e0739

Please sign in to comment.