@agoric/cosmic-swingset 0.41.4-dev-914bee2.0 → 0.41.4-dev-3656582.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-914bee2.0+914bee2",
3
+ "version": "0.41.4-dev-3656582.0+3656582",
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-914bee2.0+914bee2",
26
- "@agoric/cosmos": "0.34.2-dev-914bee2.0+914bee2",
27
- "@agoric/deploy-script-support": "0.10.4-dev-914bee2.0+914bee2",
28
- "@agoric/internal": "0.3.3-dev-914bee2.0+914bee2",
29
- "@agoric/store": "0.9.3-dev-914bee2.0+914bee2",
30
- "@agoric/swing-store": "0.9.2-dev-914bee2.0+914bee2",
31
- "@agoric/swingset-vat": "0.32.3-dev-914bee2.0+914bee2",
32
- "@agoric/telemetry": "0.6.3-dev-914bee2.0+914bee2",
33
- "@agoric/vm-config": "0.1.1-dev-914bee2.0+914bee2",
25
+ "@agoric/builders": "0.1.1-dev-3656582.0+3656582",
26
+ "@agoric/cosmos": "0.34.2-dev-3656582.0+3656582",
27
+ "@agoric/deploy-script-support": "0.10.4-dev-3656582.0+3656582",
28
+ "@agoric/internal": "0.3.3-dev-3656582.0+3656582",
29
+ "@agoric/store": "0.9.3-dev-3656582.0+3656582",
30
+ "@agoric/swing-store": "0.9.2-dev-3656582.0+3656582",
31
+ "@agoric/swingset-vat": "0.32.3-dev-3656582.0+3656582",
32
+ "@agoric/telemetry": "0.6.3-dev-3656582.0+3656582",
33
+ "@agoric/vm-config": "0.1.1-dev-3656582.0+3656582",
34
34
  "@endo/bundle-source": "^3.4.0",
35
35
  "@endo/env-options": "^1.1.6",
36
36
  "@endo/errors": "^1.2.5",
@@ -71,5 +71,5 @@
71
71
  "typeCoverage": {
72
72
  "atLeast": 80.53
73
73
  },
74
- "gitHead": "914bee2aa7472039ba230267d72027b940bf8a1c"
74
+ "gitHead": "3656582420c8930d16683ff7cd72b9c2c9f89425"
75
75
  }
package/src/chain-main.js CHANGED
@@ -1,14 +1,14 @@
1
1
  // @ts-check
2
2
 
3
- import { resolve as pathResolve } from 'path';
3
+ import path from 'node:path';
4
4
  import v8 from 'node:v8';
5
5
  import process from 'node:process';
6
6
  import fs from 'node:fs';
7
7
  import fsPromises from 'node:fs/promises';
8
- import { performance } from 'perf_hooks';
9
- import { resolve as importMetaResolve } from 'import-meta-resolve';
10
- import tmpfs from 'tmp';
8
+ import { performance } from 'node:perf_hooks';
11
9
  import { fork } from 'node:child_process';
10
+ import { resolve as importMetaResolve } from 'import-meta-resolve';
11
+ import tmp from 'tmp';
12
12
 
13
13
  import { Fail, q } from '@endo/errors';
14
14
  import { E } from '@endo/far';
@@ -33,6 +33,10 @@ import { makeShutdown } from '@agoric/internal/src/node/shutdown.js';
33
33
  import * as STORAGE_PATH from '@agoric/internal/src/chain-storage-paths.js';
34
34
  import * as ActionType from '@agoric/internal/src/action-types.js';
35
35
  import { BridgeId, CosmosInitKeyToBridgeId } from '@agoric/internal';
