@odatano/core 1.11.0 → 2.0.0-rc.1
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/@cds-models/CardanoIndexerService/index.d.ts +142 -0
- package/@cds-models/CardanoIndexerService/index.js +23 -0
- package/@cds-models/CardanoODataService/index.d.ts +693 -2172
- package/@cds-models/CardanoODataService/index.js +88 -390
- package/@cds-models/CardanoSignService/index.d.ts +443 -1574
- package/@cds-models/CardanoSignService/index.js +62 -293
- package/@cds-models/CardanoTransactionService/index.d.ts +431 -1488
- package/@cds-models/CardanoTransactionService/index.js +60 -271
- package/@cds-models/CardanoWorkerService/index.d.ts +224 -0
- package/@cds-models/CardanoWorkerService/index.js +32 -0
- package/@cds-models/_/index.d.ts +70 -40
- package/@cds-models/_/index.js +17 -32
- package/@cds-models/cds/outbox/index.d.ts +28 -0
- package/@cds-models/index.d.ts +225 -522
- package/@cds-models/index.js +35 -218
- package/@cds-models/odatano/cardano/index.d.ts +896 -2947
- package/@cds-models/odatano/cardano/index.js +109 -536
- package/@cds-models/sap/common/index.d.ts +196 -600
- package/@cds-models/sap/common/index.js +28 -269
- package/README.md +136 -102
- package/db/schema.cds +283 -1
- package/db/types.cds +48 -0
- package/package.json +41 -32
- package/src/index.d.ts +1 -1
- package/src/index.js +10 -2
- package/src/plugin.js +12 -2
- package/srv/blockchain/backends/blockfrost-backend.d.ts +21 -2
- package/srv/blockchain/backends/blockfrost-backend.js +68 -15
- package/srv/blockchain/backends/cardano-backend.d.ts +69 -0
- package/srv/blockchain/backends/cardano-backend.js +13 -0
- package/srv/blockchain/backends/koios-backend.d.ts +26 -2
- package/srv/blockchain/backends/koios-backend.js +147 -15
- package/srv/blockchain/backends/ogmios-backend.d.ts +37 -6
- package/srv/blockchain/backends/ogmios-backend.js +254 -5
- package/srv/blockchain/cardano-client.d.ts +19 -0
- package/srv/blockchain/cardano-client.js +36 -0
- package/srv/blockchain/cardano-indexer.d.ts +50 -1
- package/srv/blockchain/cardano-indexer.js +191 -0
- package/srv/blockchain/crawler/crawler.d.ts +151 -0
- package/srv/blockchain/crawler/crawler.js +677 -0
- package/srv/blockchain/crawler/hooks.d.ts +43 -0
- package/srv/blockchain/crawler/hooks.js +62 -0
- package/srv/blockchain/crawler/index.d.ts +26 -0
- package/srv/blockchain/crawler/index.js +135 -0
- package/srv/blockchain/crawler/sync-state.d.ts +94 -0
- package/srv/blockchain/crawler/sync-state.js +265 -0
- package/srv/blockchain/signing/hsm-signer.d.ts +45 -0
- package/srv/blockchain/signing/hsm-signer.js +8 -1
- package/srv/blockchain/wallet-worker/build-request.d.ts +26 -0
- package/srv/blockchain/wallet-worker/build-request.js +341 -0
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +86 -0
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +228 -0
- package/srv/blockchain/wallet-worker/index.d.ts +14 -0
- package/srv/blockchain/wallet-worker/index.js +80 -0
- package/srv/blockchain/wallet-worker/job-store.d.ts +261 -0
- package/srv/blockchain/wallet-worker/job-store.js +564 -0
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +43 -0
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +99 -0
- package/srv/blockchain/wallet-worker/signers.d.ts +57 -0
- package/srv/blockchain/wallet-worker/signers.js +131 -0
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +145 -0
- package/srv/blockchain/wallet-worker/wallet-worker.js +542 -0
- package/srv/cardano-indexer-service.cds +73 -0
- package/srv/cardano-indexer-service.d.ts +2 -0
- package/srv/cardano-indexer-service.js +76 -0
- package/srv/cardano-service.js +22 -1
- package/srv/cardano-tx-service.d.ts +1 -11
- package/srv/cardano-tx-service.js +11 -162
- package/srv/cardano-worker-service.cds +125 -0
- package/srv/cardano-worker-service.d.ts +2 -0
- package/srv/cardano-worker-service.js +199 -0
- package/srv/server.d.ts +32 -1
- package/srv/server.js +228 -2
- package/srv/utils/collections.d.ts +13 -0
- package/srv/utils/collections.js +24 -0
- package/srv/utils/crypto.d.ts +16 -0
- package/srv/utils/crypto.js +75 -0
- package/srv/utils/error-codes.d.ts +6 -0
- package/srv/utils/error-codes.js +6 -0
- package/srv/utils/errors.d.ts +12 -0
- package/srv/utils/errors.js +45 -0
- package/srv/utils/mappers.js +13 -3
- package/srv/utils/service-events.d.ts +26 -0
- package/srv/utils/service-events.js +46 -0
- package/srv/utils/tx-request-parsers.d.ts +58 -0
- package/srv/utils/tx-request-parsers.js +170 -0
- package/srv/utils/tx-utils.d.ts +2 -1
- package/srv/utils/tx-utils.js +3 -2
- package/srv/utils/types.d.ts +2 -1
- package/@cds-models/CardanoODataService/index.d.ts.map +0 -1
- package/@cds-models/CardanoODataService/index.js.map +0 -1
- package/@cds-models/CardanoODataService/index.ts +0 -776
- package/@cds-models/CardanoSignService/index.d.ts.map +0 -1
- package/@cds-models/CardanoSignService/index.js.map +0 -1
- package/@cds-models/CardanoSignService/index.ts +0 -569
- package/@cds-models/CardanoTransactionService/index.d.ts.map +0 -1
- package/@cds-models/CardanoTransactionService/index.js.map +0 -1
- package/@cds-models/CardanoTransactionService/index.ts +0 -526
- package/@cds-models/_/index.d.ts.map +0 -1
- package/@cds-models/_/index.js.map +0 -1
- package/@cds-models/_/index.ts +0 -96
- package/@cds-models/cds/outbox/index.ts +0 -27
- package/@cds-models/index.d.ts.map +0 -1
- package/@cds-models/index.js.map +0 -1
- package/@cds-models/index.ts +0 -245
- package/@cds-models/odatano/cardano/index.d.ts.map +0 -1
- package/@cds-models/odatano/cardano/index.js.map +0 -1
- package/@cds-models/odatano/cardano/index.ts +0 -789
- package/@cds-models/sap/common/index.d.ts.map +0 -1
- package/@cds-models/sap/common/index.js.map +0 -1
- package/@cds-models/sap/common/index.ts +0 -249
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type { CardanoClient } from '../cardano-client';
|
|
2
|
+
import type { CardanoIndexer } from '../cardano-indexer';
|
|
3
|
+
import { type CrawlSyncStatusValue } from './sync-state';
|
|
4
|
+
/** Runtime configuration for the chain crawler (loaded from cds.requires by the server). */
|
|
5
|
+
export interface CrawlerConfig {
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
/** Pre-sync origin. Required (slot+hash) when enabled; the crawler resumes from here on a fresh DB. */
|
|
8
|
+
startSlot?: number;
|
|
9
|
+
startBlockHash?: string;
|
|
10
|
+
startHeight?: number;
|
|
11
|
+
/** 'ogmios' = chain-sync only, 'pagination' = Blockfrost/Koios only, 'auto' = chain-sync if available else pagination. */
|
|
12
|
+
source: 'ogmios' | 'pagination' | 'auto';
|
|
13
|
+
/** Blocks fetched per catch-up round (pagination path). */
|
|
14
|
+
batchSize: number;
|
|
15
|
+
/** Stay this many blocks behind the tip to avoid the volatile chain edge. */
|
|
16
|
+
confirmationDepth: number;
|
|
17
|
+
/** Poll cadence when caught up / on transient errors (pagination path). */
|
|
18
|
+
pollIntervalMs: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* CardanoCrawler — pre-sync engine (v2.0). Streams the chain forward from a configured
|
|
22
|
+
* start block and bulk-indexes Blocks + Transactions (+ inputs/outputs/assets) into the
|
|
23
|
+
* DB, so consumers can query local data instead of hitting a backend per request.
|
|
24
|
+
*
|
|
25
|
+
* Two sources (see CRAWLER_DESIGN.md):
|
|
26
|
+
* - **Ogmios chain-sync** (primary): ordered rollForward + native rollBackward (reorg).
|
|
27
|
+
* - **Blockfrost/Koios pagination** (fallback): forward walk + parent-hash reorg recovery.
|
|
28
|
+
*
|
|
29
|
+
* Lifecycle: start() launches the ingest pipeline detached so the HTTP server binds
|
|
30
|
+
* immediately, but the pipeline promise is retained — stop() halts the loops (waking
|
|
31
|
+
* any pending poll sleep) and AWAITS the pipeline, so shutdown never races in-flight
|
|
32
|
+
* block writes. All per-block writes are atomic. The crawler NEVER crawls from genesis
|
|
33
|
+
* implicitly — it requires an explicit configured start point or an existing cursor.
|
|
34
|
+
*/
|
|
35
|
+
export declare class CardanoCrawler {
|
|
36
|
+
private readonly client;
|
|
37
|
+
private readonly indexer;
|
|
38
|
+
private readonly network;
|
|
39
|
+
private readonly config;
|
|
40
|
+
/** Present for production instances created by index.ts; omitted in engine unit tests. */
|
|
41
|
+
private readonly leaseOwner?;
|
|
42
|
+
/** Transient-failure retries per block before giving up. */
|
|
43
|
+
private static readonly PERSIST_RETRIES;
|
|
44
|
+
/** Timeout for direct backend calls (the crawler bypasses the client's resilience layer). */
|
|
45
|
+
private static readonly CALL_TIMEOUT_MS;
|
|
46
|
+
private running;
|
|
47
|
+
private chainSyncHandle;
|
|
48
|
+
/** The detached ingest pipeline — awaited by stop() so teardown never races it. */
|
|
49
|
+
private pipeline;
|
|
50
|
+
/** Resolver that cancels a pending poll sleep (set while sleeping). */
|
|
51
|
+
private wake;
|
|
52
|
+
/** Cancellers for backend waits, so shutdown is not held hostage by their timeout. */
|
|
53
|
+
private readonly callCancels;
|
|
54
|
+
/** Chain-sync callback promises outlive openChainSync(); stop() explicitly drains them. */
|
|
55
|
+
private readonly inFlightCallbacks;
|
|
56
|
+
private haltPromise;
|
|
57
|
+
private finalStatus;
|
|
58
|
+
/** Set only by an unrecoverable halt — clears desiredRunning so restarts stay down. */
|
|
59
|
+
private latchOnHalt;
|
|
60
|
+
private leaseHeld;
|
|
61
|
+
private leaseHeartbeat;
|
|
62
|
+
private leaseWake;
|
|
63
|
+
constructor(client: CardanoClient, indexer: CardanoIndexer, network: string, config: CrawlerConfig,
|
|
64
|
+
/** Present for production instances created by index.ts; omitted in engine unit tests. */
|
|
65
|
+
leaseOwner?: string | undefined);
|
|
66
|
+
isRunning(): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Start crawling. Does NOT await the ingest pipeline (fire-and-forget).
|
|
69
|
+
* Refuses to start without a resume point: an explicit configured start block or an
|
|
70
|
+
* existing cursor — never an implicit full-chain sync from genesis.
|
|
71
|
+
*/
|
|
72
|
+
start(): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Stop crawling and WAIT for the pipeline to finish its in-flight step: halts the
|
|
75
|
+
* loops (waking any pending poll sleep), closes the chain-sync stream, records the
|
|
76
|
+
* final status, then awaits the detached pipeline so callers (shutdownAppContext)
|
|
77
|
+
* can safely tear down backends/DB afterwards.
|
|
78
|
+
*/
|
|
79
|
+
stop(finalStatus?: CrawlSyncStatusValue): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Halt without awaiting the pipeline — the variant safe to call FROM INSIDE the
|
|
82
|
+
* pipeline (persistBlock failure, stream onError), where awaiting the pipeline
|
|
83
|
+
* would deadlock.
|
|
84
|
+
*/
|
|
85
|
+
/**
|
|
86
|
+
* @param latch clears `desiredRunning`, so NO restart brings the crawler back —
|
|
87
|
+
* only an operator's resumeCrawler does. Reserved for failures a restart cannot
|
|
88
|
+
* fix (misconfiguration, missing resume point). Runtime failures — a dropped
|
|
89
|
+
* chain-sync socket, a provider outage, a node restart — must leave it false,
|
|
90
|
+
* otherwise a routine node restart silently disables the pre-sync for good.
|
|
91
|
+
*/
|
|
92
|
+
private halt;
|
|
93
|
+
/**
|
|
94
|
+
* Start teardown without awaiting it. Internal callers can therefore halt from
|
|
95
|
+
* inside a tracked callback/pipeline without waiting on their own promise.
|
|
96
|
+
*/
|
|
97
|
+
private beginHalt;
|
|
98
|
+
private runIngestPipeline;
|
|
99
|
+
/** Bound a direct backend call — these bypass the client's timeout/breaker layer. */
|
|
100
|
+
private withTimeout;
|
|
101
|
+
private runChainSync;
|
|
102
|
+
/**
|
|
103
|
+
* Candidate intersection points, NEWEST FIRST: the cursor, then an exponentially
|
|
104
|
+
* spaced ladder of our own already-crawled ancestors, then the configured start
|
|
105
|
+
* block as the deepest anchor.
|
|
106
|
+
*
|
|
107
|
+
* Why more than the cursor: if the cursor's block was orphaned while the crawler
|
|
108
|
+
* was down, a single-point intersection fails outright ("No intersection found")
|
|
109
|
+
* and the stream never opens. With ancestors on the list the node intersects at
|
|
110
|
+
* the last common block and reports it as a rollBackward — the ordinary reorg path
|
|
111
|
+
* that handleReorg already implements. Doubling offsets cover ~32k blocks with 16
|
|
112
|
+
* points; anything deeper is past any realistic rollback and should fail loudly.
|
|
113
|
+
*/
|
|
114
|
+
private buildIntersectionPoints;
|
|
115
|
+
/** Track streamed callbacks because closing a socket does not imply DB callbacks finished. */
|
|
116
|
+
private trackCallback;
|
|
117
|
+
private runPagination;
|
|
118
|
+
/**
|
|
119
|
+
* Pagination reorg recovery: walk back by height comparing the on-chain block hash with
|
|
120
|
+
* our stored one until they agree — that height is the fork point. If the last-indexed
|
|
121
|
+
* block still matches on-chain, there is no reorg (returns false → treat as transient).
|
|
122
|
+
*/
|
|
123
|
+
private tryReorgRecovery;
|
|
124
|
+
/**
|
|
125
|
+
* Persist one block atomically and advance the cursor. Transient failures are retried
|
|
126
|
+
* a few times (recording the error streak); only repeated failure stops the crawler —
|
|
127
|
+
* the cursor is not advanced on failure, so a resume re-syncs cleanly from it.
|
|
128
|
+
* Marks the cursor 'synced' when the block is at the reported tip.
|
|
129
|
+
* @returns true when the block was persisted, false when the crawler was stopped
|
|
130
|
+
*/
|
|
131
|
+
private persistBlock;
|
|
132
|
+
/**
|
|
133
|
+
* Handle a chain rollback: in one transaction, delete every block after the fork point
|
|
134
|
+
* and exactly the transactions belonging to those blocks (plus their child rows), reset
|
|
135
|
+
* the cursor to the fork, and write a CardanoReorgLog audit row.
|
|
136
|
+
*
|
|
137
|
+
* The cut runs on the absolute-slot axis of Blocks (same axis as the fork point), and
|
|
138
|
+
* transactions are resolved via their blockHash — so:
|
|
139
|
+
* - an unresolvable fork height can never widen the delete (no height-0 fallback), and
|
|
140
|
+
* - lazily-indexed transactions of blocks the crawler never wrote are left untouched.
|
|
141
|
+
*/
|
|
142
|
+
private handleReorg;
|
|
143
|
+
/** Renew the lease while an Ogmios stream is idle; block writes renew it transactionally. */
|
|
144
|
+
private startLeaseHeartbeat;
|
|
145
|
+
/** Record state only while this instance still owns the lease. */
|
|
146
|
+
private recordCrawlerError;
|
|
147
|
+
private leaseSleep;
|
|
148
|
+
/** Cancellable, unref'd delay — halt() wakes it so shutdown never waits out a poll. */
|
|
149
|
+
private sleep;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=crawler.d.ts.map
|