@agoric/swingset-vat 0.33.0-upgrade-16-dev-0df76a7.0 → 0.33.0-upgrade-17-dev-a61cdab.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.
Files changed (76) hide show
  1. package/README.md +1 -1
  2. package/package.json +31 -30
  3. package/src/controller/controller.js +48 -1
  4. package/src/controller/initializeKernel.js +35 -10
  5. package/src/controller/initializeSwingset.js +6 -3
  6. package/src/controller/startXSnap.js +1 -1
  7. package/src/controller/upgradeSwingset.js +212 -0
  8. package/src/devices/bridge/device-bridge.js +1 -1
  9. package/src/devices/bundle/device-bundle.js +1 -1
  10. package/src/devices/command/command.js +1 -2
  11. package/src/devices/command/device-command.js +1 -2
  12. package/src/devices/lib/deviceTools.js +1 -1
  13. package/src/devices/loopbox/device-loopbox.js +1 -1
  14. package/src/devices/loopbox/loopbox.js +1 -1
  15. package/src/devices/mailbox/device-mailbox.js +1 -2
  16. package/src/devices/mailbox/mailbox.js +1 -2
  17. package/src/devices/plugin/device-plugin.js +1 -1
  18. package/src/devices/timer/device-timer.js +1 -1
  19. package/src/devices/timer/timer.js +1 -1
  20. package/src/devices/vat-admin/device-vat-admin.js +4 -2
  21. package/src/index.js +1 -1
  22. package/src/kernel/deviceManager.js +1 -1
  23. package/src/kernel/deviceSlots.js +1 -1
  24. package/src/kernel/deviceTranslator.js +1 -1
  25. package/src/kernel/dummyMeterControl.js +1 -1
  26. package/src/kernel/gc-actions.js +55 -34
  27. package/src/kernel/kernel.js +216 -51
  28. package/src/kernel/kernelSyscall.js +2 -13
  29. package/src/kernel/parseKernelSlots.js +1 -1
  30. package/src/kernel/slogger.js +2 -2
  31. package/src/kernel/state/deviceKeeper.js +1 -1
  32. package/src/kernel/state/kernelKeeper.js +427 -81
  33. package/src/kernel/state/reachable.js +1 -1
  34. package/src/kernel/state/stats.js +1 -1
  35. package/src/kernel/state/storageHelper.js +1 -1
  36. package/src/kernel/state/vatKeeper.js +159 -44
  37. package/src/kernel/vat-admin-hooks.js +4 -1
  38. package/src/kernel/vat-loader/manager-factory.js +1 -2
  39. package/src/kernel/vat-loader/manager-helper.js +1 -1
  40. package/src/kernel/vat-loader/manager-local.js +1 -1
  41. package/src/kernel/vat-loader/manager-subprocess-node.js +1 -1
  42. package/src/kernel/vat-loader/manager-subprocess-xsnap.js +1 -1
  43. package/src/kernel/vat-loader/vat-loader.js +2 -2
  44. package/src/kernel/vat-warehouse.js +5 -1
  45. package/src/kernel/vatTranslator.js +1 -4
  46. package/src/lib/assertOptions.js +1 -1
  47. package/src/lib/capdata.js +1 -1
  48. package/src/lib/id.js +1 -1
  49. package/src/lib/message.js +1 -1
  50. package/src/lib/parseVatSlots.js +1 -1
  51. package/src/lib/recordVatOptions.js +18 -6
  52. package/src/lib/runPolicies.js +50 -4
  53. package/src/lib/storageAPI.js +1 -1
  54. package/src/lib/workerOptions.js +1 -1
  55. package/src/supervisors/subprocess-node/supervisor-subprocess-node.js +1 -1
  56. package/src/types-external.js +71 -22
  57. package/src/types-internal.js +56 -3
  58. package/src/vats/comms/clist-inbound.js +1 -1
  59. package/src/vats/comms/clist-kernel.js +1 -1
  60. package/src/vats/comms/clist-outbound.js +1 -1
  61. package/src/vats/comms/controller.js +1 -1
  62. package/src/vats/comms/delivery.js +1 -1
  63. package/src/vats/comms/dispatch.js +1 -1
  64. package/src/vats/comms/gc-comms.js +1 -1
  65. package/src/vats/comms/parseLocalSlots.js +1 -1
  66. package/src/vats/comms/parseRemoteSlot.js +1 -1
  67. package/src/vats/comms/remote.js +1 -1
  68. package/src/vats/comms/state.js +1 -1
  69. package/src/vats/timer/vat-timer.js +9 -9
  70. package/src/vats/vat-admin/vat-vat-admin.js +23 -8
  71. package/src/vats/vattp/vat-vattp.js +1 -1
  72. package/tools/bootstrap-relay.js +1 -3
  73. package/tools/bundleTool.js +9 -1
  74. package/tools/dvo-test-harness.js +1 -1
  75. package/tools/manual-timer.js +1 -1
  76. package/tools/run-utils.js +1 -1
