@agoric/cosmic-swingset 0.41.4-dev-b31bd09.0 → 0.41.4-dev-1976c50.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/cosmic-swingset",
3
- "version": "0.41.4-dev-b31bd09.0+b31bd09",
3
+ "version": "0.41.4-dev-1976c50.0+1976c50",
4
4
  "description": "Agoric's Cosmos blockchain integration",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,15 +22,15 @@
22
22
  "author": "Agoric",
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
- "@agoric/builders": "0.1.1-dev-b31bd09.0+b31bd09",
26
- "@agoric/cosmos": "0.34.2-dev-b31bd09.0+b31bd09",
27
- "@agoric/deploy-script-support": "0.10.4-dev-b31bd09.0+b31bd09",
28
- "@agoric/internal": "0.3.3-dev-b31bd09.0+b31bd09",
29
- "@agoric/store": "0.9.3-dev-b31bd09.0+b31bd09",
30
- "@agoric/swing-store": "0.9.2-dev-b31bd09.0+b31bd09",
31
- "@agoric/swingset-vat": "0.32.3-dev-b31bd09.0+b31bd09",
32
- "@agoric/telemetry": "0.6.3-dev-b31bd09.0+b31bd09",
33
- "@agoric/vm-config": "0.1.1-dev-b31bd09.0+b31bd09",
25
+ "@agoric/builders": "0.1.1-dev-1976c50.0+1976c50",
26
+ "@agoric/cosmos": "0.34.2-dev-1976c50.0+1976c50",
27
+ "@agoric/deploy-script-support": "0.10.4-dev-1976c50.0+1976c50",
28
+ "@agoric/internal": "0.3.3-dev-1976c50.0+1976c50",
29
+ "@agoric/store": "0.9.3-dev-1976c50.0+1976c50",
30
+ "@agoric/swing-store": "0.9.2-dev-1976c50.0+1976c50",
31
+ "@agoric/swingset-vat": "0.32.3-dev-1976c50.0+1976c50",
32
+ "@agoric/telemetry": "0.6.3-dev-1976c50.0+1976c50",
33
+ "@agoric/vm-config": "0.1.1-dev-1976c50.0+1976c50",
34
34
  "@endo/bundle-source": "^3.4.0",
35
35
  "@endo/env-options": "^1.1.6",
36
36
  "@endo/errors": "^1.2.5",
@@ -39,6 +39,7 @@
39
39
  "@endo/init": "^1.1.4",
40
40
  "@endo/marshal": "^1.5.3",
41
41
  "@endo/nat": "^5.0.10",
42
+ "@endo/patterns": "^1.4.3",
42
43
  "@endo/promise-kit": "^1.1.5",
43
44
  "@iarna/toml": "^2.2.3",
44
45
  "@opentelemetry/api": "~1.3.0",
@@ -70,5 +71,5 @@
70
71
  "typeCoverage": {
71
72
  "atLeast": 80.6
72
73
  },
73
- "gitHead": "b31bd097f992f1a6eb83c9cba42ea97752efd061"
74
+ "gitHead": "1976c502bcaac2e7d21f42b30447671a61053236"
74
75
  }
package/src/chain-main.js CHANGED
@@ -12,6 +12,9 @@ import { fork } from 'node:child_process';
12
12
 
13
13
  import { Fail, q } from '@endo/errors';
14
14
  import { E } from '@endo/far';
15
+ import { makeMarshal } from '@endo/marshal';
16
+ import { isNat } from '@endo/nat';
17
+ import { M, mustMatch } from '@endo/patterns';
15
18
  import engineGC from '@agoric/internal/src/lib-nodejs/engine-gc.js';
16
19
  import { waitUntilQuiescent } from '@agoric/internal/src/lib-nodejs/waitUntilQuiescent.js';
