-
Notifications
You must be signed in to change notification settings - Fork 212
/
namesByAddress-fix-proposal.js
55 lines (50 loc) · 1.65 KB
/
namesByAddress-fix-proposal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/** @file core eval proposal to fix namesByAddress by upgrading vat-provisioning */
import { E } from '@endo/far';
const vatUpgrade = /** @type {const} */ ({
name: 'provisioning',
opts: {
// vatParameters not used by provisioning vat
upgradeMessage: 'fix namesByAddress',
},
});
/**
* Upgrade provisioning vat and replace namesByAddress in bootstrap promise
* space
*
* @param {BootstrapPowers} powers
* @param {object} options
* @param {{ provisioningRef: { bundleID: string } }} options.options
*
* @typedef {string} BundleID
*/
export const upgradeProvisioningVat = async (powers, options) => {
console.log('upgradeProvisioningVat...');
const { vatStore, vatAdminSvc } = powers.consume;
const { namesByAddress: resolver } = powers.produce;
const { name, opts } = vatUpgrade;
const { bundleID } = options.options.provisioningRef;
const vatInfo = await E(vatStore).get(name);
console.log(vatUpgrade.name, vatInfo, bundleID);
const { root, adminNode } = vatInfo;
const bundleCap = await E(vatAdminSvc).getBundleCap(bundleID);
const incarnation = await E(adminNode).upgrade(bundleCap, opts);
console.log({ ...vatUpgrade, incarnation });
const { namesByAddress } = await E(root).getNamesByAddressKit();
resolver.reset();
resolver.resolve(namesByAddress);
};
export const getManifestForProvisioning = (_powers, { provisioningRef }) => ({
/** @type {import('../core/lib-boot').BootstrapManifest} */
manifest: {
[upgradeProvisioningVat.name]: {
consume: {
vatStore: true,
vatAdminSvc: true,
},
produce: {
namesByAddress: true,
},
},
},
options: { provisioningRef },
});