@odatano/core 2.0.0-rc.2 → 2.0.0-rc.21
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/CardanoAgentService/index.d.ts +251 -0
- package/@cds-models/CardanoAgentService/index.js +36 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +139 -2
- package/@cds-models/CardanoIndexerService/index.js +18 -0
- package/@cds-models/CardanoODataService/index.d.ts +231 -6
- package/@cds-models/CardanoODataService/index.js +27 -0
- package/@cds-models/CardanoSignService/index.d.ts +5 -2
- package/@cds-models/CardanoTransactionService/index.d.ts +9 -9
- package/@cds-models/odatano/cardano/index.d.ts +323 -6
- package/@cds-models/odatano/cardano/index.js +33 -0
- package/README.md +195 -136
- package/db/schema.cds +2133 -1633
- package/package.json +181 -173
- package/scripts/migrate-slot-leader.mjs +104 -0
- package/scripts/migrate-txseq.mjs +147 -0
- package/src/index.d.ts +10 -10
- package/src/index.js +24 -14
- package/src/plugin.js +39 -52
- package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
- package/srv/blockchain/backends/blockfrost-backend.js +45 -158
- package/srv/blockchain/backends/cardano-backend.d.ts +83 -158
- package/srv/blockchain/backends/cardano-backend.js +14 -5
- package/srv/blockchain/backends/koios-backend.d.ts +126 -60
- package/srv/blockchain/backends/koios-backend.js +293 -203
- package/srv/blockchain/backends/ogmios-backend.d.ts +69 -94
- package/srv/blockchain/backends/ogmios-backend.js +319 -185
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +32 -0
- package/srv/blockchain/backends/ogmios-frame-guard.js +142 -0
- package/srv/blockchain/cardano-client.d.ts +57 -204
- package/srv/blockchain/cardano-client.js +94 -226
- package/srv/blockchain/cardano-indexer.d.ts +176 -240
- package/srv/blockchain/cardano-indexer.js +615 -338
- package/srv/blockchain/cardano-tx-builder.d.ts +29 -82
- package/srv/blockchain/cardano-tx-builder.js +88 -128
- package/srv/blockchain/crawler/certificate-backfill.d.ts +45 -0
- package/srv/blockchain/crawler/certificate-backfill.js +150 -0
- package/srv/blockchain/crawler/crawler.d.ts +121 -53
- package/srv/blockchain/crawler/crawler.js +403 -89
- package/srv/blockchain/crawler/hooks.d.ts +3 -14
- package/srv/blockchain/crawler/index.d.ts +5 -0
- package/srv/blockchain/crawler/index.js +35 -7
- package/srv/blockchain/crawler/sync-state.d.ts +44 -28
- package/srv/blockchain/crawler/sync-state.js +115 -43
- package/srv/blockchain/crawler/utxo-set-import.d.ts +69 -0
- package/srv/blockchain/crawler/utxo-set-import.js +269 -0
- package/srv/blockchain/ledger-state.d.ts +80 -0
- package/srv/blockchain/ledger-state.js +383 -0
- package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
- package/srv/blockchain/signing/cose-verifier.js +6 -12
- package/srv/blockchain/signing/external-signer.d.ts +16 -113
- package/srv/blockchain/signing/external-signer.js +19 -122
- package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
- package/srv/blockchain/signing/hsm-signer.js +23 -63
- package/srv/blockchain/signing/signature-verifier.d.ts +8 -44
- package/srv/blockchain/signing/signature-verifier.js +13 -54
- package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
- package/srv/blockchain/signing/submission-finalizer.js +16 -48
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +71 -160
- package/srv/blockchain/transaction-building/buildooor-tx.js +185 -260
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +8 -34
- package/srv/blockchain/transaction-rows.d.ts +12 -0
- package/srv/blockchain/transaction-rows.js +42 -0
- package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
- package/srv/blockchain/wallet-worker/build-request.js +39 -23
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +25 -17
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +87 -41
- package/srv/blockchain/wallet-worker/index.js +2 -8
- package/srv/blockchain/wallet-worker/job-store.d.ts +36 -103
- package/srv/blockchain/wallet-worker/job-store.js +0 -0
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
- package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
- package/srv/blockchain/wallet-worker/signers.js +3 -8
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
- package/srv/blockchain/wallet-worker/wallet-worker.js +40 -91
- package/srv/cardano-agent-service.cds +146 -0
- package/srv/cardano-agent-service.d.ts +2 -0
- package/srv/cardano-agent-service.js +12 -0
- package/srv/cardano-indexer-service.cds +164 -73
- package/srv/cardano-indexer-service.js +156 -11
- package/srv/cardano-service.cds +45 -0
- package/srv/cardano-service.js +38 -96
- package/srv/cardano-sign-service.cds +200 -180
- package/srv/cardano-sign-service.js +55 -173
- package/srv/cardano-tx-service.cds +32 -26
- package/srv/cardano-tx-service.js +136 -196
- package/srv/cardano-worker-service.js +7 -15
- package/srv/server.d.ts +28 -86
- package/srv/server.js +95 -128
- package/srv/utils/agent-grants-config.d.ts +37 -0
- package/srv/utils/agent-grants-config.js +138 -0
- package/srv/utils/agent-grants.d.ts +262 -0
- package/srv/utils/agent-grants.js +914 -0
- package/srv/utils/agent-token-auth.d.ts +16 -0
- package/srv/utils/agent-token-auth.js +78 -0
- package/srv/utils/backend-request-handler.d.ts +2 -16
- package/srv/utils/backend-request-handler.js +3 -18
- package/srv/utils/collections.d.ts +4 -8
- package/srv/utils/collections.js +4 -8
- package/srv/utils/const.d.ts +19 -68
- package/srv/utils/const.js +20 -69
- package/srv/utils/crypto.d.ts +3 -12
- package/srv/utils/crypto.js +5 -18
- package/srv/utils/db-indexes.d.ts +25 -0
- package/srv/utils/db-indexes.js +93 -0
- package/srv/utils/db-sanitize.d.ts +27 -0
- package/srv/utils/db-sanitize.js +85 -0
- package/srv/utils/epoch-slots.d.ts +13 -0
- package/srv/utils/epoch-slots.js +25 -0
- package/srv/utils/error-codes.d.ts +18 -73
- package/srv/utils/error-codes.js +17 -70
- package/srv/utils/errors.d.ts +36 -179
- package/srv/utils/errors.js +62 -220
- package/srv/utils/liveness.d.ts +16 -0
- package/srv/utils/liveness.js +41 -0
- package/srv/utils/mappers.d.ts +89 -214
- package/srv/utils/mappers.js +289 -301
- package/srv/utils/network-context.js +2 -11
- package/srv/utils/pg-order-nulls.d.ts +14 -0
- package/srv/utils/pg-order-nulls.js +57 -0
- package/srv/utils/plutus-placeholders.d.ts +6 -18
- package/srv/utils/plutus-placeholders.js +6 -20
- package/srv/utils/rate-limiter.d.ts +46 -0
- package/srv/utils/rate-limiter.js +116 -0
- package/srv/utils/service-events.d.ts +2 -22
- package/srv/utils/service-events.js +3 -23
- package/srv/utils/signing-helper.d.ts +3 -18
- package/srv/utils/signing-helper.js +10 -32
- package/srv/utils/tx-build-helper.d.ts +18 -92
- package/srv/utils/tx-build-helper.js +32 -123
- package/srv/utils/tx-request-parsers.d.ts +14 -20
- package/srv/utils/tx-request-parsers.js +33 -20
- package/srv/utils/tx-utils.d.ts +4 -23
- package/srv/utils/tx-utils.js +12 -41
- package/srv/utils/types.d.ts +114 -169
- package/srv/utils/types.js +2 -6
- package/srv/utils/validators.d.ts +19 -89
- package/srv/utils/validators.js +31 -138
|
@@ -13,11 +13,8 @@ const errors_1 = require("../../utils/errors");
|
|
|
13
13
|
const error_codes_1 = require("../../utils/error-codes");
|
|
14
14
|
const logger = cds_1.default.log('SignatureVerifier');
|
|
15
15
|
/**
|
|
16
|
-
* blake2b-256 over the ORIGINAL transaction-body bytes (CBOR array index 0).
|
|
17
|
-
*
|
|
18
|
-
* and re-serialization can never drift it. (Historically this also sidestepped the
|
|
19
|
-
* ledger-ts AuxiliaryData.fromCbor bug on metadata-only aux_data — fixed in 0.5.6 —
|
|
20
|
-
* but byte-exactness remains the reason to stay at the raw-CBOR level.)
|
|
16
|
+
* blake2b-256 over the ORIGINAL transaction-body bytes (CBOR array index 0). subCborRef
|
|
17
|
+
* preserves the exact received bytes, so the hash matches what was signed.
|
|
21
18
|
*/
|
|
22
19
|
function computeBodyHash(txBytes) {
|
|
23
20
|
const tx = cbor_1.Cbor.parse(txBytes);
|
|
@@ -43,9 +40,8 @@ function extractVkeyWitnesses(txBytes) {
|
|
|
43
40
|
arr = arr.data;
|
|
44
41
|
if (!(arr instanceof cbor_1.CborArray))
|
|
45
42
|
return [];
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
// any entry that isn't a [vkey, signature] pair of byte strings.
|
|
43
|
+
// Skip entries that are not a [vkey, signature] pair of byte strings instead of
|
|
44
|
+
// surfacing an opaque TypeError.
|
|
49
45
|
const witnesses = [];
|
|
50
46
|
let skipped = 0;
|
|
51
47
|
for (const pair of arr.array) {
|
|
@@ -67,23 +63,11 @@ function extractVkeyWitnesses(txBytes) {
|
|
|
67
63
|
return witnesses;
|
|
68
64
|
}
|
|
69
65
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* This module provides signature verification for externally signed transactions.
|
|
73
|
-
* It ensures:
|
|
74
|
-
* 1. The signed CBOR is valid and parseable
|
|
75
|
-
* 2. The transaction body hash matches the expected hash (integrity check)
|
|
76
|
-
* 3. Required signatures are present (when specified)
|
|
77
|
-
* 4. No tampering occurred between build and sign steps
|
|
66
|
+
* Verifies externally signed transactions without private keys: CBOR parse, body-hash
|
|
67
|
+
* integrity against the build, required signers present, Ed25519 check per witness.
|
|
78
68
|
*/
|
|
79
69
|
class SignatureVerifier {
|
|
80
|
-
/**
|
|
81
|
-
* Verify a signed transaction
|
|
82
|
-
*
|
|
83
|
-
* @param signedTxCbor - The signed transaction in CBOR hex format
|
|
84
|
-
* @param options - Verification options
|
|
85
|
-
* @returns Verification result with details
|
|
86
|
-
*/
|
|
70
|
+
/** Verify a signed tx (hex CBOR); all failures are reported in the result, never thrown. */
|
|
87
71
|
verify(signedTxCbor, options = {}) {
|
|
88
72
|
const result = {
|
|
89
73
|
isValid: false,
|
|
@@ -93,8 +77,7 @@ class SignatureVerifier {
|
|
|
93
77
|
warnings: [],
|
|
94
78
|
};
|
|
95
79
|
try {
|
|
96
|
-
//
|
|
97
|
-
// matching exactly what was signed.
|
|
80
|
+
// Body hash over the original body bytes — exactly what was signed.
|
|
98
81
|
const txBytes = (0, uint8array_utils_1.fromHex)(signedTxCbor);
|
|
99
82
|
const computedHash = computeBodyHash(txBytes);
|
|
100
83
|
result.txBodyHash = computedHash;
|
|
@@ -159,13 +142,7 @@ class SignatureVerifier {
|
|
|
159
142
|
}
|
|
160
143
|
return result;
|
|
161
144
|
}
|
|
162
|
-
/**
|
|
163
|
-
* Verify signature and throw on failure
|
|
164
|
-
*
|
|
165
|
-
* @param signedTxCbor - The signed transaction in CBOR hex format
|
|
166
|
-
* @param options - Verification options
|
|
167
|
-
* @throws {TransactionValidationError} if verification fails
|
|
168
|
-
*/
|
|
145
|
+
/** Like verify(), but throws TransactionValidationError on failure. */
|
|
169
146
|
verifyOrThrow(signedTxCbor, options = {}) {
|
|
170
147
|
const result = this.verify(signedTxCbor, options);
|
|
171
148
|
if (!result.isValid) {
|
|
@@ -173,13 +150,7 @@ class SignatureVerifier {
|
|
|
173
150
|
}
|
|
174
151
|
return result;
|
|
175
152
|
}
|
|
176
|
-
/**
|
|
177
|
-
* Extract transaction body hash from unsigned or signed CBOR
|
|
178
|
-
*
|
|
179
|
-
* @param txCbor - Transaction CBOR (signed or unsigned)
|
|
180
|
-
* @returns Transaction body hash as hex string
|
|
181
|
-
* @throws {Error} if CBOR is invalid
|
|
182
|
-
*/
|
|
153
|
+
/** Body hash (hex) of an unsigned or signed tx CBOR; throws BackendError 400 on invalid CBOR. */
|
|
183
154
|
extractTxBodyHash(txCbor) {
|
|
184
155
|
try {
|
|
185
156
|
return computeBodyHash((0, uint8array_utils_1.fromHex)(txCbor));
|
|
@@ -189,12 +160,7 @@ class SignatureVerifier {
|
|
|
189
160
|
throw new errors_1.BackendError(`Failed to extract transaction body hash: ${msg}`, 400, error_codes_1.ERROR_CODES.INVALID_INPUT);
|
|
190
161
|
}
|
|
191
162
|
}
|
|
192
|
-
/**
|
|
193
|
-
* Check if a transaction is signed (has witnesses)
|
|
194
|
-
*
|
|
195
|
-
* @param txCbor - Transaction CBOR
|
|
196
|
-
* @returns true if transaction has at least one witness
|
|
197
|
-
*/
|
|
163
|
+
/** True when the tx carries at least one vkey witness. */
|
|
198
164
|
isSigned(txCbor) {
|
|
199
165
|
try {
|
|
200
166
|
return extractVkeyWitnesses((0, uint8array_utils_1.fromHex)(txCbor)).length > 0;
|
|
@@ -203,12 +169,7 @@ class SignatureVerifier {
|
|
|
203
169
|
return false;
|
|
204
170
|
}
|
|
205
171
|
}
|
|
206
|
-
/**
|
|
207
|
-
* Get witness count from transaction
|
|
208
|
-
*
|
|
209
|
-
* @param txCbor - Transaction CBOR
|
|
210
|
-
* @returns Number of witnesses
|
|
211
|
-
*/
|
|
172
|
+
/** Number of vkey witnesses in the tx (0 on invalid CBOR). */
|
|
212
173
|
getWitnessCount(txCbor) {
|
|
213
174
|
try {
|
|
214
175
|
return extractVkeyWitnesses((0, uint8array_utils_1.fromHex)(txCbor)).length;
|
|
@@ -221,9 +182,7 @@ class SignatureVerifier {
|
|
|
221
182
|
exports.SignatureVerifier = SignatureVerifier;
|
|
222
183
|
// Singleton instance
|
|
223
184
|
let verifierInstance = null;
|
|
224
|
-
/**
|
|
225
|
-
* Get the singleton SignatureVerifier instance
|
|
226
|
-
*/
|
|
185
|
+
/** Singleton SignatureVerifier. */
|
|
227
186
|
function getSignatureVerifier() {
|
|
228
187
|
if (!verifierInstance) {
|
|
229
188
|
verifierInstance = new SignatureVerifier();
|
|
@@ -15,48 +15,21 @@ export interface FinalizeParams {
|
|
|
15
15
|
signerInfo?: string;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Submit a
|
|
19
|
-
* outcome
|
|
20
|
-
*
|
|
21
|
-
* The caller must already have durably committed `status:'submitting'` (the
|
|
22
|
-
* claim). This function then:
|
|
23
|
-
* 1. submits with NO DB write-lock held (the lock was the reason concurrent
|
|
24
|
-
* submits serialized and the SQLite busy-timeout could fire mid-network),
|
|
25
|
-
* 2. on submit failure: marks the request 'failed' in its own committed tx
|
|
26
|
-
* and rethrows (NOT rolled back to a pre-submit status — losing the
|
|
27
|
-
* attempt would hide a tx the node may have accepted),
|
|
28
|
-
* 3. on success: persists the submission + 'submitted' status in a committed
|
|
29
|
-
* transaction.
|
|
30
|
-
*
|
|
31
|
-
* Crash window: a process death between (1) and (3) leaves the request durably
|
|
32
|
-
* at 'submitting'. Deferred-path requests carry their signed CBOR on the row
|
|
33
|
-
* and are re-driven at the next boot (redriveInterruptedSubmissions); sync-path
|
|
34
|
-
* requests are left for the operator/poller exactly as before.
|
|
18
|
+
* Submit a claimed signing request (status 'submitting' already committed by the caller) and
|
|
19
|
+
* persist the outcome in detached transactions, so no DB lock is held across the network call.
|
|
20
|
+
* Submit failure → 'failed' in its own tx, then rethrow. A crash before finalize leaves 'submitting'.
|
|
35
21
|
*/
|
|
36
22
|
export declare function submitAndFinalize(SigningRequests: unknown, params: FinalizeParams, afterFinalize?: (db: cds.Transaction) => Promise<void>): Promise<unknown>;
|
|
37
23
|
/**
|
|
38
|
-
* Deferred
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* transaction. Hooks the request's post-commit event: only once the caller's
|
|
42
|
-
* root transaction has committed (claim durable, pooled connection released)
|
|
43
|
-
* does the network submit + finalize run — detached via setImmediate +
|
|
44
|
-
* runWithoutAmbientTx, so no ambient transaction is held across it.
|
|
45
|
-
*
|
|
46
|
-
* If the caller's transaction rolls back instead, 'succeeded' never fires and
|
|
47
|
-
* nothing was claimed — strictly consistent.
|
|
24
|
+
* Deferred submit: runs submitAndFinalize only after the caller's root transaction has committed
|
|
25
|
+
* (claim durable, connection released), detached via setImmediate + runWithoutAmbientTx.
|
|
26
|
+
* If the caller rolls back, 'succeeded' never fires and nothing was claimed.
|
|
48
27
|
*/
|
|
49
28
|
export declare function scheduleDeferredSubmit(req: Request, SigningRequests: unknown, params: FinalizeParams): void;
|
|
50
29
|
/**
|
|
51
|
-
* Boot-time recovery: re-drive
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* Safe to repeat: a tx the node already holds finalizes as 'submitted' via the
|
|
56
|
-
* TransactionAlreadySubmittedError path in submitAndFinalize. Rows at
|
|
57
|
-
* 'submitting' WITHOUT signed CBOR (sync-path crash window) are deliberately
|
|
58
|
-
* left untouched for the operator/poller, exactly as before Layer 2.
|
|
59
|
-
*
|
|
30
|
+
* Boot-time recovery: re-drive rows at 'submitting' WITH persisted signedTxCbor (process died between
|
|
31
|
+
* the caller's commit and the detached submit). Idempotent: a tx the node already holds finalizes as
|
|
32
|
+
* 'submitted'. Rows without signed CBOR are left for the operator/poller.
|
|
60
33
|
* @returns number of rows re-driven (attempted, not necessarily succeeded)
|
|
61
34
|
*/
|
|
62
35
|
export declare function redriveInterruptedSubmissions(): Promise<number>;
|
|
@@ -13,31 +13,16 @@ const tx_build_helper_1 = require("../../utils/tx-build-helper");
|
|
|
13
13
|
const external_signer_1 = require("./external-signer");
|
|
14
14
|
const { SELECT, UPDATE } = cds_1.default.ql;
|
|
15
15
|
const logger = cds_1.default.log('SubmissionFinalizer');
|
|
16
|
-
// Lazy require
|
|
17
|
-
//
|
|
18
|
-
// getters at runtime only). Same pattern as src/plugin.ts.
|
|
16
|
+
// Lazy require avoids the srv/server.ts <-> this-module import cycle; the app-context
|
|
17
|
+
// getters are only needed at runtime.
|
|
19
18
|
function server() {
|
|
20
19
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
21
20
|
return require('../../server');
|
|
22
21
|
}
|
|
23
22
|
/**
|
|
24
|
-
* Submit a
|
|
25
|
-
* outcome
|
|
26
|
-
*
|
|
27
|
-
* The caller must already have durably committed `status:'submitting'` (the
|
|
28
|
-
* claim). This function then:
|
|
29
|
-
* 1. submits with NO DB write-lock held (the lock was the reason concurrent
|
|
30
|
-
* submits serialized and the SQLite busy-timeout could fire mid-network),
|
|
31
|
-
* 2. on submit failure: marks the request 'failed' in its own committed tx
|
|
32
|
-
* and rethrows (NOT rolled back to a pre-submit status — losing the
|
|
33
|
-
* attempt would hide a tx the node may have accepted),
|
|
34
|
-
* 3. on success: persists the submission + 'submitted' status in a committed
|
|
35
|
-
* transaction.
|
|
36
|
-
*
|
|
37
|
-
* Crash window: a process death between (1) and (3) leaves the request durably
|
|
38
|
-
* at 'submitting'. Deferred-path requests carry their signed CBOR on the row
|
|
39
|
-
* and are re-driven at the next boot (redriveInterruptedSubmissions); sync-path
|
|
40
|
-
* requests are left for the operator/poller exactly as before.
|
|
23
|
+
* Submit a claimed signing request (status 'submitting' already committed by the caller) and
|
|
24
|
+
* persist the outcome in detached transactions, so no DB lock is held across the network call.
|
|
25
|
+
* Submit failure → 'failed' in its own tx, then rethrow. A crash before finalize leaves 'submitting'.
|
|
41
26
|
*/
|
|
42
27
|
async function submitAndFinalize(SigningRequests, params, afterFinalize) {
|
|
43
28
|
// Persist the submission + 'submitted' status in its own committed transaction.
|
|
@@ -59,10 +44,8 @@ async function submitAndFinalize(SigningRequests, params, afterFinalize) {
|
|
|
59
44
|
await server().getCardanoClient().submitTransaction(params.fullSignedTxCbor);
|
|
60
45
|
}
|
|
61
46
|
catch (submitErr) {
|
|
62
|
-
// Already-submitted means the tx reached the mempool
|
|
63
|
-
//
|
|
64
|
-
// not failure: finalize it as 'submitted' (same as the happy path) instead of durably
|
|
65
|
-
// recording a spurious 'failed' for a tx the node already holds.
|
|
47
|
+
// Already-submitted means the tx reached the mempool (e.g. first backend accepted it, response
|
|
48
|
+
// lost, fallback saw the duplicate): finalize as 'submitted' rather than recording a spurious 'failed'.
|
|
66
49
|
if (submitErr instanceof errors_1.TransactionAlreadySubmittedError) {
|
|
67
50
|
logger.info({ signingRequestId: params.signingRequestId, txHash: params.txHash }, 'Submit reported already-submitted — finalizing as submitted (tx already in mempool)');
|
|
68
51
|
return finalizeSubmitted();
|
|
@@ -78,16 +61,9 @@ async function submitAndFinalize(SigningRequests, params, afterFinalize) {
|
|
|
78
61
|
return finalizeSubmitted();
|
|
79
62
|
}
|
|
80
63
|
/**
|
|
81
|
-
* Deferred
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* transaction. Hooks the request's post-commit event: only once the caller's
|
|
85
|
-
* root transaction has committed (claim durable, pooled connection released)
|
|
86
|
-
* does the network submit + finalize run — detached via setImmediate +
|
|
87
|
-
* runWithoutAmbientTx, so no ambient transaction is held across it.
|
|
88
|
-
*
|
|
89
|
-
* If the caller's transaction rolls back instead, 'succeeded' never fires and
|
|
90
|
-
* nothing was claimed — strictly consistent.
|
|
64
|
+
* Deferred submit: runs submitAndFinalize only after the caller's root transaction has committed
|
|
65
|
+
* (claim durable, connection released), detached via setImmediate + runWithoutAmbientTx.
|
|
66
|
+
* If the caller rolls back, 'succeeded' never fires and nothing was claimed.
|
|
91
67
|
*/
|
|
92
68
|
function scheduleDeferredSubmit(req, SigningRequests, params) {
|
|
93
69
|
req.on('succeeded', () => {
|
|
@@ -104,15 +80,9 @@ function scheduleDeferredSubmit(req, SigningRequests, params) {
|
|
|
104
80
|
});
|
|
105
81
|
}
|
|
106
82
|
/**
|
|
107
|
-
* Boot-time recovery: re-drive
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* Safe to repeat: a tx the node already holds finalizes as 'submitted' via the
|
|
112
|
-
* TransactionAlreadySubmittedError path in submitAndFinalize. Rows at
|
|
113
|
-
* 'submitting' WITHOUT signed CBOR (sync-path crash window) are deliberately
|
|
114
|
-
* left untouched for the operator/poller, exactly as before Layer 2.
|
|
115
|
-
*
|
|
83
|
+
* Boot-time recovery: re-drive rows at 'submitting' WITH persisted signedTxCbor (process died between
|
|
84
|
+
* the caller's commit and the detached submit). Idempotent: a tx the node already holds finalizes as
|
|
85
|
+
* 'submitted'. Rows without signed CBOR are left for the operator/poller.
|
|
116
86
|
* @returns number of rows re-driven (attempted, not necessarily succeeded)
|
|
117
87
|
*/
|
|
118
88
|
async function redriveInterruptedSubmissions() {
|
|
@@ -126,8 +96,7 @@ async function redriveInterruptedSubmissions() {
|
|
|
126
96
|
let attempted = 0;
|
|
127
97
|
for (const row of rows) {
|
|
128
98
|
try {
|
|
129
|
-
// Re-verify from the persisted CBOR
|
|
130
|
-
// time; this recomputes the witness metadata the finalize step persists).
|
|
99
|
+
// Re-verify from the persisted CBOR to recompute the witness metadata the finalize step persists.
|
|
131
100
|
const verificationResult = (0, external_signer_1.getExternalSignerModule)().verifyOrThrow(row.signedTxCbor, row.txBodyHash);
|
|
132
101
|
attempted++;
|
|
133
102
|
await submitAndFinalize(SigningRequests, {
|
|
@@ -142,9 +111,8 @@ async function redriveInterruptedSubmissions() {
|
|
|
142
111
|
logger.info({ signingRequestId: row.id, txHash: row.txBodyHash }, 'Interrupted submission re-driven');
|
|
143
112
|
}
|
|
144
113
|
catch (err) {
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
// for CBOR that verified once).
|
|
114
|
+
// Submit errors already marked the row 'failed'; verification errors leave it at
|
|
115
|
+
// 'submitting' for manual inspection.
|
|
148
116
|
logger.error({ err, signingRequestId: row.id }, 'Re-drive of interrupted submission failed');
|
|
149
117
|
}
|
|
150
118
|
}
|