@agoric/swingset-liveslots 0.10.3-u14.0 → 0.10.3-u16.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/README.md +2 -0
- package/package.json +27 -19
- package/src/cache.js +2 -1
- package/src/capdata.js +0 -1
- package/src/collectionManager.js +154 -72
- package/src/index.js +4 -1
- package/src/liveslots.js +52 -81
- package/src/message.js +4 -4
- package/src/types.js +8 -2
- package/src/vatDataTypes.d.ts +271 -0
- package/src/vatDataTypes.js +2 -0
- package/src/vatstore-iterators.js +2 -0
- package/src/virtualObjectManager.js +189 -70
- package/src/virtualReferences.js +51 -0
- package/src/watchedPromises.js +61 -16
- package/test/{test-baggage.js → baggage.test.js} +1 -2
- package/test/{test-cache.js → cache.test.js} +0 -1
- package/test/{test-collection-schema-refcount.js → collection-schema-refcount.test.js} +1 -2
- package/test/{test-collection-upgrade.js → collection-upgrade.test.js} +1 -3
- package/test/{test-collections.js → collections.test.js} +117 -14
- package/test/{test-dropped-collection-weakrefs.js → dropped-collection-weakrefs.test.js} +1 -2
- package/test/{test-durabilityChecks.js → durabilityChecks.test.js} +3 -3
- package/test/{test-facetiousness.js → facetiousness.test.js} +1 -2
- package/test/gc-and-finalize.js +30 -1
- package/test/gc-helpers.js +2 -3
- package/test/{test-gc-sensitivity.js → gc-sensitivity.test.js} +2 -2
- package/test/{test-handled-promises.js → handled-promises.test.js} +5 -7
- package/test/{test-initial-vrefs.js → initial-vrefs.test.js} +2 -3
- package/test/liveslots-helpers.js +6 -6
- package/test/{test-liveslots-mock-gc.js → liveslots-mock-gc.test.js} +2 -2
- package/test/{test-liveslots-real-gc.js → liveslots-real-gc.test.js} +44 -35
- package/test/{test-liveslots.js → liveslots.test.js} +13 -14
- package/test/mock-gc.js +1 -0
- package/test/storeGC/{test-lifecycle.js → lifecycle.test.js} +2 -2
- package/test/storeGC/{test-refcount-management.js → refcount-management.test.js} +1 -2
- package/test/storeGC/{test-scalar-store-kind.js → scalar-store-kind.test.js} +0 -1
- package/test/storeGC/{test-weak-key.js → weak-key.test.js} +1 -2
- package/test/util.js +2 -2
- package/test/vat-util.js +1 -1
- package/test/virtual-objects/{test-cease-recognition.js → cease-recognition.test.js} +2 -2
- package/test/virtual-objects/{test-cross-facet.js → cross-facet.test.js} +5 -4
- package/test/virtual-objects/{test-empty-data.js → empty-data.test.js} +1 -2
- package/test/virtual-objects/{test-facets.js → facets.test.js} +1 -2
- package/test/virtual-objects/{test-kind-changes.js → kind-changes.test.js} +2 -2
- package/test/virtual-objects/{test-reachable-vrefs.js → reachable-vrefs.test.js} +2 -2
- package/test/virtual-objects/{test-rep-tostring.js → rep-tostring.test.js} +2 -3
- package/test/virtual-objects/{test-retain-remotable.js → retain-remotable.test.js} +25 -24
- package/test/virtual-objects/{test-state-shape.js → state-shape.test.js} +2 -2
- package/test/virtual-objects/{test-virtualObjectGC.js → virtualObjectGC.test.js} +2 -2
- package/test/virtual-objects/{test-virtualObjectManager.js → virtualObjectManager.test.js} +6 -2
- package/test/virtual-objects/{test-vo-real-gc.js → vo-real-gc.test.js} +8 -8
- package/test/virtual-objects/{test-weakcollections-vref-handling.js → weakcollections-vref-handling.test.js} +1 -2
- package/test/{test-vo-test-harness.js → vo-test-harness.test.js} +0 -1
- package/test/{test-vpid-liveslots.js → vpid-liveslots.test.js} +4 -5
- package/test/waitUntilQuiescent.js +2 -1
- package/tools/fakeVirtualSupport.js +41 -24
- package/tools/prepare-test-env.js +13 -0
- package/tools/setup-vat-data.js +62 -0
- package/CHANGELOG.md +0 -93
- package/test/kmarshal.js +0 -79
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
import test from 'ava';
|
|
2
|
-
import '@endo/init/debug.js';
|
|
3
3
|
|
|
4
4
|
import { Far } from '@endo/marshal';
|
|
5
|
+
import { kser, kslot } from '@agoric/kmarshal';
|
|
5
6
|
import { M } from '@agoric/store';
|
|
6
7
|
import { makeLiveSlots } from '../../src/liveslots.js';
|
|
7
|
-
import { kser, kslot } from '../kmarshal.js';
|
|
8
8
|
import { buildSyscall } from '../liveslots-helpers.js';
|
|
9
9
|
import { makeStartVat, makeMessage } from '../util.js';
|
|
10
10
|
import { makeMockGC } from '../mock-gc.js';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
import test from 'ava';
|
|
2
|
-
import '@endo/init/debug.js';
|
|
3
3
|
|
|
4
4
|
import { Far } from '@endo/marshal';
|
|
5
|
+
import { krefOf, kser, kslot } from '@agoric/kmarshal';
|
|
5
6
|
import {
|
|
6
7
|
setupTestLiveslots,
|
|
7
8
|
findSyscallsByType,
|
|
8
9
|
} from '../liveslots-helpers.js';
|
|
9
|
-
import { krefOf, kser, kslot } from '../kmarshal.js';
|
|
10
10
|
import { parseVatSlot } from '../../src/parseVatSlots.js';
|
|
11
11
|
|
|
12
12
|
// Legs:
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
import test from 'ava';
|
|
2
|
-
import '@endo/init/debug.js';
|
|
3
3
|
|
|
4
|
+
import { kser, kslot } from '@agoric/kmarshal';
|
|
4
5
|
import {
|
|
5
6
|
makeFakeVirtualObjectManager,
|
|
6
7
|
makeFakeVirtualStuff,
|
|
7
8
|
} from '../../tools/fakeVirtualSupport.js';
|
|
8
9
|
|
|
9
|
-
import { kser, kslot } from '../kmarshal.js';
|
|
10
10
|
import { vstr } from '../util.js';
|
|
11
11
|
|
|
12
12
|
function initThing(label = 'thing', counter = 0) {
|
|
@@ -128,6 +128,7 @@ test('multifaceted virtual objects', t => {
|
|
|
128
128
|
flushStateCache();
|
|
129
129
|
t.deepEqual(log.splice(0), [
|
|
130
130
|
`get kindIDID => undefined`,
|
|
131
|
+
`get idCounters => undefined`,
|
|
131
132
|
`set kindIDID 1`,
|
|
132
133
|
`set vom.vkind.2.descriptor {"kindID":"2","tag":"multithing"}`,
|
|
133
134
|
`set vom.${kid}/1 ${multiThingVal('foo', 1)}`,
|
|
@@ -203,6 +204,7 @@ test('virtual object operations', t => {
|
|
|
203
204
|
const thing4 = makeThing('thing-4', 300); // [t4-0* t3-0* t2-0* t1-0*]
|
|
204
205
|
// t4-0: 'thing-4' 300 0
|
|
205
206
|
t.is(log.shift(), `get kindIDID => undefined`);
|
|
207
|
+
t.is(log.shift(), `get idCounters => undefined`);
|
|
206
208
|
t.is(log.shift(), `set kindIDID 1`);
|
|
207
209
|
t.is(log.shift(), `set vom.vkind.2.descriptor {"kindID":"2","tag":"thing"}`);
|
|
208
210
|
t.is(log.shift(), `set vom.vkind.3.descriptor {"kindID":"3","tag":"zot"}`);
|
|
@@ -467,6 +469,7 @@ test('symbol named methods', t => {
|
|
|
467
469
|
const thing2 = makeThing('thing-2', 100); // [t1-0* t2-0*]
|
|
468
470
|
// t2-0: 'thing-2' 100 0
|
|
469
471
|
t.is(log.shift(), `get kindIDID => undefined`);
|
|
472
|
+
t.is(log.shift(), `get idCounters => undefined`);
|
|
470
473
|
t.is(log.shift(), `set kindIDID 1`);
|
|
471
474
|
t.is(
|
|
472
475
|
log.shift(),
|
|
@@ -647,6 +650,7 @@ test('virtual object gc', t => {
|
|
|
647
650
|
});
|
|
648
651
|
|
|
649
652
|
t.is(log.shift(), `get kindIDID => undefined`);
|
|
653
|
+
t.is(log.shift(), `get idCounters => undefined`);
|
|
650
654
|
t.is(log.shift(), `set kindIDID 1`);
|
|
651
655
|
const skit = [
|
|
652
656
|
'storeKindIDTable',
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-nocheck
|
|
2
2
|
import test from 'ava';
|
|
3
|
-
import '@endo/init/debug.js';
|
|
4
3
|
|
|
5
4
|
import { Far } from '@endo/marshal';
|
|
6
|
-
import { kser, kunser } from '
|
|
5
|
+
import { kser, kunser } from '@agoric/kmarshal';
|
|
7
6
|
import { setupTestLiveslots } from '../liveslots-helpers.js';
|
|
7
|
+
import { watchCollected } from '../gc-and-finalize.js';
|
|
8
8
|
|
|
9
9
|
test('virtual object state writes', async t => {
|
|
10
|
-
let
|
|
10
|
+
let collected;
|
|
11
11
|
|
|
12
12
|
const initData = { begin: 'ning' };
|
|
13
13
|
const initStateData = { begin: kser(initData.begin) };
|
|
@@ -23,11 +23,11 @@ test('virtual object state writes', async t => {
|
|
|
23
23
|
const root = Far('root', {
|
|
24
24
|
make: () => {
|
|
25
25
|
const thing = makeThing();
|
|
26
|
-
|
|
26
|
+
collected = watchCollected(thing);
|
|
27
27
|
return thing;
|
|
28
28
|
},
|
|
29
29
|
ping: thing => {
|
|
30
|
-
|
|
30
|
+
collected = watchCollected(thing);
|
|
31
31
|
return thing.ping();
|
|
32
32
|
},
|
|
33
33
|
});
|
|
@@ -56,7 +56,7 @@ test('virtual object state writes', async t => {
|
|
|
56
56
|
|
|
57
57
|
// 'thing' is exported, but not held in RAM, so the Representative
|
|
58
58
|
// should be dropped
|
|
59
|
-
t.
|
|
59
|
+
t.true(collected.result);
|
|
60
60
|
|
|
61
61
|
// Invoking a method, on the other hand, *does* require creation of
|
|
62
62
|
// "state" and "context", and creation of "state" requires reading
|
|
@@ -70,5 +70,5 @@ test('virtual object state writes', async t => {
|
|
|
70
70
|
|
|
71
71
|
// 'thing' is again dropped by RAM, so it should be dropped. If
|
|
72
72
|
// "context" were erroneously retained, it would stick around.
|
|
73
|
-
t.
|
|
73
|
+
t.true(collected.result);
|
|
74
74
|
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
-
import '@endo/init/debug.js';
|
|
3
2
|
|
|
4
3
|
import { makeFakeVirtualObjectManager } from '../../tools/fakeVirtualSupport.js';
|
|
5
4
|
|
|
6
|
-
test('weakMap vref handling',
|
|
5
|
+
test('weakMap vref handling', t => {
|
|
7
6
|
const log = [];
|
|
8
7
|
const {
|
|
9
8
|
VirtualObjectAwareWeakMap,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
import test from 'ava';
|
|
2
|
-
import '@endo/init/debug.js';
|
|
3
3
|
|
|
4
4
|
import { E } from '@endo/eventual-send';
|
|
5
5
|
import { makePromiseKit } from '@endo/promise-kit';
|
|
6
|
-
import { Fail } from '@agoric/assert';
|
|
7
6
|
import { Far } from '@endo/marshal';
|
|
7
|
+
import { Fail } from '@agoric/assert';
|
|
8
|
+
import { kser, kslot } from '@agoric/kmarshal';
|
|
8
9
|
import { buildSyscall, makeDispatch } from './liveslots-helpers.js';
|
|
9
10
|
import { makeMessage, makeResolve, makeReject } from './util.js';
|
|
10
|
-
import { kser, kslot } from './kmarshal.js';
|
|
11
11
|
|
|
12
12
|
function hush(p) {
|
|
13
13
|
p.then(
|
|
@@ -293,7 +293,6 @@ async function doVatResolveCase23(t, which, mode, stalls) {
|
|
|
293
293
|
// another few turns. We wait some number of turns before using p1
|
|
294
294
|
// again, to exercise as many race conditions as possible.
|
|
295
295
|
for (let i = 0; i < stalls; i += 1) {
|
|
296
|
-
// eslint-disable-next-line no-await-in-loop
|
|
297
296
|
await Promise.resolve();
|
|
298
297
|
}
|
|
299
298
|
|
|
@@ -858,7 +857,7 @@ test('inter-vat circular promise references', async t => {
|
|
|
858
857
|
let r;
|
|
859
858
|
return Far('root', {
|
|
860
859
|
genPromise() {
|
|
861
|
-
[p, r] = makePR();
|
|
860
|
+
void ([p, r] = makePR());
|
|
862
861
|
return p;
|
|
863
862
|
},
|
|
864
863
|
usePromise(pa) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* global setImmediate */
|
|
2
2
|
import { makePromiseKit } from '@endo/promise-kit';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
/** @import {PromiseKit} from '@endo/promise-kit' */
|
|
4
5
|
|
|
5
6
|
// This can only be imported from the Start Compartment, where 'setImmediate'
|
|
6
7
|
// is available.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* global
|
|
1
|
+
/* global globalThis */
|
|
2
2
|
/* eslint-disable max-classes-per-file */
|
|
3
3
|
import { makeMarshal } from '@endo/marshal';
|
|
4
4
|
import { assert } from '@agoric/assert';
|
|
@@ -10,6 +10,14 @@ import { makeWatchedPromiseManager } from '../src/watchedPromises.js';
|
|
|
10
10
|
import { makeFakeVirtualObjectManager } from './fakeVirtualObjectManager.js';
|
|
11
11
|
import { makeFakeCollectionManager } from './fakeCollectionManager.js';
|
|
12
12
|
|
|
13
|
+
const { Fail } = assert;
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
WeakRef: RealWeakRef,
|
|
17
|
+
WeakMap: RealWeakMap,
|
|
18
|
+
WeakSet: RealWeakSet,
|
|
19
|
+
} = globalThis;
|
|
20
|
+
|
|
13
21
|
class FakeFinalizationRegistry {
|
|
14
22
|
// eslint-disable-next-line no-useless-constructor, no-empty-function
|
|
15
23
|
constructor() {}
|
|
@@ -31,8 +39,6 @@ class FakeWeakRef {
|
|
|
31
39
|
}
|
|
32
40
|
}
|
|
33
41
|
|
|
34
|
-
const RealWeakRef = WeakRef;
|
|
35
|
-
|
|
36
42
|
export function makeFakeLiveSlotsStuff(options = {}) {
|
|
37
43
|
let vrm;
|
|
38
44
|
function setVrm(vrmToUse) {
|
|
@@ -46,6 +52,8 @@ export function makeFakeLiveSlotsStuff(options = {}) {
|
|
|
46
52
|
log,
|
|
47
53
|
FinalizationRegistry = FakeFinalizationRegistry,
|
|
48
54
|
WeakRef = FakeWeakRef, // VRM uses this
|
|
55
|
+
WeakMap = RealWeakMap,
|
|
56
|
+
WeakSet = RealWeakSet,
|
|
49
57
|
addToPossiblyDeadSet = () => {},
|
|
50
58
|
addToPossiblyRetiredSet = () => {},
|
|
51
59
|
} = options;
|
|
@@ -152,26 +160,16 @@ export function makeFakeLiveSlotsStuff(options = {}) {
|
|
|
152
160
|
},
|
|
153
161
|
};
|
|
154
162
|
|
|
155
|
-
let nextExportID = 1;
|
|
156
163
|
function allocateExportID() {
|
|
157
|
-
|
|
158
|
-
nextExportID += 1;
|
|
159
|
-
return exportID;
|
|
164
|
+
return vrm.allocateNextID('exportID');
|
|
160
165
|
}
|
|
161
166
|
|
|
162
|
-
// different starting point for more distinct IDs
|
|
163
|
-
let nextPromiseID = 7;
|
|
164
167
|
function allocatePromiseID() {
|
|
165
|
-
|
|
166
|
-
nextPromiseID += 1;
|
|
167
|
-
return promiseID;
|
|
168
|
+
return vrm.allocateNextID('promiseID');
|
|
168
169
|
}
|
|
169
170
|
|
|
170
|
-
let nextCollectionID = 1;
|
|
171
171
|
function allocateCollectionID() {
|
|
172
|
-
|
|
173
|
-
nextCollectionID += 1;
|
|
174
|
-
return collectionID;
|
|
172
|
+
return vrm.allocateNextID('collectionID');
|
|
175
173
|
}
|
|
176
174
|
|
|
177
175
|
// note: The real liveslots slotToVal() maps slots (vrefs) to a WeakRef,
|
|
@@ -223,30 +221,42 @@ export function makeFakeLiveSlotsStuff(options = {}) {
|
|
|
223
221
|
}
|
|
224
222
|
return val;
|
|
225
223
|
}
|
|
224
|
+
let result;
|
|
226
225
|
if (virtual || durable) {
|
|
227
226
|
if (vrm) {
|
|
228
227
|
val = vrm.reanimate(slot);
|
|
229
228
|
if (facet !== undefined) {
|
|
230
|
-
|
|
229
|
+
result = vrm.getFacet(id, val, facet);
|
|
231
230
|
}
|
|
232
231
|
} else {
|
|
233
232
|
assert.fail('fake liveSlots stuff configured without vrm');
|
|
234
233
|
}
|
|
235
234
|
}
|
|
236
|
-
|
|
235
|
+
// eslint-disable-next-line no-use-before-define
|
|
236
|
+
registerEntry(baseRef, val, facet !== undefined);
|
|
237
|
+
if (!result) {
|
|
238
|
+
result = val;
|
|
239
|
+
}
|
|
240
|
+
return result;
|
|
237
241
|
}
|
|
238
242
|
|
|
239
243
|
const marshal = makeMarshal(convertValToSlot, convertSlotToVal, {
|
|
240
244
|
serializeBodyFormat: 'smallcaps',
|
|
245
|
+
marshalName: 'fakeLiveSlots',
|
|
246
|
+
errorIdNum: 80_000,
|
|
247
|
+
marshalSaveError: _err => {},
|
|
241
248
|
});
|
|
242
249
|
|
|
243
250
|
function registerEntry(baseRef, val, valIsCohort) {
|
|
251
|
+
const { facet } = parseVatSlot(baseRef);
|
|
252
|
+
!facet ||
|
|
253
|
+
Fail`registerEntry(${baseRef} should not receive individual facets`;
|
|
244
254
|
setValForSlot(baseRef, val);
|
|
245
255
|
if (valIsCohort) {
|
|
246
256
|
const { id } = parseVatSlot(baseRef);
|
|
247
|
-
vrm.getFacetNames(id).
|
|
257
|
+
for (const [index, name] of vrm.getFacetNames(id).entries()) {
|
|
248
258
|
valToSlot.set(val[name], `${baseRef}:${index}`);
|
|
249
|
-
}
|
|
259
|
+
}
|
|
250
260
|
} else {
|
|
251
261
|
valToSlot.set(val, baseRef);
|
|
252
262
|
}
|
|
@@ -281,6 +291,8 @@ export function makeFakeLiveSlotsStuff(options = {}) {
|
|
|
281
291
|
deleteEntry,
|
|
282
292
|
FinalizationRegistry,
|
|
283
293
|
WeakRef,
|
|
294
|
+
WeakMap,
|
|
295
|
+
WeakSet,
|
|
284
296
|
addToPossiblyDeadSet,
|
|
285
297
|
addToPossiblyRetiredSet,
|
|
286
298
|
dumpStore,
|
|
@@ -327,8 +339,12 @@ export function makeFakeWatchedPromiseManager(
|
|
|
327
339
|
* Configure virtual stuff with relaxed durability rules and fake liveslots
|
|
328
340
|
*
|
|
329
341
|
* @param {object} [options]
|
|
330
|
-
* @param {number} [options.cacheSize
|
|
331
|
-
* @param {boolean} [options.relaxDurabilityRules
|
|
342
|
+
* @param {number} [options.cacheSize]
|
|
343
|
+
* @param {boolean} [options.relaxDurabilityRules]
|
|
344
|
+
* @param {Map<any, any>} [options.fakeStore]
|
|
345
|
+
* @param {WeakMapConstructor} [options.WeakMap]
|
|
346
|
+
* @param {WeakSetConstructor} [options.WeakSet]
|
|
347
|
+
* @param {boolean} [options.weak]
|
|
332
348
|
*/
|
|
333
349
|
export function makeFakeVirtualStuff(options = {}) {
|
|
334
350
|
const actualOptions = {
|
|
@@ -338,9 +354,9 @@ export function makeFakeVirtualStuff(options = {}) {
|
|
|
338
354
|
const { relaxDurabilityRules } = actualOptions;
|
|
339
355
|
const fakeStuff = makeFakeLiveSlotsStuff(actualOptions);
|
|
340
356
|
const vrm = makeFakeVirtualReferenceManager(fakeStuff, relaxDurabilityRules);
|
|
357
|
+
fakeStuff.setVrm(vrm);
|
|
341
358
|
const vom = makeFakeVirtualObjectManager(vrm, fakeStuff);
|
|
342
359
|
vom.initializeKindHandleKind();
|
|
343
|
-
fakeStuff.setVrm(vrm);
|
|
344
360
|
const cm = makeFakeCollectionManager(vrm, fakeStuff, actualOptions);
|
|
345
361
|
const wpm = makeFakeWatchedPromiseManager(vrm, vom, cm, fakeStuff);
|
|
346
362
|
wpm.preparePromiseWatcherTables();
|
|
@@ -351,9 +367,9 @@ export function makeStandaloneFakeVirtualObjectManager(options = {}) {
|
|
|
351
367
|
const fakeStuff = makeFakeLiveSlotsStuff(options);
|
|
352
368
|
const { relaxDurabilityRules = true } = options;
|
|
353
369
|
const vrm = makeFakeVirtualReferenceManager(fakeStuff, relaxDurabilityRules);
|
|
370
|
+
fakeStuff.setVrm(vrm);
|
|
354
371
|
const vom = makeFakeVirtualObjectManager(vrm, fakeStuff);
|
|
355
372
|
vom.initializeKindHandleKind();
|
|
356
|
-
fakeStuff.setVrm(vrm);
|
|
357
373
|
return vom;
|
|
358
374
|
}
|
|
359
375
|
|
|
@@ -361,6 +377,7 @@ export function makeStandaloneFakeCollectionManager(options = {}) {
|
|
|
361
377
|
const fakeStuff = makeFakeLiveSlotsStuff(options);
|
|
362
378
|
const { relaxDurabilityRules = true } = options;
|
|
363
379
|
const vrm = makeFakeVirtualReferenceManager(fakeStuff, relaxDurabilityRules);
|
|
380
|
+
fakeStuff.setVrm(vrm);
|
|
364
381
|
return makeFakeCollectionManager(vrm, fakeStuff, options);
|
|
365
382
|
}
|
|
366
383
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prepare Agoric SwingSet vat global environment for testing.
|
|
3
|
+
*
|
|
4
|
+
* Installs Hardened JS (and does lockdown), plus adds mocks for virtual objects
|
|
5
|
+
* and stores.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import '@agoric/internal/src/install-ses-debug.js';
|
|
9
|
+
|
|
10
|
+
import { reincarnate } from './setup-vat-data.js';
|
|
11
|
+
|
|
12
|
+
// Install the VatData globals.
|
|
13
|
+
reincarnate();
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
/* global globalThis */
|
|
3
|
+
// This file produces the globalThis.VatData property outside of a running
|
|
4
|
+
// SwingSet so that it can be used by '@agoric/vat-data' (which only *consumes*
|
|
5
|
+
// `globalThis.VatData`) in code under test.
|
|
6
|
+
import { makeFakeVirtualStuff } from './fakeVirtualSupport.js';
|
|
7
|
+
|
|
8
|
+
const { WeakMap, WeakSet } = globalThis;
|
|
9
|
+
|
|
10
|
+
/** @type {ReturnType<makeFakeVirtualStuff>} */
|
|
11
|
+
let fakeVomKit;
|
|
12
|
+
|
|
13
|
+
globalThis.VatData = harden({
|
|
14
|
+
// @ts-expect-error spread argument for non-rest parameter
|
|
15
|
+
defineKind: (...args) => fakeVomKit.vom.defineKind(...args),
|
|
16
|
+
// @ts-expect-error spread argument for non-rest parameter
|
|
17
|
+
defineKindMulti: (...args) => fakeVomKit.vom.defineKindMulti(...args),
|
|
18
|
+
// @ts-expect-error spread argument for non-rest parameter
|
|
19
|
+
defineDurableKind: (...args) => fakeVomKit.vom.defineDurableKind(...args),
|
|
20
|
+
defineDurableKindMulti: (...args) =>
|
|
21
|
+
// @ts-expect-error spread argument for non-rest parameter
|
|
22
|
+
fakeVomKit.vom.defineDurableKindMulti(...args),
|
|
23
|
+
makeKindHandle: tag => fakeVomKit.vom.makeKindHandle(tag),
|
|
24
|
+
canBeDurable: (...args) => fakeVomKit.vom.canBeDurable(...args),
|
|
25
|
+
providePromiseWatcher: (...args) =>
|
|
26
|
+
// @ts-expect-error spread argument for non-rest parameter
|
|
27
|
+
fakeVomKit.wpm.providePromiseWatcher(...args),
|
|
28
|
+
watchPromise: (p, watcher, ...args) =>
|
|
29
|
+
fakeVomKit.wpm.watchPromise(p, watcher, ...args),
|
|
30
|
+
makeScalarBigMapStore: (...args) =>
|
|
31
|
+
fakeVomKit.cm.makeScalarBigMapStore(...args),
|
|
32
|
+
makeScalarBigWeakMapStore: (...args) =>
|
|
33
|
+
fakeVomKit.cm.makeScalarBigWeakMapStore(...args),
|
|
34
|
+
makeScalarBigSetStore: (...args) =>
|
|
35
|
+
fakeVomKit.cm.makeScalarBigSetStore(...args),
|
|
36
|
+
makeScalarBigWeakSetStore: (...args) =>
|
|
37
|
+
fakeVomKit.cm.makeScalarBigWeakSetStore(...args),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const reincarnate = (options = {}) => {
|
|
41
|
+
const { fakeStore = new Map(), fakeVomKit: fvk } = options;
|
|
42
|
+
|
|
43
|
+
if (options.fakeVomKit) {
|
|
44
|
+
fvk.vom.flushStateCache();
|
|
45
|
+
fvk.cm.flushSchemaCache();
|
|
46
|
+
fvk.vrm.flushIDCounters();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
fakeVomKit = makeFakeVirtualStuff({
|
|
50
|
+
...options,
|
|
51
|
+
fakeStore,
|
|
52
|
+
WeakMap,
|
|
53
|
+
WeakSet,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// @ts-expect-error toStringTag set imperatively so it doesn't show up in the type
|
|
57
|
+
globalThis.WeakMap = fakeVomKit.vom.VirtualObjectAwareWeakMap;
|
|
58
|
+
// @ts-expect-error ditto
|
|
59
|
+
globalThis.WeakSet = fakeVomKit.vom.VirtualObjectAwareWeakSet;
|
|
60
|
+
|
|
61
|
+
return { ...options, fakeStore, fakeVomKit };
|
|
62
|
+
};
|
package/CHANGELOG.md
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
### [0.10.3-u14.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/swingset-liveslots@0.10.3-u13.0...@agoric/swingset-liveslots@0.10.3-u14.0) (2024-02-27)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @agoric/swingset-liveslots
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
### [0.10.3-u13.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/swingset-liveslots@0.10.3-u12.0...@agoric/swingset-liveslots@0.10.3-u13.0) (2023-12-07)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @agoric/swingset-liveslots
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
### [0.10.3-u12.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/swingset-liveslots@0.10.3-u11wf.0...@agoric/swingset-liveslots@0.10.3-u12.0) (2023-11-10)
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package @agoric/swingset-liveslots
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
### [0.10.3-u11wf.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/swingset-liveslots@0.10.3-u11.0...@agoric/swingset-liveslots@0.10.3-u11wf.0) (2023-09-23)
|
|
31
|
-
|
|
32
|
-
**Note:** Version bump only for package @agoric/swingset-liveslots
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
### [0.10.3-u11.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/swingset-liveslots@0.10.2...@agoric/swingset-liveslots@0.10.3-u11.0) (2023-08-24)
|
|
39
|
-
|
|
40
|
-
**Note:** Version bump only for package @agoric/swingset-liveslots
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
### [0.10.2](https://github.com/Agoric/agoric-sdk/compare/@agoric/swingset-liveslots@0.10.1...@agoric/swingset-liveslots@0.10.2) (2023-06-02)
|
|
47
|
-
|
|
48
|
-
**Note:** Version bump only for package @agoric/swingset-liveslots
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
### [0.10.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/swingset-liveslots@0.10.0...@agoric/swingset-liveslots@0.10.1) (2023-05-24)
|
|
55
|
-
|
|
56
|
-
**Note:** Version bump only for package @agoric/swingset-liveslots
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
## 0.10.0 (2023-05-19)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
### Features
|
|
66
|
-
|
|
67
|
-
* better diagnostic for failed reanimate ([c0c9c94](https://github.com/Agoric/agoric-sdk/commit/c0c9c9433648d520aa2bcdbadbbfe877831567c7)), closes [Error#1](https://github.com/Agoric/Error/issues/1)
|
|
68
|
-
* **swingset-liveslots:** label virtual instances ([4191eb6](https://github.com/Agoric/agoric-sdk/commit/4191eb62d0e64048c3c715e5f71a53a747267350))
|
|
69
|
-
* add APIs for tracking/debugging undesired object retention (aka "leaks") ([0a7221b](https://github.com/Agoric/agoric-sdk/commit/0a7221b3c04f3b2894c30346fa2ea6fb0130c046)), closes [#7318](https://github.com/Agoric/agoric-sdk/issues/7318)
|
|
70
|
-
* move liveslots and specific tests to a new package ([0921a89](https://github.com/Agoric/agoric-sdk/commit/0921a8903b72cfefdf05a5906bcfb826cac1cc2f)), closes [#6596](https://github.com/Agoric/agoric-sdk/issues/6596)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
### Bug Fixes
|
|
74
|
-
|
|
75
|
-
* **liveslots:** allow new Kind upgrade to add new facets ([6bc6694](https://github.com/Agoric/agoric-sdk/commit/6bc6694968e6d2f529e7c91ec1efb11fdff2e2d3)), closes [#7437](https://github.com/Agoric/agoric-sdk/issues/7437)
|
|
76
|
-
* **liveslots:** retain WeakRefs to voAware collections ([3935723](https://github.com/Agoric/agoric-sdk/commit/393572396781afd17691e1366abeba696228a24e)), closes [#7371](https://github.com/Agoric/agoric-sdk/issues/7371)
|
|
77
|
-
* **swingset-liveslots:** prevent VOM infinite loop if `globalThis.WeakSet` etc are replaced ([d7b35e2](https://github.com/Agoric/agoric-sdk/commit/d7b35e28715a715ef510f2717e0040fa017caab4))
|
|
78
|
-
* adding dup entries to virtual sets is OK ([c81d367](https://github.com/Agoric/agoric-sdk/commit/c81d3677d8085eb4debe5baa416816ff94d582cf)), closes [#7234](https://github.com/Agoric/agoric-sdk/issues/7234)
|
|
79
|
-
* code updates for new marshal ([292f971](https://github.com/Agoric/agoric-sdk/commit/292f971769db69e61782f96638c2f687c3f95ac2))
|
|
80
|
-
* **SwingSet:** Don't send stopVat during upgrade ([5cc47d2](https://github.com/Agoric/agoric-sdk/commit/5cc47d2d8892690f8c1653630b41dd64cc42d73b)), closes [#6650](https://github.com/Agoric/agoric-sdk/issues/6650)
|
|
81
|
-
* **types:** return value of deleter ([457f576](https://github.com/Agoric/agoric-sdk/commit/457f5765b9fc0a693e6eb5e6644ddf4af3b791db))
|
|
82
|
-
* move many type definitions from swingset to liveslots ([727143d](https://github.com/Agoric/agoric-sdk/commit/727143d5562498e2e3013c34304f229b4dd11da5))
|
|
83
|
-
* move rejectAllPromises from stopVat to kernels-side upgradeVat ([d79623f](https://github.com/Agoric/agoric-sdk/commit/d79623f3fb3b87653dba1c71eb1153711c9d962c)), closes [#6694](https://github.com/Agoric/agoric-sdk/issues/6694)
|
|
84
|
-
* Move upgrade-time abandonExports responsibility into the kernel ([66ac657](https://github.com/Agoric/agoric-sdk/commit/66ac657d51d3d1be61ee4a6e9a621a664086ee57)), closes [#6696](https://github.com/Agoric/agoric-sdk/issues/6696)
|
|
85
|
-
* only the exo api change ([5cf3bf1](https://github.com/Agoric/agoric-sdk/commit/5cf3bf10a71dd02094365a66e87032e5d17d004f))
|
|
86
|
-
* **liveslots:** use Map for vrefStatus, not object ([1456e2a](https://github.com/Agoric/agoric-sdk/commit/1456e2ae006bb1c702383cedda5e5c407968840e))
|
|
87
|
-
* **swingset:** move a bunch of types from swingset to swingset-liveslots ([14f9bb0](https://github.com/Agoric/agoric-sdk/commit/14f9bb00c82c085dc647f23b6c90b26e6a0a6dfd))
|
|
88
|
-
* **swingset-liveslots:** Move promise rejection responsibility into the kernel ([dd29ff3](https://github.com/Agoric/agoric-sdk/commit/dd29ff35c5dc72efbbf7087849182aa7f04b2bb1)), closes [#6694](https://github.com/Agoric/agoric-sdk/issues/6694)
|
|
89
|
-
* add 'v'/'d' virtual/durable annotations to vrefs ([b859e92](https://github.com/Agoric/agoric-sdk/commit/b859e92fe041415d6e34250f672a10ad927aa33e)), closes [#6695](https://github.com/Agoric/agoric-sdk/issues/6695)
|
|
90
|
-
* update description of "FINALIZED" state ([809f366](https://github.com/Agoric/agoric-sdk/commit/809f3660c083467e76deb1487015cb24205a801d))
|
|
91
|
-
* without assertKeyPattern ([#7035](https://github.com/Agoric/agoric-sdk/issues/7035)) ([c9fcd7f](https://github.com/Agoric/agoric-sdk/commit/c9fcd7f82757732435cd96f3377e4fbfb6586ce7))
|
|
92
|
-
* **swingset-liveslots:** copy helper files to new liveslots package ([be7229f](https://github.com/Agoric/agoric-sdk/commit/be7229f7217c1ecc523069a57945a372f4a1e00e))
|
|
93
|
-
* **swingset-liveslots:** update imports of helper files ([0b4b38a](https://github.com/Agoric/agoric-sdk/commit/0b4b38a1f9efbb3e1e860172b0b802548d18ae2e))
|
package/test/kmarshal.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { Far, makeMarshal, passStyleOf } from '@endo/marshal';
|
|
2
|
-
import { assert } from '@agoric/assert';
|
|
3
|
-
|
|
4
|
-
// Simple wrapper for serializing and unserializing marshalled values inside the
|
|
5
|
-
// kernel, where we don't actually want to use clists nor actually allocate real
|
|
6
|
-
// objects, but instead to stay entirely within the domain of krefs. This is
|
|
7
|
-
// used to enable syntactic manipulation of serialized values while remaining
|
|
8
|
-
// agnostic about the internal details of the serialization encoding.
|
|
9
|
-
|
|
10
|
-
const refMap = new WeakMap();
|
|
11
|
-
|
|
12
|
-
export const kslot = (kref, iface) => {
|
|
13
|
-
assert.typeof(kref, 'string');
|
|
14
|
-
if (iface && iface.startsWith('Alleged: ')) {
|
|
15
|
-
// Encoder prepends "Alleged: " to iface string, but the decoder doesn't strip it
|
|
16
|
-
// Unclear whether it's the decoder or me who is wrong
|
|
17
|
-
iface = iface.slice(9);
|
|
18
|
-
}
|
|
19
|
-
if (
|
|
20
|
-
kref.startsWith('p') ||
|
|
21
|
-
kref.startsWith('kp') ||
|
|
22
|
-
kref.startsWith('lp') ||
|
|
23
|
-
kref.startsWith('rp')
|
|
24
|
-
) {
|
|
25
|
-
// TODO: temporary hack because smallcaps encodes promise references
|
|
26
|
-
// differently from remotable object references, and the current version of
|
|
27
|
-
// the smallcaps decoder annoyingly insists that if the encoded body string
|
|
28
|
-
// says a slot is a promise, then convertSlotToVal had better by damn return
|
|
29
|
-
// an actual Promise, even if, as in the intended use case here, we neither
|
|
30
|
-
// want nor need a promise, nor the overhead of a map to keep track of it
|
|
31
|
-
// with. This behavior is in service of defense against a hypothesized
|
|
32
|
-
// security issue whose exact nature has largely been forgotton in the
|
|
33
|
-
// months since it was first encountered. MarkM is currently researching
|
|
34
|
-
// what the problem was thought to have been, to see if it is real and to
|
|
35
|
-
// understand it if so. This will eventually result in either changes to
|
|
36
|
-
// the smallcaps encoding or to the marshal setup API to support the purely
|
|
37
|
-
// manipulative use case. In the meantime, this ugliness...
|
|
38
|
-
const p = new Promise(() => undefined);
|
|
39
|
-
refMap.set(p, kref);
|
|
40
|
-
return harden(p);
|
|
41
|
-
} else {
|
|
42
|
-
const o = Far(iface, {
|
|
43
|
-
iface: () => iface,
|
|
44
|
-
getKref: () => `${kref}`,
|
|
45
|
-
});
|
|
46
|
-
return o;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const krefOf = obj => {
|
|
51
|
-
const fromMap = refMap.get(obj);
|
|
52
|
-
if (fromMap) {
|
|
53
|
-
return fromMap;
|
|
54
|
-
}
|
|
55
|
-
// When krefOf() is called as part of kmarshal.serialize, marshal
|
|
56
|
-
// will only give it things that are 'remotable' (Promises and the
|
|
57
|
-
// Far objects created by kslot()). When krefOf() is called by
|
|
58
|
-
// kernel code (as part of extractSingleSlot() or the vat-comms
|
|
59
|
-
// equivalent), it ought to throw if 'obj' is not one of the Far
|
|
60
|
-
// objects created by our kslot().
|
|
61
|
-
assert.equal(passStyleOf(obj), 'remotable', obj);
|
|
62
|
-
const getKref = obj.getKref;
|
|
63
|
-
assert.typeof(getKref, 'function');
|
|
64
|
-
return getKref();
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const kmarshal = makeMarshal(krefOf, kslot, {
|
|
68
|
-
serializeBodyFormat: 'smallcaps',
|
|
69
|
-
errorTagging: 'off',
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
export const kser = value => kmarshal.serialize(harden(value));
|
|
73
|
-
|
|
74
|
-
export const kunser = serializedValue => kmarshal.unserialize(serializedValue);
|
|
75
|
-
|
|
76
|
-
export function makeError(message) {
|
|
77
|
-
assert.typeof(message, 'string');
|
|
78
|
-
return kser(Error(message));
|
|
79
|
-
}
|