@agoric/swingset-vat 0.32.3-dev-d8f6bce.0.d8f6bce → 0.32.3-dev-b3de433.0.b3de433

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-d8f6bce.0.d8f6bce",
3
+ "version": "0.32.3-dev-b3de433.0.b3de433",
4
4
  "description": "Vat/Container Launcher",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -22,7 +22,7 @@
22
22
  "lint:eslint": "yarn run -T eslint ."
23
23
  },
24
24
  "devDependencies": {
25
- "@agoric/xsnap": "0.14.3-dev-d8f6bce.0.d8f6bce",
25
+ "@agoric/xsnap": "0.14.3-dev-b3de433.0.b3de433",
26
26
  "@types/better-sqlite3": "^7.6.13",
27
27
  "@types/microtime": "^2.1.0",
28
28
  "@types/tmp": "^0.2.0",
@@ -30,15 +30,15 @@
30
30
  "ava": "^5.3.0"
31
31
  },
32
32
  "dependencies": {
33
- "@agoric/internal": "0.3.3-dev-d8f6bce.0.d8f6bce",
34
- "@agoric/kmarshal": "0.1.1-dev-d8f6bce.0.d8f6bce",
35
- "@agoric/store": "0.9.3-dev-d8f6bce.0.d8f6bce",
36
- "@agoric/swing-store": "0.9.2-dev-d8f6bce.0.d8f6bce",
37
- "@agoric/swingset-liveslots": "0.10.3-dev-d8f6bce.0.d8f6bce",
38
- "@agoric/swingset-xsnap-supervisor": "0.10.3-dev-d8f6bce.0.d8f6bce",
39
- "@agoric/time": "0.3.3-dev-d8f6bce.0.d8f6bce",
40
- "@agoric/vat-data": "0.5.3-dev-d8f6bce.0.d8f6bce",
41
- "@agoric/xsnap-lockdown": "0.14.1-dev-d8f6bce.0.d8f6bce",
33
+ "@agoric/internal": "0.3.3-dev-b3de433.0.b3de433",
34
+ "@agoric/kmarshal": "0.1.1-dev-b3de433.0.b3de433",
35
+ "@agoric/store": "0.9.3-dev-b3de433.0.b3de433",
36
+ "@agoric/swing-store": "0.9.2-dev-b3de433.0.b3de433",
37
+ "@agoric/swingset-liveslots": "0.10.3-dev-b3de433.0.b3de433",
38
+ "@agoric/swingset-xsnap-supervisor": "0.10.3-dev-b3de433.0.b3de433",
39
+ "@agoric/time": "0.3.3-dev-b3de433.0.b3de433",
40
+ "@agoric/vat-data": "0.5.3-dev-b3de433.0.b3de433",
41
+ "@agoric/xsnap-lockdown": "0.14.1-dev-b3de433.0.b3de433",
42
42
  "@endo/base64": "^1.0.12",
43
43
  "@endo/bundle-source": "^4.1.2",
44
44
  "@endo/captp": "^4.4.8",
@@ -105,5 +105,5 @@
105
105
  "typeCoverage": {
106
106
  "atLeast": 76.71
107
107
  },
108
- "gitHead": "d8f6bce3ae096eaaa0d864aa75af9e818b80162e"
108
+ "gitHead": "b3de4336b200fe768939266b07f1687dd6c065e4"
109
109
  }
@@ -369,54 +369,47 @@ export function makeVatKeeper(
369
369
  required = false,
370
370
  requireNew = false,
371
371
  } = options;
372
- assert(
373
- !(required && requireNew),
374
- "'required' and 'requireNew' are mutually exclusive",
375
- );
372
+ !(required && requireNew) ||
373
+ Fail`'required' and 'requireNew' are mutually exclusive`;
376
374
  typeof vatSlot === 'string' || Fail`non-string vatSlot: ${vatSlot}`;
377
375
  const { type, allocatedByVat } = parseVatSlot(vatSlot);
