@agoric/swingset-vat 0.32.3-dev-1f816f9.0 → 0.32.3-dev-d32d6ce.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 +12 -12
- package/src/controller/controller.js +47 -0
- package/src/kernel/kernel.js +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/swingset-vat",
|
|
3
|
-
"version": "0.32.3-dev-
|
|
3
|
+
"version": "0.32.3-dev-d32d6ce.0+d32d6ce",
|
|
4
4
|
"description": "Vat/Container Launcher",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -27,16 +27,16 @@
|
|
|
27
27
|
"@types/yargs-parser": "^21.0.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@agoric/internal": "0.3.3-dev-
|
|
31
|
-
"@agoric/kmarshal": "0.1.1-dev-
|
|
32
|
-
"@agoric/store": "0.9.3-dev-
|
|
33
|
-
"@agoric/swing-store": "0.9.2-dev-
|
|
34
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
35
|
-
"@agoric/swingset-xsnap-supervisor": "0.10.3-dev-
|
|
36
|
-
"@agoric/time": "0.3.3-dev-
|
|
37
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
38
|
-
"@agoric/xsnap": "0.14.3-dev-
|
|
39
|
-
"@agoric/xsnap-lockdown": "0.14.1-dev-
|
|
30
|
+
"@agoric/internal": "0.3.3-dev-d32d6ce.0+d32d6ce",
|
|
31
|
+
"@agoric/kmarshal": "0.1.1-dev-d32d6ce.0+d32d6ce",
|
|
32
|
+
"@agoric/store": "0.9.3-dev-d32d6ce.0+d32d6ce",
|
|
33
|
+
"@agoric/swing-store": "0.9.2-dev-d32d6ce.0+d32d6ce",
|
|
34
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-d32d6ce.0+d32d6ce",
|
|
35
|
+
"@agoric/swingset-xsnap-supervisor": "0.10.3-dev-d32d6ce.0+d32d6ce",
|
|
36
|
+
"@agoric/time": "0.3.3-dev-d32d6ce.0+d32d6ce",
|
|
37
|
+
"@agoric/vat-data": "0.5.3-dev-d32d6ce.0+d32d6ce",
|
|
38
|
+
"@agoric/xsnap": "0.14.3-dev-d32d6ce.0+d32d6ce",
|
|
39
|
+
"@agoric/xsnap-lockdown": "0.14.1-dev-d32d6ce.0+d32d6ce",
|
|
40
40
|
"@endo/base64": "^1.0.6",
|
|
41
41
|
"@endo/bundle-source": "^3.3.0",
|
|
42
42
|
"@endo/captp": "^4.2.2",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"typeCoverage": {
|
|
103
103
|
"atLeast": 75.1
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "d32d6ce5ab3d9686b29c4ba811b0742fac245cab"
|
|
106
106
|
}
|
|
@@ -21,6 +21,7 @@ import { waitUntilQuiescent } from '@agoric/internal/src/lib-nodejs/waitUntilQui
|
|
|
21
21
|
import { makeGcAndFinalize } from '@agoric/internal/src/lib-nodejs/gc-and-finalize.js';
|
|
22
22
|
import { kslot, krefOf } from '@agoric/kmarshal';
|
|
23
23
|
import { insistStorageAPI } from '../lib/storageAPI.js';
|
|
24
|
+
import { insistCapData } from '../lib/capdata.js';
|
|
24
25
|
import {
|
|
25
26
|
buildKernelBundle,
|
|
26
27
|
swingsetIsInitialized,
|
|
@@ -33,6 +34,10 @@ import {
|
|
|
33
34
|
import { makeStartXSnap } from './startXSnap.js';
|
|
34
35
|
import { makeStartSubprocessWorkerNode } from './startNodeSubprocess.js';
|
|
35
36
|
|
|
37
|
+
/**
|
|
38
|
+
* @typedef { import('../types-internal.js').VatID } VatID
|
|
39
|
+
*/
|
|
40
|
+
|
|
36
41
|
const endoZipBase64Sha512Shape = harden({
|
|
37
42
|
moduleFormat: 'endoZipBase64',
|
|
38
43
|
endoZipBase64: M.string(harden({ stringLengthLimit: Infinity })),
|
|
@@ -441,6 +446,48 @@ export async function makeSwingsetController(
|
|
|
441
446
|
// no emitCrankHashes here because queueToVatRoot did that
|
|
442
447
|
return result;
|
|
443
448
|
},
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* terminate a vat by ID
|
|
452
|
+
*
|
|
453
|
+
* This allows the host app to terminate any vat. The effect is
|
|
454
|
+
* equivalent to the holder of the vat's `adminNode` calling
|
|
455
|
+
* `E(adminNode).terminateWithFailure(reason)`, or the vat itself
|
|
456
|
+
* calling `vatPowers.exitVatWithFailure(reason)`. It accepts a
|
|
457
|
+
* reason capdata structure (use 'kser()' to build one), which
|
|
458
|
+
* will be included in rejection data for the promise available to
|
|
459
|
+
* `E(adminNode).done()`, just like the internal termination APIs.
|
|
460
|
+
* Note that no slots/krefs are allowed in 'reason' when
|
|
461
|
+
* terminating the vat externally.
|
|
462
|
+
*
|
|
463
|
+
* This is a superpower available only from the host app, not from
|
|
464
|
+
* within vats, since `vatID` is merely a string and can be forged
|
|
465
|
+
* trivially. The host app is responsible for supplying the right
|
|
466
|
+
* vatID to kill, by looking at the database or logs (note that
|
|
467
|
+
* vats do not know their own vatID, and `controller.vatNameToID`
|
|
468
|
+
* only works for static vats, not dynamic).
|
|
469
|
+
*
|
|
470
|
+
* This will cause state changes in the swing-store (specifically
|
|
471
|
+
* marking the vat as terminated, and rejection all its
|
|
472
|
+
* outstanding promises), which must be committed before they will
|
|
473
|
+
* be durable. Either call `hostStorage.commit()` immediately
|
|
474
|
+
* after calling this, or call `controller.run()` and *then*
|
|
475
|
+
* `hostStorage.commit()` as you would normally do in response to
|
|
476
|
+
* other I/O or timer activity.
|
|
477
|
+
*
|
|
478
|
+
* The first `controller.run()` after this call will delete all
|
|
479
|
+
* the old vat's state at once, unless you use a
|
|
480
|
+
* [`runPolicy`](../docs/run-policy.md) to rate-limit cleanups.
|
|
481
|
+
*
|
|
482
|
+
* @param {VatID} vatID
|
|
483
|
+
* @param {SwingSetCapData} reasonCD
|
|
484
|
+
*/
|
|
485
|
+
|
|
486
|
+
terminateVat(vatID, reasonCD) {
|
|
487
|
+
insistCapData(reasonCD);
|
|
488
|
+
assert(reasonCD.slots.length === 0, 'no slots allowed in reason');
|
|
489
|
+
kernel.terminateVatExternally(vatID, reasonCD);
|
|
490
|
+
},
|
|
444
491
|
});
|
|
445
492
|
|
|
446
493
|
writeSlogObject({ type: 'kernel-init-finish' });
|
package/src/kernel/kernel.js
CHANGED
|
@@ -2063,6 +2063,16 @@ export default function buildKernel(
|
|
|
2063
2063
|
hooks[hookName] = hook;
|
|
2064
2064
|
}
|
|
2065
2065
|
|
|
2066
|
+
function terminateVatExternally(vatID, reasonCD) {
|
|
2067
|
+
assert(started, 'must do kernel.start() before terminateVatExternally()');
|
|
2068
|
+
insistCapData(reasonCD);
|
|
2069
|
+
assert(reasonCD.slots.length === 0, 'no slots allowed in reason');
|
|
2070
|
+
// this fires a promise when worker is dead, mostly for tests, so don't
|
|
2071
|
+
// give it to external callers
|
|
2072
|
+
void terminateVat(vatID, true, reasonCD);
|
|
2073
|
+
console.log(`scheduled vatID ${vatID} for termination`);
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2066
2076
|
const kernel = harden({
|
|
2067
2077
|
// these are meant for the controller
|
|
2068
2078
|
installBundle,
|
|
@@ -2138,6 +2148,7 @@ export default function buildKernel(
|
|
|
2138
2148
|
kpStatus,
|
|
2139
2149
|
kpResolution,
|
|
2140
2150
|
addDeviceHook,
|
|
2151
|
+
terminateVatExternally,
|
|
2141
2152
|
});
|
|
2142
2153
|
|
|
2143
2154
|
return kernel;
|