Skip to content

Commit

Permalink
refactor: two proposals installed contractGovernor bundle; stop it
Browse files Browse the repository at this point in the history
Pass just the bundleId through from the first proposal to the second,
and then reset() the value.

Also cleaned up some leftover permissions
  • Loading branch information
Chris-Hibbert committed Oct 21, 2024
1 parent 1ac26b7 commit 6582793
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 46 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
63 changes: 38 additions & 25 deletions packages/inter-protocol/src/proposals/add-auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,51 @@ 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 } };
* }} 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,
contractGovernor: governorInstallationP,
},
},
issuer: {
consume: { [Stable.symbol]: stableIssuerP },
},
},
issuer: {
consume: { [Stable.symbol]: stableIssuerP },
},
}) => {
{ options: { contractGovernorRef: contractGovernorBundle } },
) => {
trace('addAuction start');
const STORAGE_PATH = 'auction';

Expand Down Expand Up @@ -179,6 +190,7 @@ export const addAuction = async ({
);

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

export const ADD_AUCTION_MANIFEST = harden({
Expand All @@ -197,6 +209,7 @@ export const ADD_AUCTION_MANIFEST = harden({
produce: {
auctioneerKit: true,
auctionUpgradeNewInstance: true,
newContractGovBundleId: true,
},
instance: {
consume: { reserve: true },
Expand Down Expand Up @@ -224,7 +237,7 @@ export const getManifestForAddAuction = async (
) => {
return {
manifest: ADD_AUCTION_MANIFEST,
options: { auctioneerRef, contractGovernorRef },
options: { contractGovernorRef },
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 6582793

Please sign in to comment.