Skip to content

Commit

Permalink
chore: update installations when restarting or upgrading (#10999)
Browse files Browse the repository at this point in the history
## Description

I've known for a while that there was something magic about the `installations` keyword in `getManifestForFoo` in coreEval proposals, but I was never able to track it down. Now I've found the relevant code. In [`coreProposalBehavior`](https://github.com/Agoric/agoric-sdk/blob/a67bf2862935b4187f423813cfa327c0fea187b8/packages/deploy-script-support/src/coreProposalBehavior.js#L169) (which is copied into generated proposals), if the manifest contains named `installations`, then they are added to **both agoricNames and the bootstrap promiseSpace**.  When upgrading a contract to a new installation, the installation should nearly always be updated this way.

This PR updates all the proposals/scripts currently slated for upgrade-19 to include their upgraded bundles in `installations` so future references will automatically pick them up.

### Security Considerations

related to security and reliability of the contracts, not the chain.

### Scaling Considerations

not relevant.

### Documentation Considerations

I updated the *README* in deploy-script-support.

### Testing Considerations

The `n:upgrade-next` and `z:acceptance` tests continue to pass. 

### Upgrade Considerations

PSM is the only contract being upgraded in Upgrade19 that starts up multiple copies, and it was already doing this correctly.
  • Loading branch information
Chris-Hibbert authored Feb 13, 2025
1 parent 729fe8e commit 9db2909
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const { keys } = Object;
const knownVariants = keys(configurations);

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
export const defaultProposalBuilder = async (_, opts) => {
export const defaultProposalBuilder = async ({ publishRef, install }, opts) => {
const config = opts.config || configurations[opts.variant];
console.log('feeDist OPTS', opts, config);
if (!config) {
Expand All @@ -58,7 +58,15 @@ export const defaultProposalBuilder = async (_, opts) => {
return harden({
sourceSpec:
'@agoric/inter-protocol/src/proposals/replace-fee-distributor.js',
getManifestCall: [getManifestForReplaceFeeDistributor.name, { ...params }],
getManifestCall: [
getManifestForReplaceFeeDistributor.name,
{
feeDistributorRef: publishRef(
install('@agoric/inter-protocol/src/feeDistributor.js'),
),
...params,
},
],
});
};

Expand Down
12 changes: 10 additions & 2 deletions packages/builders/scripts/inter-protocol/replace-feeDistributor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@ import { getManifestForReplaceFeeDistributor } from '@agoric/inter-protocol/src/
import { SECONDS_PER_HOUR } from '@agoric/inter-protocol/src/proposals/econ-behaviors.js';

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
export const defaultProposalBuilder = async (_, opts) => {
export const defaultProposalBuilder = async ({ publishRef, install }, opts) => {
console.log('feeDist OPTS', opts);
return harden({
sourceSpec:
'@agoric/inter-protocol/src/proposals/replace-fee-distributor.js',
getManifestCall: [getManifestForReplaceFeeDistributor.name, { ...opts }],
getManifestCall: [
getManifestForReplaceFeeDistributor.name,
{
feeDistributorRef: publishRef(
install('@agoric/inter-protocol/src/feeDistributor.js'),
),
...opts,
},
],
});
};

Expand Down
7 changes: 4 additions & 3 deletions packages/deploy-script-support/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ are theirselves (recursive) permits. See `BootstrapManifiest` in
[lib-boot.js](../vats/src/core/lib-boot.js).

The manifest object returned from a "getManifestCall" invocation may also
include "installations" to register in `agoricNames` and/or "options" to be
provided as the "options" property of the second argument for each call of the
manifest's functions:
include "installations" (they'll be registered with `agoricNames` and in the
bootstrap promise space) and/or "options" (they'll be provided as the "options"
property of the second argument for each call of the manifest's functions):

```js
/** @type {import('@agoric/vats/src/core/lib-boot').BootstrapManifest} */
const gameManifest = harden({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ harden(replaceFeeDistributor);

const t = 'replaceFeeDistributor';
export const getManifestForReplaceFeeDistributor = async (
_,
feeDistributorOptions,
{ restoreRef },
{ feeDistributorRef, ...feeDistributorOptions },
) => ({
manifest: {
[replaceFeeDistributor.name]: {
Expand Down Expand Up @@ -191,5 +191,8 @@ export const getManifestForReplaceFeeDistributor = async (
},
},
},
installations: {
feeDistributor: restoreRef(feeDistributorRef),
},
options: { ...feeDistributorOptions },
});
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const upgradeWalletFactory = async (
console.log(`Successfully upgraded WalletFactory`);
};

export const getManifestForUpgradeWallet = (_powers, { walletRef }) => ({
export const getManifestForUpgradeWallet = ({ restoreRef }, { walletRef }) => ({
manifest: {
[upgradeWalletFactory.name]: {
consume: {
Expand All @@ -56,5 +56,6 @@ export const getManifestForUpgradeWallet = (_powers, { walletRef }) => ({
},
},
},
installations: { walletFactory: restoreRef(walletRef) },
options: { walletRef },
});
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const upgradeAssetReserve = async (
};

export const getManifestForUpgradingAssetReserve = (
_powers,
{ restoreRef },
{ assetReserveRef },
) => ({
manifest: {
Expand All @@ -89,5 +89,6 @@ export const getManifestForUpgradingAssetReserve = (
},
},
},
installations: { reserve: restoreRef(assetReserveRef) },
options: { assetReserveRef },
});
3 changes: 2 additions & 1 deletion packages/vats/src/proposals/upgrade-mintHolder-proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const upgradeMintHolder = async (
};

export const getManifestForUpgradingMintHolder = (
_powers,
{ restoreRef },
{ contractRef, labelList },
) => ({
manifest: {
Expand All @@ -70,5 +70,6 @@ export const getManifestForUpgradingMintHolder = (
},
},
},
installations: { mintHolder: restoreRef(contractRef) },
options: { contractRef, labelList },
});
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const upgradeProvisionPool = async (
};

export const getManifestForUpgradingProvisionPool = (
_powers,
{ restoreRef },
{ provisionPoolRef },
) => ({
manifest: {
Expand All @@ -128,5 +128,6 @@ export const getManifestForUpgradingProvisionPool = (
produce: {},
},
},
installations: { provisionPool: restoreRef(provisionPoolRef) },
options: { provisionPoolRef },
});

0 comments on commit 9db2909

Please sign in to comment.