@agoric/swingset-vat 0.33.0-upgrade-19-dev-0754752.0 → 0.33.0-upgrade-18a-dev-4ee0508.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 +30 -29
- package/src/controller/controller.js +34 -43
- package/src/controller/initializeKernel.js +1 -0
- package/src/controller/initializeSwingset.js +18 -15
- package/src/kernel/kernel.js +9 -7
- package/src/kernel/slogger.js +121 -124
- package/src/kernel/state/kernelKeeper.js +33 -11
- package/src/kernel/state/vatKeeper.js +47 -23
- package/src/kernel/vat-loader/manager-factory.js +45 -26
- package/src/kernel/vat-loader/manager-subprocess-xsnap.js +2 -26
- package/src/kernel/vat-loader/vat-loader.js +3 -3
- package/src/supervisors/supervisor-helper.js +10 -9
- package/src/typeGuards.js +21 -23
- package/src/types-external.js +38 -39
- package/src/types-internal.js +3 -2
- package/src/vats/timer/vat-timer.js +0 -2
- package/tools/bundleTool.js +1 -5
- package/tools/run-utils.js +50 -52
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/swingset-vat",
|
|
3
|
-
"version": "0.33.0-upgrade-
|
|
3
|
+
"version": "0.33.0-upgrade-18a-dev-4ee0508.0+4ee0508",
|
|
4
4
|
"description": "Vat/Container Launcher",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -27,37 +27,37 @@
|
|
|
27
27
|
"@types/yargs-parser": "^21.0.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@agoric/internal": "0.4.0-upgrade-
|
|
31
|
-
"@agoric/kmarshal": "0.1.1-upgrade-
|
|
32
|
-
"@agoric/store": "0.9.3-upgrade-
|
|
33
|
-
"@agoric/swing-store": "0.10.0-upgrade-
|
|
34
|
-
"@agoric/swingset-liveslots": "0.10.3-upgrade-
|
|
35
|
-
"@agoric/swingset-xsnap-supervisor": "0.10.3-upgrade-
|
|
36
|
-
"@agoric/time": "0.3.3-upgrade-
|
|
37
|
-
"@agoric/vat-data": "0.5.3-upgrade-
|
|
38
|
-
"@agoric/xsnap-lockdown": "0.14.1-upgrade-
|
|
30
|
+
"@agoric/internal": "0.4.0-upgrade-18a-dev-4ee0508.0+4ee0508",
|
|
31
|
+
"@agoric/kmarshal": "0.1.1-upgrade-18a-dev-4ee0508.0+4ee0508",
|
|
32
|
+
"@agoric/store": "0.9.3-upgrade-18a-dev-4ee0508.0+4ee0508",
|
|
33
|
+
"@agoric/swing-store": "0.10.0-upgrade-18a-dev-4ee0508.0+4ee0508",
|
|
34
|
+
"@agoric/swingset-liveslots": "0.10.3-upgrade-18a-dev-4ee0508.0+4ee0508",
|
|
35
|
+
"@agoric/swingset-xsnap-supervisor": "0.10.3-upgrade-18a-dev-4ee0508.0+4ee0508",
|
|
36
|
+
"@agoric/time": "0.3.3-upgrade-18a-dev-4ee0508.0+4ee0508",
|
|
37
|
+
"@agoric/vat-data": "0.5.3-upgrade-18a-dev-4ee0508.0+4ee0508",
|
|
38
|
+
"@agoric/xsnap-lockdown": "0.14.1-upgrade-18a-dev-4ee0508.0+4ee0508",
|
|
39
39
|
"@endo/base64": "^1.0.9",
|
|
40
|
-
"@endo/bundle-source": "^3.5.
|
|
41
|
-
"@endo/captp": "^4.4.
|
|
42
|
-
"@endo/check-bundle": "^1.0.
|
|
43
|
-
"@endo/compartment-mapper": "^1.
|
|
44
|
-
"@endo/errors": "^1.2.
|
|
45
|
-
"@endo/eventual-send": "^1.
|
|
46
|
-
"@endo/far": "^1.1.
|
|
47
|
-
"@endo/import-bundle": "^1.3.
|
|
48
|
-
"@endo/init": "^1.1.
|
|
49
|
-
"@endo/marshal": "^1.6.
|
|
50
|
-
"@endo/nat": "^5.0.
|
|
51
|
-
"@endo/pass-style": "^1.4.
|
|
52
|
-
"@endo/patterns": "^1.4.
|
|
53
|
-
"@endo/promise-kit": "^1.1.
|
|
54
|
-
"@endo/ses-ava": "^1.2.
|
|
55
|
-
"@endo/stream": "^1.2.
|
|
40
|
+
"@endo/bundle-source": "^3.5.0",
|
|
41
|
+
"@endo/captp": "^4.4.3",
|
|
42
|
+
"@endo/check-bundle": "^1.0.12",
|
|
43
|
+
"@endo/compartment-mapper": "^1.4.0",
|
|
44
|
+
"@endo/errors": "^1.2.8",
|
|
45
|
+
"@endo/eventual-send": "^1.2.8",
|
|
46
|
+
"@endo/far": "^1.1.9",
|
|
47
|
+
"@endo/import-bundle": "^1.3.2",
|
|
48
|
+
"@endo/init": "^1.1.7",
|
|
49
|
+
"@endo/marshal": "^1.6.2",
|
|
50
|
+
"@endo/nat": "^5.0.13",
|
|
51
|
+
"@endo/pass-style": "^1.4.7",
|
|
52
|
+
"@endo/patterns": "^1.4.7",
|
|
53
|
+
"@endo/promise-kit": "^1.1.8",
|
|
54
|
+
"@endo/ses-ava": "^1.2.8",
|
|
55
|
+
"@endo/stream": "^1.2.8",
|
|
56
56
|
"@endo/zip": "^1.0.9",
|
|
57
57
|
"ansi-styles": "^6.2.1",
|
|
58
58
|
"anylogger": "^0.21.0",
|
|
59
59
|
"better-sqlite3": "^9.1.1",
|
|
60
|
-
"import-meta-resolve": "^
|
|
60
|
+
"import-meta-resolve": "^2.2.1",
|
|
61
61
|
"microtime": "^3.1.0",
|
|
62
62
|
"semver": "^6.3.0",
|
|
63
63
|
"tmp": "^0.2.1",
|
|
@@ -94,7 +94,8 @@
|
|
|
94
94
|
"require": [
|
|
95
95
|
"@endo/init/debug.js"
|
|
96
96
|
],
|
|
97
|
-
"timeout": "20m"
|
|
97
|
+
"timeout": "20m",
|
|
98
|
+
"workerThreads": false
|
|
98
99
|
},
|
|
99
100
|
"publishConfig": {
|
|
100
101
|
"access": "public"
|
|
@@ -102,5 +103,5 @@
|
|
|
102
103
|
"typeCoverage": {
|
|
103
104
|
"atLeast": 76.28
|
|
104
105
|
},
|
|
105
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "4ee05088e5ada989a866a11ff65838d395505ce6"
|
|
106
107
|
}
|
|
@@ -16,7 +16,6 @@ import { initSwingStore } from '@agoric/swing-store';
|
|
|
16
16
|
import { mustMatch, M } from '@endo/patterns';
|
|
17
17
|
import { checkBundle } from '@endo/check-bundle/lite.js';
|
|
18
18
|
import { deepCopyJsonable } from '@agoric/internal/src/js-utils.js';
|
|
19
|
-
import { makeLimitedConsole } from '@agoric/internal/src/ses-utils.js';
|
|
20
19
|
import engineGC from '@agoric/internal/src/lib-nodejs/engine-gc.js';
|
|
21
20
|
import { startSubprocessWorker } from '@agoric/internal/src/lib-nodejs/spawnSubprocessWorker.js';
|
|
22
21
|
import { waitUntilQuiescent } from '@agoric/internal/src/lib-nodejs/waitUntilQuiescent.js';
|
|
@@ -36,10 +35,6 @@ import {
|
|
|
36
35
|
import { makeStartXSnap } from './startXSnap.js';
|
|
37
36
|
import { makeStartSubprocessWorkerNode } from './startNodeSubprocess.js';
|
|
38
37
|
|
|
39
|
-
/**
|
|
40
|
-
* @import {EReturn} from '@endo/far';
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
38
|
/**
|
|
44
39
|
* @typedef { import('../types-internal.js').VatID } VatID
|
|
45
40
|
*/
|
|
@@ -57,32 +52,34 @@ export function computeSha512(bytes) {
|
|
|
57
52
|
return hash.digest().toString('hex');
|
|
58
53
|
}
|
|
59
54
|
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
55
|
+
/** @param {string | ((args: unknown[]) => string)} tagOrTagCreator */
|
|
56
|
+
function makeConsole(tagOrTagCreator) {
|
|
57
|
+
/** @type {(level: string) => (args: unknown[]) => void} */
|
|
58
|
+
let makeLoggerForLevel;
|
|
59
|
+
if (typeof tagOrTagCreator === 'function') {
|
|
60
|
+
const tagToLogger = new Map();
|
|
61
|
+
makeLoggerForLevel =
|
|
62
|
+
level =>
|
|
63
|
+
(...args) => {
|
|
64
|
+
// Retrieve the logger from cache.
|
|
65
|
+
const tag = tagOrTagCreator(args);
|
|
66
|
+
let logger = tagToLogger.get(tag);
|
|
67
|
+
if (!logger) {
|
|
68
|
+
logger = anylogger(tag);
|
|
69
|
+
tagToLogger.set(tag, logger);
|
|
70
|
+
}
|
|
71
|
+
// Actually log the message.
|
|
72
|
+
return logger[level](...args);
|
|
73
|
+
};
|
|
74
|
+
} else {
|
|
75
|
+
const logger = anylogger(tagOrTagCreator);
|
|
76
|
+
makeLoggerForLevel = level => logger[level];
|
|
71
77
|
}
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
let logger = prefixToLogger.get(prefix);
|
|
78
|
-
if (!logger) {
|
|
79
|
-
logger = anylogger(prefix);
|
|
80
|
-
prefixToLogger.set(prefix, logger);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return logger[level](...args);
|
|
84
|
-
};
|
|
85
|
-
});
|
|
78
|
+
const cons = {};
|
|
79
|
+
for (const level of ['debug', 'log', 'info', 'warn', 'error']) {
|
|
80
|
+
cons[level] = makeLoggerForLevel(level);
|
|
81
|
+
}
|
|
82
|
+
return harden(cons);
|
|
86
83
|
}
|
|
87
84
|
|
|
88
85
|
/**
|
|
@@ -212,23 +209,17 @@ export async function makeSwingsetController(
|
|
|
212
209
|
process.on('unhandledRejection', unhandledRejectionHandler);
|
|
213
210
|
}
|
|
214
211
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
kernelConsole[level](...args);
|
|
219
|
-
writeSlogObject({ type: 'console', source: 'kernel', args });
|
|
220
|
-
};
|
|
221
|
-
});
|
|
212
|
+
function kernelRequire(what) {
|
|
213
|
+
Fail`kernelRequire unprepared to satisfy require(${what})`;
|
|
214
|
+
}
|
|
222
215
|
writeSlogObject({ type: 'import-kernel-start' });
|
|
223
216
|
const kernelNS = await importBundle(kernelBundle, {
|
|
224
217
|
filePrefix: 'kernel/...',
|
|
225
218
|
endowments: {
|
|
226
|
-
console:
|
|
219
|
+
console: makeConsole(`${debugPrefix}SwingSet:kernel`),
|
|
227
220
|
// See https://github.com/Agoric/agoric-sdk/issues/9515
|
|
228
221
|
assert: globalThis.assert,
|
|
229
|
-
require:
|
|
230
|
-
what => Fail`kernelRequire unprepared to satisfy require(${what})`,
|
|
231
|
-
),
|
|
222
|
+
require: kernelRequire,
|
|
232
223
|
URL: globalThis.Base64, // Unavailable only on XSnap
|
|
233
224
|
Base64: globalThis.Base64, // Available only on XSnap
|
|
234
225
|
},
|
|
@@ -486,7 +477,7 @@ export async function makeSwingsetController(
|
|
|
486
477
|
*
|
|
487
478
|
* The first `controller.run()` after this call will delete all
|
|
488
479
|
* the old vat's state at once, unless you use a
|
|
489
|
-
* [`runPolicy`](
|
|
480
|
+
* [`runPolicy`](../docs/run-policy.md) to rate-limit cleanups.
|
|
490
481
|
*
|
|
491
482
|
* @param {VatID} vatID
|
|
492
483
|
* @param {SwingSetCapData} reasonCD
|
|
@@ -503,7 +494,7 @@ export async function makeSwingsetController(
|
|
|
503
494
|
|
|
504
495
|
return controller;
|
|
505
496
|
}
|
|
506
|
-
/** @typedef {
|
|
497
|
+
/** @typedef {Awaited<ReturnType<typeof makeSwingsetController>>} SwingsetController */
|
|
507
498
|
|
|
508
499
|
/**
|
|
509
500
|
* NB: To be used only in tests. An app with this may not survive a reboot.
|
|
@@ -100,6 +100,7 @@ export async function initializeKernel(config, kernelStorage, options = {}) {
|
|
|
100
100
|
// the VatManager, since it isn't available until the bundle is evaluated
|
|
101
101
|
assertKnownOptions(creationOptions, [
|
|
102
102
|
'enablePipelining',
|
|
103
|
+
'metered',
|
|
103
104
|
'managerType',
|
|
104
105
|
'enableDisavow',
|
|
105
106
|
'enableSetup',
|
|
@@ -442,24 +442,26 @@ export async function initializeSwingset(
|
|
|
442
442
|
* The host application gives us
|
|
443
443
|
* config.[vats|devices].NAME.[bundle|bundleSpec|sourceSpec|bundleName] .
|
|
444
444
|
* The 'bundleName' option points into
|
|
445
|
-
* config.bundles.BUNDLENAME.[bundle|bundleSpec|sourceSpec], which can
|
|
445
|
+
* config.bundles.BUNDLENAME.[bundle|bundleSpec|sourceSpec] , which can
|
|
446
446
|
* also include arbitrary named bundles that will be made available to
|
|
447
|
-
* E(vatAdminService).getNamedBundleCap(bundleName),
|
|
447
|
+
* E(vatAdminService).getNamedBundleCap(bundleName) ,and temporarily as
|
|
448
448
|
* E(vatAdminService).createVatByName(bundleName)
|
|
449
449
|
*
|
|
450
450
|
* The 'kconfig' we pass through to initializeKernel has
|
|
451
451
|
* kconfig.[vats|devices].NAME.bundleID and
|
|
452
|
-
* kconfig.namedBundleIDs.BUNDLENAME=bundleID, which both point into
|
|
452
|
+
* kconfig.namedBundleIDs.BUNDLENAME=bundleID , which both point into
|
|
453
453
|
* kconfig.idToBundle.BUNDLEID=bundle
|
|
454
454
|
*
|
|
455
|
-
* @param {SwingSetConfigProperties} desc
|
|
455
|
+
* @param {SwingSetConfigProperties | { bundleName: string }} desc
|
|
456
456
|
* @param {Record<string, *>} [nameToBundle]
|
|
457
457
|
*/
|
|
458
458
|
async function getBundle(desc, nameToBundle) {
|
|
459
459
|
trace(
|
|
460
460
|
'getBundle',
|
|
461
461
|
Object.keys(desc),
|
|
462
|
+
// @ts-expect-error optional
|
|
462
463
|
desc.moduleFormat,
|
|
464
|
+
// @ts-expect-error optional
|
|
463
465
|
desc.endoZipBase64Sha512 || desc.sourceSpec,
|
|
464
466
|
);
|
|
465
467
|
|
|
@@ -487,9 +489,8 @@ export async function initializeSwingset(
|
|
|
487
489
|
throw Error(`unknown mode in desc`, desc);
|
|
488
490
|
}
|
|
489
491
|
|
|
492
|
+
// fires with BundleWithID: { ...bundle, id }
|
|
490
493
|
/**
|
|
491
|
-
* Returns a bundle record with an "id" property from an input that might be missing it.
|
|
492
|
-
*
|
|
493
494
|
* @param {EndoZipBase64Bundle & {id?: string}} bundle
|
|
494
495
|
* @returns {Promise<EndoZipBase64Bundle & {id: string}>} bundle
|
|
495
496
|
*/
|
|
@@ -507,9 +508,11 @@ export async function initializeSwingset(
|
|
|
507
508
|
};
|
|
508
509
|
}
|
|
509
510
|
|
|
511
|
+
// fires with BundleWithID: { ...bundle, id }
|
|
512
|
+
|
|
510
513
|
/**
|
|
511
514
|
*
|
|
512
|
-
* @param {SwingSetConfigProperties & {bundleID?: string}} desc
|
|
515
|
+
* @param {(SwingSetConfigProperties | { bundleName: string }) & {bundleID?: string }} desc
|
|
513
516
|
* @param {Record<string, EndoZipBase64Bundle>} [nameToBundle]
|
|
514
517
|
*/
|
|
515
518
|
async function processDesc(desc, nameToBundle) {
|
|
@@ -523,14 +526,14 @@ export async function initializeSwingset(
|
|
|
523
526
|
modes.length === 1 ||
|
|
524
527
|
Fail`need =1 of bundle/bundleSpec/sourceSpec/bundleName, got ${modes}`;
|
|
525
528
|
const mode = modes[0];
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
529
|
+
return getBundle(desc, nameToBundle)
|
|
530
|
+
.then(addBundleID)
|
|
531
|
+
.then(bundleWithID => {
|
|
532
|
+
// replace original .sourceSpec/etc with a uniform .bundleID
|
|
533
|
+
delete desc[mode];
|
|
534
|
+
desc.bundleID = bundleWithID.id;
|
|
535
|
+
return bundleWithID;
|
|
536
|
+
});
|
|
534
537
|
}
|
|
535
538
|
|
|
536
539
|
/**
|
package/src/kernel/kernel.js
CHANGED
|
@@ -9,7 +9,7 @@ import { makeUpgradeDisconnection } from '@agoric/internal/src/upgrade-api.js';
|
|
|
9
9
|
import { kser, kslot, makeError } from '@agoric/kmarshal';
|
|
10
10
|
import { assertKnownOptions } from '../lib/assertOptions.js';
|
|
11
11
|
import { foreverPolicy } from '../lib/runPolicies.js';
|
|
12
|
-
import {
|
|
12
|
+
import { makeVatManagerFactory } from './vat-loader/manager-factory.js';
|
|
13
13
|
import { makeVatWarehouse } from './vat-warehouse.js';
|
|
14
14
|
import makeDeviceManager from './deviceManager.js';
|
|
15
15
|
import makeKernelKeeper, {
|
|
@@ -110,10 +110,11 @@ export default function buildKernel(
|
|
|
110
110
|
warehousePolicy,
|
|
111
111
|
overrideVatManagerOptions = {},
|
|
112
112
|
} = kernelRuntimeOptions;
|
|
113
|
-
const logStartup = verbose ? console.debug : () =>
|
|
113
|
+
const logStartup = verbose ? console.debug : () => 0;
|
|
114
114
|
|
|
115
115
|
const vatAdminRootKref = kernelStorage.kvStore.get('vatAdminRootKref');
|
|
116
116
|
|
|
117
|
+
/** @type { KernelSlog } */
|
|
117
118
|
const kernelSlog = writeSlogObject
|
|
118
119
|
? makeSlogger(slogCallbacks, writeSlogObject)
|
|
119
120
|
: makeDummySlogger(slogCallbacks, makeConsole('disabled slogger'));
|
|
@@ -166,9 +167,10 @@ export default function buildKernel(
|
|
|
166
167
|
harden(testLog);
|
|
167
168
|
|
|
168
169
|
function makeSourcedConsole(vatID) {
|
|
169
|
-
const origConsole = makeConsole(
|
|
170
|
-
source
|
|
171
|
-
|
|
170
|
+
const origConsole = makeConsole(args => {
|
|
171
|
+
const source = args.shift();
|
|
172
|
+
return `${debugPrefix}SwingSet:${source}:${vatID}`;
|
|
173
|
+
});
|
|
172
174
|
return kernelSlog.vatConsole(vatID, origConsole);
|
|
173
175
|
}
|
|
174
176
|
|
|
@@ -1555,7 +1557,7 @@ export default function buildKernel(
|
|
|
1555
1557
|
gcAndFinalize,
|
|
1556
1558
|
meterControl: makeDummyMeterControl(),
|
|
1557
1559
|
});
|
|
1558
|
-
const
|
|
1560
|
+
const vatManagerFactory = makeVatManagerFactory({
|
|
1559
1561
|
allVatPowers,
|
|
1560
1562
|
kernelKeeper,
|
|
1561
1563
|
vatEndowments,
|
|
@@ -1650,7 +1652,7 @@ export default function buildKernel(
|
|
|
1650
1652
|
}
|
|
1651
1653
|
|
|
1652
1654
|
const vatLoader = makeVatLoader({
|
|
1653
|
-
|
|
1655
|
+
vatManagerFactory,
|
|
1654
1656
|
kernelSlog,
|
|
1655
1657
|
makeSourcedConsole,
|
|
1656
1658
|
kernelKeeper,
|