Skip to content

Commit

Permalink
10248 install contractGovernor once (#10256)
Browse files Browse the repository at this point in the history
closes: #10248

## Description

#10163 (priceFeed coreEval) installed the contractGovernor twice, unnecessarily. This installs it once, and passes the reference from the auction proposal to the vaultFactory proposal.

### Security Considerations

Repairs a minor issue with legibility of upgraded contracts.

### Scaling Considerations

N/A

### Documentation Considerations

N/A

### Testing Considerations

priceFeed update tests continue to pass.

### Upgrade Considerations

This will be included with the priceFeed coreEval, which is expected to be added to upgrade 18.
  • Loading branch information
mergify[bot] authored Oct 21, 2024
2 parents 1ac26b7 + e319cd1 commit 7f90751
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 48 deletions.
6 changes: 0 additions & 6 deletions packages/builders/scripts/vats/upgradeVaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ export const defaultProposalBuilder = async ({ publishRef, install }) =>
'../bundles/bundle-vaultFactory.js',
),
),
contractGovernorRef: publishRef(
install(
'@agoric/governance/src/contractGovernor.js',
'../bundles/bundle-contractGovernor.js',
),
),
},
],
});
Expand Down
78 changes: 51 additions & 27 deletions packages/inter-protocol/src/proposals/add-auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,56 @@ const trace = makeTracer('NewAuction', true);
/**
* @typedef {PromiseSpaceOf<{
* auctionUpgradeNewInstance: Instance;
* newContractGovBundleId: string;
* }>} interlockPowers
*/

