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

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 (120) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +6 -12
  2. package/@cds-models/CardanoIndexerService/index.d.ts +200 -2
  3. package/@cds-models/CardanoIndexerService/index.js +24 -0
  4. package/@cds-models/CardanoODataService/index.d.ts +49 -6
  5. package/@cds-models/CardanoODataService/index.js +4 -0
  6. package/@cds-models/CardanoSignService/index.d.ts +3 -3
  7. package/@cds-models/CardanoWorkerService/index.d.ts +4 -3
  8. package/@cds-models/index.d.ts +9 -1
  9. package/@cds-models/index.js +2 -1
  10. package/@cds-models/odatano/cardano/index.d.ts +59 -5
  11. package/@cds-models/odatano/cardano/index.js +6 -0
  12. package/README.md +29 -17
  13. package/db/schema.cds +117 -24
  14. package/db/types.cds +8 -0
  15. package/package.json +17 -15
  16. package/scripts/migrate-schema.mjs +334 -0
  17. package/src/index.d.ts +7 -5
  18. package/src/index.js +12 -10
  19. package/src/plugin.js +6 -7
  20. package/srv/blockchain/backends/blockfrost-backend.js +9 -1
  21. package/srv/blockchain/backends/cardano-backend.d.ts +15 -0
  22. package/srv/blockchain/backends/cardano-backend.js +5 -0
  23. package/srv/blockchain/backends/koios-backend.js +16 -10
  24. package/srv/blockchain/backends/ogmios-backend.d.ts +9 -3
  25. package/srv/blockchain/backends/ogmios-backend.js +60 -18
  26. package/srv/blockchain/cardano-client.d.ts +5 -4
  27. package/srv/blockchain/cardano-client.js +46 -13
  28. package/srv/blockchain/cardano-indexer.d.ts +116 -9
  29. package/srv/blockchain/cardano-indexer.js +436 -189
  30. package/srv/blockchain/crawler/account-snapshots.d.ts +29 -0
  31. package/srv/blockchain/crawler/account-snapshots.js +153 -0
  32. package/srv/blockchain/crawler/asset-registry-backfill.d.ts +23 -1
  33. package/srv/blockchain/crawler/asset-registry-backfill.js +91 -1
  34. package/srv/blockchain/crawler/certificate-backfill.d.ts +2 -0
  35. package/srv/blockchain/crawler/certificate-backfill.js +10 -3
  36. package/srv/blockchain/crawler/crawler.d.ts +15 -0
  37. package/srv/blockchain/crawler/crawler.js +68 -3
  38. package/srv/blockchain/crawler/input-asset-copies.d.ts +34 -0
  39. package/srv/blockchain/crawler/input-asset-copies.js +171 -0
  40. package/srv/blockchain/crawler/metadata-position-backfill.d.ts +16 -0
  41. package/srv/blockchain/crawler/metadata-position-backfill.js +55 -0
  42. package/srv/blockchain/crawler/output-datum-backfill.d.ts +39 -0
  43. package/srv/blockchain/crawler/output-datum-backfill.js +110 -0
  44. package/srv/blockchain/crawler/transaction-backfill.d.ts +2 -0
  45. package/srv/blockchain/crawler/transaction-backfill.js +12 -8
  46. package/srv/blockchain/pool-metadata.d.ts +15 -0
  47. package/srv/blockchain/pool-metadata.js +132 -0
  48. package/srv/blockchain/signing/cose-verifier.d.ts +3 -1
  49. package/srv/blockchain/signing/cose-verifier.js +144 -56
  50. package/srv/blockchain/signing/hsm-signer.js +2 -1
  51. package/srv/blockchain/signing/submission-finalizer.d.ts +15 -4
  52. package/srv/blockchain/signing/submission-finalizer.js +201 -69
  53. package/srv/blockchain/stored-chain.js +1 -1
  54. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +1 -3
  55. package/srv/blockchain/transaction-building/buildooor-tx.js +34 -54
  56. package/srv/blockchain/transaction-presence.d.ts +5 -0
  57. package/srv/blockchain/transaction-presence.js +29 -0
  58. package/srv/blockchain/transaction-rows.js +1 -1
  59. package/srv/blockchain/wallet-worker/build-request.d.ts +4 -1
  60. package/srv/blockchain/wallet-worker/build-request.js +25 -0
  61. package/srv/blockchain/wallet-worker/confirmation-tracker.js +1 -1
  62. package/srv/blockchain/wallet-worker/job-store.d.ts +17 -7
  63. package/srv/blockchain/wallet-worker/job-store.js +0 -0
  64. package/srv/blockchain/wallet-worker/signers.d.ts +2 -0
  65. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +2 -0
  66. package/srv/blockchain/wallet-worker/wallet-worker.js +42 -32
  67. package/srv/cardano-agent-service.cds +11 -12
  68. package/srv/cardano-agent-service.js +2 -0
  69. package/srv/cardano-backend-service.cds +34 -1
  70. package/srv/cardano-backend-service.js +20 -17
  71. package/srv/cardano-indexer-service.cds +153 -12
  72. package/srv/cardano-indexer-service.js +175 -29
  73. package/srv/cardano-service.cds +67 -3
  74. package/srv/cardano-service.js +132 -67
  75. package/srv/cardano-sign-service.cds +30 -20
  76. package/srv/cardano-sign-service.js +13 -10
  77. package/srv/cardano-tx-service.cds +15 -1
  78. package/srv/cardano-tx-service.js +4 -1
  79. package/srv/cardano-worker-service.cds +16 -7
  80. package/srv/cardano-worker-service.js +31 -22
  81. package/srv/cbor/parse.js +11 -34
  82. package/srv/config.d.ts +113 -0
  83. package/srv/config.js +409 -0
  84. package/srv/server.d.ts +9 -14
  85. package/srv/server.js +32 -316
  86. package/srv/utils/agent-access.d.ts +9 -0
  87. package/srv/utils/agent-access.js +67 -0
  88. package/srv/utils/agent-grants-config.d.ts +0 -17
  89. package/srv/utils/agent-grants-config.js +6 -81
  90. package/srv/utils/agent-grants.d.ts +6 -19
  91. package/srv/utils/agent-grants.js +69 -130
  92. package/srv/utils/const.d.ts +4 -0
  93. package/srv/utils/const.js +5 -1
  94. package/srv/utils/db-indexes.js +11 -3
  95. package/srv/utils/error-codes.d.ts +4 -0
  96. package/srv/utils/error-codes.js +4 -0
  97. package/srv/utils/errors.d.ts +6 -0
  98. package/srv/utils/errors.js +23 -1
  99. package/srv/utils/liveness.js +2 -5
  100. package/srv/utils/mappers.d.ts +5 -7
  101. package/srv/utils/mappers.js +22 -9
  102. package/srv/utils/pg-order-nulls.js +4 -3
  103. package/srv/utils/readiness.d.ts +12 -0
  104. package/srv/utils/readiness.js +29 -0
  105. package/srv/utils/result-numbers.d.ts +15 -0
  106. package/srv/utils/result-numbers.js +61 -0
  107. package/srv/utils/tx-request-parsers.d.ts +1 -1
  108. package/srv/utils/tx-request-parsers.js +3 -3
  109. package/srv/utils/tx-utils.d.ts +3 -0
  110. package/srv/utils/tx-utils.js +17 -3
  111. package/srv/utils/types.d.ts +16 -3
  112. package/scripts/migrate-txseq.mjs +0 -138
  113. package/srv/blockchain/transaction-building/buildooor-fee-patch.d.ts +0 -13
  114. package/srv/blockchain/transaction-building/buildooor-fee-patch.js +0 -71
  115. package/srv/blockchain/transaction-building/caller-datums.d.ts +0 -15
  116. package/srv/blockchain/transaction-building/caller-datums.js +0 -133
  117. package/srv/cbor/redeemer-tag-patch.d.ts +0 -3
  118. package/srv/cbor/redeemer-tag-patch.js +0 -61
  119. package/srv/utils/legacy-service-paths.d.ts +0 -11
  120. package/srv/utils/legacy-service-paths.js +0 -58
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const cds_1 = __importDefault(require("@sap/cds"));
7
7
  const deep_json_1 = require("./utils/deep-json");
