@agoric/vats 0.15.2-dev-da94029.0 → 0.15.2-dev-d950170.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/vats",
|
|
3
|
-
"version": "0.15.2-dev-
|
|
3
|
+
"version": "0.15.2-dev-d950170.0+d950170",
|
|
4
4
|
"description": "Agoric's Vat library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"typeCoverage": {
|
|
80
80
|
"atLeast": 90.49
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "d9501704148a9118bc62a9d84aada966dc2deb0f"
|
|
83
83
|
}
|
|
@@ -13,6 +13,14 @@ export function upgradeVatsGeneric({ consume: { vatAdminSvc, vatStore } }: Boots
|
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
15
|
}): Promise<void>;
|
|
16
|
+
export function upgradeZoeContractsGeneric({ consume }: PromiseSpaceOf<Record<string, any>>, options: {
|
|
17
|
+
options: {
|
|
18
|
+
contractKitSpecs: ContractKitSpec[];
|
|
19
|
+
installationBundleRefs: {
|
|
20
|
+
[bundleName: string]: VatSourceRef;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}): Promise<void>;
|
|
16
24
|
export function getManifestForUpgradingVats(_powers: any, { bundleRefs, vatOptions }: {
|
|
17
25
|
bundleRefs: any;
|
|
18
26
|
vatOptions: any;
|
|
@@ -31,4 +39,32 @@ export function getManifestForUpgradingVats(_powers: any, { bundleRefs, vatOptio
|
|
|
31
39
|
vatOptions: any;
|
|
32
40
|
};
|
|
33
41
|
};
|
|
42
|
+
export function getManifestForUpgradingZoeContractKits({ restoreRef }: any, { contractKitSpecs, installationBundleRefs }: {
|
|
43
|
+
contractKitSpecs: ContractKitSpec[];
|
|
44
|
+
installationBundleRefs: {
|
|
45
|
+
[bundleName: string]: VatSourceRef;
|
|
46
|
+
};
|
|
47
|
+
}): {
|
|
48
|
+
manifest: {
|
|
49
|
+
[upgradeZoeContractsGeneric.name]: {
|
|
50
|
+
consume: {
|
|
51
|
+
instancePrivateArgs: boolean;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
installations: {
|
|
56
|
+
[k: string]: any;
|
|
57
|
+
};
|
|
58
|
+
options: {
|
|
59
|
+
contractKitSpecs: ContractKitSpec[];
|
|
60
|
+
installationBundleRefs: {
|
|
61
|
+
[bundleName: string]: VatSourceRef;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export type ContractKitSpec = {
|
|
66
|
+
kitLookup: string[];
|
|
67
|
+
bundleName: string;
|
|
68
|
+
entrypoint?: string;
|
|
69
|
+
};
|
|
34
70
|
//# sourceMappingURL=upgrade-vats-generic-proposal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-vats-generic-proposal.d.ts","sourceRoot":"","sources":["upgrade-vats-generic-proposal.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upgrade-vats-generic-proposal.d.ts","sourceRoot":"","sources":["upgrade-vats-generic-proposal.js"],"names":[],"mappings":"AAwBO,2EAjBI,eAAe,GAAG;IACxB,OAAO,EAAE;QACP,WAAW,EAAE,WAAW,CAAC;QACzB,QAAQ,EAAE,QAAQ,CACxB,MAAc,EACd,OAAe,sBAAsB,EAAE,gBAAgB,CAChD,CAAC;KACH,CAAC;CACH,WAED;IAKW,OAAO,EALV;QACN,UAAU,EAAE;YAAE,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAAA;SAAE,CAAC;QAChD,UAAU,CAAC,EAAE;YACjB,CAAO,OAAO,EAAE,MAAM,GAAG,OAAO,sBAAsB,EAAE,iBAAiB,CAAC;SACrE,CAAC;KACH;CACH,iBAoBA;AAcM,wDAPI,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,WAE3C;IAGW,OAAO,EAHV;QACN,gBAAgB,EAAE,eAAe,EAAE,CAAC;QACpC,sBAAsB,EAAE;YAAE,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,CAAA;SAAE,CAAC;KAChE;CACH,iBAqEA;AAEM;;;;;QAKH,CAAC,kBAAkB,CAAC,IAAI,CAAC;;;;;;UAMxB;;;;;;EAGH;AAUK,uEAPI,GAAG,gDACH;IACN,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,sBAAsB,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,CAAA;KAAE,CAAC;CAChE;;QAoBE,CAAC,0BAA0B,CAAC,IAAI,CAAC;;;;UAIhC;;;;;;;;;;;EAaN;8BA3IY;IAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { E } from '@endo/far';
|
|
2
2
|
|
|
3
|
+
import { makeTracer } from '@agoric/internal';
|
|
4
|
+
|
|
5
|
+
const trace = makeTracer('UpgradeVats');
|
|
6
|
+
|
|
3
7
|
/**
|
|
4
8
|
* @param {BootstrapPowers & {
|
|
5
9
|
* consume: {
|
|
@@ -22,16 +26,103 @@ export const upgradeVatsGeneric = async (
|
|
|
22
26
|
{ consume: { vatAdminSvc, vatStore } },
|
|
23
27
|
options,
|
|
24
28
|
) => {
|
|
29
|
+
trace('Starting upgrade of vats');
|
|
25
30
|
const { bundleRefs, vatOptions = {} } = options.options;
|
|
26
31
|
|
|
27
32
|
for await (const [name, ref] of Object.entries(bundleRefs)) {
|
|
28
33
|
assert(ref.bundleID, `bundleID missing for ${name}`);
|
|
29
|
-
|
|
34
|
+
trace(name, `BUNDLE ID: `, ref.bundleID);
|
|
30
35
|
const bundleCap = await E(vatAdminSvc).getBundleCap(ref.bundleID);
|
|
31
36
|
|
|
37
|
+
trace(name, 'Getting admin node from vatStore');
|
|
32
38
|
const { adminNode } = await E(vatStore).get(name);
|
|
39
|
+
trace(name, 'Upgrading via adminNode');
|
|
33
40
|
await E(adminNode).upgrade(bundleCap, vatOptions[name] || {});
|
|
34
41
|
}
|
|
42
|
+
|
|
43
|
+
trace('Done upgrading vats');
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @typedef {{ kitLookup: string[]; bundleName: string; entrypoint?: string }} ContractKitSpec
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param {PromiseSpaceOf<Record<string, any>>} powers
|
|
52
|
+
* @param {object} options
|
|
53
|
+
* @param {{
|
|
54
|
+
* contractKitSpecs: ContractKitSpec[];
|
|
55
|
+
* installationBundleRefs: { [bundleName: string]: VatSourceRef };
|
|
56
|
+
* }} options.options
|
|
57
|
+
*/
|
|
58
|
+
export const upgradeZoeContractsGeneric = async ({ consume }, options) => {
|
|
59
|
+
trace('Starting upgrade of Zoe contract kits');
|
|
60
|
+
|
|
61
|
+
const { instancePrivateArgs: instancePrivateArgsP } = consume;
|
|
62
|
+
|
|
63
|
+
const { contractKitSpecs, installationBundleRefs } = options.options;
|
|
64
|
+
|
|
65
|
+
const kitWithPrivateArgs = async (kitName, contractKitP) => {
|
|
66
|
+
trace(kitName, 'awaiting contract kit');
|
|
67
|
+
const contractKit = await contractKitP;
|
|
68
|
+
if (contractKit.privateArgs) {
|
|
69
|
+
trace(
|
|
70
|
+
kitName,
|
|
71
|
+
'contractKit already has privateArgs',
|
|
72
|
+
contractKit.privateArgs,
|
|
73
|
+
);
|
|
74
|
+
return harden(contractKit);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// If the privateArgs are not directly on the contractKit, they may be
|
|
78
|
+
// on the instancePrivateArgs.
|
|
79
|
+
trace(kitName, 'getting privateArgs from instancePrivateArgs');
|
|
80
|
+
const privateArgs = await E(instancePrivateArgsP).get(contractKit.instance);
|
|
81
|
+
trace(
|
|
82
|
+
kitName,
|
|
83
|
+
'adding instancePrivateArgs',
|
|
84
|
+
privateArgs,
|
|
85
|
+
'to contract kit',
|
|
86
|
+
);
|
|
87
|
+
return harden({ ...contractKit, privateArgs });
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
await null;
|
|
91
|
+
for (const { kitLookup, bundleName } of contractKitSpecs) {
|
|
92
|
+
const humanLookup = JSON.stringify(kitLookup);
|
|
93
|
+
trace(humanLookup, 'Looking for contract kit');
|
|
94
|
+
let contractKit = consume;
|
|
95
|
+
for (let i = 0; i < kitLookup.length; i += 1) {
|
|
96
|
+
contractKit = await contractKit[kitLookup[i]];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const { adminFacet, privateArgs } = await kitWithPrivateArgs(
|
|
100
|
+
humanLookup,
|
|
101
|
+
contractKit,
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const contractRef = installationBundleRefs[bundleName];
|
|
105
|
+
assert(contractRef, `No installation bundle found for ${bundleName}`);
|
|
106
|
+
assert(
|
|
107
|
+
contractRef.bundleID,
|
|
108
|
+
`No bundleID found for ${bundleName} in installationBundleRefs`,
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
trace(humanLookup, 'Upgrading contract kit to', bundleName);
|
|
112
|
+
const upgradeResult = await E(adminFacet).upgradeContract(
|
|
113
|
+
contractRef.bundleID,
|
|
114
|
+
privateArgs,
|
|
115
|
+
);
|
|
116
|
+
trace(
|
|
117
|
+
humanLookup,
|
|
118
|
+
'Upgraded contract kit to',
|
|
119
|
+
bundleName,
|
|
120
|
+
'completed with',
|
|
121
|
+
upgradeResult,
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
trace('Done upgrading contract kits.');
|
|
35
126
|
};
|
|
36
127
|
|
|
37
128
|
export const getManifestForUpgradingVats = (
|
|
@@ -49,3 +140,47 @@ export const getManifestForUpgradingVats = (
|
|
|
49
140
|
},
|
|
50
141
|
options: { bundleRefs, vatOptions },
|
|
51
142
|
});
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @param {any} powers
|
|
146
|
+
* @param {{
|
|
147
|
+
* contractKitSpecs: ContractKitSpec[];
|
|
148
|
+
* installationBundleRefs: { [bundleName: string]: VatSourceRef };
|
|
149
|
+
* }} options
|
|
150
|
+
* @returns
|
|
151
|
+
*/
|
|
152
|
+
export const getManifestForUpgradingZoeContractKits = (
|
|
153
|
+
{ restoreRef },
|
|
154
|
+
{ contractKitSpecs, installationBundleRefs },
|
|
155
|
+
) => {
|
|
156
|
+
const consumePermits = {
|
|
157
|
+
instancePrivateArgs: true,
|
|
158
|
+
};
|
|
159
|
+
for (const { kitLookup } of contractKitSpecs) {
|
|
160
|
+
let current = consumePermits;
|
|
161
|
+
for (let i = 0; i < kitLookup.length - 1; i += 1) {
|
|
162
|
+
current = current[kitLookup[i]] || (current[kitLookup[i]] = {});
|
|
163
|
+
}
|
|
164
|
+
current[kitLookup[kitLookup.length - 1]] ||= true;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
manifest: {
|
|
169
|
+
[upgradeZoeContractsGeneric.name]: {
|
|
170
|
+
// Other consume permits should only be added in the definition of
|
|
171
|
+
// `consumePermits`, at the top of this function.
|
|
172
|
+
consume: consumePermits,
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
installations: Object.fromEntries(
|
|
176
|
+
Object.entries(installationBundleRefs).map(([bundleName, bundleRef]) => [
|
|
177
|
+
bundleName,
|
|
178
|
+
restoreRef(bundleRef),
|
|
179
|
+
]),
|
|
180
|
+
),
|
|
181
|
+
options: {
|
|
182
|
+
contractKitSpecs,
|
|
183
|
+
installationBundleRefs,
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
};
|