package/src/index.js CHANGED
@@ -9,7 +9,7 @@ export {
9
9
  loadBasedir,
10
10
  loadSwingsetConfigFile,
11
11
  } from './controller/initializeSwingset.js';
12
-
12
+ export { upgradeSwingset } from './controller/upgradeSwingset.js';
13
13
  export {
14
14
  buildMailboxStateMap,
15
15
  buildMailbox,
@@ -1,4 +1,4 @@
1
- import { assert, Fail } from '@agoric/assert';
1
+ import { assert, Fail } from '@endo/errors';
2
2
  import { makeDeviceSlots } from './deviceSlots.js';
3
3
  import { insistCapData } from '../lib/capdata.js';
4
4
 
@@ -1,6 +1,6 @@
1
1
  import { Remotable, makeMarshal } from '@endo/marshal';
2
2
  import { passStyleOf } from '@endo/far';
3
- import { assert, Fail } from '@agoric/assert';
3
+ import { assert, Fail } from '@endo/errors';
4
4
  import {
5
5
  insistVatType,
6
6
  makeVatSlot,
@@ -1,5 +1,5 @@
1
1
  // @ts-nocheck
2
- import { assert, Fail } from '@agoric/assert';
2
+ import { assert, Fail } from '@endo/errors';
3
3
  import { insistMessage } from '../lib/message.js';
4
4
  import { insistKernelType } from './parseKernelSlots.js';
5
5
  import { insistVatType, parseVatSlot } from '../lib/parseVatSlots.js';
@@ -1,4 +1,4 @@
1
- import { assert } from '@agoric/assert';
1
+ import { assert } from '@endo/errors';
2
2
 
3
3
  export function makeDummyMeterControl() {
4
4
  let meteringDisabled = 0;
@@ -1,10 +1,15 @@
1
- import { Fail } from '@agoric/assert';
1
+ import { Fail } from '@endo/errors';
2
2
  import { insistKernelType } from './parseKernelSlots.js';
3
3
  import { insistVatID } from '../lib/id.js';
4
4
 
5
+ /** @import {TotalMap} from '@agoric/internal'; */
6
+
5
7
  /**
8
+ * @typedef {`v${number}`} VatID
9
+ * @typedef {`ko${number}`} KOID
6
10
  * @typedef {'dropExport' | 'retireExport' | 'retireImport'} GCActionType
7
11
  * @typedef {'dropExports' | 'retireExports' | 'retireImports'} GCQueueEventType
12
+ * @typedef {`${VatID} ${GCActionType} ${KOID}`} GCActionString
8
13
  */
9
14
 
10
15
  /**
@@ -16,17 +21,23 @@ const actionTypePriorities = ['dropExport', 'retireExport', 'retireImport'];
16
21
 
17
22
  /**
18
23
  * A mapping of GC action type to queue event type.
19
- *
20
- * @type {Map<GCActionType, GCQueueEventType>}
21
24
  */
22
- const queueTypeFromActionType = new Map([
23
- ['dropExport', 'dropExports'],
24
- ['retireExport', 'retireExports'],
25
- ['retireImport', 'retireImports'],
26
- ]);
25
+ const queueTypeFromActionType =
26
+ /** @type {TotalMap<GCActionType, GCQueueEventType>} */ (
27
+ new Map([
28
+ ['dropExport', 'dropExports'],
29
+ ['retireExport', 'retireExports'],
30
+ ['retireImport', 'retireImports'],
31
+ ])
32
+ );
27
33
 
34
+ /**
35
+ * @param {GCActionString} s
36
+ */
28
37
  function parseAction(s) {
29
- const [vatID, type, kref] = s.split(' ');
38
+ const [vatID, type, kref] = /** @type {[VatID, GCActionType, KOID]} */ (
39
+ s.split(' ')
40
+ );
30
41
  insistVatID(vatID);
31
42
  queueTypeFromActionType.has(type) || Fail`unknown type ${type}`;
32
43
  insistKernelType('object', kref);
@@ -62,11 +73,16 @@ export function processGCActionSet(kernelKeeper) {
62
73
  // we must bypass the action as redundant (since it's an error to delete
63
74
  // the same c-list entry twice).
64
75
 
65
- // This `filterAction` function looks at each queued GC Action and decides
66
- // whether the current state of the c-lsits and reference counts warrants
67
- // permits the action to run, or if it should be negated/bypassed.
68
-
69
- function filterAction(vatKeeper, action, type, kref) {
76
+ /**
77
+ * Inspect a queued GC action and decide whether the current state of c-lists
78
+ * and reference counts warrants processing it, or if it should instead be
79
+ * negated/bypassed.
80
+ *
81
+ * @param {import('../types-external.js').VatKeeper} vatKeeper
82
+ * @param {GCActionType} type
83
+ * @param {KOID} kref
84
+ */
85
+ function shouldProcessAction(vatKeeper, type, kref) {
70
86
  const hasCList = vatKeeper.hasCListEntry(kref);
71
87
  const isReachable = hasCList ? vatKeeper.getReachableFlag(kref) : undefined;
72
88
  const exists = kernelKeeper.kernelObjectExists(kref);
@@ -107,12 +123,16 @@ export function processGCActionSet(kernelKeeper) {
107
123
  // may need to change to support that, to ensure that `dropExport` and
108
124
  // `retireExport` can both be delivered.
109
125
 
110
- function filterActions(vatID, groupedActions) {
126
+ /**
127
+ * @param {VatID} vatID
128
+ * @param {GCActionString[]} groupedActions
129
+ */
130
+ function krefsToProcess(vatID, groupedActions) {
111
131
  const vatKeeper = kernelKeeper.provideVatKeeper(vatID);
112
132
  const krefs = [];
113
133
  for (const action of groupedActions) {
114
134
  const { type, kref } = parseAction(action);
115
- if (filterAction(vatKeeper, action, type, kref)) {
135
+ if (shouldProcessAction(vatKeeper, type, kref)) {
116
136
  krefs.push(kref);
117
137
  }
118
138
  allActionsSet.delete(action);
@@ -121,49 +141,50 @@ export function processGCActionSet(kernelKeeper) {
121
141
  return krefs;
122
142
  }
123
143
 
124
- const grouped = new Map(); // grouped.get(vatID).get(type) = krefs to process
144
+ /** @type {TotalMap<VatID, TotalMap<GCActionType, GCActionString[]>>} */
145
+ const actionsByVat = new Map();
125
146
  for (const action of allActionsSet) {
126
147
  const { vatID, type } = parseAction(action);
127
- if (!grouped.has(vatID)) {
128
- grouped.set(vatID, new Map());
148
+ if (!actionsByVat.has(vatID)) {
149
+ actionsByVat.set(vatID, new Map());
129
150
  }
130
- const forVat = grouped.get(vatID);
131
- if (!forVat.has(type)) {
132
- forVat.set(type, []);
151
+ const actionsForVatByType = actionsByVat.get(vatID);
152
+ if (!actionsForVatByType.has(type)) {
153
+ actionsForVatByType.set(type, []);
133
154
  }
134
- forVat.get(type).push(action);
155
+ actionsForVatByType.get(type).push(action);
135
156
  }
136
157
 
137
- const vatIDs = Array.from(grouped.keys());
158
+ const vatIDs = Array.from(actionsByVat.keys());
138
159
  vatIDs.sort();
139
160
  for (const vatID of vatIDs) {
140
- const forVat = grouped.get(vatID);
161
+ const actionsForVatByType = actionsByVat.get(vatID);
141
162
  // find the highest-priority type of work to do within this vat
142
163
  for (const type of actionTypePriorities) {
143
- if (forVat.has(type)) {
144
- const actions = forVat.get(type);
145
- const krefs = filterActions(vatID, actions);
164
+ if (actionsForVatByType.has(type)) {
165
+ const actions = actionsForVatByType.get(type);
166
+ const krefs = krefsToProcess(vatID, actions);
146
167
  if (krefs.length) {
147
168
  // at last, we act
148
169
  krefs.sort();
149
170
  // remove the work we're about to do from the durable set
150
171
  kernelKeeper.setGCActions(allActionsSet);
151
- const queueType = /** @type {GCQueueEventType} */ (
152
- queueTypeFromActionType.get(type)
153
- );
172
+ const queueType = queueTypeFromActionType.get(type);
154
173
  return harden({ type: queueType, vatID, krefs });
155
174
  }
156
175
  }
157
176
  }
158
177
  }
178
+
159
179
  if (actionSetUpdated) {
160
180
  // remove negated items from the durable set
161
181
  kernelKeeper.setGCActions(allActionsSet);
162
- // return a special gc-nop event to tell kernel to record our
182
+ // return a special event to tell kernel to record our
163
183
  // DB changes in their own crank
164
184
  return harden({ type: 'negated-gc-action', vatID: undefined });
165
- } else {
166
- return undefined; // no GC work to do and no DB changes
167
185
  }
186
+
187
+ // no GC work to do and no DB changes
188
+ return undefined;
168
189
  }
169
190
  harden(processGCActionSet);