@agoric/swingset-vat 0.33.0-upgrade-18a-dev-61134db.0 → 0.33.0-upgrade-19-dev-0754752.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 +29 -30
- package/src/controller/controller.js +43 -34
- package/src/controller/initializeKernel.js +0 -1
- package/src/controller/initializeSwingset.js +15 -18
- package/src/kernel/kernel.js +7 -9
- package/src/kernel/slogger.js +124 -121
- package/src/kernel/state/kernelKeeper.js +11 -33
- package/src/kernel/state/vatKeeper.js +23 -47
- package/src/kernel/vat-loader/manager-factory.js +26 -45
- package/src/kernel/vat-loader/manager-subprocess-xsnap.js +26 -2
- package/src/kernel/vat-loader/vat-loader.js +3 -3
- package/src/supervisors/supervisor-helper.js +9 -10
- package/src/typeGuards.js +23 -21
- package/src/types-external.js +39 -38
- package/src/types-internal.js +2 -3
- package/src/vats/timer/vat-timer.js +2 -0
- package/tools/bundleTool.js +5 -1
- package/tools/run-utils.js +52 -50
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-19-dev-0754752.0+0754752",
|
|
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-19-dev-0754752.0+0754752",
|
|
31
|
+
"@agoric/kmarshal": "0.1.1-upgrade-19-dev-0754752.0+0754752",
|
|
32
|
+
"@agoric/store": "0.9.3-upgrade-19-dev-0754752.0+0754752",
|
|
33
|
+
"@agoric/swing-store": "0.10.0-upgrade-19-dev-0754752.0+0754752",
|
|
34
|
+
"@agoric/swingset-liveslots": "0.10.3-upgrade-19-dev-0754752.0+0754752",
|
|
35
|
+
"@agoric/swingset-xsnap-supervisor": "0.10.3-upgrade-19-dev-0754752.0+0754752",
|
|
36
|
+
"@agoric/time": "0.3.3-upgrade-19-dev-0754752.0+0754752",
|
|
37
|
+
"@agoric/vat-data": "0.5.3-upgrade-19-dev-0754752.0+0754752",
|
|
38
|
+
"@agoric/xsnap-lockdown": "0.14.1-upgrade-19-dev-0754752.0+0754752",
|
|
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.1",
|
|
41
|
+
"@endo/captp": "^4.4.4",
|
|
42
|
+
"@endo/check-bundle": "^1.0.13",
|
|
43
|
+
"@endo/compartment-mapper": "^1.5.0",
|
|
44
|
+
"@endo/errors": "^1.2.9",
|
|
45
|
+
"@endo/eventual-send": "^1.3.0",
|
|
46
|
+
"@endo/far": "^1.1.10",
|
|
47
|
+
"@endo/import-bundle": "^1.3.3",
|
|
48
|
+
"@endo/init": "^1.1.8",
|
|
49
|
+
"@endo/marshal": "^1.6.3",
|
|
50
|
+
"@endo/nat": "^5.0.14",
|
|
51
|
+
"@endo/pass-style": "^1.4.8",
|
|
52
|
+
"@endo/patterns": "^1.4.8",
|
|
53
|
+
"@endo/promise-kit": "^1.1.9",
|
|
54
|
+
"@endo/ses-ava": "^1.2.9",
|
|
55
|
+
"@endo/stream": "^1.2.9",
|
|
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": "^4.1.0",
|
|
61
61
|
"microtime": "^3.1.0",
|
|
62
62
|
"semver": "^6.3.0",
|
|
63
63
|
"tmp": "^0.2.1",
|
|
@@ -94,8 +94,7 @@
|
|
|
94
94
|
"require": [
|
|
95
95
|
"@endo/init/debug.js"
|
|
96
96
|
],
|
|
97
|
-
"timeout": "20m"
|
|
98
|
-
"workerThreads": false
|
|
97
|
+
"timeout": "20m"
|
|
99
98
|
},
|
|
100
99
|
"publishConfig": {
|
|
101
100
|
"access": "public"
|
|
@@ -103,5 +102,5 @@
|
|
|
103
102
|
"typeCoverage": {
|
|
104
103
|
"atLeast": 76.28
|
|
105
104
|
},
|
|
106
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "07547522e9d8a06692fa5ff12c35230ddb4b252b"
|
|
107
106
|
}
|
|
@@ -16,6 +16,7 @@ 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';
|
|
19
20
|
import engineGC from '@agoric/internal/src/lib-nodejs/engine-gc.js';
|
|
20
21
|
import { startSubprocessWorker } from '@agoric/internal/src/lib-nodejs/spawnSubprocessWorker.js';
|
|
21
22
|
import { waitUntilQuiescent } from '@agoric/internal/src/lib-nodejs/waitUntilQuiescent.js';
|
|
@@ -35,6 +36,10 @@ import {
|
|
|
35
36
|
import { makeStartXSnap } from './startXSnap.js';
|
|
36
37
|
import { makeStartSubprocessWorkerNode } from './startNodeSubprocess.js';
|
|
37
38
|
|
|
39
|
+
/**
|
|
40
|
+
* @import {EReturn} from '@endo/far';
|
|
41
|
+
*/
|
|
42
|
+
|
|
38
43
|
/**
|
|
39
44
|
* @typedef { import('../types-internal.js').VatID } VatID
|
|
40
45
|
*/
|
|
@@ -52,34 +57,32 @@ export function computeSha512(bytes) {
|
|
|
52
57
|
return hash.digest().toString('hex');
|
|
53
58
|
}
|
|
54
59
|
|
|
55
|
-
/**
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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];
|
|
77
|
-
}
|
|
78
|
-
const cons = {};
|
|
79
|
-
for (const level of ['debug', 'log', 'info', 'warn', 'error']) {
|
|
80
|
-
cons[level] = makeLoggerForLevel(level);
|
|
60
|
+
/**
|
|
61
|
+
* Make logger functions from either a prefix string or a function that receives
|
|
62
|
+
* the first argument of a log-method invocation and returns a replacement that
|
|
63
|
+
* provides more detail for source identification.
|
|
64
|
+
*
|
|
65
|
+
* @param {string | ((originalSource: unknown) => string)} prefixer
|
|
66
|
+
*/
|
|
67
|
+
function makeConsole(prefixer) {
|
|
68
|
+
if (typeof prefixer !== 'function') {
|
|
69
|
+
const logger = anylogger(prefixer);
|
|
70
|
+
return makeLimitedConsole(level => logger[level]);
|
|
81
71
|
}
|
|
82
|
-
|
|
72
|
+
|
|
73
|
+
const prefixToLogger = new Map();
|
|
74
|
+
return makeLimitedConsole(level => {
|
|
75
|
+
return (source, ...args) => {
|
|
76
|
+
const prefix = prefixer(source);
|
|
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
|
+
});
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
/**
|
|
@@ -209,17 +212,23 @@ export async function makeSwingsetController(
|
|
|
209
212
|
process.on('unhandledRejection', unhandledRejectionHandler);
|
|
210
213
|
}
|
|
211
214
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
+
const kernelConsole = makeConsole(`${debugPrefix}SwingSet:kernel`);
|
|
216
|
+
const sloggingKernelConsole = makeLimitedConsole(level => {
|
|
217
|
+
return (...args) => {
|
|
218
|
+
kernelConsole[level](...args);
|
|
219
|
+
writeSlogObject({ type: 'console', source: 'kernel', args });
|
|
220
|
+
};
|
|
221
|
+
});
|
|
215
222
|
writeSlogObject({ type: 'import-kernel-start' });
|
|
216
223
|
const kernelNS = await importBundle(kernelBundle, {
|
|
217
224
|
filePrefix: 'kernel/...',
|
|
218
225
|
endowments: {
|
|
219
|
-
console:
|
|
226
|
+
console: sloggingKernelConsole,
|
|
220
227
|
// See https://github.com/Agoric/agoric-sdk/issues/9515
|
|
221
228
|
assert: globalThis.assert,
|
|
222
|
-
require:
|
|
229
|
+
require: harden(
|
|
230
|
+
what => Fail`kernelRequire unprepared to satisfy require(${what})`,
|
|
231
|
+
),
|
|
223
232
|
URL: globalThis.Base64, // Unavailable only on XSnap
|
|
224
233
|
Base64: globalThis.Base64, // Available only on XSnap
|
|
225
234
|
},
|
|
@@ -477,7 +486,7 @@ export async function makeSwingsetController(
|
|
|
477
486
|
*
|
|
478
487
|
* The first `controller.run()` after this call will delete all
|
|
479
488
|
* the old vat's state at once, unless you use a
|
|
480
|
-
* [`runPolicy`](
|
|
489
|
+
* [`runPolicy`](../../docs/run-policy.md) to rate-limit cleanups.
|
|
481
490
|
*
|
|
482
491
|
* @param {VatID} vatID
|
|
483
492
|
* @param {SwingSetCapData} reasonCD
|
|
@@ -494,7 +503,7 @@ export async function makeSwingsetController(
|
|
|
494
503
|
|
|
495
504
|
return controller;
|
|
496
505
|
}
|
|
497
|
-
/** @typedef {
|
|
506
|
+
/** @typedef {EReturn<typeof makeSwingsetController>} SwingsetController */
|
|
498
507
|
|
|
499
508
|
/**
|
|
500
509
|
* NB: To be used only in tests. An app with this may not survive a reboot.
|
|
@@ -100,7 +100,6 @@ 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',
|
|
104
103
|
'managerType',
|
|
105
104
|
'enableDisavow',
|
|
106
105
|
'enableSetup',
|
|
@@ -442,26 +442,24 @@ 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]
|
|
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
|
|
452
|
+
* kconfig.namedBundleIDs.BUNDLENAME=bundleID, which both point into
|
|
453
453
|
* kconfig.idToBundle.BUNDLEID=bundle
|
|
454
454
|
*
|
|
455
|
-
* @param {SwingSetConfigProperties
|
|
455
|
+
* @param {SwingSetConfigProperties} 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
|
|
463
462
|
desc.moduleFormat,
|
|
464
|
-
// @ts-expect-error optional
|
|
465
463
|
desc.endoZipBase64Sha512 || desc.sourceSpec,
|
|
466
464
|
);
|
|
467
465
|
|
|
@@ -489,8 +487,9 @@ export async function initializeSwingset(
|
|
|
489
487
|
throw Error(`unknown mode in desc`, desc);
|
|
490
488
|
}
|
|
491
489
|
|
|
492
|
-
// fires with BundleWithID: { ...bundle, id }
|
|
493
490
|
/**
|
|
491
|
+
* Returns a bundle record with an "id" property from an input that might be missing it.
|
|
492
|
+
*
|
|
494
493
|
* @param {EndoZipBase64Bundle & {id?: string}} bundle
|
|
495
494
|
* @returns {Promise<EndoZipBase64Bundle & {id: string}>} bundle
|
|
496
495
|
*/
|
|
@@ -508,11 +507,9 @@ export async function initializeSwingset(
|
|
|
508
507
|
};
|
|
509
508
|
}
|
|
510
509
|
|
|
511
|
-
// fires with BundleWithID: { ...bundle, id }
|
|
512
|
-
|
|
513
510
|
/**
|
|
514
511
|
*
|
|
515
|
-
* @param {
|
|
512
|
+
* @param {SwingSetConfigProperties & {bundleID?: string}} desc
|
|
516
513
|
* @param {Record<string, EndoZipBase64Bundle>} [nameToBundle]
|
|
517
514
|
*/
|
|
518
515
|
async function processDesc(desc, nameToBundle) {
|
|
@@ -526,14 +523,14 @@ export async function initializeSwingset(
|
|
|
526
523
|
modes.length === 1 ||
|
|
527
524
|
Fail`need =1 of bundle/bundleSpec/sourceSpec/bundleName, got ${modes}`;
|
|
528
525
|
const mode = modes[0];
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
526
|
+
|
|
527
|
+
// Remove the original mode in favor of a uniform "bundleID" property.
|
|
528
|
+
const bundle = await getBundle(desc, nameToBundle);
|
|
529
|
+
const bundleWithID = await addBundleID(bundle);
|
|
530
|
+
delete desc[mode];
|
|
531
|
+
desc.bundleID = bundleWithID.id;
|
|
532
|
+
|
|
533
|
+
return bundleWithID;
|
|
537
534
|
}
|
|
538
535
|
|
|
539
536
|
/**
|
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 { makeVatManagerMaker } 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,11 +110,10 @@ 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 : () => {};
|
|
114
114
|
|
|
115
115
|
const vatAdminRootKref = kernelStorage.kvStore.get('vatAdminRootKref');
|
|
116
116
|
|
|
117
|
-
/** @type { KernelSlog } */
|
|
118
117
|
const kernelSlog = writeSlogObject
|
|
119
118
|
? makeSlogger(slogCallbacks, writeSlogObject)
|
|
120
119
|
: makeDummySlogger(slogCallbacks, makeConsole('disabled slogger'));
|
|
@@ -167,10 +166,9 @@ export default function buildKernel(
|
|
|
167
166
|
harden(testLog);
|
|
168
167
|
|
|
169
168
|
function makeSourcedConsole(vatID) {
|
|
170
|
-
const origConsole = makeConsole(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
});
|
|
169
|
+
const origConsole = makeConsole(
|
|
170
|
+
source => `${debugPrefix}SwingSet:${source}:${vatID}`,
|
|
171
|
+
);
|
|
174
172
|
return kernelSlog.vatConsole(vatID, origConsole);
|
|
175
173
|
}
|
|
176
174
|
|
|
@@ -1557,7 +1555,7 @@ export default function buildKernel(
|
|
|
1557
1555
|
gcAndFinalize,
|
|
1558
1556
|
meterControl: makeDummyMeterControl(),
|
|
1559
1557
|
});
|
|
1560
|
-
const
|
|
1558
|
+
const makeVatManager = makeVatManagerMaker({
|
|
1561
1559
|
allVatPowers,
|
|
1562
1560
|
kernelKeeper,
|
|
1563
1561
|
vatEndowments,
|
|
@@ -1652,7 +1650,7 @@ export default function buildKernel(
|
|
|
1652
1650
|
}
|
|
1653
1651
|
|
|
1654
1652
|
const vatLoader = makeVatLoader({
|
|
1655
|
-
|
|
1653
|
+
makeVatManager,
|
|
1656
1654
|
kernelSlog,
|
|
1657
1655
|
makeSourcedConsole,
|
|
1658
1656
|
kernelKeeper,
|