Skip to content

Commit

Permalink
get auction instance from promise returned by addAuction (#9944)
Browse files Browse the repository at this point in the history
refs: #9940

## Description

#9937 unintentionally upgraded the vaultFactory with the instance of the old auction. This change asks the promise space for the auction instance after the new auction startup is complete.

### Security Considerations

None.

### Scaling Considerations

None.

### Documentation Considerations

None.

###Testing Considerations

This will be tested on Ollinet and emerynet before deployment.

I tested locally on a3p by watching the logs to see that the vaults synced to the new auction schedule.

###Upgrade Considerations

upgrade vaults and auctions so they work together.
  • Loading branch information
mergify[bot] authored Aug 22, 2024
2 parents 7a08c6a + 9fc5ba9 commit b84a426
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 29 deletions.
26 changes: 12 additions & 14 deletions packages/inter-protocol/src/proposals/add-auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const trace = makeTracer('NewAuction', true);

/**
* @typedef {PromiseSpaceOf<{
* auctionsUpgradeComplete: boolean;
* auctionUpgradeNewInstance: Instance;
* }>} interlockPowers
*/

Expand All @@ -20,15 +20,15 @@ const trace = makeTracer('NewAuction', true);
export const addAuction = async (
{
consume: {
zoe,
auctioneerKit: legacyKitP,
board,
chainTimerService,
priceAuthority,
chainStorage,
chainTimerService,
economicCommitteeCreatorFacet: electorateCreatorFacet,
auctioneerKit: legacyKitP,
priceAuthority,
zoe,
},
produce: { auctioneerKit: produceAuctioneerKit, auctionsUpgradeComplete },
produce: { auctioneerKit: produceAuctioneerKit, auctionUpgradeNewInstance },
instance: {
consume: { reserve: reserveInstance },
},
Expand Down Expand Up @@ -165,26 +165,24 @@ export const addAuction = async (
governorAdminFacet: governorStartResult.adminFacet,
}),
);
// don't overwrite auctioneerKit or auction instance yet. Wait until
// upgrade-vault.js

auctionsUpgradeComplete.resolve(true);
auctionUpgradeNewInstance.resolve(governedInstance);
};

export const ADD_AUCTION_MANIFEST = harden({
[addAuction.name]: {
consume: {
zoe: true,
auctioneerKit: true,
board: true,
chainTimerService: true,
priceAuthority: true,
chainStorage: true,
chainTimerService: true,
economicCommitteeCreatorFacet: true,
auctioneerKit: true,
priceAuthority: true,
zoe: true,
},
produce: {
auctioneerKit: true,
auctionsUpgradeComplete: true,
auctionUpgradeNewInstance: true,
},
instance: {
consume: { reserve: true },
Expand Down
45 changes: 30 additions & 15 deletions packages/inter-protocol/src/proposals/upgrade-vaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { E } from '@endo/far';
import { makeNotifierFromAsyncIterable } from '@agoric/notifier';
import { AmountMath } from '@agoric/ertp/src/index.js';
import { makeTracer } from '@agoric/internal/src/index.js';
import { Fail } from '@endo/errors';
import { TimeMath } from '@agoric/time';

const trace = makeTracer('upgrade Vaults proposal');

/**
* @typedef {PromiseSpaceOf<{
* auctionsUpgradeComplete: boolean;
* auctionUpgradeNewInstance: Instance;
* }>} interlockPowers
*/

Expand All @@ -19,13 +21,14 @@ const trace = makeTracer('upgrade Vaults proposal');
export const upgradeVaults = async (
{
consume: {
vaultFactoryKit,
zoe,
auctionUpgradeNewInstance,
chainTimerService,
economicCommitteeCreatorFacet: electorateCreatorFacet,
reserveKit,
auctionsUpgradeComplete,
vaultFactoryKit,
zoe,
},
produce: { auctionsUpgradeComplete: auctionsUpgradeCompleteProducer },
produce: { auctionUpgradeNewInstance: auctionUpgradeNewInstanceProducer },
installation: {
produce: { VaultFactory: produceVaultInstallation },
},
Expand All @@ -52,8 +55,20 @@ export const upgradeVaults = async (
produceVaultInstallation.reset();
produceVaultInstallation.resolve(installationP);

await auctionsUpgradeComplete;
auctionsUpgradeCompleteProducer.reset();
const [auctionOldInstance, auctionNewInstance] = await Promise.all([
auctioneerInstanceP,
auctionUpgradeNewInstance,
]);
auctionOldInstance !== auctionNewInstance ||
Fail`Auction instance didn't change`;
auctionUpgradeNewInstanceProducer.reset();
const publicFacet = E(zoe).getPublicFacet(auctionNewInstance);
/** @type {import('@agoric/inter-protocol/src/auction/scheduler.js').FullSchedule} */
const schedules = await E(publicFacet).getSchedules();
const now = await E(chainTimerService).getCurrentTimestamp();
(schedules.nextAuctionSchedule &&
TimeMath.compareAbs(schedules.nextAuctionSchedule.startTime, now) > 0) ||
Fail`Expected next start time in the future ${schedules.nextAuctionSchedule?.startTime}`;

const readCurrentDirectorParams = async () => {
const { publicFacet: directorPF } = kit;
Expand Down Expand Up @@ -131,15 +146,14 @@ export const upgradeVaults = async (
E.get(reserveKit).creatorFacet,
).makeShortfallReportingInvitation();

const [poserInvitation, auctioneerInstance] = await Promise.all([
E(electorateCreatorFacet).getPoserInvitation(),
auctioneerInstanceP,
]);
const poserInvitation = await E(
electorateCreatorFacet,
).getPoserInvitation();

/** @type {import('../../src/vaultFactory/vaultFactory').VaultFactoryContract['privateArgs']} */
const newPrivateArgs = harden({
...privateArgs,
auctioneerInstance,
auctioneerInstance: auctionNewInstance,
initialPoserInvitation: poserInvitation,
initialShortfallInvitation: shortfallInvitation,
managerParams: managerParamValues,
Expand Down Expand Up @@ -171,17 +185,18 @@ export const getManifestForUpgradeVaults = async (
manifest: {
[upgradeVaults.name]: {
consume: {
auctionUpgradeNewInstance: uV,
chainTimerService: uV,
economicCommitteeCreatorFacet: uV,
reserveKit: uV,
vaultFactoryKit: uV,
zoe: uV,
auctionsUpgradeComplete: uV,
},
produce: { auctionsUpgradeComplete: uV },
produce: { auctionUpgradeNewInstance: uV },
installation: {
produce: { VaultFactory: true },
},
instance: { consume: { auctioneer: uV } },
instance: { consume: { auctioneer: true } },
},
},
options: { ...vaultUpgradeOptions },
Expand Down

0 comments on commit b84a426

Please sign in to comment.