@ocap/resolver 1.32.0 → 1.32.2
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/esm/explorer.mjs +12 -3
- package/esm/follower.d.mts +18 -1
- package/esm/follower.mjs +39 -9
- package/esm/hooks.mjs +1 -1
- package/esm/index.d.mts +2 -2
- package/esm/index.mjs +3 -3
- package/esm/node-preferences.mjs +7 -6
- package/esm/replayer.d.mts +58 -6
- package/esm/replayer.mjs +102 -34
- package/lib/explorer.cjs +13 -3
- package/lib/follower.cjs +38 -8
- package/lib/follower.d.cts +18 -1
- package/lib/hooks.cjs +2 -2
- package/lib/index.cjs +3 -2
- package/lib/index.d.cts +2 -2
- package/lib/node-preferences.cjs +6 -5
- package/lib/replayer.cjs +104 -33
- package/lib/replayer.d.cts +58 -6
- package/package.json +16 -15
package/lib/replayer.cjs
CHANGED
|
@@ -5,6 +5,11 @@ let _ocap_tx_protocols = require("@ocap/tx-protocols");
|
|
|
5
5
|
let _ocap_util = require("@ocap/util");
|
|
6
6
|
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
7
7
|
let _ocap_state = require("@ocap/state");
|
|
8
|
+
let _ocap_tx_pipeline = require("@ocap/tx-pipeline");
|
|
9
|
+
let lodash_cloneDeep = require("lodash/cloneDeep");
|
|
10
|
+
lodash_cloneDeep = require_rolldown_runtime.__toESM(lodash_cloneDeep);
|
|
11
|
+
let lodash_merge = require("lodash/merge");
|
|
12
|
+
lodash_merge = require_rolldown_runtime.__toESM(lodash_merge);
|
|
8
13
|
|
|
9
14
|
//#region src/replayer.ts
|
|
10
15
|
/**
|
|
@@ -22,6 +27,8 @@ let _ocap_state = require("@ocap/state");
|
|
|
22
27
|
* - Enforces pre-commit `expectedCommitHash` on `statedb.runAsLambda` so any state divergence rolls back
|
|
23
28
|
* SQLite atomically BEFORE `COMMIT` and before appending to `ledger.sqlite`.
|
|
24
29
|
*/
|
|
30
|
+
/** Error code of a replayed entry refused for a timestamp ahead of the local clock (retryable, never halting). */
|
|
31
|
+
const FUTURE_LEDGER_ENTRY_TIMESTAMP = "FUTURE_LEDGER_ENTRY_TIMESTAMP";
|
|
25
32
|
function normalizeHexLower(raw) {
|
|
26
33
|
return String(raw ?? "").trim().replace(/^0x/i, "").toLowerCase();
|
|
27
34
|
}
|
|
@@ -44,7 +51,7 @@ function isLocalStorageEngineError(err, depth = 0) {
|
|
|
44
51
|
return cause !== void 0 && cause !== err ? isLocalStorageEngineError(cause, depth + 1) : false;
|
|
45
52
|
}
|
|
46
53
|
var LedgerEntryReplayer = class {
|
|
47
|
-
constructor(resolver) {
|
|
54
|
+
constructor(resolver, options = {}) {
|
|
48
55
|
this.activeSubLambdaOverride = null;
|
|
49
56
|
this.lastCommittedHash = null;
|
|
50
57
|
this.lastCommitMismatchError = null;
|
|
@@ -52,6 +59,12 @@ var LedgerEntryReplayer = class {
|
|
|
52
59
|
this.mutex = Promise.resolve();
|
|
53
60
|
this.resolver = resolver;
|
|
54
61
|
this.emptyFilter = new _ocap_state.Blacklist();
|
|
62
|
+
const guard = options.futureTimestampGuard;
|
|
63
|
+
if (guard) {
|
|
64
|
+
if (!Number.isSafeInteger(guard.activationSequence) || guard.activationSequence < 1) throw new _ocap_util_lib_error.CustomError("INVALID_CONFIG", `futureTimestampGuard.activationSequence must be a positive integer, got ${String(guard.activationSequence)}`);
|
|
65
|
+
if (!Number.isSafeInteger(guard.maxSkewMs) || guard.maxSkewMs < 0) throw new _ocap_util_lib_error.CustomError("INVALID_CONFIG", `futureTimestampGuard.maxSkewMs must be a non-negative integer, got ${String(guard.maxSkewMs)}`);
|
|
66
|
+
}
|
|
67
|
+
this.futureTimestampGuard = guard ? { ...guard } : null;
|
|
55
68
|
const statedb = resolver.statedb;
|
|
56
69
|
const runAsLambda = typeof statedb.runAsLambda === "function" ? async (fn, opts = {}) => {
|
|
57
70
|
const expectedCommitHash = this.activeExpectedCommitHash;
|
|
@@ -141,39 +154,75 @@ var LedgerEntryReplayer = class {
|
|
|
141
154
|
if (computedTxHash.toUpperCase() !== entry.hash.toUpperCase()) throw new _ocap_util_lib_error.CustomError(throwCodeOnMismatch, `Ledger entry txRaw hash mismatch at seq=${entry.sequence}: computed ${computedTxHash}, entry has ${entry.hash}`);
|
|
142
155
|
}
|
|
143
156
|
/**
|
|
157
|
+
* #1961 future-timestamp guard (no-op unless `futureTimestampGuard` is configured). Throws a retryable
|
|
158
|
+
* `FUTURE_LEDGER_ENTRY_TIMESTAMP` that is neither a local divergence nor a peer authentication failure, so the
|
|
159
|
+
* follower logs it, keeps its state and retries on the next sync cycle.
|
|
160
|
+
*/
|
|
161
|
+
assertEntryTimestampNotInFuture(entry) {
|
|
162
|
+
const guard = this.futureTimestampGuard;
|
|
163
|
+
if (!guard || !Number.isSafeInteger(entry?.sequence) || entry.sequence < guard.activationSequence) return;
|
|
164
|
+
const nowMs = guard.now ? guard.now() : Date.now();
|
|
165
|
+
if (!Number.isFinite(nowMs) || entry.timestamp <= nowMs + guard.maxSkewMs) return;
|
|
166
|
+
const info = {
|
|
167
|
+
sequence: entry.sequence,
|
|
168
|
+
hash: String(entry.hash ?? ""),
|
|
169
|
+
timestamp: entry.timestamp,
|
|
170
|
+
nowMs,
|
|
171
|
+
maxSkewMs: guard.maxSkewMs,
|
|
172
|
+
activationSequence: guard.activationSequence
|
|
173
|
+
};
|
|
174
|
+
try {
|
|
175
|
+
guard.onReject?.(info);
|
|
176
|
+
} catch {}
|
|
177
|
+
const err = new _ocap_util_lib_error.CustomError(FUTURE_LEDGER_ENTRY_TIMESTAMP, `Ledger entry seq=${entry.sequence} timestamp ${entry.timestamp} is ${entry.timestamp - nowMs} ms ahead of the local clock (max skew ${guard.maxSkewMs} ms, guard active from seq=${guard.activationSequence}); will retry`);
|
|
178
|
+
err.retryable = true;
|
|
179
|
+
throw err;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
144
182
|
* Pre-replay wire & primitive validation for untrusted network hot-tail / cold-segment payloads (#1710).
|
|
145
|
-
* Throws `INVALID_LEDGER_ENTRY` (peer-disqualifying, non-halting) on any malformed wire field or lossy JSON coercion
|
|
183
|
+
* Throws `INVALID_LEDGER_ENTRY` (peer-disqualifying, non-halting) on any malformed wire field or lossy JSON coercion,
|
|
184
|
+
* and the retryable `FUTURE_LEDGER_ENTRY_TIMESTAMP` when the #1961 guard is on (unless the entry is local).
|
|
146
185
|
*/
|
|
147
|
-
validateWireEntry(entry) {
|
|
186
|
+
validateWireEntry(entry, options = {}) {
|
|
148
187
|
if (!entry || typeof entry !== "object" || !Number.isSafeInteger(entry.sequence) || entry.sequence < 1 || !Number.isSafeInteger(entry.nonce) || entry.nonce < 0 || !Number.isSafeInteger(entry.timestamp) || entry.timestamp < 0 || entry.timestamp > 864e13 || typeof entry.hash !== "string" || typeof entry.from !== "string" || typeof entry.pk !== "string" || typeof entry.signature !== "string" || typeof entry.txRaw !== "string" || typeof entry.txType !== "string" || typeof entry.chainId !== "string" || typeof entry.entryHash !== "string" || typeof entry.finalized !== "boolean" || entry.stateCommitHash !== void 0 && typeof entry.stateCommitHash !== "string" || entry.tx === null || typeof entry.tx !== "object" || Array.isArray(entry.tx)) throw new _ocap_util_lib_error.CustomError("INVALID_LEDGER_ENTRY", `Ledger entry seq=${String(entry?.sequence)} has invalid wire primitive types`);
|
|
149
188
|
this.verifyRawTxHashMatchesEntry(entry, "INVALID_LEDGER_ENTRY");
|
|
150
189
|
this.authenticateAndDecodeEntry(entry);
|
|
190
|
+
if (!options.skipFutureTimestampCheck) this.assertEntryTimestampNotInFuture(entry);
|
|
151
191
|
}
|
|
152
192
|
authenticateAndDecodeEntry(entry) {
|
|
153
193
|
const authRes = (0, _arcblock_ledger_core.authenticateEntryDecodedFields)(entry, true, { requireFullWireEntry: true });
|
|
154
|
-
if (!authRes.ok) throw new _ocap_util_lib_error.CustomError("INVALID_LEDGER_ENTRY", `Ledger entry seq=${entry.sequence} failed field authentication: ${authRes.reason}`);
|
|
194
|
+
if (!authRes.ok) throw new _ocap_util_lib_error.CustomError("INVALID_LEDGER_ENTRY", `Ledger entry seq=${entry.sequence} hash=${String(entry.hash)} failed field authentication: ${authRes.reason}`);
|
|
155
195
|
return authRes.decodedTx;
|
|
156
196
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
197
|
+
/**
|
|
198
|
+
* Index a rejected-but-ledgered entry (finalized, no stateCommitHash) with the row the leader wrote for it: the
|
|
199
|
+
* leader's `sendTx` passes the context of its `DecodeTx` + `DecodeItx` pipes to `_indexRejectedLedgerTx`, so the
|
|
200
|
+
* follower builds that context from the entry's txRaw with the same pipes and the time pinned to the entry
|
|
201
|
+
* (#1875). Only the rejection code differs: it is not in the ledger, so the row says `ORPHAN_LEDGER_ENTRY`.
|
|
202
|
+
*/
|
|
203
|
+
async indexOrphanEntry(entry) {
|
|
204
|
+
const ctx = {
|
|
205
|
+
txBase64: entry.txRaw,
|
|
206
|
+
config: this.resolver.config,
|
|
207
|
+
extra: { txTime: entry.timestamp }
|
|
208
|
+
};
|
|
209
|
+
const runPipe = (pipe) => new Promise((resolve, reject) => {
|
|
210
|
+
try {
|
|
211
|
+
pipe(ctx, (err) => err ? reject(err) : resolve());
|
|
212
|
+
} catch (err) {
|
|
213
|
+
reject(err);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
try {
|
|
217
|
+
await runPipe(_ocap_tx_pipeline.pipes.DecodeTx);
|
|
218
|
+
await runPipe(_ocap_tx_pipeline.pipes.DecodeItx);
|
|
219
|
+
} catch (err) {
|
|
220
|
+
throw new _ocap_util_lib_error.CustomError("INVALID_LEDGER_ENTRY", `Orphan ledger entry seq=${entry.sequence} hash=${entry.hash} does not decode as the leader decodes it: ${err instanceof Error ? err.message : String(err)}`);
|
|
221
|
+
}
|
|
222
|
+
if (String(ctx.txHash ?? "").toUpperCase() !== String(entry.hash).toUpperCase()) throw new _ocap_util_lib_error.CustomError("TX_HASH_MISMATCH", `Orphan ledger entry seq=${entry.sequence} hash=${entry.hash}: txRaw does not hash to its entry hash`);
|
|
223
|
+
const leaderCtx = (0, lodash_merge.default)((0, lodash_cloneDeep.default)(ctx), ctx);
|
|
224
|
+
leaderCtx.ledgerSequence = entry.sequence;
|
|
225
|
+
await this.resolver._indexRejectedLedgerTx(leaderCtx, { code: "ORPHAN_LEDGER_ENTRY" });
|
|
177
226
|
await this.resolver.flushIndexWrites();
|
|
178
227
|
}
|
|
179
228
|
/**
|
|
@@ -204,8 +253,9 @@ var LedgerEntryReplayer = class {
|
|
|
204
253
|
}
|
|
205
254
|
if (entry.sequence !== localLatestSeq + 1) throw new _ocap_util_lib_error.CustomError("SEQUENCE_GAP", `Non-contiguous replay sequence: localLatest=${localLatestSeq}, got seq=${entry.sequence}`);
|
|
206
255
|
}
|
|
256
|
+
if (appendToLedger) this.assertEntryTimestampNotInFuture(entry);
|
|
207
257
|
this.verifyRawTxHashMatchesEntry(entry);
|
|
208
|
-
|
|
258
|
+
this.authenticateAndDecodeEntry(entry);
|
|
209
259
|
const expectedStateCommit = (entry.stateCommitHash ?? "").trim();
|
|
210
260
|
if (appendToLedger) {
|
|
211
261
|
const v2Cutoff = options.entryHashV2From === "infinity" ? Number.POSITIVE_INFINITY : typeof options.entryHashV2From === "number" ? options.entryHashV2From : this.resolver.ledger.getEntryHashV2From?.() ?? 1;
|
|
@@ -214,7 +264,7 @@ var LedgerEntryReplayer = class {
|
|
|
214
264
|
}
|
|
215
265
|
if (!expectedStateCommit) {
|
|
216
266
|
if (appendToLedger) await this.appendVerifiedEntryToLedger(entry, options.entryHashV2From);
|
|
217
|
-
await this.indexOrphanEntry(entry
|
|
267
|
+
await this.indexOrphanEntry(entry);
|
|
218
268
|
return {
|
|
219
269
|
status: "orphan-indexed",
|
|
220
270
|
sequence: entry.sequence,
|
|
@@ -295,7 +345,7 @@ var LedgerEntryReplayer = class {
|
|
|
295
345
|
if (entry.finalized !== true) throw new _ocap_util_lib_error.CustomError("UNFINALIZED_LEDGER_ENTRY", `Proposal entry seq=${String(entry.sequence)} must be finalized`);
|
|
296
346
|
if (entry.chainId !== expectedChainId) throw new _ocap_util_lib_error.CustomError("CHAIN_ID_MISMATCH", `Proposal entry chainId mismatch at seq=${String(entry.sequence)}: expected ${expectedChainId}, got ${entry.chainId}`);
|
|
297
347
|
if (entry.sequence !== baseSeq + i + 1) throw new _ocap_util_lib_error.CustomError("SEQUENCE_GAP", `Proposal entry sequence mismatch at index ${i}: expected ${baseSeq + i + 1}, got ${entry.sequence}`);
|
|
298
|
-
this.validateWireEntry(entry);
|
|
348
|
+
this.validateWireEntry(entry, { skipFutureTimestampCheck: options.skipFutureTimestampCheck });
|
|
299
349
|
const expectedStateCommit = (entry.stateCommitHash ?? "").trim();
|
|
300
350
|
const expectedEntryHash = (0, _arcblock_ledger_core.computeEntryHash)(entry.sequence, entry.txRaw, expectedStateCommit, entry.sequence >= v2Cutoff ? 2 : 1);
|
|
301
351
|
if (entry.entryHash !== expectedEntryHash) throw new _ocap_util_lib_error.CustomError("INVALID_LEDGER_ENTRY", `Proposal entryHash mismatch at seq=${entry.sequence}: expected ${expectedEntryHash}, got ${entry.entryHash}`);
|
|
@@ -368,9 +418,27 @@ var LedgerEntryReplayer = class {
|
|
|
368
418
|
};
|
|
369
419
|
});
|
|
370
420
|
}
|
|
421
|
+
/** Upper-cased hashes of `entries` that neither `indexdb.tx` nor `statedb.tx` holds (one `$in` count per page). */
|
|
422
|
+
async hashesMissingFromIndex(entries) {
|
|
423
|
+
const missing = /* @__PURE__ */ new Set();
|
|
424
|
+
if (entries.length === 0) return missing;
|
|
425
|
+
const hashes = [...new Set(entries.map((e) => String(e.hash).toUpperCase()))];
|
|
426
|
+
const { indexdb, statedb } = this.resolver;
|
|
427
|
+
if (await indexdb.tx.count({ hash: { $in: hashes } }) === hashes.length) return missing;
|
|
428
|
+
for (const hash of hashes) {
|
|
429
|
+
if (await indexdb.tx.count({ hash }) > 0) continue;
|
|
430
|
+
if (await Promise.resolve(statedb?.tx?.get?.(hash))) continue;
|
|
431
|
+
missing.add(hash);
|
|
432
|
+
}
|
|
433
|
+
return missing;
|
|
434
|
+
}
|
|
371
435
|
/**
|
|
372
|
-
*
|
|
373
|
-
* orphan
|
|
436
|
+
* After `rebuildIndex()`, index the force-finalized orphan entries of `[fromSeq, toSeq]` that the index does not
|
|
437
|
+
* have yet. An orphan is an entry without a `stateCommitHash` (its tx never reached the statedb, so the build
|
|
438
|
+
* from the statedb cannot see it) whose tx is in neither `indexdb.tx` nor `statedb.tx`. Entries the index already
|
|
439
|
+
* holds are skipped before any decoding: beta's ledger starts with 434k migrated entries without a
|
|
440
|
+
* `stateCommitHash` and in a legacy entry shape, all indexed by the build (#1875). Every entry that is processed
|
|
441
|
+
* is authenticated as before and fails closed.
|
|
374
442
|
*/
|
|
375
443
|
async indexExistingOrphanEntries(fromSeq = 1, toSeq) {
|
|
376
444
|
const latestSeq = toSeq ?? await this.resolver.ledger.getLatestSequence();
|
|
@@ -379,11 +447,13 @@ var LedgerEntryReplayer = class {
|
|
|
379
447
|
const pageSize = 200;
|
|
380
448
|
for (let cursor = Math.max(1, fromSeq); cursor <= latestSeq; cursor += pageSize) {
|
|
381
449
|
const end = Math.min(latestSeq, cursor + pageSize - 1);
|
|
382
|
-
const
|
|
383
|
-
|
|
450
|
+
const candidates = (await this.resolver.ledger.getRange(cursor, end)).filter((entry) => !entry.stateCommitHash || !entry.stateCommitHash.trim());
|
|
451
|
+
const missing = await this.hashesMissingFromIndex(candidates);
|
|
452
|
+
for (const entry of candidates) {
|
|
453
|
+
if (!missing.has(String(entry.hash).toUpperCase())) continue;
|
|
384
454
|
this.verifyRawTxHashMatchesEntry(entry);
|
|
385
|
-
|
|
386
|
-
await this.indexOrphanEntry(entry
|
|
455
|
+
this.authenticateAndDecodeEntry(entry);
|
|
456
|
+
await this.indexOrphanEntry(entry);
|
|
387
457
|
indexedCount++;
|
|
388
458
|
}
|
|
389
459
|
}
|
|
@@ -392,4 +462,5 @@ var LedgerEntryReplayer = class {
|
|
|
392
462
|
};
|
|
393
463
|
|
|
394
464
|
//#endregion
|
|
465
|
+
exports.FUTURE_LEDGER_ENTRY_TIMESTAMP = FUTURE_LEDGER_ENTRY_TIMESTAMP;
|
|
395
466
|
exports.LedgerEntryReplayer = LedgerEntryReplayer;
|
package/lib/replayer.d.cts
CHANGED
|
@@ -28,6 +28,38 @@ interface IDryRunVerifyEntriesOptions {
|
|
|
28
28
|
expectedPrevSequence?: number;
|
|
29
29
|
prevStateRoot?: string | null;
|
|
30
30
|
entryHashV2From?: number | 'infinity';
|
|
31
|
+
/** Entries come from the local ledger (crash reconciliation), not from a peer: skip the future-timestamp guard. */
|
|
32
|
+
skipFutureTimestampCheck?: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface IValidateWireEntryOptions {
|
|
35
|
+
/** Entries come from the local ledger (crash reconciliation), not from a peer: skip the future-timestamp guard. */
|
|
36
|
+
skipFutureTimestampCheck?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** Error code of a replayed entry refused for a timestamp ahead of the local clock (retryable, never halting). */
|
|
39
|
+
declare const FUTURE_LEDGER_ENTRY_TIMESTAMP = "FUTURE_LEDGER_ENTRY_TIMESTAMP";
|
|
40
|
+
interface IFutureTimestampRejection {
|
|
41
|
+
sequence: number;
|
|
42
|
+
hash: string;
|
|
43
|
+
timestamp: number;
|
|
44
|
+
nowMs: number;
|
|
45
|
+
maxSkewMs: number;
|
|
46
|
+
activationSequence: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* #1961: `entry.timestamp` is not covered by `entryHash`, so a leader can stamp a real entry with a future time
|
|
50
|
+
* (and with it every time lock the tx sets). A follower refuses peer entries at or after `activationSequence` whose
|
|
51
|
+
* timestamp is more than `maxSkewMs` ahead of its own clock. Past timestamps are always accepted (no monotonic
|
|
52
|
+
* rule, #1972). The refusal is retryable: the entry is accepted once the local clock catches up.
|
|
53
|
+
*/
|
|
54
|
+
interface IFutureTimestampGuardOptions {
|
|
55
|
+
activationSequence: number;
|
|
56
|
+
maxSkewMs: number;
|
|
57
|
+
now?: () => number;
|
|
58
|
+
onReject?: (info: IFutureTimestampRejection) => void;
|
|
59
|
+
}
|
|
60
|
+
interface ILedgerEntryReplayerOptions {
|
|
61
|
+
/** Unset (default): no timestamp guard, today's behavior. */
|
|
62
|
+
futureTimestampGuard?: IFutureTimestampGuardOptions;
|
|
31
63
|
}
|
|
32
64
|
interface IDryRunVerifyEntriesResult {
|
|
33
65
|
derivedStateRoot: string;
|
|
@@ -43,16 +75,30 @@ declare class LedgerEntryReplayer {
|
|
|
43
75
|
private lastCommitMismatchError;
|
|
44
76
|
private lastStorageError;
|
|
45
77
|
private mutex;
|
|
46
|
-
|
|
78
|
+
private readonly futureTimestampGuard;
|
|
79
|
+
constructor(resolver: IReplayerResolverTarget, options?: ILedgerEntryReplayerOptions);
|
|
47
80
|
private runExclusive;
|
|
48
81
|
private appendVerifiedEntryToLedger;
|
|
49
82
|
private verifyRawTxHashMatchesEntry;
|
|
83
|
+
/**
|
|
84
|
+
* #1961 future-timestamp guard (no-op unless `futureTimestampGuard` is configured). Throws a retryable
|
|
85
|
+
* `FUTURE_LEDGER_ENTRY_TIMESTAMP` that is neither a local divergence nor a peer authentication failure, so the
|
|
86
|
+
* follower logs it, keeps its state and retries on the next sync cycle.
|
|
87
|
+
*/
|
|
88
|
+
assertEntryTimestampNotInFuture(entry: ILedgerEntry): void;
|
|
50
89
|
/**
|
|
51
90
|
* Pre-replay wire & primitive validation for untrusted network hot-tail / cold-segment payloads (#1710).
|
|
52
|
-
* Throws `INVALID_LEDGER_ENTRY` (peer-disqualifying, non-halting) on any malformed wire field or lossy JSON coercion
|
|
91
|
+
* Throws `INVALID_LEDGER_ENTRY` (peer-disqualifying, non-halting) on any malformed wire field or lossy JSON coercion,
|
|
92
|
+
* and the retryable `FUTURE_LEDGER_ENTRY_TIMESTAMP` when the #1961 guard is on (unless the entry is local).
|
|
53
93
|
*/
|
|
54
|
-
validateWireEntry(entry: ILedgerEntry): void;
|
|
94
|
+
validateWireEntry(entry: ILedgerEntry, options?: IValidateWireEntryOptions): void;
|
|
55
95
|
private authenticateAndDecodeEntry;
|
|
96
|
+
/**
|
|
97
|
+
* Index a rejected-but-ledgered entry (finalized, no stateCommitHash) with the row the leader wrote for it: the
|
|
98
|
+
* leader's `sendTx` passes the context of its `DecodeTx` + `DecodeItx` pipes to `_indexRejectedLedgerTx`, so the
|
|
99
|
+
* follower builds that context from the entry's txRaw with the same pipes and the time pinned to the entry
|
|
100
|
+
* (#1875). Only the rejection code differs: it is not in the ledger, so the row says `ORPHAN_LEDGER_ENTRY`.
|
|
101
|
+
*/
|
|
56
102
|
private indexOrphanEntry;
|
|
57
103
|
/**
|
|
58
104
|
* Replay a single finalized `ILedgerEntry` sequentially (`concurrency = 1`).
|
|
@@ -64,11 +110,17 @@ declare class LedgerEntryReplayer {
|
|
|
64
110
|
* and post-execution `_state_commit` hash with zero mutations to `statedb`, `trusted`, `indexdb`, or `ledger`.
|
|
65
111
|
*/
|
|
66
112
|
dryRunVerifyEntries(entries: ILedgerEntry[], options?: IDryRunVerifyEntriesOptions): Promise<IDryRunVerifyEntriesResult>;
|
|
113
|
+
/** Upper-cased hashes of `entries` that neither `indexdb.tx` nor `statedb.tx` holds (one `$in` count per page). */
|
|
114
|
+
private hashesMissingFromIndex;
|
|
67
115
|
/**
|
|
68
|
-
*
|
|
69
|
-
* orphan
|
|
116
|
+
* After `rebuildIndex()`, index the force-finalized orphan entries of `[fromSeq, toSeq]` that the index does not
|
|
117
|
+
* have yet. An orphan is an entry without a `stateCommitHash` (its tx never reached the statedb, so the build
|
|
118
|
+
* from the statedb cannot see it) whose tx is in neither `indexdb.tx` nor `statedb.tx`. Entries the index already
|
|
119
|
+
* holds are skipped before any decoding: beta's ledger starts with 434k migrated entries without a
|
|
120
|
+
* `stateCommitHash` and in a legacy entry shape, all indexed by the build (#1875). Every entry that is processed
|
|
121
|
+
* is authenticated as before and fails closed.
|
|
70
122
|
*/
|
|
71
123
|
indexExistingOrphanEntries(fromSeq?: number, toSeq?: number): Promise<number>;
|
|
72
124
|
}
|
|
73
125
|
//#endregion
|
|
74
|
-
export { IDryRunVerifyEntriesOptions, IDryRunVerifyEntriesResult, IReplayEntryOptions, IReplayEntryResult, IReplayerResolverTarget, LedgerEntryReplayer };
|
|
126
|
+
export { FUTURE_LEDGER_ENTRY_TIMESTAMP, IDryRunVerifyEntriesOptions, IDryRunVerifyEntriesResult, IFutureTimestampGuardOptions, IFutureTimestampRejection, ILedgerEntryReplayerOptions, IReplayEntryOptions, IReplayEntryResult, IReplayerResolverTarget, IValidateWireEntryOptions, LedgerEntryReplayer };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.32.
|
|
6
|
+
"version": "1.32.2",
|
|
7
7
|
"description": "GraphQL resolver built upon ocap statedb and GQL layer",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./lib/index.cjs",
|
|
@@ -54,21 +54,22 @@
|
|
|
54
54
|
"tsdown": "^0.18.4"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@arcblock/did": "1.32.
|
|
58
|
-
"@arcblock/did-ext": "1.32.
|
|
59
|
-
"@arcblock/did-util": "1.32.
|
|
60
|
-
"@arcblock/ledger-core": "1.32.
|
|
57
|
+
"@arcblock/did": "1.32.2",
|
|
58
|
+
"@arcblock/did-ext": "1.32.2",
|
|
59
|
+
"@arcblock/did-util": "1.32.2",
|
|
60
|
+
"@arcblock/ledger-core": "1.32.2",
|
|
61
61
|
"@arcblock/nft-display": "^3.2.3",
|
|
62
|
-
"@arcblock/validator": "1.32.
|
|
63
|
-
"@ocap/config": "1.32.
|
|
64
|
-
"@ocap/indexdb": "1.32.
|
|
65
|
-
"@ocap/mcrypto": "1.32.
|
|
66
|
-
"@ocap/message": "1.32.
|
|
67
|
-
"@ocap/state": "1.32.
|
|
68
|
-
"@ocap/tx-
|
|
69
|
-
"@ocap/
|
|
70
|
-
"@ocap/
|
|
71
|
-
"@ocap/
|
|
62
|
+
"@arcblock/validator": "1.32.2",
|
|
63
|
+
"@ocap/config": "1.32.2",
|
|
64
|
+
"@ocap/indexdb": "1.32.2",
|
|
65
|
+
"@ocap/mcrypto": "1.32.2",
|
|
66
|
+
"@ocap/message": "1.32.2",
|
|
67
|
+
"@ocap/state": "1.32.2",
|
|
68
|
+
"@ocap/tx-pipeline": "1.32.2",
|
|
69
|
+
"@ocap/tx-protocols": "1.32.2",
|
|
70
|
+
"@ocap/types": "1.32.2",
|
|
71
|
+
"@ocap/util": "1.32.2",
|
|
72
|
+
"@ocap/wallet": "1.32.2",
|
|
72
73
|
"debug": "^4.4.3",
|
|
73
74
|
"express": "^4.22.1",
|
|
74
75
|
"lodash": "^4.17.23",
|