@agoric/swingset-vat 0.32.3-dev-02967de.0 → 0.32.3-dev-d268023.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 +11 -11
- package/src/controller/upgradeSwingset.js +50 -37
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-d268023.0+d268023",
|
|
4
4
|
"description": "Vat/Container Launcher",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -27,15 +27,15 @@
|
|
|
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-lockdown": "0.14.1-dev-
|
|
30
|
+
"@agoric/internal": "0.3.3-dev-d268023.0+d268023",
|
|
31
|
+
"@agoric/kmarshal": "0.1.1-dev-d268023.0+d268023",
|
|
32
|
+
"@agoric/store": "0.9.3-dev-d268023.0+d268023",
|
|
33
|
+
"@agoric/swing-store": "0.9.2-dev-d268023.0+d268023",
|
|
34
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-d268023.0+d268023",
|
|
35
|
+
"@agoric/swingset-xsnap-supervisor": "0.10.3-dev-d268023.0+d268023",
|
|
36
|
+
"@agoric/time": "0.3.3-dev-d268023.0+d268023",
|
|
37
|
+
"@agoric/vat-data": "0.5.3-dev-d268023.0+d268023",
|
|
38
|
+
"@agoric/xsnap-lockdown": "0.14.1-dev-d268023.0+d268023",
|
|
39
39
|
"@endo/base64": "^1.0.9",
|
|
40
40
|
"@endo/bundle-source": "^3.5.0",
|
|
41
41
|
"@endo/captp": "^4.4.3",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"typeCoverage": {
|
|
104
104
|
"atLeast": 76.24
|
|
105
105
|
},
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "d268023329cb462972a8f1f6f124fdd3f70c6f6e"
|
|
107
107
|
}
|
|
@@ -10,13 +10,38 @@ import {
|
|
|
10
10
|
import { enumeratePrefixedKeys } from '../kernel/state/storageHelper.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* @import {RunQueueEvent} from '../types-internal.js';
|
|
13
|
+
* @import {ReapDirtThreshold, RunQueueEvent} from '../types-internal.js';
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Parse a string of decimal digits into a number.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} digits
|
|
20
|
+
* @param {string} label
|
|
21
|
+
* @returns {number}
|
|
22
|
+
*/
|
|
23
|
+
const mustParseInt = (digits, label) => {
|
|
24
|
+
assert(
|
|
25
|
+
digits.match(/^\d+$/),
|
|
26
|
+
`expected ${label}=${digits} to be a decimal integer`,
|
|
27
|
+
);
|
|
28
|
+
return Number(digits);
|
|
29
|
+
};
|
|
19
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Called for each vat when upgradeSwingset migrates from v0 to v1.
|
|
33
|
+
*
|
|
34
|
+
* @param {KVStore} kvStore
|
|
35
|
+
* @param {(key: string) => string} getRequired
|
|
36
|
+
* @param {ReapDirtThreshold} defaultReapDirtThreshold
|
|
37
|
+
* @param {string} vatID
|
|
38
|
+
*/
|
|
39
|
+
const upgradeVatV0toV1 = (
|
|
40
|
+
kvStore,
|
|
41
|
+
getRequired,
|
|
42
|
+
defaultReapDirtThreshold,
|
|
43
|
+
vatID,
|
|
44
|
+
) => {
|
|
20
45
|
// schema v0:
|
|
21
46
|
// Each vat has a `vNN.reapInterval` and `vNN.reapCountdown`.
|
|
22
47
|
// vNN.options has a `.reapInterval` property (however it was not
|
|
@@ -33,15 +58,10 @@ const upgradeVatV0toV1 = (kvStore, defaultReapDirtThreshold, vatID) => {
|
|
|
33
58
|
// `defaultReapDirtThreshold`)
|
|
34
59
|
|
|
35
60
|
const reapDirtKey = `${vatID}.reapDirt`;
|
|
36
|
-
|
|
37
|
-
assert(kvStore.has(oldReapIntervalKey), oldReapIntervalKey);
|
|
38
|
-
assert(kvStore.has(oldReapCountdownKey), oldReapCountdownKey);
|
|
39
61
|
assert(!kvStore.has(reapDirtKey), reapDirtKey);
|
|
40
62
|
|
|
41
|
-
const reapIntervalString =
|
|
42
|
-
const reapCountdownString =
|
|
43
|
-
assert(reapIntervalString !== undefined);
|
|
44
|
-
assert(reapCountdownString !== undefined);
|
|
63
|
+
const reapIntervalString = getRequired(oldReapIntervalKey);
|
|
64
|
+
const reapCountdownString = getRequired(oldReapCountdownKey);
|
|
45
65
|
|
|
46
66
|
const intervalIsNever = reapIntervalString === 'never';
|
|
47
67
|
const countdownIsNever = reapCountdownString === 'never';
|
|
@@ -62,8 +82,11 @@ const upgradeVatV0toV1 = (kvStore, defaultReapDirtThreshold, vatID) => {
|
|
|
62
82
|
threshold.never = true;
|
|
63
83
|
} else {
|
|
64
84
|
// deduce delivery count from old countdown values
|
|
65
|
-
const reapInterval =
|
|
66
|
-
const reapCountdown =
|
|
85
|
+
const reapInterval = mustParseInt(reapIntervalString, oldReapIntervalKey);
|
|
86
|
+
const reapCountdown = mustParseInt(
|
|
87
|
+
reapCountdownString,
|
|
88
|
+
oldReapCountdownKey,
|
|
89
|
+
);
|
|
67
90
|
const deliveries = reapInterval - reapCountdown;
|
|
68
91
|
reapDirt.deliveries = Math.max(deliveries, 0); // just in case
|
|
69
92
|
if (reapInterval !== defaultReapDirtThreshold.deliveries) {
|
|
@@ -76,7 +99,7 @@ const upgradeVatV0toV1 = (kvStore, defaultReapDirtThreshold, vatID) => {
|
|
|
76
99
|
kvStore.set(reapDirtKey, JSON.stringify(reapDirt));
|
|
77
100
|
|
|
78
101
|
// Update options to use the new schema.
|
|
79
|
-
const options = JSON.parse(
|
|
102
|
+
const options = JSON.parse(getRequired(vatOptionsKey));
|
|
80
103
|
delete options.reapInterval;
|
|
81
104
|
options.reapDirtThreshold = threshold;
|
|
82
105
|
kvStore.set(vatOptionsKey, JSON.stringify(options));
|
|
@@ -104,14 +127,11 @@ const upgradeVatV0toV1 = (kvStore, defaultReapDirtThreshold, vatID) => {
|
|
|
104
127
|
*/
|
|
105
128
|
export const upgradeSwingset = kernelStorage => {
|
|
106
129
|
const { kvStore } = kernelStorage;
|
|
107
|
-
let modified = false;
|
|
108
130
|
/** @type {RunQueueEvent[]} */
|
|
109
131
|
const upgradeEvents = [];
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
let version = Number(vstring);
|
|
132
|
+
const vstring = kvStore.get('version');
|
|
133
|
+
const version = Number(vstring) || 0;
|
|
134
|
+
let newVersion;
|
|
115
135
|
|
|
116
136
|
/**
|
|
117
137
|
* @param {string} key
|
|
@@ -166,11 +186,7 @@ export const upgradeSwingset = kernelStorage => {
|
|
|
166
186
|
assert(kvStore.has(oldDefaultReapIntervalKey));
|
|
167
187
|
assert(!kvStore.has(DEFAULT_REAP_DIRT_THRESHOLD_KEY));
|
|
168
188
|
|
|
169
|
-
/**
|
|
170
|
-
* @typedef { import('../types-internal.js').ReapDirtThreshold } ReapDirtThreshold
|
|
171
|
-
*/
|
|
172
|
-
|
|
173
|
-
/** @type ReapDirtThreshold */
|
|
189
|
+
/** @type {ReapDirtThreshold} */
|
|
174
190
|
const threshold = {
|
|
175
191
|
deliveries: 'never',
|
|
176
192
|
gcKrefs: 'never',
|
|
@@ -179,9 +195,7 @@ export const upgradeSwingset = kernelStorage => {
|
|
|
179
195
|
|
|
180
196
|
const oldValue = getRequired(oldDefaultReapIntervalKey);
|
|
181
197
|
if (oldValue !== 'never') {
|
|
182
|
-
|
|
183
|
-
assert.typeof(value, 'number');
|
|
184
|
-
threshold.deliveries = value;
|
|
198
|
+
threshold.deliveries = mustParseInt(oldValue, oldDefaultReapIntervalKey);
|
|
185
199
|
// if BOYD wasn't turned off entirely (eg
|
|
186
200
|
// defaultReapInterval='never', which only happens in unit
|
|
187
201
|
// tests), then pretend we wanted a gcKrefs= threshold all
|
|
@@ -196,22 +210,20 @@ export const upgradeSwingset = kernelStorage => {
|
|
|
196
210
|
|
|
197
211
|
// now upgrade all vats
|
|
198
212
|
for (const [_name, vatID] of getAllStaticVats(kvStore)) {
|
|
199
|
-
upgradeVatV0toV1(kvStore, threshold, vatID);
|
|
213
|
+
upgradeVatV0toV1(kvStore, getRequired, threshold, vatID);
|
|
200
214
|
}
|
|
201
215
|
for (const vatID of getAllDynamicVats(getRequired)) {
|
|
202
|
-
upgradeVatV0toV1(kvStore, threshold, vatID);
|
|
216
|
+
upgradeVatV0toV1(kvStore, getRequired, threshold, vatID);
|
|
203
217
|
}
|
|
204
218
|
|
|
205
|
-
|
|
206
|
-
version = 1;
|
|
219
|
+
newVersion = 1;
|
|
207
220
|
}
|
|
208
221
|
|
|
209
222
|
if (version < 2) {
|
|
210
223
|
// schema v2: add vats.terminated = []
|
|
211
224
|
assert(!kvStore.has('vats.terminated'));
|
|
212
225
|
kvStore.set('vats.terminated', JSON.stringify([]));
|
|
213
|
-
|
|
214
|
-
version = 2;
|
|
226
|
+
newVersion = 2;
|
|
215
227
|
}
|
|
216
228
|
|
|
217
229
|
if (version < 3) {
|
|
@@ -322,10 +334,11 @@ export const upgradeSwingset = kernelStorage => {
|
|
|
322
334
|
}
|
|
323
335
|
|
|
324
336
|
console.log(` - #9039 remediation complete, ${count} notifies to inject`);
|
|
325
|
-
|
|
326
|
-
version = 3;
|
|
337
|
+
newVersion = 3;
|
|
327
338
|
}
|
|
328
339
|
|
|
340
|
+
const modified = newVersion !== undefined;
|
|
341
|
+
|
|
329
342
|
if (upgradeEvents.length) {
|
|
330
343
|
assert(modified);
|
|
331
344
|
// stash until host calls controller.injectQueuedUpgradeEvents()
|
|
@@ -335,7 +348,7 @@ export const upgradeSwingset = kernelStorage => {
|
|
|
335
348
|
}
|
|
336
349
|
|
|
337
350
|
if (modified) {
|
|
338
|
-
kvStore.set('version', `${
|
|
351
|
+
kvStore.set('version', `${newVersion}`);
|
|
339
352
|
}
|
|
340
353
|
return harden({ modified });
|
|
341
354
|
};
|