@odatano/core 2.0.0-rc.50 → 2.0.0-rc.51

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 (151) hide show
  1. package/@cds-models/CardanoBackendService/index.d.ts +14 -3
  2. package/@cds-models/CardanoBackendService/index.js +1 -0
  3. package/@cds-models/CardanoIndexerService/index.d.ts +98 -0
  4. package/@cds-models/CardanoIndexerService/index.js +10 -0
  5. package/@cds-models/CardanoODataService/index.d.ts +3 -0
  6. package/@cds-models/CardanoSignService/index.d.ts +13 -0
  7. package/@cds-models/CardanoSignService/index.js +1 -0
  8. package/@cds-models/CardanoTransactionService/index.d.ts +12 -0
  9. package/@cds-models/CardanoTransactionService/index.js +1 -0
  10. package/@cds-models/CardanoWorkerService/index.d.ts +28 -0
  11. package/@cds-models/CardanoWorkerService/index.js +2 -0
  12. package/@cds-models/index.d.ts +13 -3
  13. package/@cds-models/index.js +4 -3
  14. package/@cds-models/odatano/cardano/index.d.ts +14 -0
  15. package/README.md +45 -149
  16. package/db/schema.cds +63 -10
  17. package/db/types.cds +10 -0
  18. package/package.json +7 -44
  19. package/scripts/deploy-schema.mjs +113 -0
  20. package/scripts/migrate-schema.mjs +209 -15
  21. package/srv/blockchain/backends/blockfrost-backend.d.ts +2 -4
  22. package/srv/blockchain/backends/blockfrost-backend.js +61 -45
  23. package/srv/blockchain/backends/call-signal.d.ts +7 -0
  24. package/srv/blockchain/backends/call-signal.js +22 -0
  25. package/srv/blockchain/backends/cardano-backend.d.ts +6 -3
  26. package/srv/blockchain/backends/koios-backend.d.ts +9 -6
  27. package/srv/blockchain/backends/koios-backend.js +145 -207
  28. package/srv/blockchain/backends/odatano-backend.d.ts +2 -1
  29. package/srv/blockchain/backends/odatano-backend.js +51 -9
  30. package/srv/blockchain/backends/ogmios-backend.d.ts +1 -2
  31. package/srv/blockchain/backends/ogmios-backend.js +82 -48
  32. package/srv/blockchain/cardano-client.d.ts +15 -5
  33. package/srv/blockchain/cardano-client.js +143 -71
  34. package/srv/blockchain/cardano-indexer.d.ts +27 -16
  35. package/srv/blockchain/cardano-indexer.js +223 -102
  36. package/srv/blockchain/circuit-breaker.d.ts +1 -0
  37. package/srv/blockchain/circuit-breaker.js +6 -0
  38. package/srv/blockchain/crawler/account-snapshots.js +22 -2
  39. package/srv/blockchain/crawler/asset-decimals-backfill.d.ts +2 -0
  40. package/srv/blockchain/crawler/asset-decimals-backfill.js +29 -29
  41. package/srv/blockchain/crawler/asset-registry-backfill.d.ts +3 -0
  42. package/srv/blockchain/crawler/asset-registry-backfill.js +4 -0
  43. package/srv/blockchain/crawler/asset-slice-backfill.d.ts +35 -0
  44. package/srv/blockchain/crawler/asset-slice-backfill.js +149 -0
  45. package/srv/blockchain/crawler/certificate-backfill.d.ts +4 -0
  46. package/srv/blockchain/crawler/certificate-backfill.js +15 -3
  47. package/srv/blockchain/crawler/crawler.d.ts +22 -1
  48. package/srv/blockchain/crawler/crawler.js +223 -24
  49. package/srv/blockchain/crawler/credential-backfill.d.ts +2 -0
  50. package/srv/blockchain/crawler/credential-backfill.js +43 -66
  51. package/srv/blockchain/crawler/input-asset-copies.d.ts +4 -4
  52. package/srv/blockchain/crawler/input-asset-copies.js +17 -27
  53. package/srv/blockchain/crawler/key-pages.d.ts +12 -0
  54. package/srv/blockchain/crawler/key-pages.js +48 -0
  55. package/srv/blockchain/crawler/metadata-position-backfill.d.ts +6 -0
  56. package/srv/blockchain/crawler/metadata-position-backfill.js +23 -19
  57. package/srv/blockchain/crawler/output-datum-backfill.d.ts +3 -1
  58. package/srv/blockchain/crawler/output-datum-backfill.js +8 -18
  59. package/srv/blockchain/crawler/sync-state.d.ts +5 -1
  60. package/srv/blockchain/crawler/sync-state.js +63 -106
  61. package/srv/blockchain/crawler/transaction-backfill.d.ts +2 -0
  62. package/srv/blockchain/crawler/transaction-backfill.js +6 -13
  63. package/srv/blockchain/crawler/utxo-set-import.js +2 -2
  64. package/srv/blockchain/crawler/window-plan.d.ts +31 -0
  65. package/srv/blockchain/crawler/window-plan.js +59 -0
  66. package/srv/blockchain/ledger-state.d.ts +2 -2
  67. package/srv/blockchain/ledger-state.js +139 -37
  68. package/srv/blockchain/signing/external-signer.js +5 -5
  69. package/srv/blockchain/signing/failed-recheck.d.ts +17 -0
  70. package/srv/blockchain/signing/failed-recheck.js +135 -0
  71. package/srv/blockchain/signing/landing-proof.d.ts +60 -0
  72. package/srv/blockchain/signing/landing-proof.js +224 -0
  73. package/srv/blockchain/signing/signature-verifier.js +10 -13
  74. package/srv/blockchain/signing/submission-finalizer.d.ts +17 -3
  75. package/srv/blockchain/signing/submission-finalizer.js +90 -29
  76. package/srv/blockchain/stored-chain.d.ts +1 -2
  77. package/srv/blockchain/stored-chain.js +36 -15
  78. package/srv/blockchain/transaction-building/buildooor-tx.js +16 -10
  79. package/srv/blockchain/transaction-presence.d.ts +8 -1
  80. package/srv/blockchain/transaction-presence.js +12 -12
  81. package/srv/blockchain/wallet-worker/build-request.d.ts +6 -6
  82. package/srv/blockchain/wallet-worker/build-request.js +35 -365
  83. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +23 -2
  84. package/srv/blockchain/wallet-worker/confirmation-tracker.js +140 -23
  85. package/srv/blockchain/wallet-worker/invalidation.d.ts +35 -0
  86. package/srv/blockchain/wallet-worker/invalidation.js +128 -0
  87. package/srv/blockchain/wallet-worker/job-store.d.ts +28 -2
  88. package/srv/blockchain/wallet-worker/job-store.js +107 -80
  89. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +21 -2
  90. package/srv/blockchain/wallet-worker/wallet-worker.js +241 -57
  91. package/srv/cardano-agent-service.cds +1 -1
  92. package/srv/cardano-agent-service.js +8 -0
  93. package/srv/cardano-backend-service.cds +4 -1
  94. package/srv/cardano-backend-service.js +26 -9
  95. package/srv/cardano-indexer-service.cds +448 -387
  96. package/srv/cardano-indexer-service.js +226 -281
  97. package/srv/cardano-service.cds +7 -5
  98. package/srv/cardano-service.js +404 -69
  99. package/srv/cardano-sign-service.cds +11 -1
  100. package/srv/cardano-sign-service.js +161 -108
  101. package/srv/cardano-tx-service.cds +15 -4
  102. package/srv/cardano-tx-service.js +105 -604
  103. package/srv/cardano-worker-service.cds +25 -2
  104. package/srv/cardano-worker-service.js +56 -4
  105. package/srv/config.d.ts +4 -0
  106. package/srv/config.js +10 -0
  107. package/srv/server.js +5 -7
  108. package/srv/utils/agent-access.d.ts +4 -2
  109. package/srv/utils/agent-access.js +26 -7
  110. package/srv/utils/agent-grants.d.ts +1 -1
  111. package/srv/utils/agent-grants.js +7 -8
  112. package/srv/utils/agent-token-auth.js +45 -5
  113. package/srv/utils/build-request.d.ts +52 -0
  114. package/srv/utils/build-request.js +487 -0
  115. package/srv/utils/collections.d.ts +1 -0
  116. package/srv/utils/collections.js +11 -0
  117. package/srv/utils/const.d.ts +10 -2
  118. package/srv/utils/const.js +13 -6
  119. package/srv/utils/crypto.js +5 -4
  120. package/srv/utils/db-indexes.d.ts +5 -1
  121. package/srv/utils/db-indexes.js +79 -14
  122. package/srv/utils/db-kind.d.ts +23 -0
  123. package/srv/utils/db-kind.js +42 -0
  124. package/srv/utils/detached-run.d.ts +41 -0
  125. package/srv/utils/detached-run.js +101 -0
  126. package/srv/utils/epoch-slots.d.ts +1 -0
  127. package/srv/utils/epoch-slots.js +7 -0
  128. package/srv/utils/error-codes.d.ts +4 -0
  129. package/srv/utils/error-codes.js +4 -0
  130. package/srv/utils/errors.d.ts +10 -1
  131. package/srv/utils/errors.js +51 -9
  132. package/srv/utils/lease.d.ts +20 -0
  133. package/srv/utils/lease.js +62 -0
  134. package/srv/utils/mappers.d.ts +9 -0
  135. package/srv/utils/mappers.js +57 -67
  136. package/srv/utils/navigation.d.ts +17 -0
  137. package/srv/utils/navigation.js +52 -0
  138. package/srv/utils/network-context.d.ts +0 -1
  139. package/srv/utils/network-context.js +8 -3
  140. package/srv/utils/pg-inline-json.js +3 -3
  141. package/srv/utils/pg-order-nulls.js +3 -3
  142. package/srv/utils/resolution.d.ts +13 -0
  143. package/srv/utils/resolution.js +47 -0
  144. package/srv/utils/row-values.d.ts +7 -0
  145. package/srv/utils/row-values.js +27 -0
  146. package/srv/utils/tx-build-helper.d.ts +15 -0
  147. package/srv/utils/tx-build-helper.js +28 -13
  148. package/srv/utils/types.d.ts +35 -43
  149. package/srv/utils/types.js +1 -17
  150. package/srv/utils/validators.d.ts +2 -2
  151. package/srv/utils/validators.js +14 -25
