@agoric/swingset-vat 0.32.3-upgrade-16-dev-91eb8f4.0 → 0.32.3-upgrade-17-dev-e67cd91.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/README.md +1 -1
- package/package.json +31 -30
- package/src/controller/controller.js +48 -1
- package/src/controller/initializeKernel.js +35 -10
- package/src/controller/initializeSwingset.js +6 -3
- package/src/controller/startXSnap.js +1 -1
- package/src/controller/upgradeSwingset.js +212 -0
- package/src/devices/bridge/device-bridge.js +1 -1
- package/src/devices/bundle/device-bundle.js +1 -1
- package/src/devices/command/command.js +1 -2
- package/src/devices/command/device-command.js +1 -2
- package/src/devices/lib/deviceTools.js +1 -1
- package/src/devices/loopbox/device-loopbox.js +1 -1
- package/src/devices/loopbox/loopbox.js +1 -1
- package/src/devices/mailbox/device-mailbox.js +1 -2
- package/src/devices/mailbox/mailbox.js +1 -2
- package/src/devices/plugin/device-plugin.js +1 -1
- package/src/devices/timer/device-timer.js +1 -1
- package/src/devices/timer/timer.js +1 -1
- package/src/devices/vat-admin/device-vat-admin.js +4 -2
- package/src/index.js +1 -1
- package/src/kernel/deviceManager.js +1 -1
- package/src/kernel/deviceSlots.js +1 -1
- package/src/kernel/deviceTranslator.js +1 -1
- package/src/kernel/dummyMeterControl.js +1 -1
- package/src/kernel/gc-actions.js +55 -34
- package/src/kernel/kernel.js +216 -51
- package/src/kernel/kernelSyscall.js +2 -13
- package/src/kernel/parseKernelSlots.js +1 -1
- package/src/kernel/slogger.js +2 -2
- package/src/kernel/state/deviceKeeper.js +1 -1
- package/src/kernel/state/kernelKeeper.js +427 -81
- package/src/kernel/state/reachable.js +1 -1
- package/src/kernel/state/stats.js +1 -1
- package/src/kernel/state/storageHelper.js +1 -1
- package/src/kernel/state/vatKeeper.js +159 -44
- package/src/kernel/vat-admin-hooks.js +4 -1
- package/src/kernel/vat-loader/manager-factory.js +1 -2
- package/src/kernel/vat-loader/manager-helper.js +1 -1
- package/src/kernel/vat-loader/manager-local.js +1 -1
- package/src/kernel/vat-loader/manager-subprocess-node.js +1 -1
- package/src/kernel/vat-loader/manager-subprocess-xsnap.js +1 -1
- package/src/kernel/vat-loader/vat-loader.js +2 -2
- package/src/kernel/vat-warehouse.js +5 -1
- package/src/kernel/vatTranslator.js +1 -4
- package/src/lib/assertOptions.js +1 -1
- package/src/lib/capdata.js +1 -1
- package/src/lib/id.js +1 -1
- package/src/lib/message.js +1 -1
- package/src/lib/parseVatSlots.js +1 -1
- package/src/lib/recordVatOptions.js +18 -6
- package/src/lib/runPolicies.js +50 -4
- package/src/lib/storageAPI.js +1 -1
- package/src/lib/workerOptions.js +1 -1
- package/src/supervisors/subprocess-node/supervisor-subprocess-node.js +1 -1
- package/src/types-external.js +71 -22
- package/src/types-internal.js +56 -3
- package/src/vats/comms/clist-inbound.js +1 -1
- package/src/vats/comms/clist-kernel.js +1 -1
- package/src/vats/comms/clist-outbound.js +1 -1
- package/src/vats/comms/controller.js +1 -1
- package/src/vats/comms/delivery.js +1 -1
- package/src/vats/comms/dispatch.js +1 -1
- package/src/vats/comms/gc-comms.js +1 -1
- package/src/vats/comms/parseLocalSlots.js +1 -1
- package/src/vats/comms/parseRemoteSlot.js +1 -1
- package/src/vats/comms/remote.js +1 -1
- package/src/vats/comms/state.js +1 -1
- package/src/vats/timer/vat-timer.js +9 -9
- package/src/vats/vat-admin/vat-vat-admin.js +23 -8
- package/src/vats/vattp/vat-vattp.js +1 -1
- package/tools/bootstrap-relay.js +1 -3
- package/tools/bundleTool.js +9 -1
- package/tools/dvo-test-harness.js +1 -1
- package/tools/manual-timer.js +1 -1
- package/tools/run-utils.js +1 -1
package/src/types-external.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/** @import { ERef } from '@endo/far' */
|
|
1
|
+
/** @import { ERef } from '@endo/far'; */
|
|
2
2
|
|
|
3
3
|
export {};
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @import {Guarded} from '@endo/exo'
|
|
7
|
-
* @import {Passable, RemotableObject} from '@endo/pass-style'
|
|
6
|
+
* @import {Guarded} from '@endo/exo';
|
|
7
|
+
* @import {Passable, RemotableObject} from '@endo/pass-style';
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/* This file defines types that part of the external API of swingset. That
|
|
@@ -28,14 +28,14 @@ export {};
|
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* @typedef {
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* }
|
|
31
|
+
* @typedef {object} KernelOptions
|
|
32
|
+
* @property {ManagerType} [defaultManagerType]
|
|
33
|
+
* @property {number | 'never'} [defaultReapGCKrefs]
|
|
34
|
+
* @property {number | 'never'} [defaultReapInterval]
|
|
35
|
+
* @property {boolean} [relaxDurabilityRules]
|
|
36
|
+
* @property {number} [snapshotInitial]
|
|
37
|
+
* @property {number} [snapshotInterval]
|
|
38
|
+
* @property {boolean} [pinBootstrapRoot]
|
|
39
39
|
*/
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -167,6 +167,7 @@ export {};
|
|
|
167
167
|
* bundleName: string
|
|
168
168
|
* }} BundleName
|
|
169
169
|
* @typedef {(SourceSpec | BundleSpec | BundleRef | BundleName ) & {
|
|
170
|
+
* bundleID?: BundleID,
|
|
170
171
|
* creationOptions?: Record<string, any>,
|
|
171
172
|
* parameters?: Record<string, any>,
|
|
172
173
|
* }} SwingSetConfigProperties
|
|
@@ -218,19 +219,65 @@ export {};
|
|
|
218
219
|
*/
|
|
219
220
|
|
|
220
221
|
/**
|
|
222
|
+
* PolicyInput is used internally within kernel.js, returned by each
|
|
223
|
+
* message processor, and used to decide which of the host's runPolicy
|
|
224
|
+
* methods to invoke. The 'details' portion of PolicyInput is passed
|
|
225
|
+
* as an argument to those methods, so those types are
|
|
226
|
+
* externally-visible.
|
|
227
|
+
*
|
|
228
|
+
* @typedef { { exports: number,
|
|
229
|
+
* imports: number,
|
|
230
|
+
* kv: number,
|
|
231
|
+
* snapshots: number,
|
|
232
|
+
* transcripts: number,
|
|
233
|
+
* } } CleanupWork
|
|
234
|
+
*
|
|
235
|
+
* @typedef { { total: number } & CleanupWork } PolicyInputCleanupCounts
|
|
236
|
+
* @typedef { { cleanups: PolicyInputCleanupCounts, computrons?: bigint } } PolicyInputCleanupDetails
|
|
221
237
|
* @typedef { { computrons?: bigint } } PolicyInputDetails
|
|
238
|
+
*
|
|
222
239
|
* @typedef { [tag: 'none', details: PolicyInputDetails ] } PolicyInputNone
|
|
223
240
|
* @typedef { [tag: 'create-vat', details: PolicyInputDetails ]} PolicyInputCreateVat
|
|
224
241
|
* @typedef { [tag: 'crank', details: PolicyInputDetails ] } PolicyInputCrankComplete
|
|
225
242
|
* @typedef { [tag: 'crank-failed', details: PolicyInputDetails ]} PolicyInputCrankFailed
|
|
226
|
-
* @typedef {
|
|
227
|
-
*
|
|
228
|
-
* @typedef {
|
|
243
|
+
* @typedef { [tag: 'cleanup', details: PolicyInputCleanupDetails] } PolicyInputCleanup
|
|
244
|
+
*
|
|
245
|
+
* @typedef { PolicyInputNone | PolicyInputCreateVat | PolicyInputCrankComplete |
|
|
246
|
+
* PolicyInputCrankFailed | PolicyInputCleanup } PolicyInput
|
|
247
|
+
*
|
|
248
|
+
* CleanupBudget is the internal record used to limit the slow
|
|
249
|
+
* deletion of terminated vats. Each property limits the number of
|
|
250
|
+
* deletions per 'cleanup-terminated-vat' run-queue event, for a
|
|
251
|
+
* specific phase (imports, exports, snapshots, etc). It must always
|
|
252
|
+
* have a 'default' property, which is used for phases that aren't
|
|
253
|
+
* otherwise specified.
|
|
254
|
+
*
|
|
255
|
+
* @typedef { { default: number } & Partial<CleanupWork> } CleanupBudget
|
|
256
|
+
*
|
|
257
|
+
* PolicyOutputCleanupBudget is the return value of
|
|
258
|
+
* runPolicy.allowCleanup(), and tells the kernel how much it is
|
|
259
|
+
* allowed to clean up. It is either a CleanupBudget, or 'true' to
|
|
260
|
+
* allow unlimited cleanup, or 'false' to forbid any cleanup.
|
|
261
|
+
*
|
|
262
|
+
* @typedef {CleanupBudget | true | false} PolicyOutputCleanupBudget
|
|
263
|
+
*
|
|
264
|
+
* PolicyOutput is the boolean returned by all the other runPolicy
|
|
265
|
+
* methods, where 'true' means "keep going", and 'false' means "stop
|
|
266
|
+
* now".
|
|
267
|
+
*
|
|
268
|
+
* @typedef {boolean} PolicyOutput
|
|
269
|
+
*
|
|
270
|
+
* @typedef { {
|
|
271
|
+
* allowCleanup?: () => boolean | PolicyOutputCleanupBudget,
|
|
272
|
+
* vatCreated: (details: {}) => PolicyOutput,
|
|
229
273
|
* crankComplete: (details: { computrons?: bigint }) => PolicyOutput,
|
|
230
274
|
* crankFailed: (details: {}) => PolicyOutput,
|
|
231
275
|
* emptyCrank: () => PolicyOutput,
|
|
276
|
+
* didCleanup?: (details: PolicyInputCleanupDetails) => PolicyOutput,
|
|
232
277
|
* } } RunPolicy
|
|
233
|
-
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
/**
|
|
234
281
|
* @typedef {object} VatWarehousePolicy
|
|
235
282
|
* @property { number } [maxVatsOnline] Limit the number of simultaneous workers
|
|
236
283
|
* @property { boolean } [restartWorkerOnSnapshot] Reload worker immediately upon snapshot creation
|
|
@@ -292,13 +339,15 @@ export {};
|
|
|
292
339
|
* reconstructed via replay. If false, no such record is kept.
|
|
293
340
|
* Defaults to true.
|
|
294
341
|
* @property { number | 'never' } [reapInterval]
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
342
|
+
* Trigger a bringOutYourDead after the vat has received
|
|
343
|
+
* this many deliveries. If the value is 'never',
|
|
344
|
+
* 'bringOutYourDead' will not be triggered by a delivery
|
|
345
|
+
* count (but might be triggered for other reasons).
|
|
346
|
+
* @property { number | 'never' } [reapGCKrefs]
|
|
347
|
+
* Trigger a bringOutYourDead when the vat has been given
|
|
348
|
+
* this many krefs in GC deliveries (dropImports,
|
|
349
|
+
* retireImports, retireExports). If the value is 'never',
|
|
350
|
+
* GC deliveries and their krefs are not treated specially.
|
|
302
351
|
* @property { boolean } [critical]
|
|
303
352
|
*/
|
|
304
353
|
|
package/src/types-internal.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
export {};
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
+
* The host provides (external) KernelOptions as part of the
|
|
5
|
+
* SwingSetConfig record it passes to initializeSwingset(). This
|
|
6
|
+
* internal type represents the modified form passed to
|
|
7
|
+
* initializeKernel() and kernelKeeper.createStartingKernelState .
|
|
8
|
+
*
|
|
9
|
+
* @typedef {object} InternalKernelOptions
|
|
10
|
+
* @property {ManagerType} [defaultManagerType]
|
|
11
|
+
* @property {ReapDirtThreshold} [defaultReapDirtThreshold]
|
|
12
|
+
* @property {boolean} [relaxDurabilityRules]
|
|
13
|
+
* @property {number} [snapshotInitial]
|
|
14
|
+
* @property {number} [snapshotInterval]
|
|
15
|
+
*
|
|
16
|
+
*
|
|
4
17
|
* The internal data that controls which worker we use (and how we use it) is
|
|
5
18
|
* stored in a WorkerOptions record, which comes in "local", "node-subprocess",
|
|
6
19
|
* and "xsnap" flavors.
|
|
@@ -35,11 +48,48 @@ export {};
|
|
|
35
48
|
* @property { boolean } enableSetup
|
|
36
49
|
* @property { boolean } enablePipelining
|
|
37
50
|
* @property { boolean } useTranscript
|
|
38
|
-
* @property {
|
|
51
|
+
* @property { ReapDirtThreshold } reapDirtThreshold
|
|
39
52
|
* @property { boolean } critical
|
|
40
53
|
* @property { MeterID } [meterID] // property must be present, but can be undefined
|
|
41
54
|
* @property { WorkerOptions } workerOptions
|
|
42
55
|
* @property { boolean } enableDisavow
|
|
56
|
+
*
|
|
57
|
+
* @typedef ChangeVatOptions
|
|
58
|
+
* @property {number} [reapInterval]
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Reap/BringOutYourDead/BOYD Scheduling
|
|
63
|
+
*
|
|
64
|
+
* We trigger a BringOutYourDead delivery (which "reaps" all dead
|
|
65
|
+
* objects from the vat) after a certain threshold of "dirt" has
|
|
66
|
+
* accumulated. This type is used to define the thresholds for three
|
|
67
|
+
* counters: 'deliveries', 'gcKrefs', and 'computrons'. If a property
|
|
68
|
+
* is a number, we trigger BOYD when the counter for that property
|
|
69
|
+
* exceeds the threshold value. If a property is the string 'never' or
|
|
70
|
+
* missing we do not use that counter to trigger BOYD.
|
|
71
|
+
*
|
|
72
|
+
* Each vat has a .reapDirtThreshold in their vNN.options record,
|
|
73
|
+
* which overrides the kernel-wide settings in
|
|
74
|
+
* 'kernel.defaultReapDirtThreshold'
|
|
75
|
+
*
|
|
76
|
+
* @typedef {object} ReapDirtThreshold
|
|
77
|
+
* @property {number | 'never'} [deliveries]
|
|
78
|
+
* @property {number | 'never'} [gcKrefs]
|
|
79
|
+
* @property {number | 'never'} [computrons]
|
|
80
|
+
* @property {boolean} [never]
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Each counter in Dirt matches a threshold in
|
|
85
|
+
* ReapDirtThreshold. Missing values are treated as zero, so vats
|
|
86
|
+
* start with {} and accumulate dirt as deliveries are made, until a
|
|
87
|
+
* BOYD clears them.
|
|
88
|
+
*
|
|
89
|
+
* @typedef {object} Dirt
|
|
90
|
+
* @property {number} [deliveries]
|
|
91
|
+
* @property {number} [gcKrefs]
|
|
92
|
+
* @property {number} [computrons]
|
|
43
93
|
*/
|
|
44
94
|
|
|
45
95
|
/**
|
|
@@ -86,17 +136,20 @@ export {};
|
|
|
86
136
|
* @typedef { { type: 'upgrade-vat', vatID: VatID, upgradeID: string,
|
|
87
137
|
* bundleID: BundleID, vatParameters: SwingSetCapData,
|
|
88
138
|
* upgradeMessage: string } } RunQueueEventUpgradeVat
|
|
89
|
-
* @typedef { { type: 'changeVatOptions', vatID: VatID, options:
|
|
139
|
+
* @typedef { { type: 'changeVatOptions', vatID: VatID, options: ChangeVatOptions } } RunQueueEventChangeVatOptions
|
|
90
140
|
* @typedef { { type: 'startVat', vatID: VatID, vatParameters: SwingSetCapData } } RunQueueEventStartVat
|
|
91
141
|
* @typedef { { type: 'dropExports', vatID: VatID, krefs: string[] } } RunQueueEventDropExports
|
|
92
142
|
* @typedef { { type: 'retireExports', vatID: VatID, krefs: string[] } } RunQueueEventRetireExports
|
|
93
143
|
* @typedef { { type: 'retireImports', vatID: VatID, krefs: string[] } } RunQueueEventRetireImports
|
|
94
144
|
* @typedef { { type: 'negated-gc-action', vatID?: VatID } } RunQueueEventNegatedGCAction
|
|
95
145
|
* @typedef { { type: 'bringOutYourDead', vatID: VatID } } RunQueueEventBringOutYourDead
|
|
146
|
+
* @import {CleanupBudget} from './types-external.js';
|
|
147
|
+
* @typedef { { type: 'cleanup-terminated-vat', vatID: VatID,
|
|
148
|
+
* budget: CleanupBudget } } RunQueueEventCleanupTerminatedVat
|
|
96
149
|
* @typedef { RunQueueEventNotify | RunQueueEventSend | RunQueueEventCreateVat |
|
|
97
150
|
* RunQueueEventUpgradeVat | RunQueueEventChangeVatOptions | RunQueueEventStartVat |
|
|
98
151
|
* RunQueueEventDropExports | RunQueueEventRetireExports | RunQueueEventRetireImports |
|
|
99
|
-
* RunQueueEventNegatedGCAction | RunQueueEventBringOutYourDead
|
|
152
|
+
* RunQueueEventNegatedGCAction | RunQueueEventBringOutYourDead | RunQueueEventCleanupTerminatedVat
|
|
100
153
|
* } RunQueueEvent
|
|
101
154
|
*/
|
|
102
155
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Nat } from '@endo/nat';
|
|
2
|
-
import { assert, Fail } from '@
|
|
2
|
+
import { assert, Fail } from '@endo/errors';
|
|
3
3
|
import { kser, kunser, kslot, krefOf } from '@agoric/kmarshal';
|
|
4
4
|
|
|
5
5
|
// deliverToController() is used for local vats which want to talk to us as a
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-use-before-define */
|
|
2
2
|
|
|
3
|
-
import { assert, Fail } from '@
|
|
3
|
+
import { assert, Fail } from '@endo/errors';
|
|
4
4
|
import { kser } from '@agoric/kmarshal';
|
|
5
5
|
import { parseLocalSlot, insistLocalType } from './parseLocalSlots.js';
|
|
6
6
|
import { makeUndeliverableError } from '../../lib/makeUndeliverableError.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Nat } from '@endo/nat';
|
|
2
|
-
import { assert, Fail } from '@
|
|
2
|
+
import { assert, Fail } from '@endo/errors';
|
|
3
3
|
|
|
4
4
|
// Local object/promise references (in the comms vat) contain a two-tuple of
|
|
5
5
|
// (type, index). All object references point to entries in the Local Object
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Nat } from '@endo/nat';
|
|
2
|
-
import { assert, Fail } from '@
|
|
2
|
+
import { assert, Fail } from '@endo/errors';
|
|
3
3
|
|
|
4
4
|
// Object/promise references (in remote messages) contain a three-tuple of
|
|
5
5
|
// (type, allocator flag, index). The allocator flag inside an inbound
|
package/src/vats/comms/remote.js
CHANGED
package/src/vats/comms/state.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* eslint-disable no-use-before-define */
|
|
2
2
|
|
|
3
|
+
import { assert } from '@endo/errors';
|
|
3
4
|
import { Far, E, passStyleOf } from '@endo/far';
|
|
4
5
|
import { makePromiseKit } from '@endo/promise-kit';
|
|
5
6
|
import { Nat } from '@endo/nat';
|
|
6
|
-
import { assert } from '@agoric/assert';
|
|
7
7
|
import {
|
|
8
8
|
provideKindHandle,
|
|
9
9
|
provideDurableMapStore,
|
|
@@ -16,8 +16,8 @@ import { makeScalarWeakMapStore } from '@agoric/store';
|
|
|
16
16
|
import { TimeMath } from '@agoric/time';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* @import {Passable, RemotableObject} from '@endo/pass-style'
|
|
20
|
-
* @import {Key} from '@endo/patterns'
|
|
19
|
+
* @import {Passable, RemotableObject} from '@endo/pass-style';
|
|
20
|
+
* @import {Key} from '@endo/patterns';
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
// This consumes O(N) RAM only for outstanding promises, via wakeAt(),
|
|
@@ -25,12 +25,12 @@ import { TimeMath } from '@agoric/time';
|
|
|
25
25
|
// client). Everything else should remain in the DB.
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* @import {Timestamp} from '@agoric/time'
|
|
29
|
-
* @import {TimestampRecord} from '@agoric/time'
|
|
30
|
-
* @import {TimestampValue} from '@agoric/time'
|
|
31
|
-
* @import {RelativeTime} from '@agoric/time'
|
|
32
|
-
* @import {RelativeTimeValue} from '@agoric/time'
|
|
33
|
-
* @import {TimerService} from '@agoric/time'
|
|
28
|
+
* @import {Timestamp} from '@agoric/time';
|
|
29
|
+
* @import {TimestampRecord} from '@agoric/time';
|
|
30
|
+
* @import {TimestampValue} from '@agoric/time';
|
|
31
|
+
* @import {RelativeTime} from '@agoric/time';
|
|
32
|
+
* @import {RelativeTimeValue} from '@agoric/time';
|
|
33
|
+
* @import {TimerService} from '@agoric/time';
|
|
34
34
|
*
|
|
35
35
|
* @typedef {object} Handler
|
|
36
36
|
* Handler is a user-provided Far object with .wake(time) used for callbacks
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* must ensure that only data goes in and out. It's also responsible for turning
|
|
6
6
|
* device affordances into objects that can be used by code in other vats.
|
|
7
7
|
*/
|
|
8
|
+
import { Nat, isNat } from '@endo/nat';
|
|
9
|
+
import { q, Fail } from '@endo/errors';
|
|
8
10
|
import { makePromiseKit } from '@endo/promise-kit';
|
|
9
11
|
// import { makeNotifierKit } from '@agoric/notifier'; // XXX RESTORE
|
|
10
12
|
import { Far, E, passStyleOf } from '@endo/far';
|
|
11
|
-
import { Nat, isNat } from '@endo/nat';
|
|
12
13
|
import {
|
|
13
14
|
provide,
|
|
14
15
|
makeScalarBigMapStore,
|
|
@@ -17,7 +18,11 @@ import {
|
|
|
17
18
|
prepareSingleton,
|
|
18
19
|
} from '@agoric/vat-data';
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
/**
|
|
22
|
+
* @import {VatAdminRootDeviceNode} from '../../devices/vat-admin/device-vat-admin.js';
|
|
23
|
+
* @import {DProxy} from'../plugin-manager.js';
|
|
24
|
+
* @import {Baggage} from '@agoric/vat-data';
|
|
25
|
+
*/
|
|
21
26
|
|
|
22
27
|
const managerTypes = ['local', 'node-subprocess', 'xsnap', 'xs-worker']; // xs-worker is alias
|
|
23
28
|
|
|
@@ -26,14 +31,25 @@ function producePRR() {
|
|
|
26
31
|
return /** @type {const} */ ([promise, { resolve, reject }]);
|
|
27
32
|
}
|
|
28
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Build root object of the bootstrap vat.
|
|
36
|
+
*
|
|
37
|
+
* @param {VatPowers & {
|
|
38
|
+
* D: DProxy;
|
|
39
|
+
* }} vatPowers
|
|
40
|
+
* @param {never} _vatParameters
|
|
41
|
+
* @param {Baggage} baggage
|
|
42
|
+
*/
|
|
29
43
|
export function buildRootObject(vatPowers, _vatParameters, baggage) {
|
|
30
44
|
const criticalVatKey = prepareSingleton(baggage, 'criticalVatKey', {});
|
|
31
45
|
|
|
32
46
|
const { D } = vatPowers;
|
|
33
47
|
const pendingVatCreations = new Map(); // vatID -> { resolve, reject } for promise
|
|
34
|
-
|
|
48
|
+
/** @type {Map<BundleID, PromiseKit<BundleCap>>} */
|
|
49
|
+
const pendingBundles = new Map();
|
|
35
50
|
const pendingUpgrades = new Map(); // upgradeID -> Promise<UpgradeResults>
|
|
36
51
|
|
|
52
|
+
/** @type {import('../plugin-manager.js').Device<VatAdminRootDeviceNode>} */
|
|
37
53
|
let vatAdminDev;
|
|
38
54
|
|
|
39
55
|
const runningVats = new Map(); // vatID -> [doneP, { resolve, reject }]
|
|
@@ -201,7 +217,7 @@ export function buildRootObject(vatPowers, _vatParameters, baggage) {
|
|
|
201
217
|
console.log(`bundle ${bundleID} missing, hoping for reinstall`);
|
|
202
218
|
return;
|
|
203
219
|
}
|
|
204
|
-
pendingBundles.get(bundleID)
|
|
220
|
+
pendingBundles.get(bundleID)?.resolve(bundlecap);
|
|
205
221
|
pendingBundles.delete(bundleID);
|
|
206
222
|
checkForQuiescence();
|
|
207
223
|
}
|
|
@@ -318,9 +334,7 @@ export function buildRootObject(vatPowers, _vatParameters, baggage) {
|
|
|
318
334
|
noteRunningVat(vatID);
|
|
319
335
|
|
|
320
336
|
const adminNode = makeAdminNode(vatID);
|
|
321
|
-
return E.when(pendingP, root => {
|
|
322
|
-
return { adminNode, root };
|
|
323
|
-
});
|
|
337
|
+
return E.when(pendingP, root => harden({ adminNode, root }));
|
|
324
338
|
}
|
|
325
339
|
|
|
326
340
|
function getCriticalVatKey() {
|
|
@@ -421,8 +435,9 @@ export function buildRootObject(vatPowers, _vatParameters, baggage) {
|
|
|
421
435
|
if (!pendingBundles.has(bundleID)) {
|
|
422
436
|
pendingBundles.set(bundleID, makePromiseKit());
|
|
423
437
|
}
|
|
424
|
-
return pendingBundles.get(bundleID)
|
|
438
|
+
return pendingBundles.get(bundleID)?.promise;
|
|
425
439
|
},
|
|
440
|
+
/** @type {(bundleID: BundleID) => BundleCap} */
|
|
426
441
|
getBundleCap(bundleID) {
|
|
427
442
|
const bundlecap = D(vatAdminDev).getBundleCap(bundleID);
|
|
428
443
|
if (bundlecap) {
|
package/tools/bootstrap-relay.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fail, q } from '@endo/errors';
|
|
2
2
|
import { objectMap } from '@agoric/internal';
|
|
3
3
|
import { Far, E } from '@endo/far';
|
|
4
4
|
import { makePromiseKit } from '@endo/promise-kit';
|
|
5
5
|
import { buildManualTimer } from './manual-timer.js';
|
|
6
6
|
|
|
7
|
-
const { Fail, quote: q } = assert;
|
|
8
|
-
|
|
9
7
|
export const buildRootObject = () => {
|
|
10
8
|
const timer = buildManualTimer();
|
|
11
9
|
let vatAdmin;
|
package/tools/bundleTool.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { makeNodeBundleCache as wrappedMaker } from '@endo/bundle-source/cache.js';
|
|
2
2
|
import styles from 'ansi-styles'; // less authority than 'chalk'
|
|
3
3
|
|
|
4
|
+
/** @type {typeof wrappedMaker} */
|
|
4
5
|
export const makeNodeBundleCache = async (dest, options, loadModule, pid) => {
|
|
5
6
|
const log = (...args) => {
|
|
6
7
|
const flattened = args.map(arg =>
|
|
@@ -16,8 +17,9 @@ export const makeNodeBundleCache = async (dest, options, loadModule, pid) => {
|
|
|
16
17
|
};
|
|
17
18
|
return wrappedMaker(dest, { log, ...options }, loadModule, pid);
|
|
18
19
|
};
|
|
20
|
+
/** @typedef {Awaited<ReturnType<typeof makeNodeBundleCache>>} BundleCache */
|
|
19
21
|
|
|
20
|
-
/** @type {Map<string,
|
|
22
|
+
/** @type {Map<string, Promise<BundleCache>>} */
|
|
21
23
|
const providedCaches = new Map();
|
|
22
24
|
|
|
23
25
|
/**
|
|
@@ -28,9 +30,11 @@ const providedCaches = new Map();
|
|
|
28
30
|
* @param {{ format?: string, dev?: boolean }} options
|
|
29
31
|
* @param {(id: string) => Promise<any>} loadModule
|
|
30
32
|
* @param {number} [pid]
|
|
33
|
+
* @returns {Promise<BundleCache>}
|
|
31
34
|
*/
|
|
32
35
|
export const provideBundleCache = (dest, options, loadModule, pid) => {
|
|
33
36
|
const uniqueDest = [dest, options.format, options.dev].join('-');
|
|
37
|
+
// store the promise instead of awaiting to prevent a race
|
|
34
38
|
let bundleCache = providedCaches.get(uniqueDest);
|
|
35
39
|
if (!bundleCache) {
|
|
36
40
|
bundleCache = makeNodeBundleCache(dest, options, loadModule, pid);
|
|
@@ -40,5 +44,9 @@ export const provideBundleCache = (dest, options, loadModule, pid) => {
|
|
|
40
44
|
};
|
|
41
45
|
harden(provideBundleCache);
|
|
42
46
|
|
|
47
|
+
/**
|
|
48
|
+
* @param {string} dest
|
|
49
|
+
* @returns {Promise<BundleCache>}
|
|
50
|
+
*/
|
|
43
51
|
export const unsafeMakeBundleCache = dest =>
|
|
44
52
|
makeNodeBundleCache(dest, {}, s => import(s));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line import/order
|
|
2
2
|
import { test } from './prepare-test-env-ava.js';
|
|
3
3
|
|
|
4
|
-
import { assert } from '@
|
|
4
|
+
import { assert } from '@endo/errors';
|
|
5
5
|
import { makeMarshal } from '@endo/marshal';
|
|
6
6
|
import { initSwingStore } from '@agoric/swing-store';
|
|
7
7
|
import { initializeSwingset, makeSwingsetController } from '../src/index.js';
|
package/tools/manual-timer.js
CHANGED
package/tools/run-utils.js
CHANGED