36
+ import {
37
+ makeArchiveSnapshot,
38
+ makeArchiveTranscript,
39
+ } from '@agoric/swing-store';
36
40
  import {
37
41
  makeBufferedStorage,
38
42
  makeReadCachingStorage,
@@ -76,6 +80,8 @@ const toNumber = specimen => {
76
80
  * @property {number} [maxVatsOnline]
77
81
  * @property {'debug' | 'operational'} [vatSnapshotRetention]
78
82
  * @property {'archival' | 'operational'} [vatTranscriptRetention]
83
+ * @property {string} [vatSnapshotArchiveDir]
84
+ * @property {string} [vatTranscriptArchiveDir]
79
85
  */
80
86
  const SwingsetConfigShape = M.splitRecord(
81
87
  // All known properties are optional, but unknown properties are not allowed.
@@ -85,6 +91,8 @@ const SwingsetConfigShape = M.splitRecord(
85
91
  maxVatsOnline: M.number(),
86
92
  vatSnapshotRetention: M.or('debug', 'operational'),
87
93
  vatTranscriptRetention: M.or('archival', 'operational'),
94
+ vatSnapshotArchiveDir: M.string(),
95
+ vatTranscriptArchiveDir: M.string(),
88
96
  },
89
97
  {},
90
98
  );
@@ -159,8 +167,8 @@ const makePrefixedBridgeStorage = (
159
167
  return fromBridgeStringValue(ret);
160
168
  },
161
169
  set: (key, value) => {
162
- const path = `${prefix}${key}`;
163
- const entry = [path, toBridgeStringValue(value)];
170
+ const fullPath = `${prefix}${key}`;
171
+ const entry = [fullPath, toBridgeStringValue(value)];
164
172
  call(
165
173
  stringify({
166
174
  method: setterMethod,
@@ -169,8 +177,8 @@ const makePrefixedBridgeStorage = (
169
177
  );
170
178
  },
171
179
  delete: key => {
172
- const path = `${prefix}${key}`;
173
- const entry = [path];
180
+ const fullPath = `${prefix}${key}`;
181
+ const entry = [fullPath];
174
182
  call(
175
183
  stringify({
176
184
  method: setterMethod,
@@ -315,8 +323,13 @@ export default async function main(progname, args, { env, homedir, agcc }) {
315
323
  /** @type {CosmosSwingsetConfig} */
316
324
  const swingsetConfig = harden(initAction.resolvedConfig || {});
317
325
  validateSwingsetConfig(swingsetConfig);
318
- const { slogfile, vatSnapshotRetention, vatTranscriptRetention } =
319
- swingsetConfig;
326
+ const {
327
+ slogfile,
328
+ vatSnapshotRetention,
329
+ vatTranscriptRetention,
330
+ vatSnapshotArchiveDir,
331
+ vatTranscriptArchiveDir,
332
+ } = swingsetConfig;
320
333
  const keepSnapshots = vatSnapshotRetention
321
334
  ? vatSnapshotRetention !== 'operational'
322
335
  : ['1', 'true'].includes(XSNAP_KEEP_SNAPSHOTS);
@@ -471,14 +484,14 @@ export default async function main(progname, args, { env, homedir, agcc }) {
471
484
  const swingStoreTraceFile = processValue.getPath({
472
485
  envName: 'SWING_STORE_TRACE',
473
486
  flagName: 'trace-store',
474
- trueValue: pathResolve(stateDBDir, 'store-trace.log'),
487
+ trueValue: path.resolve(stateDBDir, 'store-trace.log'),
475
488
  });
476
489
 
477
490
  const nodeHeapSnapshots = Number.parseInt(NODE_HEAP_SNAPSHOTS, 10);
478
491
 
479
492
  let lastCommitTime = 0;
480
493
  let commitCallsSinceLastSnapshot = NaN;
481
- const snapshotBaseDir = pathResolve(stateDBDir, 'node-heap-snapshots');
494
+ const snapshotBaseDir = path.resolve(stateDBDir, 'node-heap-snapshots');
482
495
 
483
496
  if (nodeHeapSnapshots >= 0) {
484
497
  fs.mkdirSync(snapshotBaseDir, { recursive: true });
@@ -514,7 +527,7 @@ export default async function main(progname, args, { env, homedir, agcc }) {
514
527
  ) {
515
528
  commitCallsSinceLastSnapshot = 0;
516
529
  heapSnapshot = `Heap-${process.pid}-${Date.now()}.heapsnapshot`;
517
- const snapshotPath = pathResolve(snapshotBaseDir, heapSnapshot);
530
+ const snapshotPath = path.resolve(snapshotBaseDir, heapSnapshot);
518
531
  v8.writeHeapSnapshot(snapshotPath);
519
532
  heapSnapshotTime = performance.now() - t3;
520
533
  }
@@ -537,6 +550,14 @@ export default async function main(progname, args, { env, homedir, agcc }) {
537
550
  }
538
551
  };
539
552
 
553
+ const fsPowers = { fs, path, tmp };
554
+ const archiveSnapshot = vatSnapshotArchiveDir
555
+ ? makeArchiveSnapshot(vatSnapshotArchiveDir, fsPowers)
556
+ : undefined;
557
+ const archiveTranscript = vatTranscriptArchiveDir
558
+ ? makeArchiveTranscript(vatTranscriptArchiveDir, fsPowers)
559
+ : undefined;
560
+
540
561
  const s = await launch({
541
562
  actionQueueStorage,
542
563
  highPriorityQueueStorage,
@@ -556,6 +577,8 @@ export default async function main(progname, args, { env, homedir, agcc }) {
556
577
  swingStoreTraceFile,
557
578
  keepSnapshots,
558
579
  keepTranscripts,
580
+ archiveSnapshot,
581
+ archiveTranscript,
559
582
  afterCommitCallback,
560
583
  swingsetConfig,
561
584
  });
@@ -608,7 +631,7 @@ export default async function main(progname, args, { env, homedir, agcc }) {
608
631
  );
609
632
  return performStateSyncImport(options, {
610
633
  fs: { ...fs, ...fsPromises },
611
- pathResolve,
634
+ pathResolve: path.resolve,
612
635
  log: null,
613
636
  });
614
637
  }
@@ -632,7 +655,7 @@ export default async function main(progname, args, { env, homedir, agcc }) {
632
655
  stateSyncExport = exportData;
633
656
 
634
657
  await new Promise((resolve, reject) => {
635
- tmpfs.dir(
658
+ tmp.dir(
636
659
  {
637
660
  prefix: `agd-state-sync-${blockHeight}-`,
638
661
  unsafeCleanup: true,
@@ -332,6 +332,8 @@ export async function launch({
332
332
  swingStoreExportCallback,
333
333
  keepSnapshots,
334
334
  keepTranscripts,
335
+ archiveSnapshot,
336
+ archiveTranscript,
335
337
  afterCommitCallback = async () => ({}),
336
338
  swingsetConfig,
337
339
  }) {
@@ -375,6 +377,8 @@ export async function launch({
375
377
  exportCallback: swingStoreExportSyncCallback,
376
378
  keepSnapshots,
377
379
  keepTranscripts,
380
+ archiveSnapshot,
381
+ archiveTranscript,
378
382
  });
379
383
  const { kvStore, commit } = hostStorage;
380
384