@agoric/swingset-vat 0.32.3-dev-c962ba0.0 → 0.32.3-dev-533d84a.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/swingset-vat",
3
- "version": "0.32.3-dev-c962ba0.0+c962ba0",
3
+ "version": "0.32.3-dev-533d84a.0+533d84a",
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-c962ba0.0+c962ba0",
31
- "@agoric/kmarshal": "0.1.1-dev-c962ba0.0+c962ba0",
32
- "@agoric/store": "0.9.3-dev-c962ba0.0+c962ba0",
33
- "@agoric/swing-store": "0.9.2-dev-c962ba0.0+c962ba0",
34
- "@agoric/swingset-liveslots": "0.10.3-dev-c962ba0.0+c962ba0",
35
- "@agoric/swingset-xsnap-supervisor": "0.10.3-dev-c962ba0.0+c962ba0",
36
- "@agoric/time": "0.3.3-dev-c962ba0.0+c962ba0",
37
- "@agoric/vat-data": "0.5.3-dev-c962ba0.0+c962ba0",
38
- "@agoric/xsnap-lockdown": "0.14.1-dev-c962ba0.0+c962ba0",
30
+ "@agoric/internal": "0.3.3-dev-533d84a.0+533d84a",
31
+ "@agoric/kmarshal": "0.1.1-dev-533d84a.0+533d84a",
32
+ "@agoric/store": "0.9.3-dev-533d84a.0+533d84a",
33
+ "@agoric/swing-store": "0.9.2-dev-533d84a.0+533d84a",
34
+ "@agoric/swingset-liveslots": "0.10.3-dev-533d84a.0+533d84a",
35
+ "@agoric/swingset-xsnap-supervisor": "0.10.3-dev-533d84a.0+533d84a",
36
+ "@agoric/time": "0.3.3-dev-533d84a.0+533d84a",
37
+ "@agoric/vat-data": "0.5.3-dev-533d84a.0+533d84a",
38
+ "@agoric/xsnap-lockdown": "0.14.1-dev-533d84a.0+533d84a",
39
39
  "@endo/base64": "^1.0.9",
40
40
  "@endo/bundle-source": "^4.0.0",
41
41
  "@endo/captp": "^4.4.5",
@@ -102,5 +102,5 @@
102
102
  "typeCoverage": {
103
103
  "atLeast": 76.47
104
104
  },
105
- "gitHead": "c962ba0771022947027b9bd76339a3ab21406b20"
105
+ "gitHead": "533d84a756c981bd973def6437b9f05aa732caa3"
106
106
  }
