@agoric/swingset-vat 0.32.3-dev-57db88d.0.57db88d → 0.32.3-dev-acbc12e.0.acbc12e
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 +11 -11
- package/src/controller/upgradeSwingset.js +73 -0
- package/src/index.js +4 -1
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-acbc12e.0.acbc12e",
|
|
4
4
|
"description": "Vat/Container Launcher",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"ava": "^8.0.1"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@agoric/internal": "0.3.3-dev-
|
|
32
|
-
"@agoric/kmarshal": "0.1.1-dev-
|
|
33
|
-
"@agoric/store": "0.9.3-dev-
|
|
34
|
-
"@agoric/swing-store": "0.9.2-dev-
|
|
35
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
36
|
-
"@agoric/swingset-xsnap-supervisor": "0.10.3-dev-
|
|
37
|
-
"@agoric/time": "0.3.3-dev-
|
|
38
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
39
|
-
"@agoric/xsnap-lockdown": "0.14.1-dev-
|
|
31
|
+
"@agoric/internal": "0.3.3-dev-acbc12e.0.acbc12e",
|
|
32
|
+
"@agoric/kmarshal": "0.1.1-dev-acbc12e.0.acbc12e",
|
|
33
|
+
"@agoric/store": "0.9.3-dev-acbc12e.0.acbc12e",
|
|
34
|
+
"@agoric/swing-store": "0.9.2-dev-acbc12e.0.acbc12e",
|
|
35
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-acbc12e.0.acbc12e",
|
|
36
|
+
"@agoric/swingset-xsnap-supervisor": "0.10.3-dev-acbc12e.0.acbc12e",
|
|
37
|
+
"@agoric/time": "0.3.3-dev-acbc12e.0.acbc12e",
|
|
38
|
+
"@agoric/vat-data": "0.5.3-dev-acbc12e.0.acbc12e",
|
|
39
|
+
"@agoric/xsnap-lockdown": "0.14.1-dev-acbc12e.0.acbc12e",
|
|
40
40
|
"@endo/base64": "^1.1.1",
|
|
41
41
|
"@endo/bundle-source": "^4.3.2",
|
|
42
42
|
"@endo/captp": "^4.5.1",
|
|
@@ -106,5 +106,5 @@
|
|
|
106
106
|
"typeCoverage": {
|
|
107
107
|
"atLeast": 77.18
|
|
108
108
|
},
|
|
109
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "acbc12e3724691dcaa8798b7b59cdf1ad06bfe8c"
|
|
110
110
|
}
|
|
@@ -15,6 +15,79 @@ import { enumeratePrefixedKeys } from '../kernel/state/storageHelper.js';
|
|
|
15
15
|
* @import {SwingStoreKernelStorage} from '../types-external.js';
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* A host-injected, in-place change to a single running vat's persisted
|
|
20
|
+
* options, applied at a chain software upgrade.
|
|
21
|
+
*
|
|
22
|
+
* @typedef {object} VatOptionUpdate
|
|
23
|
+
* @property {string} vatID the exact vatID to update (e.g. 'v288'). Selection
|
|
24
|
+
* is by vatID, not by name/label, since a vat's name/label may be ambiguous
|
|
25
|
+
* (e.g. a chain running several incarnations of the same contract).
|
|
26
|
+
* @property {boolean} [critical] when set, promote/demote the vat's
|
|
27
|
+
* `critical` flag, read fresh by kernel.js `terminateVat()` to decide
|
|
28
|
+
* whether to `panic()` instead of severing the vat.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Apply host-injected per-vat option updates in place, by read-modify-writing
|
|
33
|
+
* each named vat's `${vatID}.options` blob. This is deliberately NOT a schema
|
|
34
|
+
* migration and bumps no `version`. It is idempotent, and each target vat is
|
|
35
|
+
* checked to be a live, non-terminated dynamic vat.
|
|
36
|
+
*
|
|
37
|
+
* Must be called at a deterministic point while SwingSet is not running, e.g.
|
|
38
|
+
* from the upgrade handler of the cosmic-swingset host.
|
|
39
|
+
*
|
|
40
|
+
* There is currently no mechanism to flip `critical` on a running vat through
|
|
41
|
+
* vat-admin (that would require a more complex vat upgrade), so this is a
|
|
42
|
+
* host-driven change straight to the kvStore blob, the same read-modify-write
|
|
43
|
+
* `upgradeSwingset` and `vatKeeper.setReapDirtThreshold` already perform.
|
|
44
|
+
*
|
|
45
|
+
* @param {KVStore} kvStore the kernel kvStore (kernelStorage.kvStore)
|
|
46
|
+
* @param {VatOptionUpdate[]} [vatOptionUpdates]
|
|
47
|
+
* @returns {string[]} human-readable descriptions of the vats actually changed
|
|
48
|
+
*/
|
|
49
|
+
export const applyVatOptionUpdates = (kvStore, vatOptionUpdates = []) => {
|
|
50
|
+
if (!vatOptionUpdates.length) return [];
|
|
51
|
+
|
|
52
|
+
/** @type {(key: string) => string} */
|
|
53
|
+
const getRequired = key => {
|
|
54
|
+
kvStore.has(key) || Fail`storage lacks required key ${key}`;
|
|
55
|
+
return /** @type {string} */ (kvStore.get(key));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const terminated = new Set(
|
|
59
|
+
JSON.parse(kvStore.get('vats.terminated') || '[]'),
|
|
60
|
+
);
|
|
61
|
+
const dynamicVats = new Set(getAllDynamicVats(getRequired));
|
|
62
|
+
|
|
63
|
+
const changed = [];
|
|
64
|
+
for (const update of vatOptionUpdates) {
|
|
65
|
+
const { vatID, critical } = update;
|
|
66
|
+
// The target must be a live, non-terminated dynamic vat.
|
|
67
|
+
dynamicVats.has(vatID) ||
|
|
68
|
+
Fail`vat-option-update: ${vatID} is not a live dynamic vat`;
|
|
69
|
+
!terminated.has(vatID) || Fail`vat-option-update: ${vatID} is terminated`;
|
|
70
|
+
const optionsKey = `${vatID}.options`;
|
|
71
|
+
const options = JSON.parse(getRequired(optionsKey));
|
|
72
|
+
let dirty = false;
|
|
73
|
+
if (critical !== undefined && !!options.critical !== critical) {
|
|
74
|
+
options.critical = critical;
|
|
75
|
+
dirty = true;
|
|
76
|
+
}
|
|
77
|
+
if (dirty) {
|
|
78
|
+
kvStore.set(optionsKey, JSON.stringify(options));
|
|
79
|
+
changed.push(`${vatID} (${options.name})`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
console.log(
|
|
83
|
+
`vat-option-update: changed ${changed.length} vat(s): ${
|
|
84
|
+
changed.join(', ') || '(none)'
|
|
85
|
+
}`,
|
|
86
|
+
);
|
|
87
|
+
return changed;
|
|
88
|
+
};
|
|
89
|
+
harden(applyVatOptionUpdates);
|
|
90
|
+
|
|
18
91
|
/**
|
|
19
92
|
* Parse a string of decimal digits into a number.
|
|
20
93
|
*
|
package/src/index.js
CHANGED
|
@@ -14,7 +14,10 @@ export {
|
|
|
14
14
|
loadSwingsetConfigFile,
|
|
15
15
|
normalizeConfig,
|
|
16
16
|
} from './controller/swingset-config-node.js';
|
|
17
|
-
export {
|
|
17
|
+
export {
|
|
18
|
+
upgradeSwingset,
|
|
19
|
+
applyVatOptionUpdates,
|
|
20
|
+
} from './controller/upgradeSwingset.js';
|
|
18
21
|
export {
|
|
19
22
|
buildMailboxStateMap,
|
|
20
23
|
buildMailbox,
|