8
8
  const backend_request_handler_1 = require("./utils/backend-request-handler");
9
+ const tx_utils_1 = require("./utils/tx-utils");
10
+ const result_numbers_1 = require("./utils/result-numbers");
9
11
  const errors_1 = require("./utils/errors");
10
12
  const validators_1 = require("./utils/validators");
11
13
  const server_1 = require("./server");
@@ -15,7 +17,9 @@ const logger = cds_1.default.log('CardanoBackendService');
15
17
  const MAX_LIST = 500;
16
18
  // Provider-shaped answers for another ODATANO instance. Stored blocks and txs come from the index.
17
19
  // The rest goes through the indexer's resolvers. Answers are JSON strings so big integers survive.
20
+ // Nothing is written here, so every database read runs outside the request transaction.
18
21
  module.exports = (srv) => {
22
+ (0, result_numbers_1.answerNumbersAsText)(srv);
19
23
  const client = () => (0, server_1.getCardanoClient)();
20
24
  const indexer = () => (0, server_1.getCardanoIndexer)();
21
25
  /** Register an operation: validate, run, answer the JSON of the result. */
@@ -57,7 +61,7 @@ module.exports = (srv) => {
57
61
  };
58
62
  // --- blocks and transactions -------------------------------------------------------------------
59
63
  op('GetTransaction', async ({ hash }, db) => {
60
- const stored = (await (0, stored_chain_1.readTransactionsByHash)(db, [String(hash)])).get(String(hash));
64
+ const stored = (await (0, tx_utils_1.readOutside)(db, (d) => (0, stored_chain_1.readTransactionsByHash)(d, [String(hash)]))).get(String(hash));
61
65
  if (stored && !(0, stored_chain_1.lacksOutpoints)(stored))
62
66
  return stored;
63
67
  if (stored) {
@@ -66,12 +70,12 @@ module.exports = (srv) => {
66
70
  return stored;
67
71
  return client().getTransaction(String(hash)).catch(() => stored);
68
72
  }
69
- await indexer().refuseOutsideCrawl(db, 'getTransaction', `Transaction ${hash}`);
73
+ await (0, tx_utils_1.readOutside)(db, (d) => indexer().refuseOutsideCrawl(d, 'getTransaction', `Transaction ${hash}`));
70
74
  return client().getTransaction(String(hash));
71
75
  }, need(validators_1.isTxHash, 'hash', 'transaction hash'));
72
76
  op('GetTransactionsBatch', async ({ hashes }, db) => {
73
77
  const wanted = hashes;
74
- const found = await (0, stored_chain_1.readTransactionsByHash)(db, wanted);
78
+ const found = await (0, tx_utils_1.readOutside)(db, (d) => (0, stored_chain_1.readTransactionsByHash)(d, wanted));
75
79
  const absent = wanted.filter(h => !found.has(h));
76
80
  // old rows without input outpoints: the backend's copy replaces them when it has one
77
81
  const stale = wanted.filter(h => found.has(h) && (0, stored_chain_1.lacksOutpoints)(found.get(h)));
@@ -91,21 +95,19 @@ module.exports = (srv) => {
91
95
  return found;
92
96
  }, jsonList('hashes', validators_1.isTxHash, 'transaction hashes'));
93
97
  op('GetTransactionMetadata', async ({ hash }, db) => {
94
- const stored = await (0, stored_chain_1.readTransactionMetadata)(db, String(hash));
98
+ const stored = await (0, tx_utils_1.readOutside)(db, async (d) => (await (0, stored_chain_1.readTransactionMetadata)(d, String(hash))) ?? (await indexer().refuseOutsideCrawl(d, 'getTransactionMetadata', `Transaction ${hash}`), null));
95
99
  if (stored)
96
100
  return stored;
97
- await indexer().refuseOutsideCrawl(db, 'getTransactionMetadata', `Transaction ${hash}`);
98
101
  return client().getTransactionMetadata(String(hash));
99
102
  }, need(validators_1.isTxHash, 'hash', 'transaction hash'));
100
103
  op('GetBlock', async ({ hash }, db) => {
101
- const stored = await (0, stored_chain_1.readBlock)(db, String(hash));
104
+ const stored = await (0, tx_utils_1.readOutside)(db, async (d) => (await (0, stored_chain_1.readBlock)(d, String(hash))) ?? (await indexer().refuseOutsideCrawl(d, 'getBlock', `Block ${hash}`), null));
102
105
  if (stored)
103
106
  return stored;
104
- await indexer().refuseOutsideCrawl(db, 'getBlock', `Block ${hash}`);
105
107
  return client().getBlock(String(hash));
106
108
  }, need(validators_1.isBlockHash, 'hash', 'block hash'));
107
109
  op('GetBlockByHeight', async ({ height }, db) => {
108
- const stored = await (0, stored_chain_1.readBlockByHeight)(db, Number(height));
110
+ const stored = await (0, tx_utils_1.readOutside)(db, (d) => (0, stored_chain_1.readBlockByHeight)(d, Number(height)));
109
111
  if (stored)
110
112
  return stored;
111
113
  const paging = client().getPaginatingBackend();
@@ -115,16 +117,17 @@ module.exports = (srv) => {
115
117
  }, need(v => Number.isInteger(Number(v)) && Number(v) >= 0, 'height', 'height'));
116
118
  op('GetNextBlocks', async ({ afterHash, count, afterHeight }, db) => {
117
119
  const n = count == null ? 1 : Number(count);
118
- const anchor = await (0, stored_chain_1.readBlock)(db, String(afterHash));
119
- if (anchor?.height != null) {
120
- const next = await (0, stored_chain_1.readNextBlocks)(db, anchor.height, n);
121
- if (next.length)
122
- return next;
123
- }
120
+ const { anchor, next, canonical } = await (0, tx_utils_1.readOutside)(db, async (d) => {
121
+ const anchor = await (0, stored_chain_1.readBlock)(d, String(afterHash));
122
+ const next = anchor?.height != null ? await (0, stored_chain_1.readNextBlocks)(d, anchor.height, n) : [];
123
+ const orphaned = !next.length && !anchor && afterHeight != null;
124
+ return { anchor, next, canonical: orphaned ? await (0, stored_chain_1.readBlockByHeight)(d, Number(afterHeight)) : null };
125
+ });
126
+ if (next.length)
127
+ return next;
124
128
  // Unknown cursor block where this chain has another block at that height: the caller's
125
129
  // cursor was orphaned. The crawler recognises this prefix and enters reorg recovery.
126
130
  if (!anchor && afterHeight != null) {
127
- const canonical = await (0, stored_chain_1.readBlockByHeight)(db, Number(afterHeight));
128
131
  if (canonical) {
129
132
  throw new errors_1.ChainPointMismatchError(`CHAIN_POINT_MISMATCH: cursor block ${afterHash} at height ${afterHeight} is no longer canonical (canonical block: ${canonical.hash})`, 'odatano');
130
133
  }
@@ -148,7 +151,7 @@ module.exports = (srv) => {
148
151
  throw new errors_1.ChainPointMismatchError(`CHAIN_POINT_MISMATCH: cursor block ${afterHash} is unknown to this instance`, 'odatano');
149
152
  }, need(validators_1.isBlockHash, 'afterHash', 'block hash'));
150
153
  op('GetBlockTransactions', async ({ blockHash }, db) => {
151
- const stored = await (0, stored_chain_1.readBlockTransactions)(db, String(blockHash));
154
+ const stored = await (0, tx_utils_1.readOutside)(db, (d) => (0, stored_chain_1.readBlockTransactions)(d, String(blockHash)));
152
155
  if (stored)
153
156
  return stored;
154
157
  const paging = client().getPaginatingBackend();
@@ -167,7 +170,7 @@ module.exports = (srv) => {
167
170
  op('GetAddressTransactionHashes', async (data, db) => indexer().resolveAddressTransactionHashes(db, String(data.address), limitOf(data, 10)), address);
168
171
  op('GetAddressTransactions', async (data, db) => {
169
172
  const hashes = await indexer().resolveAddressTransactionHashes(db, String(data.address), limitOf(data, 10));
170
- const found = await (0, stored_chain_1.readTransactionsByHash)(db, hashes);
173
+ const found = await (0, tx_utils_1.readOutside)(db, (d) => (0, stored_chain_1.readTransactionsByHash)(d, hashes));
171
174
  const missing = hashes.filter(h => !found.has(h));
172
175
  if (missing.length)
173
176
  for (const [h, t] of await client().getTransactionsBatch(missing))
@@ -1,19 +1,19 @@
1
- using { UtxoSetImportSource } from '../db/types';
1
+ using { UtxoSetImportSource, AssetRegistrySource } from '../db/types';
2
2
  using {odatano.cardano as db} from '../db/schema';
3
3
 
4
4
  // Crawler control and status. The service itself is 'any': CAP checks the service before the
5
- // operation, so anything stricter would 401 the anonymous getLiveness. Each element carries its own requirement.
5
+ // operation, so anything stricter would 401 the anonymous probes. Each element carries its own requirement.
6
6
  @requires: 'any'
7
7
  service CardanoIndexerService @(impl: './cardano-indexer-service') {
8
8
 
9
9
  @readonly
10
- @requires : 'authenticated-user'
10
+ @requires : 'Read'
11
11
  @title : 'Sync State'
12
12
  @description: 'Singleton crawl cursor: pre-sync progress, tip lag, status, errors'
13
13
  entity SyncState as projection on db.CardanoSyncState;
14
14
 
15
15
  @readonly
16
- @requires : 'authenticated-user'
16
+ @requires : 'Read'
17
17
  @title : 'Reorg Log'
18
18
  @description: 'Audit trail of chain rollbacks handled by the crawler'
19
19
  entity ReorgLog as projection on db.CardanoReorgLog;
@@ -46,6 +46,16 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
46
46
  decimalsBackfill : DecimalsBackfillStatus;
47
47
  // one-off CIP-26 registry fill of the asset catalogue (this process)
48
48
  registryBackfill : RegistryBackfillStatus;
49
+ // one-off repair of output datums (this process)
50
+ datumBackfill : DatumBackfillStatus;
51
+ // one-off chain-position fill of metadata rows (this process)
52
+ metadataBackfill : MetadataBackfillStatus;
53
+ // rebuild of epoch rows from the crawled blocks (this process)
54
+ epochBackfill : EpochBackfillStatus;
55
+ // walk that moves inputs from asset copies to their output (this process)
56
+ copyPrune : InputCopyPruneStatus;
57
+ // walk that moves inputs back to asset copies (this process)
58
+ copyRestore : InputCopyRestoreStatus;
49
59
  // per-epoch pool/DRep/pot snapshots (crawler.epochSnapshots)
50
60
  epochSnapshots : EpochSnapshotStatus;
51
61
  }
@@ -58,6 +68,9 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
58
68
  lastEpoch : Integer; // newest snapshotted epoch; null before the first
59
69
  lastSource: String; // source of that snapshot
60
70
  lastSlot : String; // block it was taken at
71
+ accounts : Boolean; // crawler.accountSnapshots configured
72
+ lastAccountEpoch : Integer; // newest epoch with an account snapshot; null before the first
73
+ lastAccountCount : Integer; // accounts in that snapshot
61
74
  }
62
75
 
63
76
  @title : 'Certificate Backfill Status'
@@ -70,6 +83,7 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
70
83
  blocks : Integer64;
71
84
  certificates : Integer64;
72
85
  withdrawals : Integer64;
86
+ removed : Integer64; // stored rows removed for transactions whose script phase failed
73
87
  startedAt : Timestamp;
74
88
  finishedAt : Timestamp;
75
89
  error : String;
@@ -85,6 +99,7 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
85
99
  blocks : Integer64;
86
100
  transactions : Integer64;
87
101
  inputs : Integer64; // input rows that got at least one field
102
+ outputs : Integer64; // output rows that got a datum or reference-script field
88
103
  redeemers : Integer64;
89
104
  datums : Integer64;
90
105
  rewritten : Integer64; // transactions whose stored rows differed in order or extent from the ledger view, now rewritten
@@ -126,7 +141,77 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
126
141
  units : Integer64; // units with a registry entry
127
142
  processed : Integer64; // units handled so far
128
143
  filled : Integer64; // units whose rows received the registry values
129
- failed : Integer64; // units the backend did not resolve
144
+ failed : Integer64; // units the backend did not resolve, or entry files that could not be read
145
+ absent : Integer64; // source file: registry units without an Assets row
146
+ skipped : Integer64; // source file: entries that describe no native asset
147
+ startedAt : Timestamp;
148
+ finishedAt : Timestamp;
149
+ error : String;
150
+ }
151
+
152
+ @title : 'Datum Backfill Status'
153
+ @description: 'Progress of the output datum repair started with backfillOutputDatums; process-local, none after a restart'
154
+ type DatumBackfillStatus {
155
+ status : String; // none | running | done | failed
156
+ scanned : Integer64; // stored outputs read
157
+ candidates : Integer64; // outputs with a datum hash and no inline datum
158
+ transactions : Integer64; // transactions read again from the backend
159
+ missing : Integer64; // candidate transactions the backend did not return
160
+ outputs : Integer64; // output rows that got a field
161
+ inputs : Integer64; // input rows that spent such an output and got the field
162
+ ledgerUtxos : Integer64; // UTxO set rows that got the field
163
+ startedAt : Timestamp;
164
+ finishedAt : Timestamp;
165
+ error : String;
166
+ }
167
+
168
+ @title : 'Epoch Backfill Status'
169
+ @description: 'Progress of the walk started with backfillEpochs; process-local, none after a restart'
170
+ type EpochBackfillStatus {
171
+ status : String; // none | running | done | failed
172
+ atEpoch : Integer; // epoch the walk has reached
173
+ toEpoch : Integer; // epoch of the crawler cursor
174
+ updated : Integer; // rows whose totals were written
175
+ created : Integer; // rows that did not exist
176
+ startedAt : Timestamp;
177
+ finishedAt : Timestamp;
178
+ error : String;
179
+ }
180
+
181
+ @title : 'Input Copy Prune Status'
182
+ @description: 'Progress of the walk started with pruneInputAssetCopies; process-local, none after a restart'
183
+ type InputCopyPruneStatus {
184
+ status : String; // none | running | done | failed
185
+ atSlot : String; // slot the walk has reached
186
+ toSlot : String; // last slot of the walk
187
+ referenced : Integer64; // inputs that read from their output now
188
+ kept : Integer64; // inputs of the walked slots left without a reference
189
+ deleted : Integer64; // copy rows deleted
190
+ startedAt : Timestamp;
191
+ finishedAt : Timestamp;
192
+ error : String;
193
+ }
194
+
195
+ @title : 'Input Copy Restore Status'
196
+ @description: 'Progress of the walk started with restoreInputAssetCopies; process-local, none after a restart'
197
+ type InputCopyRestoreStatus {
198
+ status : String; // none | running | done | failed
199
+ atSlot : String; // slot the walk has reached
200
+ toSlot : String; // last slot of the walk
201
+ restored : Integer64; // inputs that read from a copy again
202
+ rows : Integer64; // copy rows written
203
+ startedAt : Timestamp;
204
+ finishedAt : Timestamp;
205
+ error : String;
206
+ }
207
+
208
+ @title : 'Metadata Backfill Status'
209
+ @description: 'Progress of the chain-position fill started with backfillMetadataPositions; process-local, none after a restart'
210
+ type MetadataBackfillStatus {
211
+ status : String; // none | running | done | failed
212
+ atSlot : String; // slot the walk has reached
213
+ toSlot : String; // last slot that holds a stored transaction
214
+ rows : Integer64; // metadata rows that received their position
130
215
  startedAt : Timestamp;
131
216
  finishedAt : Timestamp;
132
217
  error : String;
@@ -184,7 +269,8 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
184
269
  blocksRolledBack : Integer;
185
270
  }
186
271
 
187
- @requires : 'authenticated-user'
272
+ @requires : 'Read'
273
+ @odatano.agent: 'read'
188
274
  function getStatus() returns CrawlerStatus;
189
275
 
190
276
  @title : 'Liveness'
@@ -197,50 +283,105 @@ service CardanoIndexerService @(impl: './cardano-indexer-service') {
197
283
  }
198
284
 
199
285
  // Anonymous on purpose, since a liveness probe carries no credentials.
200
- // It probes no backend or DB and reveals no secrets. Readiness stays with the authenticated getStatus.
286
+ // It probes no backend or DB and reveals no secrets.
201
287
  @title : 'Get Liveness'
202
- @description: 'Unauthenticated liveness probe: 200 while the process answers. Docker HEALTHCHECK and upstream probes use this instead of the service document.'
288
+ @description: 'Unauthenticated liveness probe: 200 while the process answers. The Docker HEALTHCHECK uses this.'
203
289
  @requires : 'any'
290
+ @odatano.agent: 'read'
204
291
  function getLiveness() returns Liveness;
205
292
 
293
+ @title : 'Readiness'
294
+ type Readiness {
295
+ status : String; // 'ready' | 'not_ready'
296
+ timestamp : Timestamp;
297
+ context : Boolean; // client, indexer and transaction builder exist
298
+ database : Boolean; // the database answers and holds the schema
299
+ hsm : Boolean; // null = no HSM configured; the HSM session is connected
300
+ }
301
+
302
+ // Anonymous like getLiveness. The body names the missing part and no configuration detail.
303
+ @title : 'Get Readiness'
304
+ @description: 'Unauthenticated readiness probe: 200 when this instance can serve requests, 503 with the same body while the app context, the database or a configured HSM is missing. Load balancers and upstream gateways use this to decide whether to route requests here.'
305
+ @requires : 'any'
306
+ @odatano.agent: 'read'
307
+ function getReadiness() returns Readiness;
308
+
206
309
  @title : 'Pause Crawler'
207
310
  @description: 'Stop the crawler (closes the chain-sync stream). Resume continues from the cursor.'
208
311
  @requires : 'Admin'
312
+ @odatano.agent: 'operator'
209
313
  action pauseCrawler() returns Boolean;
210
314
 
211
315
  @title : 'Resume Crawler'
212
316
  @description: 'Start/restart the crawler from the persisted cursor using the configured source.'
213
317
  @requires : 'Admin'
318
+ @odatano.agent: 'operator'
214
319
  action resumeCrawler() returns Boolean;
215
320
 
216
321
  @title : 'Import UTxO Set'
217
322
  @description: 'One-off import of the UTxO set that anchors crawler.utxoSet. Pause the crawler first. source=ogmios acquires the set at the crawler cursor (crawl must be at the tip); source=file loads a cardano-cli query utxo --whole-utxo dump (.json, or .ndjson from jq -c to_entries[]) taken at anchorSlot/anchorHash. source=aggregates rebuilds only the sums (LedgerAddresses, LedgerAddressAssets, LedgerAccounts) from the rows an earlier import left, e.g. after its aggregate phase failed; a cursor past the anchor is set back to it. source=scripts fills the reference-script columns (utxo_referenceScriptHash, utxo_referenceScriptSize, utxo_referenceScriptType) of rows an earlier import left empty: from the same dump (filePath), or without filePath from Ogmios for the unspent rows that hold a hash but no size; the set stays active. Runs in the background; progress via getStatus().utxoSet and the log.'
218
323
  @requires : 'Admin'
324
+ @odatano.agent: 'operator'
219
325
  action importUtxoSet(@assert.range source: UtxoSetImportSource, filePath: String,
220
326
  @assert.range: [0, _] anchorSlot: Integer64, anchorHash: String) returns UtxoSetImportResult;
221
327
 
222
328
  @title : 'Backfill Certificates'
223
- @description: 'Fill TransactionCertificates and TransactionWithdrawals for blocks the crawl already holds, from a second chain-sync stream (Ogmios). fromSlot defaults to the crawl start, toSlot to the cursor. Writes only those two tables; the crawler may keep running. Runs in the background; progress via getStatus().certificateBackfill.'
329
+ @description: 'Fill TransactionCertificates and TransactionWithdrawals for blocks the crawl already holds, from a second chain-sync stream (Ogmios), and remove the rows stored for a transaction whose script phase failed. fromSlot defaults to the crawl start, toSlot to the cursor. Writes only those two tables; the crawler may keep running. Runs in the background; progress via getStatus().certificateBackfill.'
224
330
  @requires : 'Admin'
331
+ @odatano.agent: 'operator'
225
332
  action backfillCertificates(@assert.range: [0, _] fromSlot: Integer64, @assert.range: [0, _] toSlot: Integer64) returns CertificateBackfillResult;
226
333
 
227
334
  @title : 'Backfill Transactions'
228
- @description: 'Complete transactions the crawl already holds from a second chain-sync stream (Ogmios): input outpoints, the spent output datum and reference-script hash, missing input addresses, TransactionRedeemers and TransactionDatums. Fills empty fields only; a transaction whose stored inputs differ from the stream is skipped. fromSlot defaults to the crawl start, toSlot to the cursor; the crawler may keep running. Runs in the background; progress via getStatus().transactionBackfill.'
335
+ @description: 'Complete transactions the crawl already holds from a second chain-sync stream (Ogmios): input outpoints, the spent output datum and reference-script hash, missing input addresses, empty datum and reference-script fields of stored outputs, TransactionRedeemers and TransactionDatums. Fills empty fields only; a transaction whose stored inputs differ from the stream is skipped. fromSlot defaults to the crawl start, toSlot to the cursor; the crawler may keep running. Runs in the background; progress via getStatus().transactionBackfill.'
229
336
  @requires : 'Admin'
337
+ @odatano.agent: 'operator'
230
338
  action backfillTransactions(@assert.range: [0, _] fromSlot: Integer64, @assert.range: [0, _] toSlot: Integer64) returns CertificateBackfillResult;
231
339
 
232
340
  @title : 'Backfill Payment Credentials'
233
341
  @description: 'Fill utxo.paymentCredential on TransactionOutputs, TransactionInputs and LedgerUTxOs rows written before the column existed, decoded from the stored address. Walks each table once in key order; rows that carry a credential are left alone, so a second run is a no-op. No backend call; the crawler may keep running. Runs in the background; progress via getStatus().credentialBackfill.'
234
342
  @requires : 'Admin'
343
+ @odatano.agent: 'operator'
235
344
  action backfillPaymentCredentials() returns BackfillResult;
236
345
 
346
+ @title : 'Backfill Output Datums'
347
+ @description: 'Repair stored outputs that hold a datum hash and no inline datum: their transactions are read again from a backend that serves transactions (Koios, Blockfrost or a remote ODATANO), and the inline datum and the reference-script fields it returns are written to the output, to the inputs that spent it and to its UTxO set row. Only empty fields change. An output whose datum is hash-only stays as it is and is read again on a repeat. With Ogmios as the only backend use backfillTransactions, which fills the same fields from the node. Runs in the background; progress via getStatus().datumBackfill.'
348
+ @requires : 'Admin'
349
+ @odatano.agent: 'operator'
350
+ action backfillOutputDatums() returns BackfillResult;
351
+
352
+ @title : 'Backfill Metadata Positions'
353
+ @description: 'Write the chain position (txSeq) of its transaction to every TransactionMetadata row that lacks it, so GetMetadataByLabel returns rows stored before the column existed. Walks the stored transactions by slot window. No backend call; the crawler may keep running; a repeat changes nothing. Runs in the background; progress via getStatus().metadataBackfill.'
354
+ @requires : 'Admin'
355
+ @odatano.agent: 'operator'
356
+ action backfillMetadataPositions() returns BackfillResult;
357
+
358
+ @title : 'Backfill Epochs'
359
+ @description: 'Write block count, transaction count, fees and the first and last block time of every epoch the crawl covers in full, from the stored blocks. An epoch that has no row gets one; output and active stake of an existing row stay. No backend. Runs detached; poll getStatus().epochBackfill. May be repeated.'
360
+ @requires : 'Admin'
361
+ @odatano.agent: 'operator'
362
+ action backfillEpochs() returns BackfillResult;
363
+
364
+ @title : 'Prune Input Asset Copies'
365
+ @description: 'Move the transaction inputs between fromSlot and toSlot (slot of the spending transaction) from stored asset copies to the output they spent. An input moves only when that output is stored and holds exactly the assets of its copy; its copy is deleted and it reads from the output. Answers stay the same; a long range of inputs reads slower. Disk space is free once the copy table is rewritten. restoreInputAssetCopies undoes it. slotWindow: slots per transaction, default 20000. PostgreSQL and SQLite. Runs detached; poll getStatus().copyPrune.'
366
+ @requires : 'Admin'
367
+ @odatano.agent: 'operator'
368
+ action pruneInputAssetCopies(@assert.range: [0, _] fromSlot: Integer64 not null, @assert.range: [0, _] toSlot: Integer64 not null, @assert.range: [1, 1000000] slotWindow: Integer) returns BackfillResult;
369
+
370
+ @title : 'Restore Input Asset Copies'
371
+ @description: 'Move the transaction inputs between fromSlot and toSlot (slot of the spending transaction) back to stored asset copies, written from the outputs they spent. slotWindow: slots per transaction, default 20000. PostgreSQL and SQLite. Runs detached; poll getStatus().copyRestore.'
372
+ @requires : 'Admin'
373
+ @odatano.agent: 'operator'
374
+ action restoreInputAssetCopies(@assert.range: [0, _] fromSlot: Integer64 not null, @assert.range: [0, _] toSlot: Integer64 not null, @assert.range: [1, 1000000] slotWindow: Integer) returns BackfillResult;
375
+
237
376
  @title : 'Backfill Asset Decimals'
238
377
  @description: 'Fill Assets.decimals from the CIP-68 reference datum for every catalogue unit with label 333 or 444: the reference NFT is followed from its mint through the crawled transactions to the output that holds it now, and the decimals of that datum are written to every slice of the unit. No backend call; the crawler may keep running; a repeat refreshes the values. Runs in the background; progress via getStatus().decimalsBackfill.'
239
378
  @requires : 'Admin'
379
+ @odatano.agent: 'operator'
240
380
  action backfillAssetDecimals() returns BackfillResult;
241
381
 
242
382
  @title : 'Backfill Asset Registry'
243
- @description: 'Fill the CIP-26 registry fields (registryName, registryTicker, registryDecimals, registryDescription, registryUrl, registryLogo) on every slice of every Assets unit the token registry lists, and decimals where it is still empty. The registry is off-chain, so each unit is read from the backend (needs Koios), rate limited; the crawler may keep running; a repeat refreshes the values. Runs in the background; progress via getStatus().registryBackfill.'
383
+ @description: 'Fill the CIP-26 registry fields (registryName, registryTicker, registryDecimals, registryDescription, registryUrl, registryLogo) on every slice of every Assets unit the token registry lists, and decimals where it is still empty. source koios (default): each unit is read from the backend (needs Koios), rate limited. source file: path names a folder on the server with the entry files of the registry repository (mappings of cardano-token-registry, registry of metadata-registry-testnet); units without an Assets row are counted, not created; no backend. The crawler may keep running; a repeat refreshes the values. Runs in the background; progress via getStatus().registryBackfill.'
244
384
  @requires : 'Admin'
245
- action backfillAssetRegistry() returns BackfillResult;
385
+ @odatano.agent: 'operator'
386
+ action backfillAssetRegistry(@assert.range source: AssetRegistrySource, path: String) returns BackfillResult;
246
387
  }