@@ -285,11 +285,9 @@ export const upgradeSwingset = kernelStorage => {
285
285
 
286
286
  const buggyKPIDs = []; // [kpid, vatID]
287
287
  for (const vatID of allVatIDs) {
288
- const prefix = `${vatID}.c.`;
289
- const len = prefix.length;
290
288
  const ckpPrefix = `${vatID}.c.kp`;
291
- for (const key of enumeratePrefixedKeys(kvStore, ckpPrefix)) {
292
- const kpid = key.slice(len);
289
+ for (const { suffix } of enumeratePrefixedKeys(kvStore, ckpPrefix)) {
290
+ const kpid = `kp${suffix}`;
293
291
  if (isSettled(kpid)) {
294
292
  const n = notifies.get(kpid);
295
293
  if (!n || !n.includes(vatID)) {
@@ -189,11 +189,12 @@ export function makeDeviceKeeper(kvStore, deviceID, tools) {
189
189
  /** @type {Array<[string, string, string]>} */
190
190
  const res = [];
191
191
  const prefix = `${deviceID}.c.`;
192
- for (const k of enumeratePrefixedKeys(kvStore, prefix)) {
193
- const slot = k.slice(prefix.length);
192
+ const prefixedKeys = enumeratePrefixedKeys(kvStore, prefix);
193
+
194
+ for (const { key, suffix: slot } of prefixedKeys) {
194
195
  if (!slot.startsWith('k')) {
195
196
  const devSlot = slot;
196
- const kernelSlot = kvStore.get(k);
197
+ const kernelSlot = kvStore.get(key);
197
198
  res.push([kernelSlot, deviceID, devSlot]);
198
199
  }
199
200
  }
@@ -212,9 +212,8 @@ function insistMeterID(m) {
212
212
  export const getAllStaticVats = kvStore => {
213
213
  const result = [];
214
214
  const prefix = 'vat.name.';
215
- for (const k of enumeratePrefixedKeys(kvStore, prefix)) {
216
- const vatID = kvStore.get(k) || Fail`getNextKey ensures get`;
217
- const name = k.slice(prefix.length);
215
+ for (const { key, suffix: name } of enumeratePrefixedKeys(kvStore, prefix)) {
216
+ const vatID = kvStore.get(key) || Fail`getNextKey ensures get`;
218
217
  result.push([name, vatID]);
219
218
  }
220
219
  return result;
@@ -718,17 +717,22 @@ export default function makeKernelKeeper(
718
717
  // We iterate through all ephemeral and virtual entries so the kernel
719
718
  // can ensure that they are abandoned by a vat being upgraded.
720
719
  const prefix = `${vatID}.c.`;
721
- const ephStart = `${prefix}o+`;
722
- const durStart = `${prefix}o+d`;
723
- const virStart = `${prefix}o+v`;
720
+ const ephStart = `o+`;
721
+ const durStart = `o+d`;
722
+ const virStart = `o+v`;
724
723
  /** @type {[string, string?][]} */
725
724
  const ranges = [[ephStart, durStart], [virStart]];
726
725
  for (const range of ranges) {
727
- for (const k of enumeratePrefixedKeys(kvStore, ...range)) {
728
- const vref = k.slice(prefix.length);
726
+ const rangeSuffix = range[0];
727
+ const args = /** @type {typeof ranges[0]} */ (
728
+ /** @type {unknown} */ (range.map(s => `${prefix}${s}`))
729
+ );
730
+ const prefixedKeys = enumeratePrefixedKeys(kvStore, ...args);
731
+ for (const { key, suffix } of prefixedKeys) {
732
+ const vref = `${rangeSuffix}${suffix}`;
729
733
  // exclude the root object, which is replaced by upgrade
730
734
  if (vref !== 'o+0') {
731
- const kref = kvStore.get(k);
735
+ const kref = kvStore.get(key);
732
736
  assert.typeof(kref, 'string');
733
737
  yield { kref, vref };
734
738
  }
@@ -1072,7 +1076,7 @@ export default function makeKernelKeeper(
1072
1076
 
1073
1077
  // first, scan for exported objects, which must be orphaned
1074
1078
  remaining = budget.exports ?? budget.default;
1075
- for (const k of enumeratePrefixedKeys(kvStore, exportPrefix)) {
1079
+ for (const { key } of enumeratePrefixedKeys(kvStore, exportPrefix)) {
1076
1080
  // The void for an object exported by a vat will always be of the form
1077
1081
  // `o+NN`. The '+' means that the vat exported the object (rather than
1078
1082
  // importing it) and therefore the object is owned by (i.e., within) the
@@ -1080,9 +1084,7 @@ export default function makeKernelKeeper(
1080
1084
  // begin with `vMM.c.o+`. In addition to deleting the c-list entry, we
1081
1085
  // must also delete the corresponding kernel owner entry for the object,
1082
1086
  // since the object will no longer be accessible.
1083
- const vref = stripPrefix(clistPrefix, k);
1084
- assert(vref.startsWith('o+'), vref);
1085
- const kref = kvStore.get(k);
1087
+ const kref = kvStore.get(key);
1086
1088
  // note: adds to maybeFreeKrefs, deletes c-list and .owner
1087
1089
  orphanKernelObject(kref, vatID);
1088
1090
  work.exports += 1;
@@ -1094,11 +1096,14 @@ export default function makeKernelKeeper(
1094
1096
 
1095
1097
  // then scan for imported objects, which must be decrefed
1096
1098
  remaining = budget.imports ?? budget.default;
1097
- for (const k of enumeratePrefixedKeys(kvStore, importPrefix)) {
1099
+ for (const { key, suffix } of enumeratePrefixedKeys(
1100
+ kvStore,
1101
+ importPrefix,
1102
+ )) {
1098
1103
  // abandoned imports: delete the clist entry as if the vat did a
1099
1104
  // drop+retire
1100
- const kref = kvStore.get(k) || Fail`getNextKey ensures get`;
1101
- const vref = stripPrefix(clistPrefix, k);
1105
+ const kref = kvStore.get(key) || Fail`getNextKey ensures get`;
1106
+ const vref = `o-${suffix}`;
1102
1107
  undertaker.deleteCListEntry(kref, vref);
1103
1108
  // that will also delete both db keys
1104
1109
  work.imports += 1;
@@ -1113,9 +1118,12 @@ export default function makeKernelKeeper(
1113
1118
  // kpids are still present in the dead vat's c-list. Clean those
1114
1119
  // up now.
1115
1120
  remaining = budget.promises ?? budget.default;
1116
- for (const k of enumeratePrefixedKeys(kvStore, promisePrefix)) {
1117
- const kref = kvStore.get(k) || Fail`getNextKey ensures get`;
1118
- const vref = stripPrefix(clistPrefix, k);
1121
+ for (const { key, suffix } of enumeratePrefixedKeys(
1122
+ kvStore,
1123
+ promisePrefix,
1124
+ )) {
1125
+ const kref = kvStore.get(key) || Fail`getNextKey ensures get`;
1126
+ const vref = `p${suffix}`;
1119
1127
  undertaker.deleteCListEntry(kref, vref);
1120
1128
  // that will also delete both db keys
1121
1129
  work.promises += 1;
@@ -1127,8 +1135,8 @@ export default function makeKernelKeeper(
1127
1135
 
1128
1136
  // now loop back through everything and delete it all
1129
1137
  remaining = budget.kv ?? budget.default;
1130
- for (const k of enumeratePrefixedKeys(kvStore, `${vatID}.`)) {
1131
- kvStore.delete(k);
1138
+ for (const { key } of enumeratePrefixedKeys(kvStore, `${vatID}.`)) {
1139
+ kvStore.delete(key);
1132
1140
  work.kv += 1;
1133
1141
  remaining -= 1;
1134
1142
  if (remaining <= 0) {
@@ -1167,11 +1175,11 @@ export default function makeKernelKeeper(
1167
1175
  kvStore.set(DYNAMIC_IDS_KEY, JSON.stringify(newDynamicVatIDs));
1168
1176
  } else {
1169
1177
  kdebug(`removing static vat ${vatID}`);
1170
- for (const k of enumeratePrefixedKeys(kvStore, 'vat.name.')) {
1171
- if (kvStore.get(k) === vatID) {
1172
- kvStore.delete(k);
1178
+ const prefixedKeys = enumeratePrefixedKeys(kvStore, 'vat.name.');
1179
+ for (const { key, suffix: name } of prefixedKeys) {
1180
+ if (kvStore.get(key) === vatID) {
1181
+ kvStore.delete(key);
1173
1182
  const VAT_NAMES_KEY = 'vat.names';
1174
- const name = k.slice('vat.name.'.length);
1175
1183
  const oldStaticVatNames = JSON.parse(getRequired(VAT_NAMES_KEY));
1176
1184
  const newStaticVatNames = oldStaticVatNames.filter(v => v !== name);
1177
1185
  kvStore.set(VAT_NAMES_KEY, JSON.stringify(newStaticVatNames));
@@ -1240,7 +1248,7 @@ export default function makeKernelKeeper(
1240
1248
  function* enumeratePromisesByDecider(vatID) {
1241
1249
  insistVatID(vatID);
1242
1250
  const promisePrefix = `${vatID}.c.p`;
1243
- for (const k of enumeratePrefixedKeys(kvStore, promisePrefix)) {
1251
+ for (const { key } of enumeratePrefixedKeys(kvStore, promisePrefix)) {
1244
1252
  // The vpid for a promise imported or exported by a vat (and thus
1245
1253
  // potentially a promise for which the vat *might* be the decider) will
1246
1254
  // always be of the form `p+NN` or `p-NN`. The corresponding vpid->kpid
@@ -1250,7 +1258,7 @@ export default function makeKernelKeeper(
1250
1258
  // whether the vat is the decider or not. If it is, we add the promise
1251
1259
  // to the list of promises that must be rejected because the dead vat
1252
1260
  // will never be able to act upon them.
1253
- const kpid = getRequired(k);
1261
+ const kpid = getRequired(key);
1254
1262
  const p = getKernelPromise(kpid);
1255
1263
  if (p.state === 'unresolved' && p.decider === vatID) {
1256
1264
  yield [kpid, p];
@@ -1449,9 +1457,9 @@ export default function makeKernelKeeper(
1449
1457
 
1450
1458
  function getDevices() {
1451
1459
  const result = [];
1452
- for (const k of enumeratePrefixedKeys(kvStore, 'device.name.')) {
1453
- const name = k.slice(12);
1454
- const deviceID = kvStore.get(k) || Fail`getNextKey ensures get`;
1460
+ const prefixedKeys = enumeratePrefixedKeys(kvStore, 'device.name.');
1461
+ for (const { key, suffix: name } of prefixedKeys) {
1462
+ const deviceID = kvStore.get(key) || Fail`getNextKey ensures get`;
1455
1463
  result.push([name, deviceID]);
1456
1464
  }
1457
1465
  return result;
@@ -13,7 +13,8 @@ import { Fail } from '@endo/errors';
13
13
  * @param {KVStore} kvStore
14
14
  * @param {string} prefix
15
15
  * @param {string} [exclusiveEnd]
16
- * @yields {string} the next key with the prefix that is not >= exclusiveEnd
16
+ * @yields {{key: string; suffix: string}} the next `key` with the prefix that is not >= exclusiveEnd
17
+ * and the `suffix` which is obtained by stripping the supplied prefix from the key
17
18
  */
18
19
  export function* enumeratePrefixedKeys(kvStore, prefix, exclusiveEnd) {
19
20
  /** @type {string | undefined} */
@@ -26,7 +27,7 @@ export function* enumeratePrefixedKeys(kvStore, prefix, exclusiveEnd) {
26
27
  if (exclusiveEnd && key >= exclusiveEnd) {
27
28
  break;
28
29
  }
29
- yield key;
30
+ yield { key, suffix: key.slice(prefix.length) };
30
31
  }
31
32
  }
32
33
  harden(enumeratePrefixedKeys);
@@ -761,11 +761,13 @@ export function makeVatKeeper(
761
761
  function dumpState() {
762
762
  const res = [];
763
763
  const prefix = `${vatID}.c.`;
764
- for (const k of enumeratePrefixedKeys(kvStore, prefix)) {
765
- const slot = k.slice(prefix.length);
764
+ for (const { key, suffix: slot } of enumeratePrefixedKeys(
765
+ kvStore,
766
+ prefix,
767
+ )) {
766
768
  if (!slot.startsWith('k')) {
767
769
  const vatSlot = slot;
768
- const kernelSlot = kvStore.get(k) || Fail`getNextKey ensures get`;
770
+ const kernelSlot = kvStore.get(key) || Fail`getNextKey ensures get`;
769
771
  /** @type { [string, string, string] } */
770
772
  const item = [kernelSlot, vatID, vatSlot];
771
773
  res.push(item);