Skip to content

Commit b6379da

Browse files
Specify a bundle to use when upgrading auctions (#9937)
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.
1 parent aedfac6 commit b6379da

File tree

4 files changed

+105
-155
lines changed

4 files changed

+105
-155
lines changed

a3p-integration/proposals/a:vaults-auctions/upgradeVaults.test.js

+16
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,25 @@ const triggerAuction = async t => {
7373
t.is(atomOut, '+5200000');
7474
};
7575

76+
// contract vat names are based on bundleID
77+
const ORIGINAL_AUCTION_VAT_NAME = 'zcf-b1-a5683-auctioneer';
78+
79+
const newAuctioneerFromNewBundle = details => {
80+
for (const detail of details) {
81+
if (
82+
!detail.vatName.includes('governor') &&
83+
detail.vatName !== ORIGINAL_AUCTION_VAT_NAME
84+
) {
85+
return true;
86+
}
87+
}
88+
return false;
89+
};
90+
7691
const checkAuctionVat = async t => {
7792
const details = await getDetailsMatchingVats('auctioneer');
7893

94+
t.true(newAuctioneerFromNewBundle(details));
7995
// This query matches both the auction and its governor, so double the count
8096
t.true(Object.keys(details).length > 2);
8197
};

packages/builders/scripts/vats/add-auction.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
import { makeHelpers } from '@agoric/deploy-script-support';
22

33
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
4-
export const defaultProposalBuilder = async () => {
4+
export const defaultProposalBuilder = async ({ publishRef, install }) => {
55
return harden({
66
sourceSpec: '@agoric/inter-protocol/src/proposals/add-auction.js',
7-
getManifestCall: ['getManifestForAddAuction'],
7+
getManifestCall: [
8+
'getManifestForAddAuction',
9+
{
10+
auctionsRef: publishRef(
11+
install(
12+
'@agoric/inter-protocol/src/auction/auctioneer.js',
13+
'../../inter-protocol/bundles/bundle-auctioneer.js',
14+
),
15+
),
16+
},
17+
],
818
});
919
};
1020

packages/inter-protocol/src/proposals/add-auction.js

+53-30
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,47 @@ const trace = makeTracer('NewAuction', true);
1515
/**
1616
* @param {import('./econ-behaviors.js').EconomyBootstrapPowers &
1717
* interlockPowers} powers
18+
* @param {{ options: { auctionsRef: { bundleID: string } } }} options
1819
*/
19-
export const addAuction = async ({
20-
consume: {
21-
zoe,
22-
board,
23-
chainTimerService,
24-
priceAuthority,
25-
chainStorage,
26-
economicCommitteeCreatorFacet: electorateCreatorFacet,
27-
auctioneerKit: legacyKitP,
28-
},
29-
produce: { newAuctioneerKit, auctionsUpgradeComplete },
30-
instance: {
31-
consume: { reserve: reserveInstance },
32-
},
33-
installation: {
20+
export const addAuction = async (
21+
{
3422
consume: {
35-
auctioneer: auctionInstallation,
36-
contractGovernor: contractGovernorInstallation,
23+
zoe,
24+
board,
25+
chainTimerService,
26+
priceAuthority,
27+
chainStorage,
28+
economicCommitteeCreatorFacet: electorateCreatorFacet,
29+
auctioneerKit: legacyKitP,
30+
},
31+
produce: { auctioneerKit: produceAuctioneerKit, auctionsUpgradeComplete },
32+
instance: {
33+
consume: { reserve: reserveInstance },
34+
},
35+
installation: {
36+
consume: { contractGovernor: contractGovernorInstallation },
37+
produce: { auctioneer: produceInstallation },
38+
},
39+
issuer: {
40+
consume: { [Stable.symbol]: stableIssuerP },
3741
},
3842
},
39-
issuer: {
40-
consume: { [Stable.symbol]: stableIssuerP },
41-
},
42-
}) => {
43-
trace('addAuction start');
43+
{ options },
44+
) => {
45+
trace('addAuction start', options);
4446
const STORAGE_PATH = 'auction';
47+
const { auctionsRef } = options;
4548

4649
const poserInvitationP = E(electorateCreatorFacet).getPoserInvitation();
50+
const bundleID = auctionsRef.bundleID;
51+
/**
52+
* @type {Promise<
53+
* Installation<import('../../src/auction/auctioneer.js')['start']>
54+
* >}
55+
*/
56+
const installationP = E(zoe).installBundleID(bundleID);
57+
produceInstallation.reset();
58+
produceInstallation.resolve(installationP);
4759

4860
const [
4961
initialPoserInvitation,
@@ -89,10 +101,12 @@ export const addAuction = async ({
89101
},
90102
);
91103

104+
const installation = await installationP;
105+
92106
const governorTerms = await deeplyFulfilledObject(
93107
harden({
94108
timer: chainTimerService,
95-
governedContractInstallation: auctionInstallation,
109+
governedContractInstallation: installation,
96110
governed: {
97111
terms: auctionTerms,
98112
issuerKeywordRecord: { Bid: stableIssuer },
@@ -103,7 +117,7 @@ export const addAuction = async ({
103117
}),
104118
);
105119

106-
/** @type {GovernorStartedInstallationKit<typeof auctionInstallation>} */
120+
/** @type {GovernorStartedInstallationKit<typeof installationP>} */
107121
const governorStartResult = await E(zoe).startInstance(
108122
contractGovernorInstallation,
109123
undefined,
@@ -137,7 +151,8 @@ export const addAuction = async ({
137151
),
138152
);
139153

140-
newAuctioneerKit.resolve(
154+
produceAuctioneerKit.reset();
155+
produceAuctioneerKit.resolve(
141156
harden({
142157
label: 'auctioneer',
143158
creatorFacet: governedCreatorFacet,
@@ -168,25 +183,33 @@ export const ADD_AUCTION_MANIFEST = harden({
168183
auctioneerKit: true,
169184
},
170185
produce: {
171-
newAuctioneerKit: true,
186+
auctioneerKit: true,
172187
auctionsUpgradeComplete: true,
173188
},
174189
instance: {
175190
consume: { reserve: true },
176191
},
177192
installation: {
178193
consume: {
179-
auctioneer: true,
180194
contractGovernor: true,
181195
},
196+
produce: { auctioneer: true },
182197
},
183198
issuer: {
184199
consume: { [Stable.symbol]: true },
185200
},
186201
},
187202
});
188203

189-
/* Add a new auction to a chain that already has one. */
190-
export const getManifestForAddAuction = async () => {
191-
return { manifest: ADD_AUCTION_MANIFEST };
204+
/**
205+
* Add a new auction to a chain that already has one.
206+
*
207+
* @param {object} _ign
208+
* @param {any} addAuctionOptions
209+
*/
210+
export const getManifestForAddAuction = async (_ign, addAuctionOptions) => {
211+
return {
212+
manifest: ADD_AUCTION_MANIFEST,
213+
options: addAuctionOptions,
214+
};
192215
};

0 commit comments

Comments
 (0)