@agoric/swingset-liveslots 0.10.3-dev-414e88b.0 → 0.10.3-dev-7728545.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-liveslots",
3
- "version": "0.10.3-dev-414e88b.0+414e88b",
3
+ "version": "0.10.3-dev-7728545.0+7728545",
4
4
  "description": "SwingSet ocap support layer",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -17,9 +17,9 @@
17
17
  "lint:eslint": "eslint ."
18
18
  },
19
19
  "dependencies": {
20
- "@agoric/assert": "0.6.1-dev-414e88b.0+414e88b",
21
- "@agoric/internal": "0.3.3-dev-414e88b.0+414e88b",
22
- "@agoric/store": "0.9.3-dev-414e88b.0+414e88b",
20
+ "@agoric/assert": "0.6.1-dev-7728545.0+7728545",
21
+ "@agoric/internal": "0.3.3-dev-7728545.0+7728545",
22
+ "@agoric/store": "0.9.3-dev-7728545.0+7728545",
23
23
  "@endo/eventual-send": "^0.17.5",
24
24
  "@endo/exo": "^0.2.5",
25
25
  "@endo/far": "^0.2.21",
@@ -31,7 +31,7 @@
31
31
  "@endo/promise-kit": "^0.2.59"
32
32
  },
33
33
  "devDependencies": {
34
- "@agoric/kmarshal": "0.1.1-dev-414e88b.0+414e88b",
34
+ "@agoric/kmarshal": "0.1.1-dev-7728545.0+7728545",
35
35
  "ava": "^5.3.0"
36
36
  },
37
37
  "files": [
@@ -67,5 +67,5 @@
67
67
  "typeCoverage": {
68
68
  "atLeast": 71.48
69
69
  },
70
- "gitHead": "414e88b972e607d7e41cee57c0fc080f62e81f38"
70
+ "gitHead": "7728545e0aeacc459474f51ef0837dbc12c78e52"
71
71
  }
