Skip to content

Commit

Permalink
feat: replace zoe and zcf
Browse files Browse the repository at this point in the history
  • Loading branch information
mhofman committed Jan 31, 2024
1 parent e9e2da6 commit e052586
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 14 deletions.
6 changes: 6 additions & 0 deletions a3p-integration/proposals/a:upgrade-14/post.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ test(`Smart Wallet vat was upgraded`, async t => {

t.is(incarnation, 2);
});

test(`Zoe vat was upgraded`, async t => {
const incarnation = await getIncarnation('zoe');

t.is(incarnation, 1);
});
14 changes: 0 additions & 14 deletions a3p-integration/proposals/a:upgrade-14/sanity.test.js

This file was deleted.

2 changes: 2 additions & 0 deletions golang/cosmos/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,8 @@ func upgrade14Handler(app *GaiaApp, targetUpgrade string) func(sdk.Context, upgr
CoreProposalSteps := []vm.CoreProposalStep{
// First, upgrade wallet factory
vm.CoreProposalStepForModules("@agoric/vats/scripts/build-wallet-factory2-upgrade.js"),
// Then, upgrade Zoe and ZCF
vm.CoreProposalStepForModules("@agoric/vats/scripts/replace-zoe.js"),
}

app.upgradeDetails = &upgradeDetails{
Expand Down
19 changes: 19 additions & 0 deletions packages/vats/scripts/replace-zoe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { makeHelpers } from '@agoric/deploy-script-support';

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
export const defaultProposalBuilder = async ({ publishRef, install }) =>
harden({
sourceSpec: '@agoric/vats/src/proposals/zcf-proposal.js',
getManifestCall: [
'getManifestForZoe',
{
zoeRef: publishRef(install('@agoric/vats/src/vat-zoe.js')),
zcfRef: publishRef(install('@agoric/zoe/src/contractFacet/vatRoot.js')),
},
],
});

export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
await writeCoreProposal('replace-zcf', defaultProposalBuilder);
};
49 changes: 49 additions & 0 deletions packages/vats/src/proposals/zcf-proposal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { E } from '@endo/far';

/**
* @param {BootstrapPowers & {
* consume: {
* vatAdminSvc: VatAdminSvc;
* vatStore: MapStore<
* string,
* import('@agoric/swingset-vat').CreateVatResults
* >;
* };
* }} powers
* @param {object} options
* @param {{ zoeRef: VatSourceRef; zcfRef: VatSourceRef }} options.options
*/
export const upgradeZcf = async (
{ consume: { vatAdminSvc, vatStore } },
options,
) => {
const { zoeRef, zcfRef } = options.options;

assert(zoeRef.bundleID);
const zoeBundleCap = await E(vatAdminSvc).getBundleCap(zoeRef.bundleID);
console.log(`ZOE BUNDLE ID: `, zoeRef.bundleID);

const { adminNode, root: zoeRoot } = await E(vatStore).get('zoe');

await E(adminNode).upgrade(zoeBundleCap, {});

const zoeConfigFacet = await E(zoeRoot).getZoeConfigFacet();
await E(zoeConfigFacet).updateZcfBundleId(zcfRef.bundleID);
console.log(`ZCF BUNDLE ID: `, zcfRef.bundleID);
};

export const getManifestForZoe = (_powers, { zoeRef, zcfRef }) => ({
manifest: {
[upgradeZcf.name]: {
consume: {
vatAdminSvc: 'vatAdminSvc',
vatStore: 'vatStore',
},
produce: {},
},
},
options: {
zoeRef,
zcfRef,
},
});

0 comments on commit e052586

Please sign in to comment.