378
376
  const vatKey = `${vatID}.c.${vatSlot}`;
379
- if (!kvStore.has(vatKey)) {
377
+ if (kvStore.has(vatKey)) {
378
+ !requireNew || Fail`vref ${q(vatSlot)} is already allocated`;
379
+ } else {
380
380
  !required || Fail`vref ${vatSlot} not in clist`;
381
- if (allocatedByVat) {
382
- let kernelSlot;
383
- if (type === 'object') {
384
- // this sets the initial refcount to reachable:0 recognizable:0
385
- kernelSlot = addKernelObject(vatID);
386
- } else if (type === 'device') {
387
- Fail`normal vats aren't allowed to export device nodes`;
388
- } else if (type === 'promise') {
389
- kernelSlot = addKernelPromiseForVat(vatID);
390
- } else {
391
- Fail`unknown type ${type}`;
392
- }
393
- // now increment the refcount with isExport=true and
394
- // onlyRecognizable=true, which will skip object exports (we only
395
- // count imports) and leave the reachability count at zero
396
- const incopts = { isExport: true, onlyRecognizable: true };
397
- incrementRefCount(kernelSlot, `${vatID}|vk|clist`, incopts);
398
- const kernelKey = `${vatID}.c.${kernelSlot}`;
399
- incStat('clistEntries');
400
- // we add the key as "unreachable" but "recognizable", and then rely
401
- // on setReachableFlag() at the end to both mark it reachable and to
402
- // update any necessary refcounts consistently
403
- kvStore.set(kernelKey, buildReachableAndVatSlot(false, vatSlot));
404
- kvStore.set(vatKey, kernelSlot);
405
- kernelSlog.changeCList(
406
- vatID,
407
- getCrankNumber(),
408
- 'export',
409
- kernelSlot,
410
- vatSlot,
411
- );
412
- kdebug(`Add mapping v->k ${kernelKey}<=>${vatKey}`);
381
+ allocatedByVat || Fail`unknown vatSlot ${q(vatSlot)}`;
382
+ let kernelSlot;
383
+ if (type === 'object') {
384
+ // this sets the initial refcount to reachable:0 recognizable:0
385
+ kernelSlot = addKernelObject(vatID);
386
+ } else if (type === 'device') {
387
+ Fail`normal vats aren't allowed to export device nodes`;
388
+ } else if (type === 'promise') {
389
+ kernelSlot = addKernelPromiseForVat(vatID);
413
390
  } else {
414
- // the vat didn't allocate it, and the kernel didn't allocate it
415
- // (else it would have been in the c-list), so it must be bogus
416
- Fail`unknown vatSlot ${q(vatSlot)}`;
391
+ Fail`unknown type ${type}`;
417
392
  }
418
- } else if (requireNew) {
419
- Fail`vref ${q(vatSlot)} is already allocated`;
393
+ // now increment the refcount with isExport=true and
394
+ // onlyRecognizable=true, which will skip object exports (we only
395
+ // count imports) and leave the reachability count at zero
396
+ const incopts = { isExport: true, onlyRecognizable: true };
397
+ incrementRefCount(kernelSlot, `${vatID}|vk|clist`, incopts);
398
+ const kernelKey = `${vatID}.c.${kernelSlot}`;
399
+ incStat('clistEntries');
400
+ // we add the key as "unreachable" but "recognizable", and then rely
401
+ // on setReachableFlag() at the end to both mark it reachable and to
402
+ // update any necessary refcounts consistently
403
+ kvStore.set(kernelKey, buildReachableAndVatSlot(false, vatSlot));
404
+ kvStore.set(vatKey, kernelSlot);
405
+ kernelSlog.changeCList(
406
+ vatID,
407
+ getCrankNumber(),
408
+ 'export',
409
+ kernelSlot,
410
+ vatSlot,
411
+ );
412
+ kdebug(`Add mapping v->k ${kernelKey}<=>${vatKey}`);
420
413
  }
421
414
  const kernelSlot = getRequired(vatKey);
422
415