@agoric/swingset-liveslots 0.10.3-u18.0 → 0.10.3-u18.1

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-liveslots",
3
- "version": "0.10.3-u18.0",
3
+ "version": "0.10.3-u18.1",
4
4
  "description": "SwingSet ocap support layer",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -17,22 +17,22 @@
17
17
  "lint:eslint": "eslint ."
18
18
  },
19
19
  "dependencies": {
20
- "@agoric/internal": "^0.4.0-u18.0",
21
- "@agoric/store": "^0.9.3-u18.0",
22
- "@endo/env-options": "^1.1.7",
23
- "@endo/errors": "^1.2.7",
24
- "@endo/eventual-send": "^1.2.7",
25
- "@endo/exo": "^1.5.6",
26
- "@endo/far": "^1.1.8",
27
- "@endo/init": "^1.1.6",
28
- "@endo/marshal": "^1.6.1",
29
- "@endo/nat": "^5.0.12",
30
- "@endo/pass-style": "^1.4.6",
31
- "@endo/patterns": "^1.4.6",
32
- "@endo/promise-kit": "^1.1.7"
20
+ "@agoric/internal": "^0.4.0-u18.1",
21
+ "@agoric/store": "^0.9.3-u18.1",
22
+ "@endo/env-options": "^1.1.8",
23
+ "@endo/errors": "^1.2.8",
24
+ "@endo/eventual-send": "^1.2.8",
25
+ "@endo/exo": "^1.5.7",
26
+ "@endo/far": "^1.1.9",
27
+ "@endo/init": "^1.1.7",
28
+ "@endo/marshal": "^1.6.2",
29
+ "@endo/nat": "^5.0.13",
30
+ "@endo/pass-style": "^1.4.7",
31
+ "@endo/patterns": "^1.4.7",
32
+ "@endo/promise-kit": "^1.1.8"
33
33
  },
34
34
  "devDependencies": {
35
- "@agoric/kmarshal": "^0.1.1-u18.0",
35
+ "@agoric/kmarshal": "^0.1.1-u18.1",
36
36
  "ava": "^5.3.0"
37
37
  },
38
38
  "files": [
@@ -68,5 +68,5 @@
68
68
  "typeCoverage": {
69
69
  "atLeast": 75.24
70
70
  },
71
- "gitHead": "c22e7250188bbdb07bc021dffdb88af0309a7aa8"
71
+ "gitHead": "f8c45b8a2e29a51522a81a6692af25b2d7f6b50f"
72
72
  }