@@ -590,12 +590,12 @@ test('durable kind IDs can be reanimated', t => {
590
590
 
591
591
  // Store it in the store without having used it
592
592
  placeToPutIt.init('savedKindID', kindHandle);
593
- t.is(log.shift(), 'get vc.1.ssavedKindID => undefined');
593
+ t.is(log.shift(), 'get vc.4.ssavedKindID => undefined');
594
594
  t.is(log.shift(), `get vom.rc.${khid} => undefined`);
595
595
  t.is(log.shift(), `set vom.rc.${khid} 1`);
596
- t.is(log.shift(), `set vc.1.ssavedKindID ${vstr(kind)}`);
597
- t.is(log.shift(), 'get vc.1.|entryCount => 0');
598
- t.is(log.shift(), 'set vc.1.|entryCount 1');
596
+ t.is(log.shift(), `set vc.4.ssavedKindID ${vstr(kind)}`);
597
+ t.is(log.shift(), 'get vc.4.|entryCount => 0');
598
+ t.is(log.shift(), 'set vc.4.|entryCount 1');
599
599
  t.deepEqual(log, []);
600
600
 
601
601
  // Forget its Representative
@@ -609,7 +609,7 @@ test('durable kind IDs can be reanimated', t => {
609
609
 
610
610
  // Fetch it from the store, which should reanimate it
611
611
  const fetchedKindID = placeToPutIt.get('savedKindID');
612
- t.is(log.shift(), `get vc.1.ssavedKindID => ${vstr(kind)}`);
612
+ t.is(log.shift(), `get vc.4.ssavedKindID => ${vstr(kind)}`);
613
613
  t.is(
614
614
  log.shift(),
615
615
  'get vom.dkind.10.descriptor => {"kindID":"10","tag":"testkind"}',
@@ -658,9 +658,23 @@ test('virtual object gc', t => {
658
658
  ];
659
659
  t.is(log.shift(), `get storeKindIDTable => undefined`);
660
660
  t.is(log.shift(), `set ${skit[0]} ${skit[1]}`);
661
+ t.is(log.shift(), 'set vc.1.|nextOrdinal 1');
662
+ t.is(log.shift(), 'set vc.1.|entryCount 0');
663
+ t.is(log.shift(), 'get watcherTableID => undefined');
664
+ t.is(log.shift(), 'set vc.2.|nextOrdinal 1');
665
+ t.is(log.shift(), 'set vc.2.|entryCount 0');
666
+ t.is(log.shift(), 'set watcherTableID o+d6/2');
667
+ t.is(log.shift(), 'get vom.rc.o+d6/2 => undefined');
668
+ t.is(log.shift(), 'set vom.rc.o+d6/2 1');
669
+ t.is(log.shift(), 'get watchedPromiseTableID => undefined');
670
+ t.is(log.shift(), 'set vc.3.|nextOrdinal 1');
671
+ t.is(log.shift(), 'set vc.3.|entryCount 0');
672
+ t.is(log.shift(), 'set watchedPromiseTableID o+d6/3');
673
+ t.is(log.shift(), 'get vom.rc.o+d6/3 => undefined');
674
+ t.is(log.shift(), 'set vom.rc.o+d6/3 1');
661
675
  t.is(
662
676
  log.shift(),
663
- `set vom.vkind.10.descriptor {"kindID":"10","tag":"thing"}`,
677
+ 'set vom.vkind.10.descriptor {"kindID":"10","tag":"thing"}',
664
678
  );
665
679
  t.is(log.shift(), `set vom.vkind.11.descriptor {"kindID":"11","tag":"ref"}`);
666
680
  t.deepEqual(log, []);
@@ -686,6 +700,12 @@ test('virtual object gc', t => {
686
700
  t.deepEqual(dumpStore(), [
687
701
  ['kindIDID', '1'],
688
702
  skit,
703
+ ['vc.1.|entryCount', '0'],
704
+ ['vc.1.|nextOrdinal', '1'],
705
+ ['vc.2.|entryCount', '0'],
706
+ ['vc.2.|nextOrdinal', '1'],
707
+ ['vc.3.|entryCount', '0'],
708
+ ['vc.3.|nextOrdinal', '1'],
689
709
  [`vom.${tbase}/1`, minThing('thing #1')],
690
710
  [`vom.${tbase}/2`, minThing('thing #2')],
691
711
  [`vom.${tbase}/3`, minThing('thing #3')],
@@ -695,8 +715,12 @@ test('virtual object gc', t => {
695
715
  [`vom.${tbase}/7`, minThing('thing #7')],
696
716
  [`vom.${tbase}/8`, minThing('thing #8')],
697
717
  [`vom.${tbase}/9`, minThing('thing #9')],
718
+ ['vom.rc.o+d6/2', '1'],
719
+ ['vom.rc.o+d6/3', '1'],
698
720
  ['vom.vkind.10.descriptor', '{"kindID":"10","tag":"thing"}'],
699
721
  ['vom.vkind.11.descriptor', '{"kindID":"11","tag":"ref"}'],
722
+ ['watchedPromiseTableID', 'o+d6/3'],
723
+ ['watcherTableID', 'o+d6/2'],
700
724
  ]);
701
725
 
702
726
  // This is what the finalizer would do if the local reference was dropped and GC'd
@@ -722,6 +746,12 @@ test('virtual object gc', t => {
722
746
  t.deepEqual(dumpStore(), [
723
747
  ['kindIDID', '1'],
724
748
  skit,
749
+ ['vc.1.|entryCount', '0'],
750
+ ['vc.1.|nextOrdinal', '1'],
751
+ ['vc.2.|entryCount', '0'],
752
+ ['vc.2.|nextOrdinal', '1'],
753
+ ['vc.3.|entryCount', '0'],
754
+ ['vc.3.|nextOrdinal', '1'],
725
755
  [`vom.es.${tbase}/1`, 'r'],
726
756
  [`vom.${tbase}/1`, minThing('thing #1')],
727
757
  [`vom.${tbase}/2`, minThing('thing #2')],
@@ -732,8 +762,12 @@ test('virtual object gc', t => {
732
762
  [`vom.${tbase}/7`, minThing('thing #7')],
733
763
  [`vom.${tbase}/8`, minThing('thing #8')],
734
764
  [`vom.${tbase}/9`, minThing('thing #9')],
765
+ ['vom.rc.o+d6/2', '1'],
766
+ ['vom.rc.o+d6/3', '1'],
735
767
  ['vom.vkind.10.descriptor', '{"kindID":"10","tag":"thing"}'],
736
768
  ['vom.vkind.11.descriptor', '{"kindID":"11","tag":"ref"}'],
769
+ ['watchedPromiseTableID', 'o+d6/3'],
770
+ ['watcherTableID', 'o+d6/2'],
737
771
  ]);
738
772
 
739
773
  // drop export -- should delete
@@ -763,6 +797,12 @@ test('virtual object gc', t => {
763
797
  t.deepEqual(dumpStore(), [
764
798
  ['kindIDID', '1'],
765
799
  skit,
800
+ ['vc.1.|entryCount', '0'],
801
+ ['vc.1.|nextOrdinal', '1'],
802
+ ['vc.2.|entryCount', '0'],
803
+ ['vc.2.|nextOrdinal', '1'],
804
+ ['vc.3.|entryCount', '0'],
805
+ ['vc.3.|nextOrdinal', '1'],
766
806
  [`vom.${tbase}/2`, minThing('thing #2')],
767
807
  [`vom.${tbase}/3`, minThing('thing #3')],
768
808
  [`vom.${tbase}/4`, minThing('thing #4')],
@@ -771,8 +811,12 @@ test('virtual object gc', t => {
771
811
  [`vom.${tbase}/7`, minThing('thing #7')],
772
812
  [`vom.${tbase}/8`, minThing('thing #8')],
773
813
  [`vom.${tbase}/9`, minThing('thing #9')],
814
+ ['vom.rc.o+d6/2', '1'],
815
+ ['vom.rc.o+d6/3', '1'],
774
816
  ['vom.vkind.10.descriptor', '{"kindID":"10","tag":"thing"}'],
775
817
  ['vom.vkind.11.descriptor', '{"kindID":"11","tag":"ref"}'],
818
+ ['watchedPromiseTableID', 'o+d6/3'],
819
+ ['watcherTableID', 'o+d6/2'],
776
820
  ]);
777
821
 
778
822
  // case 2: export, drop export, drop local ref
@@ -790,6 +834,12 @@ test('virtual object gc', t => {
790
834
  t.deepEqual(dumpStore(), [
791
835
  ['kindIDID', '1'],
792
836
  skit,
837
+ ['vc.1.|entryCount', '0'],
838
+ ['vc.1.|nextOrdinal', '1'],
839
+ ['vc.2.|entryCount', '0'],
840
+ ['vc.2.|nextOrdinal', '1'],
841
+ ['vc.3.|entryCount', '0'],
842
+ ['vc.3.|nextOrdinal', '1'],
793
843
  [`vom.es.${tbase}/2`, 's'],
794
844
  [`vom.${tbase}/2`, minThing('thing #2')],
795
845
  [`vom.${tbase}/3`, minThing('thing #3')],
@@ -799,8 +849,12 @@ test('virtual object gc', t => {
799
849
  [`vom.${tbase}/7`, minThing('thing #7')],
800
850
  [`vom.${tbase}/8`, minThing('thing #8')],
801
851
  [`vom.${tbase}/9`, minThing('thing #9')],
852
+ ['vom.rc.o+d6/2', '1'],
853
+ ['vom.rc.o+d6/3', '1'],
802
854
  ['vom.vkind.10.descriptor', '{"kindID":"10","tag":"thing"}'],
803
855
  ['vom.vkind.11.descriptor', '{"kindID":"11","tag":"ref"}'],
856
+ ['watchedPromiseTableID', 'o+d6/3'],
857
+ ['watcherTableID', 'o+d6/2'],
804
858
  ]);
805
859
 
806
860
  // drop local ref -- should delete
@@ -821,6 +875,12 @@ test('virtual object gc', t => {
821
875
  t.deepEqual(dumpStore(), [
822
876
  ['kindIDID', '1'],
823
877
  skit,
878
+ ['vc.1.|entryCount', '0'],
879
+ ['vc.1.|nextOrdinal', '1'],
880
+ ['vc.2.|entryCount', '0'],
881
+ ['vc.2.|nextOrdinal', '1'],
882
+ ['vc.3.|entryCount', '0'],
883
+ ['vc.3.|nextOrdinal', '1'],
824
884
  [`vom.${tbase}/3`, minThing('thing #3')],
825
885
  [`vom.${tbase}/4`, minThing('thing #4')],
826
886
  [`vom.${tbase}/5`, minThing('thing #5')],
@@ -828,8 +888,12 @@ test('virtual object gc', t => {
828
888
  [`vom.${tbase}/7`, minThing('thing #7')],
829
889
  [`vom.${tbase}/8`, minThing('thing #8')],
830
890
  [`vom.${tbase}/9`, minThing('thing #9')],
891
+ ['vom.rc.o+d6/2', '1'],
892
+ ['vom.rc.o+d6/3', '1'],
831
893
  ['vom.vkind.10.descriptor', '{"kindID":"10","tag":"thing"}'],
832
894
  ['vom.vkind.11.descriptor', '{"kindID":"11","tag":"ref"}'],
895
+ ['watchedPromiseTableID', 'o+d6/3'],
896
+ ['watcherTableID', 'o+d6/2'],
833
897
  ]);
834
898
 
835
899
  // case 3: drop local ref with no prior export
@@ -851,14 +915,24 @@ test('virtual object gc', t => {
851
915
  t.deepEqual(dumpStore(), [
852
916
  ['kindIDID', '1'],
853
917
  skit,
918
+ ['vc.1.|entryCount', '0'],
919
+ ['vc.1.|nextOrdinal', '1'],
920
+ ['vc.2.|entryCount', '0'],
921
+ ['vc.2.|nextOrdinal', '1'],
922
+ ['vc.3.|entryCount', '0'],
923
+ ['vc.3.|nextOrdinal', '1'],
854
924
  [`vom.${tbase}/4`, minThing('thing #4')],
855
925
  [`vom.${tbase}/5`, minThing('thing #5')],
856
926
  [`vom.${tbase}/6`, minThing('thing #6')],
857
927
  [`vom.${tbase}/7`, minThing('thing #7')],
858
928
  [`vom.${tbase}/8`, minThing('thing #8')],
859
929
  [`vom.${tbase}/9`, minThing('thing #9')],
930
+ ['vom.rc.o+d6/2', '1'],
931
+ ['vom.rc.o+d6/3', '1'],
860
932
  ['vom.vkind.10.descriptor', '{"kindID":"10","tag":"thing"}'],
861
933
  ['vom.vkind.11.descriptor', '{"kindID":"11","tag":"ref"}'],
934
+ ['watchedPromiseTableID', 'o+d6/3'],
935
+ ['watcherTableID', 'o+d6/2'],
862
936
  ]);
863
937
 
864
938
  // case 4: ref virtually, export, drop local ref, drop export
@@ -871,15 +945,25 @@ test('virtual object gc', t => {
871
945
  t.deepEqual(dumpStore(), [
872
946
  ['kindIDID', '1'],
873
947
  skit,
948
+ ['vc.1.|entryCount', '0'],
949
+ ['vc.1.|nextOrdinal', '1'],
950
+ ['vc.2.|entryCount', '0'],
951
+ ['vc.2.|nextOrdinal', '1'],
952
+ ['vc.3.|entryCount', '0'],
953
+ ['vc.3.|nextOrdinal', '1'],
874
954
  [`vom.${tbase}/4`, minThing('thing #4')],
875
955
  [`vom.${tbase}/5`, minThing('thing #5')],
876
956
  [`vom.${tbase}/6`, minThing('thing #6')],
877
957
  [`vom.${tbase}/7`, minThing('thing #7')],
878
958
  [`vom.${tbase}/8`, minThing('thing #8')],
879
959
  [`vom.${tbase}/9`, minThing('thing #9')],
960
+ ['vom.rc.o+d6/2', '1'],
961
+ ['vom.rc.o+d6/3', '1'],
880
962
  [`vom.rc.${tbase}/4`, '1'],
881
963
  ['vom.vkind.10.descriptor', '{"kindID":"10","tag":"thing"}'],
882
964
  ['vom.vkind.11.descriptor', '{"kindID":"11","tag":"ref"}'],
965
+ ['watchedPromiseTableID', 'o+d6/3'],
966
+ ['watcherTableID', 'o+d6/2'],
883
967
  ]);
884
968
  // export
885
969
  setExportStatus(`${tbase}/4`, 'reachable');
@@ -913,6 +997,12 @@ test('virtual object gc', t => {
913
997
  t.deepEqual(dumpStore(), [
914
998
  ['kindIDID', '1'],
915
999
  skit,
1000
+ ['vc.1.|entryCount', '0'],
1001
+ ['vc.1.|nextOrdinal', '1'],
1002
+ ['vc.2.|entryCount', '0'],
1003
+ ['vc.2.|nextOrdinal', '1'],
1004
+ ['vc.3.|entryCount', '0'],
1005
+ ['vc.3.|nextOrdinal', '1'],
916
1006
  [`vom.es.${tbase}/4`, 's'],
917
1007
  [`vom.es.${tbase}/5`, 'r'],
918
1008
  [`vom.${tbase}/4`, minThing('thing #4')],
@@ -921,10 +1011,14 @@ test('virtual object gc', t => {
921
1011
  [`vom.${tbase}/7`, minThing('thing #7')],
922
1012
  [`vom.${tbase}/8`, minThing('thing #8')],
923
1013
  [`vom.${tbase}/9`, minThing('thing #9')],
1014
+ ['vom.rc.o+d6/2', '1'],
1015
+ ['vom.rc.o+d6/3', '1'],
924
1016
  [`vom.rc.${tbase}/4`, '1'],
925
1017
  [`vom.rc.${tbase}/5`, '1'],
926
1018
  ['vom.vkind.10.descriptor', '{"kindID":"10","tag":"thing"}'],
927
1019
  ['vom.vkind.11.descriptor', '{"kindID":"11","tag":"ref"}'],
1020
+ ['watchedPromiseTableID', 'o+d6/3'],
1021
+ ['watcherTableID', 'o+d6/2'],
928
1022
  ]);
929
1023
  // drop local ref -- should not delete because ref'd virtually AND exported
930
1024
  pretendGC(`${tbase}/5`, false);
@@ -948,6 +1042,12 @@ test('virtual object gc', t => {
948
1042
  t.deepEqual(dumpStore(), [
949
1043
  ['kindIDID', '1'],
950
1044
  skit,
1045
+ ['vc.1.|entryCount', '0'],
1046
+ ['vc.1.|nextOrdinal', '1'],
1047
+ ['vc.2.|entryCount', '0'],
1048
+ ['vc.2.|nextOrdinal', '1'],
1049
+ ['vc.3.|entryCount', '0'],
1050
+ ['vc.3.|nextOrdinal', '1'],
951
1051
  [`vom.es.${tbase}/4`, 's'],
952
1052
  [`vom.es.${tbase}/5`, 's'],
953
1053
  [`vom.${tbase}/4`, minThing('thing #4')],
@@ -956,11 +1056,15 @@ test('virtual object gc', t => {
956
1056
  [`vom.${tbase}/7`, minThing('thing #7')],
957
1057
  [`vom.${tbase}/8`, minThing('thing #8')],
958
1058
  [`vom.${tbase}/9`, minThing('thing #9')],
1059
+ ['vom.rc.o+d6/2', '1'],
1060
+ ['vom.rc.o+d6/3', '1'],
959
1061
  [`vom.rc.${tbase}/4`, '1'],
960
1062
  [`vom.rc.${tbase}/5`, '1'],
961
1063
  [`vom.rc.${tbase}/6`, '1'],
962
1064
  ['vom.vkind.10.descriptor', '{"kindID":"10","tag":"thing"}'],
963
1065
  ['vom.vkind.11.descriptor', '{"kindID":"11","tag":"ref"}'],
1066
+ ['watchedPromiseTableID', 'o+d6/3'],
1067
+ ['watcherTableID', 'o+d6/2'],
964
1068
  ]);
965
1069
  // drop local ref -- should not delete because ref'd virtually
966
1070
  pretendGC(`${tbase}/6`, false);
@@ -970,6 +1074,12 @@ test('virtual object gc', t => {
970
1074
  t.deepEqual(dumpStore(), [
971
1075
  ['kindIDID', '1'],
972
1076
  skit,
1077
+ ['vc.1.|entryCount', '0'],
1078
+ ['vc.1.|nextOrdinal', '1'],
1079
+ ['vc.2.|entryCount', '0'],
1080
+ ['vc.2.|nextOrdinal', '1'],
1081
+ ['vc.3.|entryCount', '0'],
1082
+ ['vc.3.|nextOrdinal', '1'],
973
1083
  [`vom.es.${tbase}/4`, 's'],
974
1084
  [`vom.es.${tbase}/5`, 's'],
975
1085
  [`vom.${tbase}/4`, minThing('thing #4')],
@@ -978,11 +1088,15 @@ test('virtual object gc', t => {
978
1088
  [`vom.${tbase}/7`, minThing('thing #7')],
979
1089
  [`vom.${tbase}/8`, minThing('thing #8')],
980
1090
  [`vom.${tbase}/9`, minThing('thing #9')],
1091
+ ['vom.rc.o+d6/2', '1'],
1092
+ ['vom.rc.o+d6/3', '1'],
981
1093
  [`vom.rc.${tbase}/4`, '1'],
982
1094
  [`vom.rc.${tbase}/5`, '1'],
983
1095
  [`vom.rc.${tbase}/6`, '1'],
984
1096
  ['vom.vkind.10.descriptor', '{"kindID":"10","tag":"thing"}'],
985
1097
  ['vom.vkind.11.descriptor', '{"kindID":"11","tag":"ref"}'],
1098
+ ['watchedPromiseTableID', 'o+d6/3'],
1099
+ ['watcherTableID', 'o+d6/2'],
986
1100
  ]);
987
1101
  });
988
1102
 
@@ -2,8 +2,9 @@
2
2
  /* eslint-disable max-classes-per-file */
3
3
  import { makeMarshal } from '@endo/marshal';
4
4
  import { assert } from '@agoric/assert';
5
- import { parseVatSlot } from '../src/parseVatSlots.js';
5
+ import { isPromise } from '@endo/promise-kit';
6
6
 
7
+ import { parseVatSlot } from '../src/parseVatSlots.js';
7
8
  import { makeVirtualReferenceManager } from '../src/virtualReferences.js';
8
9
  import { makeWatchedPromiseManager } from '../src/watchedPromises.js';
9
10
  import { makeFakeVirtualObjectManager } from './fakeVirtualObjectManager.js';
@@ -163,6 +164,10 @@ export function makeFakeLiveSlotsStuff(options = {}) {
163
164
  return vrm.allocateNextID('exportID');
164
165
  }
165
166
 
167
+ function allocatePromiseID() {
168
+ return vrm.allocateNextID('promiseID');
169
+ }
170
+
166
171
  function allocateCollectionID() {
167
172
  return vrm.allocateNextID('collectionID');
168
173
  }
@@ -195,7 +200,9 @@ export function makeFakeLiveSlotsStuff(options = {}) {
195
200
 
196
201
  function convertValToSlot(val) {
197
202
  if (!valToSlot.has(val)) {
198
- const slot = `o+${allocateExportID()}`;
203
+ const slot = isPromise(val)
204
+ ? `p+${allocatePromiseID()}`
205
+ : `o+${allocateExportID()}`;
199
206
  valToSlot.set(val, slot);
200
207
  setValForSlot(slot, val);
201
208
  }
@@ -324,6 +331,7 @@ export function makeFakeWatchedPromiseManager(
324
331
  maybeExportPromise: fakeStuff.maybeExportPromise,
325
332
  });
326
333
  }
334
+
327
335
  /**
328
336
  * Configure virtual stuff with relaxed durability rules and fake liveslots
329
337
  *
@@ -348,6 +356,7 @@ export function makeFakeVirtualStuff(options = {}) {
348
356
  vom.initializeKindHandleKind();
349
357
  const cm = makeFakeCollectionManager(vrm, fakeStuff, actualOptions);
350
358
  const wpm = makeFakeWatchedPromiseManager(vrm, vom, cm, fakeStuff);
359
+ wpm.preparePromiseWatcherTables();
351
360
  return { fakeStuff, vrm, vom, cm, wpm };
352
361
  }
353
362