@@ -8,11 +8,13 @@ const cds_1 = __importDefault(require("@sap/cds"));
8
8
  const errors_1 = require("../../utils/errors");
9
9
  const collections_1 = require("../../utils/collections");
10
10
  const const_1 = require("../../utils/const");
11
+ const epoch_slots_1 = require("../../utils/epoch-slots");
11
12
  const hooks_1 = require("./hooks");
12
13
  const ledger_state_1 = require("../ledger-state");
13
14
  const transaction_rows_1 = require("../transaction-rows");
14
15
  const cardano_1 = require("#cds-models/odatano/cardano");
15
16
  const account_snapshots_1 = require("./account-snapshots");
17
+ const call_signal_1 = require("../backends/call-signal");
16
18
  const sync_state_1 = require("./sync-state");
17
19
  const { SELECT, DELETE, INSERT } = cds_1.default.ql;
18
20
  const logger = cds_1.default.log('CardanoCrawler');
@@ -55,11 +57,19 @@ class CardanoCrawler {
55
57
  static SNAPSHOT_TIMEOUT_MS = 5 * 60_000;
56
58
  /** One node request per 2000 known accounts; an hour covers a mainnet-sized set. */
57
59
  static ACCOUNT_SNAPSHOT_TIMEOUT_MS = 60 * 60_000;
60
+ /** How long a timed-out snapshot may take to end before the next attempt is allowed. */
61
+ static SNAPSHOT_ABORT_GRACE_MS = 60_000;
58
62
  /** Backoff after a failed snapshot attempt, doubling up to the cap; the marker is only set on success. */
59
63
  static SNAPSHOT_RETRY_BASE_MS = 30_000;
60
64
  static SNAPSHOT_RETRY_MAX_MS = 10 * 60_000;
61
65
  /** Retry cadence for a chain-sync backend's init while the crawl runs on pagination. */
62
66
  static CHAIN_SYNC_RETRY_MS = 30_000;
67
+ /** Wait before chain-sync is reopened after the node was found behind the cursor. */
68
+ static NODE_BEHIND_RETRY_MS = 60_000;
69
+ /** Refused rollbacks that contradict the stored chain before the crawler halts with an error. */
70
+ static MAX_ROLLBACK_REFUSALS = 5;
71
+ /** At most one node-behind warning per this interval; the rest go to debug. */
72
+ static NODE_BEHIND_LOG_MS = 10 * 60_000;
63
73
  running = false;
64
74
  chainSyncHandle = null;
65
75
  /** What the ingest loop is currently reading from; null while stopped. */
@@ -81,6 +91,10 @@ class CardanoCrawler {
81
91
  frameFailure = null;
82
92
  /** The stream closed after making progress; the ingest loop reopens chain-sync at the cursor. */
83
93
  reopenStream = false;
94
+ /** The stream ended on a refused rollback; the ingest loop retries later. */
95
+ streamRefused = false;
96
+ rollbackRefusals = 0;
97
+ nodeBehindLoggedAt = 0;
84
98
  /** Blocks persisted by the current chain-sync stream. */
85
99
  blocksThisStream = 0;
86
100
  /** Resolves the ingest loop's wait for the current chain-sync stream to end. */
@@ -98,6 +112,8 @@ class CardanoCrawler {
98
112
  /** Epoch whose pool/DRep snapshot this process has settled, and the in-flight attempt. */
99
113
  snapshotedEpoch = null;
100
114
  snapshotInFlight = null;
115
+ /** The snapshot work itself. It can outlive a timed-out attempt until it sees its abort flag. */
116
+ snapshotWork = null;
101
117
  /** Consecutive snapshot failures and the earliest time the next attempt may run. */
102
118
  snapshotFailures = 0;
103
119
  accountSnapshotWarned = false;
@@ -274,7 +290,19 @@ class CardanoCrawler {
274
290
  // pagination fetches that block, then chain-sync takes over again. Other errors halt.
275
291
  while (this.running) {
276
292
  const streamEnd = new Promise((resolve) => { this.streamEnded = resolve; });
277
- await this.runChainSync(chainSync);
293
+ try {
294
+ await this.runChainSync(chainSync);
295
+ }
296
+ catch (err) {
297
+ // With 'auto' an open that fails while the node replays falls back to pagination.
298
+ if (!this.running || err instanceof CrawlerStoppedError || err instanceof CrawlerLeaseLostError)
299
+ throw err;
300
+ if (this.config.source !== 'auto' || !this.client.getPaginatingBackend())
301
+ throw err;
302
+ logger.warn(`chain-sync could not be opened (${err instanceof Error ? err.message : String(err)}), crawling on pagination until it opens again`);
303
+ await this.runPagination({ untilChainSync: true });
304
+ continue;
305
+ }
278
306
  if (!this.chainSyncHandle)
279
307
  return; // open refused, halted, or stop() raced us
280
308
  await streamEnd;
@@ -285,6 +313,14 @@ class CardanoCrawler {
285
313
  this.reopenStream = false;
286
314
  continue;
287
315
  }
316
+ if (this.streamRefused) {
317
+ this.streamRefused = false;
318
+ if (this.config.source === 'auto' && this.client.getPaginatingBackend())
319
+ await this.runPagination({ untilChainSync: true });
320
+ else
321
+ await this.sleep(CardanoCrawler.NODE_BEHIND_RETRY_MS);
322
+ continue;
323
+ }
288
324
  if (failure?.height == null)
289
325
  return;
290
326
  logger.warn(`chain-sync cannot deliver block ${failure.height}, switching to pagination until it is behind the cursor`);
@@ -346,7 +382,7 @@ class CardanoCrawler {
346
382
  this.chainSyncProbeTimer = null;
347
383
  }
348
384
  /** Bound a direct backend call. These calls bypass the client's timeout and circuit breaker. */
349
- withTimeout(p, label, ms = CardanoCrawler.CALL_TIMEOUT_MS) {
385
+ withTimeout(p, label, ms = CardanoCrawler.CALL_TIMEOUT_MS, onTimeout) {
350
386
  return new Promise((resolve, reject) => {
351
387
  let settled = false;
352
388
  let timer;
@@ -359,7 +395,7 @@ class CardanoCrawler {
359
395
  this.callCancels.delete(cancel);
360
396
  cb();
361
397
  };
362
- timer = setTimeout(() => finish(() => reject(new errors_1.ProviderUnavailableError(`${label} timed out`, 'crawler', ms))), ms);
398
+ timer = setTimeout(() => finish(() => { onTimeout?.(); reject(new errors_1.ProviderUnavailableError(`${label} timed out`, 'crawler', ms)); }), ms);
363
399
  timer.unref?.(); // never keep the process alive for a watchdog timer
364
400
  cancel = () => finish(() => reject(new CrawlerStoppedError()));
365
401
  this.callCancels.add(cancel);
@@ -384,13 +420,14 @@ class CardanoCrawler {
384
420
  if (!this.running)
385
421
  return;
386
422
  this.clearIdleWatchdog();
387
- if (await this.persistBlock(block, txs, tip)) {
423
+ if (await this.persistBlock(block, txs, tip, true)) {
388
424
  this.blocksThisStream++;
389
425
  this.idleReopens = 0;
426
+ this.rollbackRefusals = 0;
390
427
  }
391
428
  this.armIdleWatchdog();
392
429
  }),
393
- rollBackward: (point) => this.trackCallback(async () => {
430
+ rollBackward: (point, tip) => this.trackCallback(async () => {
394
431
  if (!this.running)
395
432
  return;
396
433
  this.clearIdleWatchdog();
@@ -401,6 +438,15 @@ class CardanoCrawler {
401
438
  logger.debug(`chain-sync intersection acknowledged at slot ${point.slot}, no reorg`);
402
439
  }
403
440
  else {
441
+ const refusal = await this.rollbackRefusal(point, tip, current);
442
+ if (refusal?.nodeBehind) {
443
+ await this.waitForNode(refusal.reason);
444
+ return;
445
+ }
446
+ if (refusal) {
447
+ await this.refuseRollback(refusal.reason);
448
+ return;
449
+ }
404
450
  await this.handleReorg(point);
405
451
  }
406
452
  this.armIdleWatchdog();
@@ -529,8 +575,11 @@ class CardanoCrawler {
529
575
  heights.push(height); };
530
576
  for (let step = 1; step <= DENSE_DEPTH; step++)
531
577
  pushHeight(cursor.lastHeight - step);
532
- for (let step = 16; step <= 1 << 14; step *= 2)
578
+ // A fork is never deeper than k, so no ancestor below that is offered.
579
+ const k = this.securityParam();
580
+ for (let step = 16; step <= k; step *= 2)
533
581
  pushHeight(cursor.lastHeight - step);
582
+ pushHeight(cursor.lastHeight - k);
534
583
  if (heights.length) {
535
584
  const rows = await cds_1.default.tx((tx) => tx.run(SELECT.from(cardano_1.Blocks).columns('height', 'slot', 'hash').where({ height: { in: heights } })));
536
585
  for (const row of (rows ?? []).sort((a, b) => Number(b.height ?? 0) - Number(a.height ?? 0))) {
@@ -544,6 +593,96 @@ class CardanoCrawler {
544
593
  }
545
594
  return points;
546
595
  }
596
+ // The first block of a Byron epoch follows that epoch's boundary block, which has no height and
597
+ // is never stored. Its parent hash names that block, not the last stored one.
598
+ followsByronBoundary(block, parentSlot) {
599
+ const cfg = const_1.EPOCH_CONFIG_BY_NETWORK[this.network];
600
+ if (!cfg || block.slot == null || block.slot >= cfg.shelleyStartSlot)
601
+ return false;
602
+ // a Byron epoch is 10k slots long
603
+ const byronEpoch = (slot) => Math.floor(slot / (10 * cfg.securityParam));
604
+ return byronEpoch(block.slot) > byronEpoch(parentSlot);
605
+ }
606
+ /** Blocks the node can roll back at most (Praos `k`). */
607
+ securityParam() {
608
+ return const_1.EPOCH_CONFIG_BY_NETWORK[this.network]?.securityParam
609
+ ?? const_1.EPOCH_CONFIG_BY_NETWORK.mainnet.securityParam;
610
+ }
611
+ // Why a rollBackward must not be executed, or null for a real fork. A fork is at most k blocks
612
+ // deep, its point is a stored block, and the new chain is not shorter than the cursor.
613
+ // `nodeBehind` = the node's tip is below the cursor, so waiting resolves it; the rest contradict the stored chain.
614
+ async rollbackRefusal(point, tip, cursor) {
615
+ if (!cursor?.lastBlockHash)
616
+ return null;
617
+ if (tip?.height != null && cursor.lastHeight > 0 && tip.height < cursor.lastHeight) {
618
+ return { reason: `the node's tip ${tip.height} is behind the cursor at block ${cursor.lastHeight}`, nodeBehind: true };
619
+ }
620
+ if (point === 'origin')
621
+ return { reason: `the node rolled back to genesis while the cursor is at block ${cursor.lastHeight}`, nodeBehind: false };
622
+ const isStart = point.hash === this.config.startBlockHash;
623
+ let pointHeight = point.height ?? (isStart ? this.config.startHeight : undefined) ?? null;
624
+ if (!isStart) {
625
+ const stored = await cds_1.default.tx((tx) => tx.run(SELECT.one.from(cardano_1.Blocks).columns('hash', 'height').where({ hash: point.hash })));
626
+ if (!stored)
627
+ return { reason: `the rollback point ${point.hash} at slot ${point.slot} is not a stored block`, nodeBehind: false };
628
+ if (pointHeight == null && stored.height != null)
629
+ pointHeight = Number(stored.height);
630
+ }
631
+ // The depth is the crawled chain between the point and the cursor; lazily stored tip blocks do not count.
632
+ const k = this.securityParam();
633
+ let depth;
634
+ if (pointHeight != null && cursor.lastHeight > 0) {
635
+ depth = cursor.lastHeight - pointHeight;
636
+ }
637
+ else {
638
+ const after = await cds_1.default.tx((tx) => tx.run(SELECT.from(cardano_1.Blocks).columns('hash').where({ slot: { '>': point.slot, '<=': cursor.lastSlot } }).limit(k + 1)));
639
+ depth = (after ?? []).length;
640
+ }
641
+ if (depth > k)
642
+ return { reason: `a rollback to slot ${point.slot} would remove more than k=${k} blocks`, nodeBehind: false };
643
+ return null;
644
+ }
645
+ // Ends the stream without deleting anything and records why. The ingest loop tries again later,
646
+ // when the node has caught up and intersects at the cursor.
647
+ async waitForNode(reason) {
648
+ const now = Date.now();
649
+ if (now - this.nodeBehindLoggedAt >= CardanoCrawler.NODE_BEHIND_LOG_MS) {
650
+ logger.warn(`chain-sync rollback refused, nothing deleted: ${reason}. Waiting for the node`);
651
+ this.nodeBehindLoggedAt = now;
652
+ }
653
+ else {
654
+ logger.debug(`chain-sync rollback refused, nothing deleted: ${reason}`);
655
+ }
656
+ const recorded = await cds_1.default.tx((tx) => (0, sync_state_1.markNodeBehind)(tx, reason, this.leaseOwner)).catch((err) => {
657
+ logger.error('node-behind state could not be written:', err);
658
+ return true;
659
+ });
660
+ if (!recorded) {
661
+ await this.halt('stopped');
662
+ return;
663
+ }
664
+ await this.endStream(() => { this.streamRefused = true; });
665
+ }
666
+ // A rollback that contradicts the stored chain: nothing is deleted, the status turns error, and
667
+ // after MAX_ROLLBACK_REFUSALS in a row the crawler halts until resumeCrawler.
668
+ async refuseRollback(reason) {
669
+ this.rollbackRefusals++;
670
+ logger.error(`chain-sync rollback refused, nothing deleted: ${reason} (${this.rollbackRefusals} of ${CardanoCrawler.MAX_ROLLBACK_REFUSALS})`);
671
+ const streak = await cds_1.default.tx((tx) => (0, sync_state_1.recordRollbackRefusal)(tx, reason, this.leaseOwner)).catch((err) => {
672
+ logger.error('rollback refusal could not be written:', err);
673
+ return 0;
674
+ });
675
+ if (streak < 0) {
676
+ await this.halt('stopped');
677
+ return;
678
+ }
679
+ if (this.rollbackRefusals >= CardanoCrawler.MAX_ROLLBACK_REFUSALS) {
680
+ logger.error(`chain-sync keeps asking for a rollback the stored chain contradicts; crawler halted until resumeCrawler. Check that Ogmios serves the configured network and node: ${reason}`);
681
+ await this.halt('error', true);
682
+ return;
683
+ }
684
+ await this.endStream(() => { this.streamRefused = true; });
685
+ }
547
686
  /** Track streamed callbacks because closing a socket does not imply DB callbacks finished. */
548
687
  trackCallback(callback) {
549
688
  const promise = Promise.resolve().then(callback);
@@ -624,12 +763,20 @@ class CardanoCrawler {
624
763
  await this.pollPause(untilChainSync);
625
764
  continue;
626
765
  }
766
+ // Each block must name the one before it. A different parent means the cursor was orphaned.
767
+ let parent = { hash: cursor.lastBlockHash, slot: cursor.lastSlot };
768
+ for (const block of blocks) {
769
+ if (block.previousHash != null && block.previousHash !== parent.hash && !this.followsByronBoundary(block, parent.slot)) {
770
+ throw new Error(`${CHAIN_POINT_MISMATCH_PREFIX} block ${block.hash} at height ${block.height ?? '?'} follows ${block.previousHash}, not ${parent.hash}`);
771
+ }
772
+ parent = { hash: block.hash, slot: block.slot ?? parent.slot };
773
+ }
627
774
  for (const block of blocks) {
628
775
  if (!this.running)
629
776
  break;
630
777
  if ((block.height ?? 0) > target)
631
778
  break; // stay behind the confirmation window
632
- const txs = await this.withTimeout(backend.getBlockTransactions(block.hash), 'getBlockTransactions');
779
+ const txs = await this.withTimeout(backend.getBlockTransactions(block.hash, block.txCount), 'getBlockTransactions');
633
780
  const ok = await this.persistBlock(block, txs, tipPoint);
634
781
  if (!ok)
635
782
  return; // persistBlock already recorded + halted
@@ -711,11 +858,14 @@ class CardanoCrawler {
711
858
  // Persist + reorg (shared)
712
859
  // ---------------------------------------------------------------------------
713
860
  /** Persist one block atomically and advance the cursor. Returns false when the crawler stopped. */
714
- async persistBlock(block, txs, tip) {
861
+ async persistBlock(block, txs, tip, fromChainSync = false) {
715
862
  if (txs.length !== block.txCount) {
716
863
  throw new errors_1.ProviderUnavailableError(`Incomplete block ${block.hash}: backend returned ${txs.length}/${block.txCount} transactions`, 'crawler');
717
864
  }
718
- const isAtTip = tip != null && block.slot != null && block.slot >= tip.slot;
865
+ // Pagination stays confirmationDepth behind the tip on purpose, so that distance counts as synced.
866
+ const isAtTip = tip != null && (tip.height != null && block.height != null
867
+ ? tip.height - block.height <= this.config.confirmationDepth
868
+ : block.slot != null && block.slot >= tip.slot);
719
869
  // Fetch epoch data before the write transaction, so no DB lock is held across network I/O.
720
870
  if (block.epoch != null) {
721
871
  await this.indexer.prefetchCrawlEpoch(block.epoch);
@@ -730,7 +880,11 @@ class CardanoCrawler {
730
880
  const anchor = this.indexer.getUtxoAnchor();
731
881
  const ledgerApplied = anchor != null && (block.slot ?? 0) > anchor.slot;
732
882
  // The cursor UPDATE also renews and fences the lease; a lost lease rolls the block back.
733
- const leaseHeld = await (0, sync_state_1.advanceCursor)(tx, { slot: block.slot ?? 0, hash: block.hash, height: block.height ?? 0 }, tip ? { slot: tip.slot, height: tip.height } : undefined, isAtTip ? 'synced' : 'syncing', ledgerApplied ? { utxoAppliedSlot: block.slot ?? 0 } : undefined, this.leaseOwner);
883
+ const leaseHeld = await (0, sync_state_1.advanceCursor)(tx, { slot: block.slot ?? 0, hash: block.hash, height: block.height ?? 0 }, tip ? { slot: tip.slot, height: tip.height } : undefined, isAtTip ? 'synced' : 'syncing', {
884
+ ...(ledgerApplied ? { utxoAppliedSlot: block.slot ?? 0 } : {}),
885
+ // only a block from chain-sync shows that the node caught up
886
+ ...(fromChainSync ? { nodeBehindSince: null } : {}),
887
+ }, this.leaseOwner);
734
888
  if (!leaseHeld)
735
889
  throw new CrawlerLeaseLostError();
736
890
  });
@@ -791,11 +945,9 @@ class CardanoCrawler {
791
945
  }
792
946
  }
793
947
  }
794
- /** Epoch a slot belongs to, from the network's Shelley anchor (same math as the Ogmios mapper). */
948
+ /** Epoch a slot belongs to, from the network's Shelley anchor. */
795
949
  epochOfSlot(slot) {
796
- const cfg = const_1.EPOCH_CONFIG_BY_NETWORK[this.network]
797
- ?? const_1.EPOCH_CONFIG_BY_NETWORK.preview;
798
- return cfg.shelleyStartEpoch + Math.floor((slot - cfg.shelleyStartSlot) / cfg.slotsPerEpoch);
950
+ return (0, epoch_slots_1.epochOfSlot)(this.network, slot);
799
951
  }
800
952
  // Snapshot pools and DReps once per epoch. Ogmios reads the ledger at a block within k of the tip.
801
953
  // Koios reports only current state, so the crawl must be in the tip's epoch. Other epochs are skipped.
@@ -811,8 +963,7 @@ class CardanoCrawler {
811
963
  }
812
964
  const fromLedger = this.client.getEpochStateBackend() != null && !!block.hash;
813
965
  if (fromLedger) {
814
- const k = const_1.EPOCH_CONFIG_BY_NETWORK[this.network]?.securityParam
815
- ?? const_1.EPOCH_CONFIG_BY_NETWORK.mainnet.securityParam;
966
+ const k = this.securityParam();
816
967
  const behind = tip.height != null && block.height != null ? tip.height - block.height : null;
817
968
  if (behind == null || behind >= k - CardanoCrawler.SNAPSHOT_WINDOW_MARGIN) {
818
969
  logger.debug(`epoch ${block.epoch} snapshot skipped at height ${block.height}: ${behind ?? '?'} blocks behind the tip, outside the node's volatile window (k=${k})`);
@@ -829,20 +980,25 @@ class CardanoCrawler {
829
980
  }
830
981
  if (Date.now() < this.snapshotRetryAfter)
831
982
  return;
983
+ // A timed-out attempt still runs until it sees its abort flag; never start a second one beside it.
984
+ if (this.snapshotWork)
985
+ return;
832
986
  const epoch = block.epoch;
833
987
  const at = { slot: block.slot ?? 0, time: block.time ?? 0, hash: fromLedger ? block.hash : null };
988
+ const attempt = { aborted: false };
989
+ const stopped = () => attempt.aborted || !this.running;
834
990
  this.snapshotInFlight = this.trackCallback(async () => {
835
991
  const existing = await cds_1.default.tx(async (tx) => (await tx.run(SELECT.one.from(cardano_1.EpochLedgerSnapshots).columns('epoch').where({ epoch })))
836
992
  ?? (await tx.run(SELECT.one.from(cardano_1.PoolEpochSnapshots).columns('epoch').where({ epoch }))));
837
993
  if (!existing) {
838
- await this.withTimeout(this.indexer.snapshotEpoch(epoch, at), `snapshotEpoch(${epoch})`, CardanoCrawler.SNAPSHOT_TIMEOUT_MS);
994
+ await this.attemptWithTimeout(() => this.indexer.snapshotEpoch(epoch, at, stopped), attempt, `snapshotEpoch(${epoch})`, CardanoCrawler.SNAPSHOT_TIMEOUT_MS);
839
995
  const previous = await cds_1.default.tx((tx) => tx.run(SELECT.one.from(cardano_1.EpochLedgerSnapshots).columns('max(epoch) as e').where({ epoch: { '<': epoch } })));
840
996
  const last = previous?.e == null ? null : Number(previous.e);
841
997
  if (last != null && epoch > last + 1) {
842
998
  logger.warn(`epoch snapshots missing for epochs ${last + 1}..${epoch - 1}: passed outside the snapshot window`);
843
999
  }
844
1000
  }
845
- await this.maybeSnapshotAccounts(epoch, at);
1001
+ await this.maybeSnapshotAccounts(epoch, at, attempt);
846
1002
  this.snapshotedEpoch = epoch;
847
1003
  this.snapshotFailures = 0;
848
1004
  this.snapshotRetryAfter = 0;
@@ -859,7 +1015,7 @@ class CardanoCrawler {
859
1015
  }
860
1016
  // The account snapshot of an epoch, after its pool snapshot. Skipped with one warning without a
861
1017
  // backend that reads the ledger at a block.
862
- async maybeSnapshotAccounts(epoch, at) {
1018
+ async maybeSnapshotAccounts(epoch, at, attempt) {
863
1019
  if (!this.config.accountSnapshots)
864
1020
  return;
865
1021
  const backend = at.hash ? this.client.getRewardAccountStateBackend() : null;
@@ -869,11 +1025,34 @@ class CardanoCrawler {
869
1025
  this.accountSnapshotWarned = true;
870
1026
  return;
871
1027
  }
872
- await this.withTimeout((0, account_snapshots_1.snapshotAccounts)({
873
- backend, epoch, at: { slot: at.slot, hash: at.hash },
1028
+ const point = { slot: at.slot, hash: at.hash };
1029
+ await this.attemptWithTimeout(() => (0, account_snapshots_1.snapshotAccounts)({
1030
+ backend, epoch, at: point,
874
1031
  withdrawals: this.config.certificates,
875
- shouldStop: () => !this.running,
876
- }), `snapshotAccounts(${epoch})`, CardanoCrawler.ACCOUNT_SNAPSHOT_TIMEOUT_MS);
1032
+ shouldStop: () => attempt.aborted || !this.running,
1033
+ }), attempt, `snapshotAccounts(${epoch})`, CardanoCrawler.ACCOUNT_SNAPSHOT_TIMEOUT_MS);
1034
+ }
1035
+ // A bounded snapshot step. On a timeout the attempt is marked aborted and its call signal fires,
1036
+ // which closes its ledger-state connection, so the work ends and writes nothing more.
1037
+ attemptWithTimeout(run, attempt, label, ms) {
1038
+ const controller = new AbortController();
1039
+ const work = (0, call_signal_1.withCallSignal)(controller.signal, run);
1040
+ this.snapshotWork = work;
1041
+ const forget = () => { if (this.snapshotWork === work)
1042
+ this.snapshotWork = null; };
1043
+ work.then(forget, forget);
1044
+ return this.withTimeout(work, label, ms, () => {
1045
+ attempt.aborted = true;
1046
+ controller.abort(new Error(`${label} timed out after ${ms} ms`));
1047
+ // A work that does not end once its connection is closed must not block every later attempt.
1048
+ const grace = setTimeout(() => {
1049
+ if (this.snapshotWork !== work)
1050
+ return;
1051
+ logger.warn(`${label} did not end ${CardanoCrawler.SNAPSHOT_ABORT_GRACE_MS} ms after its timeout; its connection is closed and it writes nothing more, so the next attempt may start`);
1052
+ this.snapshotWork = null;
1053
+ }, CardanoCrawler.SNAPSHOT_ABORT_GRACE_MS);
1054
+ grace.unref?.();
1055
+ });
877
1056
  }
878
1057
  // Roll back in one transaction. Deletes blocks after the fork slot, never by height, and their transactions.
879
1058
  // Lazily indexed transactions of other blocks stay. Resets the cursor and logs the reorg.
@@ -883,6 +1062,7 @@ class CardanoCrawler {
883
1062
  let txsRolledBack = 0;
884
1063
  let emittedForkHeight = null;
885
1064
  const rolledBackTxHashes = [];
1065
+ const rolledBackUnits = new Set();
886
1066
  let ledgerInvalidated = false;
887
1067
  try {
888
1068
  await cds_1.default.tx(async (tx) => {
@@ -909,6 +1089,21 @@ class CardanoCrawler {
909
1089
  const txHashes = staleTxs.map((t) => t.hash);
910
1090
  txsRolledBack += txHashes.length;
911
1091
  rolledBackTxHashes.push(...txHashes);
1092
+ // the units the catalogue may have first seen in these transactions: outputs, inputs, mints and burns
1093
+ for (const seqChunk of (0, collections_1.chunk)(staleTxs.map((t) => t.txSeq), collections_1.IN_CHUNK)) {
1094
+ for (const query of [
1095
+ SELECT.distinct.from(cardano_1.TransactionOutputAssets).columns('unit').where({ output_txSeq: { in: seqChunk } }),
1096
+ SELECT.distinct.from(cardano_1.TransactionInputAssets).columns('unit').where({ input_txSeq: { in: seqChunk } }),
1097
+ ]) {
1098
+ for (const u of await tx.run(query) ?? [])
1099
+ rolledBackUnits.add(u.unit);
1100
+ }
1101
+ }
1102
+ for (const txChunk of (0, collections_1.chunk)(txHashes, collections_1.IN_CHUNK)) {
1103
+ const history = await tx.run(SELECT.distinct.from(cardano_1.AssetHistory_).columns('unit').where({ txHash: { in: txChunk } }));
1104
+ for (const u of history ?? [])
1105
+ rolledBackUnits.add(u.unit);
1106
+ }
912
1107
  for (const txChunk of (0, collections_1.chunk)(txHashes, collections_1.IN_CHUNK)) {
913
1108
  // These tables have no cascading delete. Remove them first so no orphans leak via OData.
914
1109
  await tx.run(DELETE.from(cardano_1.UTxOAssets).where({ utxo_hash: { in: txChunk } }));
@@ -937,12 +1132,14 @@ class CardanoCrawler {
937
1132
  ledgerInvalidated = true;
938
1133
  }
939
1134
  else {
940
- await (0, ledger_state_1.undoLedgerForTransactions)(tx, rolledBackTxHashes);
1135
+ await (0, ledger_state_1.undoLedgerForTransactions)(tx, rolledBackTxHashes, forkSlot);
941
1136
  if (persisted.appliedSlot != null && persisted.appliedSlot > forkSlot) {
942
1137
  await (0, sync_state_1.setUtxoSetState)(tx, { appliedSlot: forkSlot });
943
1138
  }
944
1139
  }
945
1140
  }
1141
+ if (rolledBackUnits.size)
1142
+ await this.indexer.reconcileRolledBackAssets(tx, [...rolledBackUnits], forkSlot);
946
1143
  await (0, sync_state_1.resetCursorTo)(tx, point === 'origin'
947
1144
  ? { slot: forkSlot, hash: this.config.startBlockHash ?? '', height: 0 }
948
1145
  : { slot: point.slot, hash: point.hash, height: forkHeight ?? 0 });
@@ -971,6 +1168,8 @@ class CardanoCrawler {
971
1168
  }
972
1169
  // The rollback may have removed this epoch's snapshot. The next block re-checks it.
973
1170
  this.snapshotedEpoch = null;
1171
+ // Epoch totals cached in memory counted the removed blocks.
1172
+ this.indexer.forgetCrawlEpochs();
974
1173
  (0, hooks_1.emitReorg)({ forkSlot, forkHeight: emittedForkHeight, blocksRolledBack });
975
1174
  logger.warn(`Reorg handled: rolled back ${blocksRolledBack} blocks (${txsRolledBack} txs) to slot ${forkSlot}`);
976
1175
  }
@@ -9,6 +9,8 @@ export interface CredentialBackfillOptions {
9
9
  /** Rows per statement. */
10
10
  chunkSize?: number;
11
11
  onProgress?: (p: CredentialBackfillProgress) => void;
12
+ /** Stops the walk before the next page. */
13
+ shouldStop?: () => boolean;
12
14
  }
13
15
  export interface CredentialTableSpec {
14
16
  name: NonNullable<CredentialBackfillProgress['table']>;
@@ -9,8 +9,10 @@ exports.backfillUtxoCredentials = backfillUtxoCredentials;
9
9
  const cds_1 = __importDefault(require("@sap/cds"));
10
10
  const mappers_1 = require("../../utils/mappers");
11
11
  const collections_1 = require("../../utils/collections");
12
+ const db_kind_1 = require("../../utils/db-kind");
13
+ const key_pages_1 = require("./key-pages");
12
14
  const cardano_1 = require("#cds-models/odatano/cardano");
13
- const { SELECT, UPDATE } = cds_1.default.ql;
15
+ const { UPDATE } = cds_1.default.ql;
14
16
  const logger = cds_1.default.log('CredentialBackfill');
15
17
  exports.CREDENTIAL_TABLES = [
16
18
  { name: 'TransactionOutputs', entity: cardano_1.TransactionOutputs, table: 'odatano_cardano_TransactionOutputs', keys: ['txSeq', 'outputIndex'], firstKeyType: 'bigint', column: 'utxo_paymentCredential', address: 'address_address', counter: 'outputs' },
@@ -20,23 +22,22 @@ exports.CREDENTIAL_TABLES = [
20
22
  // One UPDATE per chunk that joins a JSON array of fills on the key. Touches only rows without a
21
23
  // credential. Null for databases other than Postgres and SQLite, which update row by row.
22
24
  function credentialFillStatement(kind, spec) {
25
+ const bulk = (0, db_kind_1.bulkSqlKind)(kind);
26
+ if (!bulk)
27
+ return null;
23
28
  const [k1, k2] = spec.keys;
24
- if (kind === 'postgres') {
25
- return `UPDATE ${spec.table} AS t SET ${spec.column} = v.credential ` +
26
- `FROM json_to_recordset($1::json) AS v(${k1.toLowerCase()} ${spec.firstKeyType}, ${k2.toLowerCase()} integer, credential text) ` +
27
- `WHERE t.${k1} = v.${k1.toLowerCase()} AND t.${k2} = v.${k2.toLowerCase()} AND t.${spec.column} IS NULL`;
28
- }
29
- if (kind === 'sqlite' || kind === 'better-sqlite') {
30
- const cols = [k1, k2, 'credential'].map((c) => `json_extract(value, '$.${c.toLowerCase()}') AS ${c}`).join(', ');
31
- return `UPDATE ${spec.table} AS t SET ${spec.column} = v.credential FROM (SELECT ${cols} FROM json_each(?)) AS v ` +
32
- `WHERE t.${k1} = v.${k1} AND t.${k2} = v.${k2} AND t.${spec.column} IS NULL`;
33
- }
34
- return null;
29
+ return (0, db_kind_1.jsonFillUpdate)(bulk, {
30
+ table: spec.table,
31
+ keys: [[k1, spec.firstKeyType], [k2, 'integer']],
32
+ values: [['credential', 'text']],
33
+ set: `${spec.column} = v.credential`,
34
+ where: `t.${spec.column} IS NULL`,
35
+ });
35
36
  }
36
37
  async function writeFills(tx, spec, fills, chunkSize) {
37
38
  if (!fills.length)
38
39
  return;
39
- const sql = credentialFillStatement(cds_1.default.db?.kind ?? '', spec);
40
+ const sql = credentialFillStatement((0, db_kind_1.connectedDbKind)(), spec);
40
41
  const [k1, k2] = spec.keys;
41
42
  if (!sql) {
42
43
  for (const f of fills) {
@@ -50,61 +51,34 @@ async function writeFills(tx, spec, fills, chunkSize) {
50
51
  }
51
52
  }
52
53
  const keyValue = (v, type) => type === 'bigint' ? Number(v) : String(v);
53
- /** Walks one table from its lowest key; returns the rows that received a credential. */
54
- async function fillTable(spec, chunkSize, onChunk) {
55
- const [k1, k2] = spec.keys;
54
+ /** Walks one table from its lowest key; returns the rows that received a credential, or null when stopped. */
55
+ async function fillTable(spec, chunkSize, onChunk, shouldStop) {
56
56
  let filled = 0;
57
- let cursor = null;
58
57
  const decoded = new Map();
59
- for (;;) {
60
- const done = await cds_1.default.tx(async (tx) => {
61
- const where = {};
62
- if (cursor?.within) {
63
- where[k1] = cursor.first;
64
- where[k2] = { '>': cursor.second };
65
- }
66
- else if (cursor) {
67
- where[k1] = { '>': cursor.first };
68
- }
69
- const rows = (await tx.run(SELECT.from(spec.entity).columns(k1, k2, spec.address, spec.column).where(where).orderBy(k1, k2).limit(chunkSize))) ?? [];
70
- const wasWithin = cursor?.within ?? false;
71
- if (!rows.length) {
72
- if (!wasWithin)
73
- return true;
74
- cursor = { ...cursor, within: false };
75
- return false;
76
- }
77
- const full = rows.length === chunkSize;
78
- const lastFirst = rows[rows.length - 1][k1];
79
- const allSame = rows.every((r) => r[k1] === lastFirst);
80
- // The last key of a full batch may continue in the next one: its rows wait for it. When the
81
- // whole batch is that one key, the walk continues inside it by the second key.
82
- const complete = full && !allSame ? rows.filter((r) => r[k1] !== lastFirst) : rows;
83
- const fills = [];
84
- for (const r of complete) {
85
- if (r[spec.column] != null)
86
- continue;
87
- const address = r[spec.address];
88
- if (!address)
89
- continue;
90
- if (!decoded.has(address))
91
- decoded.set(address, (0, mappers_1.paymentCredentialOf)(address));
92
- const credential = decoded.get(address);
93
- if (credential)
94
- fills.push({ first: keyValue(r[k1], spec.firstKeyType), second: Number(r[k2]), credential });
95
- }
96
- await writeFills(tx, spec, fills, chunkSize);
97
- filled += fills.length;
98
- const last = complete[complete.length - 1];
99
- cursor = { first: keyValue(last[k1], spec.firstKeyType), second: Number(last[k2]), within: full && allSame };
100
- return !full && !wasWithin;
101
- });
58
+ const [k1, k2] = spec.keys;
59
+ const finished = await (0, key_pages_1.pageByKey)({
60
+ entity: spec.entity, keys: spec.keys, columns: [spec.address, spec.column], chunkSize, shouldStop,
61
+ }, async (rows) => {
62
+ const fills = [];
63
+ for (const r of rows) {
64
+ if (r[spec.column] != null)
65
+ continue;
66
+ const address = r[spec.address];
67
+ if (!address)
68
+ continue;
69
+ if (!decoded.has(address))
70
+ decoded.set(address, (0, mappers_1.paymentCredentialOf)(address));
71
+ const credential = decoded.get(address);
72
+ if (credential)
73
+ fills.push({ first: keyValue(r[k1], spec.firstKeyType), second: Number(r[k2]), credential });
74
+ }
75
+ await cds_1.default.tx((tx) => writeFills(tx, spec, fills, chunkSize));
76
+ filled += fills.length;
102
77
  onChunk(filled);
103
78
  if (decoded.size > 50_000)
104
79
  decoded.clear();
105
- if (done)
106
- return filled;
107
- }
80
+ });
81
+ return finished ? filled : null;
108
82
  }
109
83
  async function backfillUtxoCredentials(opts = {}) {
110
84
  const chunkSize = opts.chunkSize ?? 5000;
@@ -112,10 +86,13 @@ async function backfillUtxoCredentials(opts = {}) {
112
86
  for (const spec of exports.CREDENTIAL_TABLES) {
113
87
  progress.table = spec.name;
114
88
  opts.onProgress?.({ ...progress });
115
- progress[spec.counter] = await fillTable(spec, chunkSize, (filled) => {
116
- progress[spec.counter] = filled;
89
+ const filled = await fillTable(spec, chunkSize, (n) => {
90
+ progress[spec.counter] = n;
117
91
  opts.onProgress?.({ ...progress });
118
- });
92
+ }, opts.shouldStop);
93
+ if (filled === null)
94
+ return progress;
95
+ progress[spec.counter] = filled;
119
96
  }
120
97
  progress.table = null;
121
98
  logger.info(`payment credentials filled: ${progress.outputs} outputs, ${progress.inputs} inputs, ${progress.ledgerUtxos} ledger UTxOs`);
@@ -13,14 +13,14 @@ export interface InputCopyRestoreProgress {
13
13
  restored: number;
14
14
  rows: number;
15
15
  }
16
- export interface SlotWalkOptions<P> {
16
+ export interface CopyWalkOptions<P> {
17
17
  fromSlot: number;
18
18
  toSlot: number;
19
19
  slotWindow?: number;
20
20
  onProgress?: (p: P) => void;
21
+ shouldStop?: () => boolean;
21
22
  }
22
23
  export declare function referenceStatement(kind: string): string | null;
23
- /** Deletes the copies of the inputs of a window that have a reference. */
24
24
  export declare function deleteCopiesStatement(kind: string): string | null;
25
25
  /** Counts the inputs of a window that have no reference. */
26
26
  export declare function keptStatement(kind: string): string | null;
@@ -29,6 +29,6 @@ export declare function restoreCopiesStatement(kind: string): string | null;
29
29
  /** Takes the reference from the inputs of a window, once their copies are written. */
30
30
  export declare function dropReferenceStatement(kind: string): string | null;
31
31
  export declare function bothStatement(kind: string): string | null;
32
- export declare function pruneInputAssetCopies(opts: SlotWalkOptions<InputCopyPruneProgress>): Promise<InputCopyPruneProgress>;
33
- export declare function restoreInputAssetCopies(opts: SlotWalkOptions<InputCopyRestoreProgress>): Promise<InputCopyRestoreProgress>;
32
+ export declare function pruneInputAssetCopies(opts: CopyWalkOptions<InputCopyPruneProgress>): Promise<InputCopyPruneProgress>;
33
+ export declare function restoreInputAssetCopies(opts: CopyWalkOptions<InputCopyRestoreProgress>): Promise<InputCopyRestoreProgress>;
34
34
  //# sourceMappingURL=input-asset-copies.d.ts.map