/**
* @param {import('./econ-behaviors.js').EconomyBootstrapPowers &
* interlockPowers} powers
* @param {{
* options: {
* contractGovernorRef: { bundleID: string };
* contractGovernorInstallation: Installation;
* };
* }} options
*/
export const addAuction = async ({
consume: {
agoricNamesAdmin,
auctioneerKit: legacyKitP,
board,
chainStorage,
chainTimerService,
economicCommitteeCreatorFacet: electorateCreatorFacet,
econCharterKit,
priceAuthority8400,
zoe,
},
produce: { auctioneerKit: produceAuctioneerKit, auctionUpgradeNewInstance },
instance: {
consume: { reserve: reserveInstance },
produce: { auctioneer: auctionInstance },
},
installation: {
export const addAuction = async (
{
consume: {
auctioneer: auctioneerInstallationP,
contractGovernor: governorInstallationP,
agoricNamesAdmin,
auctioneerKit: legacyKitP,
board,
chainStorage,
chainTimerService,
economicCommitteeCreatorFacet: electorateCreatorFacet,
econCharterKit,
priceAuthority8400,
zoe,
},
produce: {
auctioneerKit: produceAuctioneerKit,
auctionUpgradeNewInstance,
newContractGovBundleId,
},
instance: {
consume: { reserve: reserveInstance },
produce: { auctioneer: auctionInstance },
},
installation: {
consume: { auctioneer: auctioneerInstallationP },
},
issuer: {
consume: { [Stable.symbol]: stableIssuerP },
},
},
issuer: {
consume: { [Stable.symbol]: stableIssuerP },
{
options: {
contractGovernorRef: contractGovernorBundle,
contractGovernorInstallation,
},
},
}) => {
) => {
trace('addAuction start');
const STORAGE_PATH = 'auction';

Expand All @@ -53,14 +69,12 @@ export const addAuction = async ({
stableIssuer,
legacyKit,
auctioneerInstallation,
governorInstallation,
] = await Promise.all([
poserInvitationP,
E(E(zoe).getInvitationIssuer()).getAmountOf(poserInvitationP),
stableIssuerP,
legacyKitP,
auctioneerInstallationP,
governorInstallationP,
]);

// Each field has an extra layer of type + value:
Expand Down Expand Up @@ -109,9 +123,14 @@ export const addAuction = async ({
}),
);

const bundleIdFromZoe = await E(zoe).getBundleIDFromInstallation(
contractGovernorInstallation,
);
trace('governor bundle ID', bundleIdFromZoe, contractGovernorBundle.bundleID);

/** @type {GovernorStartedInstallationKit<typeof auctioneerInstallationP>} */
const governorStartResult = await E(zoe).startInstance(
governorInstallation,
contractGovernorInstallation,
undefined,
governorTerms,
harden({
Expand Down Expand Up @@ -179,6 +198,7 @@ export const addAuction = async ({
);

auctionUpgradeNewInstance.resolve(governedInstance);
newContractGovBundleId.resolve(contractGovernorBundle.bundleID);
};

export const ADD_AUCTION_MANIFEST = harden({
Expand All @@ -197,6 +217,7 @@ export const ADD_AUCTION_MANIFEST = harden({
produce: {
auctioneerKit: true,
auctionUpgradeNewInstance: true,
newContractGovBundleId: true,
},
instance: {
consume: { reserve: true },
Expand All @@ -222,9 +243,12 @@ export const getManifestForAddAuction = async (
{ restoreRef },
{ auctioneerRef, contractGovernorRef },
) => {
const contractGovernorInstallation = restoreRef(contractGovernorRef);
return {
manifest: ADD_AUCTION_MANIFEST,
options: { auctioneerRef, contractGovernorRef },
// XXX we should be able to receive contractGovernorInstallation via
// installations.consume, but the received installation isn't right.
options: { contractGovernorRef, contractGovernorInstallation },
installations: {
auctioneer: restoreRef(auctioneerRef),
contractGovernor: restoreRef(contractGovernorRef),
Expand Down
37 changes: 22 additions & 15 deletions packages/inter-protocol/src/proposals/upgrade-vaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const trace = makeTracer('upgrade Vaults proposal');
* @typedef {PromiseSpaceOf<{
* priceAuthority8400: Instance;
* auctionUpgradeNewInstance: Instance;
* newContractGovBundleId: string;
* }>} interlockPowers
*/

Expand All @@ -19,7 +20,6 @@ const trace = makeTracer('upgrade Vaults proposal');
* @param {{
* options: {
* VaultFactoryBundle: { bundleID: string };
* contractGovernorBundle: { bundleID: string };
* };
* }} options
*/
Expand All @@ -33,13 +33,17 @@ export const upgradeVaults = async (
vaultFactoryKit,
zoe,
priceAuthority8400,
newContractGovBundleId: newContractGovBundleIdP,
},
produce: {
auctionUpgradeNewInstance: auctionUpgradeNewInstanceProducer,
newContractGovBundleId: newContractGovBundleIdErasor,
},
produce: { auctionUpgradeNewInstance: auctionUpgradeNewInstanceProducer },
instance: {
consume: { auctioneer: auctioneerInstanceP },
},
},
{ options: { VaultFactoryBundle: vaultBundleRef, contractGovernorBundle } },
{ options: { VaultFactoryBundle: vaultBundleRef } },
) => {
const kit = await vaultFactoryKit;
const { instance: directorInstance } = kit;
Expand Down Expand Up @@ -151,10 +155,15 @@ export const upgradeVaults = async (
const vaultFactoryPrivateArgs = kit.privateArgs;
trace('restarting governor');

const ecf = await electorateCreatorFacet;
const [ecf, newContractGovBundleId] = await Promise.all([
electorateCreatorFacet,
newContractGovBundleIdP,
]);
newContractGovBundleIdErasor.reset();

// upgrade vaultFactory governor. Won't be needed next time: see #10063
await E(kit.governorAdminFacet).upgradeContract(
contractGovernorBundle.bundleID,
newContractGovBundleId,
harden({
electorateCreatorFacet: ecf,
governed: vaultFactoryPrivateArgs,
Expand All @@ -174,7 +183,7 @@ const uV = 'upgradeVaults';
*/
export const getManifestForUpgradeVaults = async (
{ restoreRef },
{ VaultFactoryRef, contractGovernorRef },
{ VaultFactoryRef },
) => {
return {
manifest: {
Expand All @@ -187,18 +196,16 @@ export const getManifestForUpgradeVaults = async (
reserveKit: uV,
vaultFactoryKit: uV,
zoe: uV,
newContractGovBundleId: uV,
},
produce: {
auctionUpgradeNewInstance: uV,
newContractGovBundleId: uV,
},
produce: { auctionUpgradeNewInstance: uV },
instance: { consume: { auctioneer: uV } },
},
},
installations: {
VaultFactory: restoreRef(VaultFactoryRef),
contractGovernor: restoreRef(contractGovernorRef),
},
options: {
VaultFactoryBundle: VaultFactoryRef,
contractGovernorBundle: contractGovernorRef,
},
installations: { VaultFactory: restoreRef(VaultFactoryRef) },
options: { VaultFactoryBundle: VaultFactoryRef },
};
};

0 comments on commit 7f90751

Please sign in to comment.