@@ -146,56 +146,48 @@ export function makeCollectionManager(
146
146
  scalarMapStore: {
147
147
  hasWeakKeys: false,
148
148
  kindID: 0,
149
- // eslint-disable-next-line no-use-before-define
150
149
  reanimator: reanimateMapStore,
151
150
  durable: false,
152
151
  },
153
152
  scalarWeakMapStore: {
154
153
  hasWeakKeys: true,
155
154
  kindID: 0,
156
- // eslint-disable-next-line no-use-before-define
157
155
  reanimator: reanimateWeakMapStore,
158
156
  durable: false,
159
157
  },
160
158
  scalarSetStore: {
161
159
  hasWeakKeys: false,
162
160
  kindID: 0,
163
- // eslint-disable-next-line no-use-before-define
164
161
  reanimator: reanimateSetStore,
165
162
  durable: false,
166
163
  },
167
164
  scalarWeakSetStore: {
168
165
  hasWeakKeys: true,
169
166
  kindID: 0,
170
- // eslint-disable-next-line no-use-before-define
171
167
  reanimator: reanimateWeakSetStore,
172
168
  durable: false,
173
169
  },
174
170
  scalarDurableMapStore: {
175
171
  hasWeakKeys: false,
176
172
  kindID: 0,
177
- // eslint-disable-next-line no-use-before-define
178
173
  reanimator: reanimateMapStore,
179
174
  durable: true,
180
175
  },
181
176
  scalarDurableWeakMapStore: {
182
177
  hasWeakKeys: true,
183
178
  kindID: 0,
184
- // eslint-disable-next-line no-use-before-define
185
179
  reanimator: reanimateWeakMapStore,
186
180
  durable: true,
187
181
  },
188
182
  scalarDurableSetStore: {
189
183
  hasWeakKeys: false,
190
184
  kindID: 0,
191
- // eslint-disable-next-line no-use-before-define
192
185
  reanimator: reanimateSetStore,
193
186
  durable: true,
194
187
  },
195
188
  scalarDurableWeakSetStore: {
196
189
  hasWeakKeys: true,
197
190
  kindID: 0,
198
- // eslint-disable-next-line no-use-before-define
199
191
  reanimator: reanimateWeakSetStore,
200
192
  durable: true,
201
193
  },
@@ -218,7 +210,6 @@ export function makeCollectionManager(
218
210
  vrm.registerKind(
219
211
  kindID,
220
212
  storeKindInfo[kind].reanimator,
221
- // eslint-disable-next-line no-use-before-define
222
213
  deleteCollection,
223
214
  storeKindInfo[kind].durable,
224
215
  );
@@ -313,7 +304,6 @@ export function makeCollectionManager(
313
304
  // * vref(o-4) -> "vc.5.r0000000001:o-4"
314
305
 
315
306
  const encodeRemotable = remotable => {
316
- // eslint-disable-next-line no-use-before-define
317
307
  const ordinal = getOrdinal(remotable);
318
308
  ordinal !== undefined || Fail`no ordinal for ${remotable}`;
319
309
  const ordinalTag = zeroPad(ordinal, BIGINT_TAG_LEN);
package/src/liveslots.js CHANGED
@@ -155,10 +155,8 @@ function build(
155
155
  const { type, allocatedByVat, virtual, durable } = parseVatSlot(vref);
156
156
  if (type === 'object' && allocatedByVat) {
157
157
  if (virtual || durable) {
158
- // eslint-disable-next-line no-use-before-define
159
158
  vrm.setExportStatus(vref, 'reachable');
160
159
  } else {
161
- // eslint-disable-next-line no-use-before-define
162
160
  const remotable = requiredValForSlot(vref);
163
161
  exportedRemotables.add(remotable);
164
162
  kernelRecognizableRemotables.add(vref);
@@ -183,7 +181,6 @@ function build(
183
181
 
184
182
  if (wr && !wr.deref()) {
185
183
  // we're in the COLLECTED state, or FINALIZED after a re-introduction
186
- // eslint-disable-next-line no-use-before-define
187
184
  addToPossiblyDeadSet(baseRef);
188
185
  slotToVal.delete(baseRef);
189
186
  }
@@ -209,11 +206,9 @@ function build(
209
206
  // Support: o~.[prop](...args) remote method invocation
210
207
  lsdebug(`makeImportedPresence handler.applyMethod (${slot})`);
211
208
  if (disavowedPresences.has(o)) {
212
- // eslint-disable-next-line no-use-before-define
213
209
  exitVatWithFailure(disavowalError);
214
210
  throw disavowalError;
215
211
  }
216
- // eslint-disable-next-line no-use-before-define
217
212
  return queueMessage(slot, prop, args, returnedP);
218
213
  },
219
214
  applyFunction(o, args, returnedP) {
@@ -222,7 +217,6 @@ function build(
222
217
  get(o, prop) {
223
218
  lsdebug(`makeImportedPresence handler.get (${slot})`);
224
219
  if (disavowedPresences.has(o)) {
225
- // eslint-disable-next-line no-use-before-define
226
220
  exitVatWithFailure(disavowalError);
227
221
  throw disavowalError;
228
222
  }
@@ -294,7 +288,6 @@ function build(
294
288
  console.error(`mIPromise handler called after resolution`);
295
289
  Fail`mIPromise handler called after resolution`;
296
290
  }
297
- // eslint-disable-next-line no-use-before-define
298
291
  return queueMessage(vpid, prop, args, returnedP);
299
292
  },
300
293
  get(p, prop) {
@@ -347,17 +340,14 @@ function build(
347
340
  // use a slot from the corresponding allocateX
348
341
 
349
342
  function allocateExportID() {
350
- // eslint-disable-next-line no-use-before-define
351
343
  return vrm.allocateNextID('exportID');
352
344
  }
353
345
 
354
346
  function allocateCollectionID() {
355
- // eslint-disable-next-line no-use-before-define
356
347
  return vrm.allocateNextID('collectionID');
357
348
  }
358
349
 
359
350
  function allocatePromiseID() {
360
- // eslint-disable-next-line no-use-before-define
361
351
  const promiseID = vrm.allocateNextID('promiseID');
362
352
  return makeVatSlot('promise', true, promiseID);
363
353
  }
@@ -385,10 +375,8 @@ function build(
385
375
  // do a syscall.resolve when it fires. The caller must finish
386
376
  // doing their syscall before this turn finishes, to ensure the
387
377
  // kernel isn't surprised by a spurious resolution.
388
- // eslint-disable-next-line no-use-before-define
389
378
  const p = requiredValForSlot(vpid);
390
379
  // if (!knownResolutions.has(p)) { // TODO really?
391
- // eslint-disable-next-line no-use-before-define
392
380
  followForKernel(vpid, p);
393
381
  return true;
394
382
  }
@@ -400,7 +388,6 @@ function build(
400
388
  return makeVatSlot('object', true, exportID);
401
389
  }
402
390
 
403
- // eslint-disable-next-line no-use-before-define
404
391
  const m = makeMarshal(convertValToSlot, convertSlotToVal, {
405
392
  marshalName: `liveSlots:${forVatID}`,
406
393
  serializeBodyFormat: 'smallcaps',
@@ -413,7 +400,6 @@ function build(
413
400
  console.warn('Logging sent error stack', err),
414
401
  });
415
402
  const unmeteredUnserialize = meterControl.unmetered(m.unserialize);
416
- // eslint-disable-next-line no-use-before-define
417
403
  const unmeteredConvertSlotToVal = meterControl.unmetered(convertSlotToVal);
418
404
 
419
405
  function getSlotForVal(val) {
@@ -458,7 +444,6 @@ function build(
458
444
  allocateExportID,
459
445
  getSlotForVal,
460
446
  requiredValForSlot,
461
- // eslint-disable-next-line no-use-before-define
462
447
  registerValue,
463
448
  m.serialize,
464
449
  unmeteredUnserialize,
@@ -471,10 +456,8 @@ function build(
471
456
  vrm,
472
457
  allocateExportID,
473
458
  allocateCollectionID,
474
- // eslint-disable-next-line no-use-before-define
475
459
  convertValToSlot,
476
460
  unmeteredConvertSlotToVal,
477
- // eslint-disable-next-line no-use-before-define
478
461
  registerValue,
479
462
  m.serialize,
480
463
  unmeteredUnserialize,
@@ -486,7 +469,6 @@ function build(
486
469
  vrm,
487
470
  vom,
488
471
  collectionManager,
489
- // eslint-disable-next-line no-use-before-define
490
472
  convertValToSlot,
491
473
  convertSlotToVal: unmeteredConvertSlotToVal,
492
474
  maybeExportPromise,
@@ -516,7 +498,6 @@ function build(
516
498
  slot = allocatePromiseID();
517
499
  } else {
518
500
  if (disavowedPresences.has(val)) {
519
- // eslint-disable-next-line no-use-before-define
520
501
  exitVatWithFailure(disavowalError);
521
502
  throw disavowalError; // cannot reference a disavowed object
522
503
  }
@@ -686,7 +667,6 @@ function build(
686
667
  const priorResolution = knownResolutions.get(p);
687
668
  if (priorResolution && !doneResolutions.has(slot)) {
688
669
  const [priorRejected, priorRes] = priorResolution;
689
- // eslint-disable-next-line no-use-before-define
690
670
  collect(slot, priorRejected, priorRes);
691
671
  }
692
672
  }
@@ -972,7 +952,6 @@ function build(
972
952
  }
973
953
  // in both cases, we are now the decider, so treat it like an
974
954
  // exported promise
975
- // eslint-disable-next-line no-use-before-define
976
955
  followForKernel(resultVPID, p);
977
956
  }
978
957
  }
@@ -1249,7 +1228,6 @@ function build(
1249
1228
  possiblyRetiredSet,
1250
1229
  slotToVal,
1251
1230
  valToSlot,
1252
- // eslint-disable-next-line no-use-before-define
1253
1231
  afterDispatchActions,
1254
1232
  });
1255
1233
 
@@ -1341,7 +1319,7 @@ function build(
1341
1319
 
1342
1320
  /**
1343
1321
  * @param {import('./types.js').VatDeliveryObject} delivery
1344
- * @returns {void | Promise<void>}
1322
+ * @returns {undefined | ReturnType<startVat>}
1345
1323
  */
1346
1324
  function dispatchToUserspace(delivery) {
1347
1325
  let result;
@@ -1,5 +1,5 @@
1
1
  /* global globalThis */
2
- /* eslint-disable no-use-before-define, jsdoc/require-returns-type */
2
+ /* eslint-disable jsdoc/require-returns-type */
3
3
 
4
4
  import { environmentOptionsListHas } from '@endo/env-options';
5
5
  import { assert, Fail, q, b } from '@endo/errors';
@@ -1,4 +1,4 @@
1
- /* eslint-disable no-use-before-define, jsdoc/require-returns-type */
1
+ /* eslint-disable jsdoc/require-returns-type */
2
2
 
3
3
  import { assert, Fail } from '@endo/errors';
4
4
  import { Nat } from '@endo/nat';
@@ -235,13 +235,23 @@ export function makeWatchedPromiseManager({
235
235
  } else {
236
236
  watchedPromiseTable.init(vpid, harden([[watcher, ...args]]));
237
237
 
238
+ promiseRegistrations.init(vpid, p);
239
+
240
+ // pseudoThen registers a settlement callback that will remove
241
+ // this promise from promiseRegistrations and
242
+ // watchedPromiseTable. To avoid triggering
243
+ // https://github.com/Agoric/agoric-sdk/issues/10757 and
244
+ // preventing slotToVal cleanup, the `pseudoThen()` should
245
+ // precede `maybeExportPromise()`. This isn't foolproof, but
246
+ // does mitigate in advance of a proper fix. See #10756 for
247
+ // details of this particular mitigation, and #10757 for the
248
+ // deeper bug.
249
+ pseudoThen(p, vpid);
250
+
238
251
  // Ensure that this vat's promises are rejected at termination.
239
252
  if (maybeExportPromise(vpid)) {
240
253
  syscall.subscribe(vpid);
241
254
  }
242
-
243
- promiseRegistrations.init(vpid, p);
244
- pseudoThen(p, vpid);
245
255
  }
246
256
  });
247
257
  }
@@ -0,0 +1,42 @@
1
+ import test from 'ava';
2
+
3
+ import { Far } from '@endo/marshal';
4
+ import { makePromiseKit } from '@endo/promise-kit';
5
+ import { setupTestLiveslots } from './liveslots-helpers.js';
6
+
7
+ const build = vatPowers => {
8
+ const { VatData } = vatPowers;
9
+ const { makeKindHandle, defineDurableKind, watchPromise } = VatData;
10
+
11
+ const kh = makeKindHandle('handler');
12
+ const init = () => ({});
13
+ const behavior = {
14
+ onFulfilled: _value => 0,
15
+ onRejected: _reason => 0,
16
+ };
17
+ const makeHandler = defineDurableKind(kh, init, behavior);
18
+
19
+ return Far('root', {
20
+ async run() {
21
+ const pr = makePromiseKit();
22
+ const handler = makeHandler();
23
+ watchPromise(pr.promise, handler);
24
+ pr.resolve('ignored');
25
+ },
26
+ });
27
+ };
28
+
29
+ test('watched local promises should not leak slotToVal entries', async t => {
30
+ const { dispatchMessage, testHooks } = await setupTestLiveslots(
31
+ t,
32
+ build,
33
+ 'vatA',
34
+ );
35
+ const { slotToVal } = testHooks;
36
+ const initial = slotToVal.size;
37
+
38
+ await dispatchMessage('run');
39
+ t.is(slotToVal.size, initial);
40
+ await dispatchMessage('run');
41
+ t.is(slotToVal.size, initial);
42
+ });
@@ -234,7 +234,6 @@ export function makeFakeLiveSlotsStuff(options = {}) {
234
234
  assert.fail('fake liveSlots stuff configured without vrm');
235
235
  }
236
236
  }
237
- // eslint-disable-next-line no-use-before-define
238
237
  registerEntry(baseRef, val, facet !== undefined);
239
238
  if (!result) {
240
239
  result = val;