Skip to content

Commit

Permalink
Specify a bundle to use when upgrading auctions (#9937)
Browse files Browse the repository at this point in the history
closes: #9936

## Description

Upload new auction code for the coreEval.

### Security Considerations

N/A

### Scaling Considerations

none

### Documentation Considerations

none

### Testing Considerations

Added a test that the new vat has a different bundle ID. I couldn't find any accessible behavioral differences to test.

### Upgrade Considerations

verify that upgrade happened.
  • Loading branch information
Chris-Hibbert authored Aug 21, 2024
1 parent aedfac6 commit b6379da
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 155 deletions.
16 changes: 16 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,25 @@ const triggerAuction = async t => {
t.is(atomOut, '+5200000');
};

// contract vat names are based on bundleID
const ORIGINAL_AUCTION_VAT_NAME = 'zcf-b1-a5683-auctioneer';

const newAuctioneerFromNewBundle = details => {
for (const detail of details) {
if (
!detail.vatName.includes('governor') &&
detail.vatName !== ORIGINAL_AUCTION_VAT_NAME
) {
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
83 changes: 53 additions & 30 deletions packages/inter-protocol/src/proposals/add-auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,47 @@ 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,
auctioneerKit: legacyKitP,
},
produce: { auctioneerKit: produceAuctioneerKit, auctionsUpgradeComplete },
instance: {
consume: { reserve: reserveInstance },
},
installation: {
consume: { contractGovernor: contractGovernorInstallation },
produce: { auctioneer: produceInstallation },
},
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);
produceInstallation.reset();
produceInstallation.resolve(installationP);

const [
initialPoserInvitation,
Expand Down Expand Up @@ -89,10 +101,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 +117,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 @@ -137,7 +151,8 @@ export const addAuction = async ({
),
);

newAuctioneerKit.resolve(
produceAuctioneerKit.reset();
produceAuctioneerKit.resolve(
harden({
label: 'auctioneer',
creatorFacet: governedCreatorFacet,
Expand Down Expand Up @@ -168,25 +183,33 @@ export const ADD_AUCTION_MANIFEST = harden({
auctioneerKit: true,
},
produce: {
newAuctioneerKit: true,
auctioneerKit: true,
auctionsUpgradeComplete: true,
},
instance: {
consume: { reserve: true },
},
installation: {
consume: {
auctioneer: true,
contractGovernor: true,
},
produce: { auctioneer: true },
},
issuer: {
consume: { [Stable.symbol]: true },
},
},
});

/* 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,
};
};
Loading

0 comments on commit b6379da

Please sign in to comment.