17
20
  import {
@@ -25,7 +28,6 @@ import {
25
28
  makeChainStorageRoot,
26
29
  makeSerializeToStorage,
27
30
  } from '@agoric/internal/src/lib-chainStorage.js';
28
- import { makeMarshal } from '@endo/marshal';
29
31
  import { makeShutdown } from '@agoric/internal/src/node/shutdown.js';
30
32
 
31
33
  import * as STORAGE_PATH from '@agoric/internal/src/chain-storage-paths.js';
@@ -72,7 +74,27 @@ const toNumber = specimen => {
72
74
  * @typedef {object} CosmosSwingsetConfig
73
75
  * @property {string} [slogfile]
74
76
  * @property {number} [maxVatsOnline]
77
+ * @property {'debug' | 'operational'} [vatSnapshotRetention]
78
+ * @property {'archival' | 'operational'} [vatTranscriptRetention]
75
79
  */
80
+ const SwingsetConfigShape = M.splitRecord(
81
+ // All known properties are optional, but unknown properties are not allowed.
82
+ {},
83
+ {
84
+ slogfile: M.string(),
85
+ maxVatsOnline: M.number(),
86
+ vatSnapshotRetention: M.or('debug', 'operational'),
87
+ vatTranscriptRetention: M.or('archival', 'operational'),
88
+ },
89
+ {},
90
+ );
91
+ const validateSwingsetConfig = swingsetConfig => {
92
+ mustMatch(swingsetConfig, SwingsetConfigShape);
93
+ const { maxVatsOnline } = swingsetConfig;
94
+ maxVatsOnline === undefined ||
95
+ (isNat(maxVatsOnline) && maxVatsOnline > 0) ||
96
+ Fail`maxVatsOnline must be a positive integer`;
97
+ };
76
98
 
77
99
  /**
78
100
  * A boot message consists of cosmosInitAction fields that are subject to
@@ -100,19 +122,6 @@ const makeBootMsg = initAction => {
100
122
  };
101
123
  };
102
124
 
103
- /**
104
- * Extract local Swingset-specific configuration which is
105
- * not part of the consensus.
106
- *
107
- * @param {CosmosSwingsetConfig} [resolvedConfig]
108
- */
109
- const makeSwingsetConfig = resolvedConfig => {
110
- const { maxVatsOnline } = resolvedConfig || {};
111
- return {
112
- maxVatsOnline,
113
- };
114
- };
115
-
116
125
  /**
117
126
  * @template {unknown} [T=unknown]
118
127
  * @param {(req: string) => string} call
@@ -301,13 +310,24 @@ export default async function main(progname, args, { env, homedir, agcc }) {
301
310
  // here so 'sendToChainStorage' can close over the single mutable instance,
302
311
  // when we updated the 'portNums.storage' value each time toSwingSet was called.
303
312
  async function launchAndInitializeSwingSet(initAction) {
313
+ const { XSNAP_KEEP_SNAPSHOTS, NODE_HEAP_SNAPSHOTS = -1 } = env;
314
+
315
+ /** @type {CosmosSwingsetConfig} */
316
+ const swingsetConfig = harden(initAction.resolvedConfig || {});
317
+ validateSwingsetConfig(swingsetConfig);
318
+ const { slogfile, vatSnapshotRetention, vatTranscriptRetention } =
319
+ swingsetConfig;
320
+ const keepSnapshots = vatSnapshotRetention
321
+ ? vatSnapshotRetention !== 'operational'
322
+ : ['1', 'true'].includes(XSNAP_KEEP_SNAPSHOTS);
323
+ const keepTranscripts = vatTranscriptRetention
324
+ ? vatTranscriptRetention !== 'operational'
325
+ : false;
326
+
304
327
  // As a kludge, back-propagate selected configuration into environment variables.
305
- const { slogfile } = initAction.resolvedConfig || {};
306
328
  // eslint-disable-next-line dot-notation
307
329
  if (slogfile) env['SLOGFILE'] = slogfile;
308
330
 
309
- const swingsetConfig = makeSwingsetConfig(initAction.resolvedConfig);
310
-
311
331
  const sendToChainStorage = msg => chainSend(portNums.storage, msg);
312
332
  // this object is used to store the mailbox state.
313
333
  const fromBridgeMailbox = data => {
@@ -442,7 +462,6 @@ export default async function main(progname, args, { env, homedir, agcc }) {
442
462
  serviceName: TELEMETRY_SERVICE_NAME,
443
463
  });
444
464
 
445
- const { XSNAP_KEEP_SNAPSHOTS, NODE_HEAP_SNAPSHOTS = -1 } = env;
446
465
  const slogSender = await makeSlogSender({
447
466
  stateDir: stateDBDir,
448
467
  env,
@@ -455,9 +474,6 @@ export default async function main(progname, args, { env, homedir, agcc }) {
455
474
  trueValue: pathResolve(stateDBDir, 'store-trace.log'),
456
475
  });
457
476
 
458
- const keepSnapshots =
459
- XSNAP_KEEP_SNAPSHOTS === '1' || XSNAP_KEEP_SNAPSHOTS === 'true';
460
-
461
477
  const nodeHeapSnapshots = Number.parseInt(NODE_HEAP_SNAPSHOTS, 10);
462
478
 
463
479
  let lastCommitTime = 0;
@@ -539,6 +555,7 @@ export default async function main(progname, args, { env, homedir, agcc }) {
539
555
  swingStoreExportCallback,
540
556
  swingStoreTraceFile,
541
557
  keepSnapshots,
558
+ keepTranscripts,
542
559
  afterCommitCallback,
543
560
  swingsetConfig,
544
561
  });
@@ -331,6 +331,7 @@ export async function launch({
331
331
  swingStoreTraceFile,
332
332
  swingStoreExportCallback,
333
333
  keepSnapshots,
334
+ keepTranscripts,
334
335
  afterCommitCallback = async () => ({}),
335
336
  swingsetConfig,
336
337
  }) {
@@ -373,6 +374,7 @@ export async function launch({
373
374
  traceFile: swingStoreTraceFile,
374
375
  exportCallback: swingStoreExportSyncCallback,
375
376
  keepSnapshots,
377
+ keepTranscripts,
376
378
  });
377
379
  const { kvStore, commit } = hostStorage;
378
380