@secondlayer/shared 15.4.2 → 15.5.0
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/dist/src/archive/range-digest.d.ts +3 -0
- package/dist/src/archive/semantic-digest-builder.d.ts +3 -0
- package/dist/src/coverage/index.d.ts +3 -0
- package/dist/src/db/index.d.ts +3 -0
- package/dist/src/db/index.js.map +2 -2
- package/dist/src/db/queries/chain-reorgs.d.ts +3 -0
- package/dist/src/db/queries/chain-reorgs.js.map +2 -2
- package/dist/src/db/queries/contracts.d.ts +3 -0
- package/dist/src/db/queries/contracts.js.map +2 -2
- package/dist/src/db/queries/instance.d.ts +3 -0
- package/dist/src/db/queries/integrity.d.ts +3 -0
- package/dist/src/db/queries/subgraph-gaps.d.ts +6 -3
- package/dist/src/db/queries/subgraph-gaps.js +11 -11
- package/dist/src/db/queries/subgraph-gaps.js.map +3 -3
- package/dist/src/db/queries/subgraph-operations.d.ts +3 -0
- package/dist/src/db/queries/subgraphs.d.ts +11 -8
- package/dist/src/db/queries/subgraphs.js +25 -19
- package/dist/src/db/queries/subgraphs.js.map +3 -3
- package/dist/src/db/queries/sync-scope.d.ts +3 -0
- package/dist/src/db/queries/webhook-replays.d.ts +3 -0
- package/dist/src/db/queries/webhooks.d.ts +3 -0
- package/dist/src/db/schema.d.ts +3 -0
- package/dist/src/db/schema.js.map +2 -2
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js.map +2 -2
- package/dist/src/insights/index.d.ts +3 -0
- package/dist/src/insights/index.js +3 -3
- package/dist/src/insights/index.js.map +3 -3
- package/dist/src/leader.js.map +2 -2
- package/dist/src/node/local-client.d.ts +3 -0
- package/dist/src/queue/listener.js.map +2 -2
- package/migrations/0203_subgraph_side_tables_subgraph_id.ts +109 -0
- package/package.json +1 -1
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/db/queries/subgraph-gaps.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { type Kysely, sql } from \"kysely\";\nimport type { Database, GapReason } from \"../types.ts\";\n\nexport interface GapRange {\n\tstart: number;\n\tend: number;\n\treason: GapReason;\n}\n\nexport interface SubgraphGapRow {\n\tid: string;\n\tsubgraphName: string;\n\tgapStart: number;\n\tgapEnd: number;\n\tsize: number;\n\treason: string;\n\tdetectedAt: Date;\n\tresolvedAt: Date | null;\n}\n\nexport interface GapSummary {\n\tsubgraphName: string;\n\tgapCount: number;\n\ttotalMissingBlocks: number;\n}\n\n/** Serializes writers of one subgraph's gap rows for the rest of the\n * transaction, so two of them can never both decide a range is uncovered. */\nasync function lockGaps(db: Kysely<Database>,
|
|
5
|
+
"import { type Kysely, sql } from \"kysely\";\nimport type { Database, GapReason } from \"../types.ts\";\n\nexport interface GapRange {\n\tstart: number;\n\tend: number;\n\treason: GapReason;\n}\n\nexport interface SubgraphGapRow {\n\tid: string;\n\tsubgraphName: string;\n\tgapStart: number;\n\tgapEnd: number;\n\tsize: number;\n\treason: string;\n\tdetectedAt: Date;\n\tresolvedAt: Date | null;\n}\n\nexport interface GapSummary {\n\tsubgraphName: string;\n\tgapCount: number;\n\ttotalMissingBlocks: number;\n}\n\n/** Serializes writers of one subgraph's gap rows for the rest of the\n * transaction, so two of them can never both decide a range is uncovered. */\nasync function lockGaps(db: Kysely<Database>, subgraphId: string) {\n\tawait sql`SELECT pg_advisory_xact_lock(hashtext(${`subgraph-gaps:${subgraphId}`}))`.execute(\n\t\tdb,\n\t);\n}\n\n/** Runs `fn` in a transaction, or in the caller's when it already has one. */\nfunction inTransaction<T>(\n\tdb: Kysely<Database>,\n\tfn: (trx: Kysely<Database>) => Promise<T>,\n): Promise<T> {\n\treturn db.isTransaction ? fn(db) : db.transaction().execute(fn);\n}\n\ntype Span = { start: number; end: number };\n\n/** `span` minus every range in `taken`: the pieces nothing covers yet. */\nfunction uncovered(span: Span, taken: Span[]): Span[] {\n\tconst pieces: Span[] = [];\n\tlet cursor = span.start;\n\tfor (const t of [...taken].sort((a, b) => a.start - b.start)) {\n\t\tif (t.end < cursor) continue;\n\t\tif (t.start > span.end) break;\n\t\tif (t.start > cursor) pieces.push({ start: cursor, end: t.start - 1 });\n\t\tcursor = Math.max(cursor, t.end + 1);\n\t}\n\tif (cursor <= span.end) pieces.push({ start: cursor, end: span.end });\n\treturn pieces;\n}\n\n/**\n * Batch-insert gap ranges for a subgraph. Only the part of each range that no\n * unresolved gap covers is inserted, so gap rows never overlap and the summaries\n * (which sum sizes) never count a block twice. Callers should still coalesce\n * contiguous skipped blocks into ranges before calling.\n */\nexport async function recordGapBatch(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n\tsubgraphName: string,\n\tgaps: GapRange[],\n): Promise<void> {\n\tif (gaps.length === 0) return;\n\tfor (const g of gaps) {\n\t\tif (g.start > g.end) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid gap range ${g.start}-${g.end}: start is after end`,\n\t\t\t);\n\t\t}\n\t}\n\n\tawait inTransaction(db, async (trx) => {\n\t\tawait lockGaps(trx, subgraphId);\n\t\tconst existing = (\n\t\t\tawait trx\n\t\t\t\t.selectFrom(\"subgraph_gaps\")\n\t\t\t\t.select([\"gap_start\", \"gap_end\"])\n\t\t\t\t.where(\"subgraph_id\", \"=\", subgraphId)\n\t\t\t\t.where(\"resolved_at\", \"is\", null)\n\t\t\t\t.where(\"gap_start\", \"<=\", Math.max(...gaps.map((g) => g.end)))\n\t\t\t\t.where(\"gap_end\", \">=\", Math.min(...gaps.map((g) => g.start)))\n\t\t\t\t.execute()\n\t\t).map((r) => ({ start: Number(r.gap_start), end: Number(r.gap_end) }));\n\n\t\t// Each insert also counts as taken for the ones after it in the batch.\n\t\tconst taken = [...existing];\n\t\tconst rows: Array<{\n\t\t\tsubgraph_id: string;\n\t\t\tsubgraph_name: string;\n\t\t\tgap_start: number;\n\t\t\tgap_end: number;\n\t\t\treason: GapReason;\n\t\t}> = [];\n\t\tfor (const g of gaps) {\n\t\t\tfor (const piece of uncovered({ start: g.start, end: g.end }, taken)) {\n\t\t\t\ttaken.push(piece);\n\t\t\t\trows.push({\n\t\t\t\t\tsubgraph_id: subgraphId,\n\t\t\t\t\tsubgraph_name: subgraphName,\n\t\t\t\t\tgap_start: piece.start,\n\t\t\t\t\tgap_end: piece.end,\n\t\t\t\t\treason: g.reason,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tif (rows.length > 0) {\n\t\t\tawait trx.insertInto(\"subgraph_gaps\").values(rows).execute();\n\t\t}\n\t});\n}\n\n/**\n * List gaps for a subgraph with computed size.\n */\nexport async function findSubgraphGaps(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n\topts?: { limit?: number; offset?: number; unresolvedOnly?: boolean },\n): Promise<{ gaps: SubgraphGapRow[]; total: number }> {\n\tconst limit = opts?.limit ?? 50;\n\tconst offset = opts?.offset ?? 0;\n\tconst unresolvedOnly = opts?.unresolvedOnly ?? true;\n\n\tlet baseQuery = db\n\t\t.selectFrom(\"subgraph_gaps\")\n\t\t.where(\"subgraph_id\", \"=\", subgraphId);\n\n\tif (unresolvedOnly) {\n\t\tbaseQuery = baseQuery.where(\"resolved_at\", \"is\", null);\n\t}\n\n\tconst [rows, countResult] = await Promise.all([\n\t\tbaseQuery\n\t\t\t.select([\n\t\t\t\t\"id\",\n\t\t\t\t\"subgraph_name\",\n\t\t\t\t\"gap_start\",\n\t\t\t\t\"gap_end\",\n\t\t\t\tsql<number>`gap_end - gap_start + 1`.as(\"size\"),\n\t\t\t\t\"reason\",\n\t\t\t\t\"detected_at\",\n\t\t\t\t\"resolved_at\",\n\t\t\t])\n\t\t\t.orderBy(\"gap_start\", \"asc\")\n\t\t\t.limit(limit)\n\t\t\t.offset(offset)\n\t\t\t.execute(),\n\t\tbaseQuery\n\t\t\t.select(sql<number>`count(*)`.as(\"count\"))\n\t\t\t.executeTakeFirstOrThrow(),\n\t]);\n\n\treturn {\n\t\tgaps: rows.map((r) => ({\n\t\t\tid: r.id,\n\t\t\tsubgraphName: r.subgraph_name,\n\t\t\tgapStart: Number(r.gap_start),\n\t\t\tgapEnd: Number(r.gap_end),\n\t\t\tsize: Number(r.size),\n\t\t\treason: r.reason,\n\t\t\tdetectedAt: r.detected_at,\n\t\t\tresolvedAt: r.resolved_at,\n\t\t})),\n\t\ttotal: Number(countResult.count),\n\t};\n}\n\n/**\n * Mark gaps as resolved within a block range. Idempotent.\n *\n * A gap inside [fromBlock, toBlock] is resolved whole. One that only partly\n * overlaps is resolved too, and what the range does not cover is reopened as\n * gaps of its own, so a walk over part of a gap repairs exactly that part.\n * With `detectedBefore`, gaps recorded at or after it stay open: a walk passes\n * its own start time (from the database clock) so a block that failed during\n * the walk is not resolved by the walk that just recorded it.\n */\nexport async function resolveGaps(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n\tfromBlock: number,\n\ttoBlock: number,\n\topts?: { detectedBefore?: Date },\n): Promise<number> {\n\treturn inTransaction(db, async (trx) => {\n\t\tawait lockGaps(trx, subgraphId);\n\t\tlet q = trx\n\t\t\t.selectFrom(\"subgraph_gaps\")\n\t\t\t.selectAll()\n\t\t\t.where(\"subgraph_id\", \"=\", subgraphId)\n\t\t\t.where(\"resolved_at\", \"is\", null)\n\t\t\t.where(\"gap_start\", \"<=\", toBlock)\n\t\t\t.where(\"gap_end\", \">=\", fromBlock);\n\t\tif (opts?.detectedBefore) {\n\t\t\tq = q.where(\"detected_at\", \"<\", opts.detectedBefore);\n\t\t}\n\t\tconst hit = await q.execute();\n\t\tif (hit.length === 0) return 0;\n\n\t\tawait trx\n\t\t\t.updateTable(\"subgraph_gaps\")\n\t\t\t.set({ resolved_at: new Date() })\n\t\t\t.where(\n\t\t\t\t\"id\",\n\t\t\t\t\"in\",\n\t\t\t\thit.map((g) => g.id),\n\t\t\t)\n\t\t\t.execute();\n\n\t\tconst reopened = hit.flatMap((g) => {\n\t\t\tconst start = Number(g.gap_start);\n\t\t\tconst end = Number(g.gap_end);\n\t\t\tconst keep: Span[] = [];\n\t\t\tif (start < fromBlock) keep.push({ start, end: fromBlock - 1 });\n\t\t\tif (end > toBlock) keep.push({ start: toBlock + 1, end });\n\t\t\treturn keep.map((k) => ({\n\t\t\t\tsubgraph_id: g.subgraph_id,\n\t\t\t\tsubgraph_name: g.subgraph_name,\n\t\t\t\tgap_start: k.start,\n\t\t\t\tgap_end: k.end,\n\t\t\t\treason: g.reason,\n\t\t\t\tdetected_at: g.detected_at,\n\t\t\t}));\n\t\t});\n\t\tif (reopened.length > 0) {\n\t\t\tawait trx.insertInto(\"subgraph_gaps\").values(reopened).execute();\n\t\t}\n\t\treturn hit.length;\n\t});\n}\n\n/**\n * Total missing blocks across unresolved gaps for a subgraph.\n */\nexport async function countSubgraphMissingBlocks(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n): Promise<number> {\n\tconst { rows } = await sql<{ total: string }>`\n SELECT COALESCE(SUM(gap_end - gap_start + 1), 0) AS total\n FROM subgraph_gaps\n WHERE subgraph_id = ${subgraphId}\n AND resolved_at IS NULL\n `.execute(db);\n\n\treturn Number(rows[0]?.total ?? 0);\n}\n\n/**\n * Aggregate gap counts + missing blocks grouped by subgraph_name.\n * Used by the /status endpoint for per-subgraph gap summary.\n */\nexport async function getGapSummaryBySubgraph(\n\tdb: Kysely<Database>,\n): Promise<GapSummary[]> {\n\tconst { rows } = await sql<{\n\t\tsubgraph_name: string;\n\t\tgap_count: string;\n\t\ttotal_missing: string;\n\t}>`\n SELECT\n subgraph_name,\n COUNT(*) AS gap_count,\n COALESCE(SUM(gap_end - gap_start + 1), 0) AS total_missing\n FROM subgraph_gaps\n WHERE resolved_at IS NULL\n GROUP BY subgraph_name\n `.execute(db);\n\n\treturn rows.map((r) => ({\n\t\tsubgraphName: r.subgraph_name,\n\t\tgapCount: Number(r.gap_count),\n\t\ttotalMissingBlocks: Number(r.total_missing),\n\t}));\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";AAAA;AA4BA,eAAe,QAAQ,CAAC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;AAAA,IAChB,UAAU,OAAO,EAAE,SAAS;AAAA,IAC5B,oBAAoB,OAAO,EAAE,aAAa;AAAA,EAC3C,EAAE;AAAA;",
|
|
8
|
+
"debugId": "5388AFEA63DF1A0C64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -258,6 +258,7 @@ interface SubgraphGapsTable {
|
|
|
258
258
|
/** Print-validate skips persisted for the authed violations GET. Cap 100/subgraph. */
|
|
259
259
|
interface SubgraphViolationsTable {
|
|
260
260
|
id: Generated<string>;
|
|
261
|
+
subgraph_id: string;
|
|
261
262
|
subgraph_name: string;
|
|
262
263
|
source_name: string;
|
|
263
264
|
block_height: number;
|
|
@@ -367,6 +368,7 @@ interface MagicLinksTable {
|
|
|
367
368
|
}
|
|
368
369
|
interface SubgraphProcessingStatsTable {
|
|
369
370
|
id: Generated<string>;
|
|
371
|
+
subgraph_id: string;
|
|
370
372
|
subgraph_name: string;
|
|
371
373
|
api_key_id: string | null;
|
|
372
374
|
bucket_start: Date | null;
|
|
@@ -395,6 +397,7 @@ interface SubgraphHealthSnapshotsTable {
|
|
|
395
397
|
/** Handler errors grouped by fingerprint. Cap 50/subgraph. */
|
|
396
398
|
interface SubgraphErrorGroupsTable {
|
|
397
399
|
id: Generated<string>;
|
|
400
|
+
subgraph_id: string;
|
|
398
401
|
subgraph_name: string;
|
|
399
402
|
fingerprint: string;
|
|
400
403
|
source_name: string;
|
|
@@ -269,6 +269,7 @@ interface SubgraphGapsTable {
|
|
|
269
269
|
/** Print-validate skips persisted for the authed violations GET. Cap 100/subgraph. */
|
|
270
270
|
interface SubgraphViolationsTable {
|
|
271
271
|
id: Generated<string>;
|
|
272
|
+
subgraph_id: string;
|
|
272
273
|
subgraph_name: string;
|
|
273
274
|
source_name: string;
|
|
274
275
|
block_height: number;
|
|
@@ -378,6 +379,7 @@ interface MagicLinksTable {
|
|
|
378
379
|
}
|
|
379
380
|
interface SubgraphProcessingStatsTable {
|
|
380
381
|
id: Generated<string>;
|
|
382
|
+
subgraph_id: string;
|
|
381
383
|
subgraph_name: string;
|
|
382
384
|
api_key_id: string | null;
|
|
383
385
|
bucket_start: Date | null;
|
|
@@ -406,6 +408,7 @@ interface SubgraphHealthSnapshotsTable {
|
|
|
406
408
|
/** Handler errors grouped by fingerprint. Cap 50/subgraph. */
|
|
407
409
|
interface SubgraphErrorGroupsTable {
|
|
408
410
|
id: Generated<string>;
|
|
411
|
+
subgraph_id: string;
|
|
409
412
|
subgraph_name: string;
|
|
410
413
|
fingerprint: string;
|
|
411
414
|
source_name: string;
|
|
@@ -1532,7 +1535,7 @@ declare function listSubgraphs(db: Kysely2<Database>, accountId?: string): Promi
|
|
|
1532
1535
|
* state (halted, cancelled, redeployed): the walk must not write on, and its
|
|
1533
1536
|
* progress never revives a halt.
|
|
1534
1537
|
*/
|
|
1535
|
-
declare function setReindexCursor(db: Kysely2<Database>,
|
|
1538
|
+
declare function setReindexCursor(db: Kysely2<Database>, subgraphId: string, lastProcessedBlock: number, blockHash?: string): Promise<boolean>;
|
|
1536
1539
|
/** Live-walk ERROR write (f069): a block whose handlers ALL failed
|
|
1537
1540
|
* (`processed === 0 && errors > 0`, `block-processor.ts`'s `applyProgress`)
|
|
1538
1541
|
* moves an `active` subgraph to 'error' and records its height as processed;
|
|
@@ -1548,14 +1551,14 @@ declare function setReindexCursor(db: Kysely2<Database>, name: string, lastProce
|
|
|
1548
1551
|
* case that needs `CursorRaceLostError`-style tx abort. Returns whether
|
|
1549
1552
|
* the write applied. Live path only: reindex/backfill halts go through
|
|
1550
1553
|
* {@link transitionSubgraph}. */
|
|
1551
|
-
declare function recordLiveError(db: Kysely2<Database>,
|
|
1552
|
-
declare function recordSubgraphProcessed(db: Kysely2<Database>,
|
|
1554
|
+
declare function recordLiveError(db: Kysely2<Database>, subgraphId: string, blockHeight: number, blockHash?: string): Promise<boolean>;
|
|
1555
|
+
declare function recordSubgraphProcessed(db: Kysely2<Database>, subgraphId: string, processed: number, errors: number, lastError?: string): Promise<void>;
|
|
1553
1556
|
/** Record a billing pause. Status, cursor, counters and `last_error` are
|
|
1554
1557
|
* untouched: a paused subgraph is healthy, just waiting on its account. */
|
|
1555
|
-
declare function markSubgraphBillingPaused(db: Kysely2<Database>,
|
|
1558
|
+
declare function markSubgraphBillingPaused(db: Kysely2<Database>, subgraphId: string, code: string): Promise<void>;
|
|
1556
1559
|
/** Clear a billing pause once reads succeed again. */
|
|
1557
|
-
declare function clearSubgraphBillingPaused(db: Kysely2<Database>,
|
|
1558
|
-
declare function updateSubgraphHandlerPath(db: Kysely2<Database>,
|
|
1560
|
+
declare function clearSubgraphBillingPaused(db: Kysely2<Database>, subgraphId: string): Promise<void>;
|
|
1561
|
+
declare function updateSubgraphHandlerPath(db: Kysely2<Database>, subgraphId: string, handlerPath: string, opts?: {
|
|
1559
1562
|
handlerCode?: string
|
|
1560
1563
|
sourceCode?: string
|
|
1561
1564
|
pin?: string | null
|
|
@@ -1596,7 +1599,7 @@ declare function deleteSubgraph(db: Kysely2<Database>, name: string, accountId?:
|
|
|
1596
1599
|
* {@link rewindLiveProgress} instead, which keeps the old unconditional
|
|
1597
1600
|
* semantics and is safe specifically because the reorg path takes a
|
|
1598
1601
|
* transaction-scoped advisory lock (`reorg.ts`) other writers can't cross. */
|
|
1599
|
-
declare function recordLiveProgress(db: Kysely2<Database>,
|
|
1602
|
+
declare function recordLiveProgress(db: Kysely2<Database>, subgraphId: string, lastProcessedBlock: number, blockHash?: string): Promise<boolean>;
|
|
1600
1603
|
/** Reorg-rewind progress write: the OLD unconditional `recordLiveProgress`
|
|
1601
1604
|
* semantics, verbatim — moves `last_processed_block` to the fork height
|
|
1602
1605
|
* regardless of its current value, because that is by definition a
|
|
@@ -1611,5 +1614,5 @@ declare function recordLiveProgress(db: Kysely2<Database>, name: string, lastPro
|
|
|
1611
1614
|
* delete+reprocess+rewind sequence — no other writer can interleave a
|
|
1612
1615
|
* forward write between the rewind and the fork block's reprocess. Do not
|
|
1613
1616
|
* call this from the live catch-up path. */
|
|
1614
|
-
declare function rewindLiveProgress(db: Kysely2<Database>,
|
|
1617
|
+
declare function rewindLiveProgress(db: Kysely2<Database>, subgraphId: string, lastProcessedBlock: number, blockHash?: string): Promise<void>;
|
|
1615
1618
|
export { clearSubgraphBillingPaused, deleteSubgraph, getSubgraph, listSubgraphs, localSubgraphAccountId, markSubgraphBillingPaused, pgSchemaName, recordLiveError, recordLiveProgress, recordSubgraphProcessed, registerSubgraph, rewindLiveProgress, setReindexCursor, subgraphMachine, transitionSubgraph, updateSubgraphHandlerPath };
|
|
@@ -201,46 +201,46 @@ async function listSubgraphs(db, accountId) {
|
|
|
201
201
|
function cursorHash(blockHash) {
|
|
202
202
|
return blockHash === undefined ? {} : { last_processed_block_hash: blockHash };
|
|
203
203
|
}
|
|
204
|
-
async function setReindexCursor(db,
|
|
204
|
+
async function setReindexCursor(db, subgraphId, lastProcessedBlock, blockHash) {
|
|
205
205
|
const result = await db.updateTable("subgraphs").set({
|
|
206
206
|
last_processed_block: lastProcessedBlock,
|
|
207
207
|
...cursorHash(blockHash),
|
|
208
208
|
updated_at: new Date
|
|
209
|
-
}).where("
|
|
209
|
+
}).where("id", "=", subgraphId).where("status", "=", "reindexing").executeTakeFirst();
|
|
210
210
|
return Number(result.numUpdatedRows ?? 0n) > 0;
|
|
211
211
|
}
|
|
212
|
-
async function recordLiveError(db,
|
|
212
|
+
async function recordLiveError(db, subgraphId, blockHeight, blockHash) {
|
|
213
213
|
const result = await db.updateTable("subgraphs").set({
|
|
214
214
|
status: "error",
|
|
215
215
|
last_processed_block: blockHeight,
|
|
216
216
|
...cursorHash(blockHash),
|
|
217
217
|
updated_at: new Date
|
|
218
|
-
}).where("
|
|
218
|
+
}).where("id", "=", subgraphId).where("status", "=", "active").where("last_processed_block", "<", blockHeight).executeTakeFirst();
|
|
219
219
|
return Number(result.numUpdatedRows ?? 0n) > 0;
|
|
220
220
|
}
|
|
221
|
-
async function recordSubgraphProcessed(db,
|
|
221
|
+
async function recordSubgraphProcessed(db, subgraphId, processed, errors, lastError) {
|
|
222
222
|
await db.updateTable("subgraphs").set({
|
|
223
223
|
total_processed: sql3`total_processed + ${processed}`,
|
|
224
224
|
total_errors: sql3`total_errors + ${errors}`,
|
|
225
225
|
...lastError ? { last_error: lastError, last_error_at: new Date } : {},
|
|
226
226
|
updated_at: new Date
|
|
227
|
-
}).where("
|
|
227
|
+
}).where("id", "=", subgraphId).execute();
|
|
228
228
|
}
|
|
229
|
-
async function markSubgraphBillingPaused(db,
|
|
229
|
+
async function markSubgraphBillingPaused(db, subgraphId, code) {
|
|
230
230
|
await db.updateTable("subgraphs").set({
|
|
231
231
|
billing_paused_at: sql3`COALESCE(billing_paused_at, now())`,
|
|
232
232
|
billing_paused_code: code,
|
|
233
233
|
updated_at: new Date
|
|
234
|
-
}).where("
|
|
234
|
+
}).where("id", "=", subgraphId).execute();
|
|
235
235
|
}
|
|
236
|
-
async function clearSubgraphBillingPaused(db,
|
|
236
|
+
async function clearSubgraphBillingPaused(db, subgraphId) {
|
|
237
237
|
await db.updateTable("subgraphs").set({
|
|
238
238
|
billing_paused_at: null,
|
|
239
239
|
billing_paused_code: null,
|
|
240
240
|
updated_at: new Date
|
|
241
|
-
}).where("
|
|
241
|
+
}).where("id", "=", subgraphId).where("billing_paused_at", "is not", null).execute();
|
|
242
242
|
}
|
|
243
|
-
async function updateSubgraphHandlerPath(db,
|
|
243
|
+
async function updateSubgraphHandlerPath(db, subgraphId, handlerPath, opts) {
|
|
244
244
|
await db.updateTable("subgraphs").set({
|
|
245
245
|
handler_path: handlerPath,
|
|
246
246
|
...opts?.handlerCode != null ? { handler_code: opts.handlerCode } : {},
|
|
@@ -251,31 +251,37 @@ async function updateSubgraphHandlerPath(db, name, handlerPath, opts) {
|
|
|
251
251
|
verification: opts.verification ? jsonb(opts.verification) : null
|
|
252
252
|
} : {},
|
|
253
253
|
updated_at: new Date
|
|
254
|
-
}).where("
|
|
254
|
+
}).where("id", "=", subgraphId).execute();
|
|
255
255
|
}
|
|
256
256
|
async function deleteSubgraph(db, name, accountId) {
|
|
257
257
|
const subgraph = await getSubgraph(db, name, accountId);
|
|
258
258
|
if (!subgraph)
|
|
259
259
|
return null;
|
|
260
260
|
const schemaName = subgraph.schema_name ?? pgSchemaName(name);
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
const remove = async (trx) => {
|
|
262
|
+
await sql3`DROP SCHEMA IF EXISTS ${sql3.raw(`"${schemaName}"`)} CASCADE`.execute(trx);
|
|
263
|
+
await trx.deleteFrom("subgraphs").where("id", "=", subgraph.id).execute();
|
|
264
|
+
};
|
|
265
|
+
if (db.isTransaction)
|
|
266
|
+
await remove(db);
|
|
267
|
+
else
|
|
268
|
+
await db.transaction().execute(remove);
|
|
263
269
|
return subgraph;
|
|
264
270
|
}
|
|
265
|
-
async function recordLiveProgress(db,
|
|
271
|
+
async function recordLiveProgress(db, subgraphId, lastProcessedBlock, blockHash) {
|
|
266
272
|
const result = await db.updateTable("subgraphs").set({
|
|
267
273
|
last_processed_block: lastProcessedBlock,
|
|
268
274
|
...cursorHash(blockHash),
|
|
269
275
|
updated_at: new Date
|
|
270
|
-
}).where("
|
|
276
|
+
}).where("id", "=", subgraphId).where("status", "=", "active").where("last_processed_block", "<", lastProcessedBlock).executeTakeFirst();
|
|
271
277
|
return Number(result.numUpdatedRows ?? 0n) > 0;
|
|
272
278
|
}
|
|
273
|
-
async function rewindLiveProgress(db,
|
|
279
|
+
async function rewindLiveProgress(db, subgraphId, lastProcessedBlock, blockHash) {
|
|
274
280
|
await db.updateTable("subgraphs").set({
|
|
275
281
|
last_processed_block: lastProcessedBlock,
|
|
276
282
|
...cursorHash(blockHash),
|
|
277
283
|
updated_at: new Date
|
|
278
|
-
}).where("
|
|
284
|
+
}).where("id", "=", subgraphId).where("status", "=", "active").execute();
|
|
279
285
|
}
|
|
280
286
|
export {
|
|
281
287
|
clearSubgraphBillingPaused,
|
|
@@ -296,5 +302,5 @@ export {
|
|
|
296
302
|
updateSubgraphHandlerPath
|
|
297
303
|
};
|
|
298
304
|
|
|
299
|
-
//# debugId=
|
|
305
|
+
//# debugId=53B116467828D4A264756E2164756E21
|
|
300
306
|
//# sourceMappingURL=subgraphs.js.map
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/db/queries/subgraphs.ts", "../src/mode.ts", "../src/schemas/subgraphs.ts", "../src/db/jsonb.ts", "../src/db/transition.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { type Kysely, sql } from \"kysely\";\nimport { isPlatformMode } from \"../../mode.ts\";\nimport {\n\tSUBGRAPH_STATES,\n\ttype SubgraphStatus,\n\ttype SubgraphVerification,\n} from \"../../schemas/subgraphs.ts\";\nimport { jsonb } from \"../jsonb.ts\";\nimport { type Machine, casTransition, defineMachine } from \"../transition.ts\";\nimport type { Database, Subgraph } from \"../types.ts\";\n\n/**\n * Subgraph lifecycle. `error` is sticky: a live walk never clears it, only a\n * redeploy (`error -> active`) or a reindex (`error -> reindexing`) does.\n * Every status write goes through {@link transitionSubgraph}; the live\n * progress writes below touch the cursor only and are gated on the status\n * they are valid for.\n */\nexport const subgraphMachine: Machine<SubgraphStatus> = defineMachine({\n\tstates: SUBGRAPH_STATES,\n\ttransitions: {\n\t\tactive: [\"reindexing\", \"error\"],\n\t\treindexing: [\"active\", \"error\"],\n\t\terror: [\"reindexing\", \"active\"],\n\t},\n});\n\n/**\n * Move a subgraph from one of `from` to `to`, writing `set` in the same\n * statement. Returns the row, or `null` when it was not in a `from` state\n * (something else, a halt or a redeploy, decided first): log and stop, never\n * retry. Staying in the same state (`reindexing -> reindexing`) is a plain\n * conditional write, not a transition.\n */\nexport function transitionSubgraph(\n\tdb: Kysely<Database>,\n\tname: string,\n\tfrom: readonly SubgraphStatus[],\n\tto: SubgraphStatus,\n\tset?: Record<string, unknown>,\n): Promise<Subgraph | null> {\n\tfor (const state of from) {\n\t\tif (state !== to) subgraphMachine.assert(state, to);\n\t}\n\treturn casTransition<SubgraphStatus, Subgraph>(db, {\n\t\ttable: \"subgraphs\",\n\t\tkey: \"name\",\n\t\tid: name,\n\t\tfrom,\n\t\tto,\n\t\tset,\n\t});\n}\n\n/** Convert a subgraph name to its PostgreSQL schema name. */\nexport function pgSchemaName(subgraphName: string): string {\n\tconst safeName = subgraphName.replace(/-/g, \"_\");\n\treturn `subgraph_${safeName}`;\n}\n\n/** OSS writes empty account_id — name is the local unique key. */\nexport function localSubgraphAccountId(accountId?: string): string {\n\tif (!isPlatformMode()) return \"\";\n\treturn accountId ?? \"\";\n}\n\nexport async function registerSubgraph(\n\tdb: Kysely<Database>,\n\tdata: {\n\t\tname: string;\n\t\tversion: string;\n\t\tdefinition: Record<string, unknown>;\n\t\tschemaHash: string;\n\t\thandlerPath: string;\n\t\tapiKeyId?: string;\n\t\taccountId?: string;\n\t\tschemaName?: string;\n\t\tstartBlock?: number;\n\t\thandlerCode?: string;\n\t\tsourceCode?: string;\n\t\tpin?: string | null;\n\t\tpinPreimage?: string | null;\n\t\tverification?: SubgraphVerification | null;\n\t},\n): Promise<Subgraph> {\n\tconst accountId = localSubgraphAccountId(data.accountId);\n\tconst values = {\n\t\tname: data.name,\n\t\tversion: data.version,\n\t\tdefinition: jsonb<Record<string, unknown>>(data.definition),\n\t\tschema_hash: data.schemaHash,\n\t\thandler_path: data.handlerPath,\n\t\taccount_id: accountId,\n\t\thandler_code: data.handlerCode ?? null,\n\t\tsource_code: data.sourceCode ?? null,\n\t\tschema_name: data.schemaName ?? null,\n\t\tstart_block: data.startBlock ?? 0,\n\t\tpin: data.pin ?? null,\n\t\tpin_preimage: data.pinPreimage ?? null,\n\t\tverification: data.verification\n\t\t\t? jsonb<SubgraphVerification>(data.verification)\n\t\t\t: null,\n\t};\n\tconst updateSet = {\n\t\tversion: data.version,\n\t\tdefinition: jsonb<Record<string, unknown>>(data.definition),\n\t\tschema_hash: data.schemaHash,\n\t\thandler_path: data.handlerPath,\n\t\thandler_code: data.handlerCode ?? null,\n\t\tsource_code: data.sourceCode ?? null,\n\t\tschema_name: data.schemaName ?? null,\n\t\tstart_block: data.startBlock ?? 0,\n\t\tpin: values.pin,\n\t\tpin_preimage: values.pin_preimage,\n\t\tverification: values.verification,\n\t\tupdated_at: new Date(),\n\t};\n\n\t// OSS: name is unique. Upsert by name so leftover rows with a non-empty\n\t// account_id (pre-local-namespace deploys) don't insert a second row.\n\tif (!isPlatformMode()) {\n\t\tconst existing = await db\n\t\t\t.selectFrom(\"subgraphs\")\n\t\t\t.select(\"id\")\n\t\t\t.where(\"name\", \"=\", data.name)\n\t\t\t.executeTakeFirst();\n\t\tif (existing) {\n\t\t\treturn await db\n\t\t\t\t.updateTable(\"subgraphs\")\n\t\t\t\t.set({ ...updateSet, account_id: \"\" })\n\t\t\t\t.where(\"id\", \"=\", existing.id)\n\t\t\t\t.returningAll()\n\t\t\t\t.executeTakeFirstOrThrow();\n\t\t}\n\t\treturn await db\n\t\t\t.insertInto(\"subgraphs\")\n\t\t\t.values(values)\n\t\t\t.returningAll()\n\t\t\t.executeTakeFirstOrThrow();\n\t}\n\n\treturn await db\n\t\t.insertInto(\"subgraphs\")\n\t\t.values(values)\n\t\t.onConflict((oc) =>\n\t\t\toc.columns([\"name\", \"account_id\"]).doUpdateSet(updateSet),\n\t\t)\n\t\t.returningAll()\n\t\t.executeTakeFirstOrThrow();\n}\n\nexport async function getSubgraph(\n\tdb: Kysely<Database>,\n\tname: string,\n\taccountId?: string,\n): Promise<Subgraph | null> {\n\tlet query = db.selectFrom(\"subgraphs\").selectAll().where(\"name\", \"=\", name);\n\n\tif (isPlatformMode() && accountId !== undefined) {\n\t\tquery = query.where(\"account_id\", \"=\", accountId);\n\t}\n\n\treturn (await query.executeTakeFirst()) ?? null;\n}\n\nexport async function listSubgraphs(\n\tdb: Kysely<Database>,\n\taccountId?: string,\n): Promise<Subgraph[]> {\n\tlet query = db.selectFrom(\"subgraphs\").selectAll();\n\tif (isPlatformMode() && accountId !== undefined) {\n\t\tquery = query.where(\"account_id\", \"=\", accountId);\n\t}\n\treturn query.execute();\n}\n\n/** The hash half of a cursor write. Absent when the caller has none; the\n * `subgraphs_clear_stale_block_hash` trigger (0197) then clears the stored hash\n * for a moved cursor instead of leaving one that names another block. */\nfunction cursorHash(blockHash: string | undefined) {\n\treturn blockHash === undefined\n\t\t? {}\n\t\t: { last_processed_block_hash: blockHash };\n}\n\n/**\n * Reindex progress: moves the cursor of a subgraph that is still\n * `reindexing`, and nothing else. Returns `false` when the subgraph left that\n * state (halted, cancelled, redeployed): the walk must not write on, and its\n * progress never revives a halt.\n */\nexport async function setReindexCursor(\n\tdb: Kysely<Database>,\n\tname: string,\n\tlastProcessedBlock: number,\n\tblockHash?: string,\n): Promise<boolean> {\n\tconst result = await db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tlast_processed_block: lastProcessedBlock,\n\t\t\t...cursorHash(blockHash),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.where(\"status\", \"=\", \"reindexing\")\n\t\t.executeTakeFirst();\n\treturn Number(result.numUpdatedRows ?? 0n) > 0;\n}\n\n/** Live-walk ERROR write (f069): a block whose handlers ALL failed\n * (`processed === 0 && errors > 0`, `block-processor.ts`'s `applyProgress`)\n * moves an `active` subgraph to 'error' and records its height as processed;\n * the cursor half goes through the same conditional `<` guard as\n * {@link recordLiveProgress}. A reindexing or already-halted subgraph is left\n * alone. Marking a subgraph 'error' is not\n * itself replay-sensitive, but it shares the `last_processed_block` column\n * with the replay guard: an unconditional write here could regress the\n * cursor a racing (successful) writer already advanced past, which is\n * exactly the regress-then-re-walk loop this guard exists to close. In\n * practice `ctx.rollbackTo` (`runner.ts`) means an all-failed block never\n * flushes writes, so a lost race here is always a silent no-op, never a\n * case that needs `CursorRaceLostError`-style tx abort. Returns whether\n * the write applied. Live path only: reindex/backfill halts go through\n * {@link transitionSubgraph}. */\nexport async function recordLiveError(\n\tdb: Kysely<Database>,\n\tname: string,\n\tblockHeight: number,\n\tblockHash?: string,\n): Promise<boolean> {\n\tconst result = await db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tstatus: \"error\",\n\t\t\tlast_processed_block: blockHeight,\n\t\t\t...cursorHash(blockHash),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.where(\"status\", \"=\", \"active\")\n\t\t.where(\"last_processed_block\", \"<\", blockHeight)\n\t\t.executeTakeFirst();\n\treturn Number(result.numUpdatedRows ?? 0n) > 0;\n}\n\nexport async function recordSubgraphProcessed(\n\tdb: Kysely<Database>,\n\tname: string,\n\tprocessed: number,\n\terrors: number,\n\tlastError?: string,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\ttotal_processed: sql`total_processed + ${processed}`,\n\t\t\ttotal_errors: sql`total_errors + ${errors}`,\n\t\t\t...(lastError\n\t\t\t\t? { last_error: lastError, last_error_at: new Date() }\n\t\t\t\t: {}),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.execute();\n}\n\n/** Record a billing pause. Status, cursor, counters and `last_error` are\n * untouched: a paused subgraph is healthy, just waiting on its account. */\nexport async function markSubgraphBillingPaused(\n\tdb: Kysely<Database>,\n\tname: string,\n\tcode: string,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tbilling_paused_at: sql`COALESCE(billing_paused_at, now())`,\n\t\t\tbilling_paused_code: code,\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.execute();\n}\n\n/** Clear a billing pause once reads succeed again. */\nexport async function clearSubgraphBillingPaused(\n\tdb: Kysely<Database>,\n\tname: string,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tbilling_paused_at: null,\n\t\t\tbilling_paused_code: null,\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.where(\"billing_paused_at\", \"is not\", null)\n\t\t.execute();\n}\n\nexport async function updateSubgraphHandlerPath(\n\tdb: Kysely<Database>,\n\tname: string,\n\thandlerPath: string,\n\topts?: {\n\t\thandlerCode?: string;\n\t\tsourceCode?: string;\n\t\tpin?: string | null;\n\t\tpinPreimage?: string | null;\n\t\tverification?: SubgraphVerification | null;\n\t},\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\thandler_path: handlerPath,\n\t\t\t...(opts?.handlerCode != null ? { handler_code: opts.handlerCode } : {}),\n\t\t\t...(opts?.sourceCode != null ? { source_code: opts.sourceCode } : {}),\n\t\t\t...(opts?.pin !== undefined ? { pin: opts.pin } : {}),\n\t\t\t...(opts?.pinPreimage !== undefined\n\t\t\t\t? { pin_preimage: opts.pinPreimage }\n\t\t\t\t: {}),\n\t\t\t...(opts?.verification !== undefined\n\t\t\t\t? {\n\t\t\t\t\t\tverification: opts.verification\n\t\t\t\t\t\t\t? jsonb<SubgraphVerification>(opts.verification)\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.execute();\n}\n\nexport async function deleteSubgraph(\n\tdb: Kysely<Database>,\n\tname: string,\n\taccountId?: string,\n): Promise<Subgraph | null> {\n\tconst subgraph = await getSubgraph(db, name, accountId);\n\tif (!subgraph) return null;\n\n\t// Use stored schema_name if available, otherwise compute\n\tconst schemaName = subgraph.schema_name ?? pgSchemaName(name);\n\n\t// Drop the subgraph's schema (CASCADE drops all tables within).\n\tawait sql`DROP SCHEMA IF EXISTS ${sql.raw(`\"${schemaName}\"`)} CASCADE`.execute(\n\t\tdb,\n\t);\n\n\t// Remove from registry\n\tawait db.deleteFrom(\"subgraphs\").where(\"id\", \"=\", subgraph.id).execute();\n\n\treturn subgraph;\n}\n\n/** Live-walk progress write: advances the cursor of an `active` subgraph and\n * never touches status. A `reindexing` or `error` subgraph is a no-op here:\n * the old promote-toward-active CASE let a live commit undo a halt and flap\n * a parked subgraph back into catch-up against its own reindex op.\n *\n * `last_processed_block` is now written CONDITIONALLY — `WHERE\n * last_processed_block < lastProcessedBlock`, mirroring\n * `advanceOperationCursor`'s (`subgraph-operations.ts`) comparison shape —\n * and returns whether THIS call actually advanced it. This used to be\n * unconditional by design, on the premise that the only two writers able to\n * advance/rewind a given subgraph's cursor concurrently (the catch-up walk\n * and the reorg handler) serialize on an in-process per-subgraph lock +\n * reorg epoch guard (`packages/subgraphs/src/runtime/catchup.ts`,\n * `subgraphBlockLockHeld` / `reorgEpoch`; f057). That guard is in-process\n * only. The f068 investigation\n * (`docs/internal/audits/asset-holdings-unreproducible-balances-f068.md`)\n * found a cross-process sequence it does not cover: a catch-up leader that\n * loses its advisory-lock connection mid-walk keeps writing (leadership is\n * checked only at walk entry, not per-iteration) while a new leader takes\n * over and walks the same range — both commit increments for overlapping\n * heights, and every regressed cursor write from the laggard re-triggers a\n * full re-walk, growing per-height application without bound. The\n * conditional advance here (paired with the fast-path replay guard armed on\n * the live path in `block-processor.ts`) is now the cross-process\n * guarantee: a block at/below the current cursor can never re-advance it,\n * so a laggard's commits can no longer regress-then-retrigger.\n *\n * This conditionality is why the reorg rewind can no longer go through this\n * function — a rewind's whole point is to move the cursor *backward*, which\n * the `<` guard would silently refuse. Reorg mode calls\n * {@link rewindLiveProgress} instead, which keeps the old unconditional\n * semantics and is safe specifically because the reorg path takes a\n * transaction-scoped advisory lock (`reorg.ts`) other writers can't cross. */\nexport async function recordLiveProgress(\n\tdb: Kysely<Database>,\n\tname: string,\n\tlastProcessedBlock: number,\n\tblockHash?: string,\n): Promise<boolean> {\n\tconst result = await db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tlast_processed_block: lastProcessedBlock,\n\t\t\t...cursorHash(blockHash),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.where(\"status\", \"=\", \"active\")\n\t\t.where(\"last_processed_block\", \"<\", lastProcessedBlock)\n\t\t.executeTakeFirst();\n\treturn Number(result.numUpdatedRows ?? 0n) > 0;\n}\n\n/** Reorg-rewind progress write: the OLD unconditional `recordLiveProgress`\n * semantics, verbatim — moves `last_processed_block` to the fork height\n * regardless of its current value, because that is by definition a\n * backward move the conditional `<` guard in `recordLiveProgress` would\n * refuse. Cursor only, `active` subgraphs only.\n *\n * Callers: exclusively the subgraph-reorg path\n * (`packages/subgraphs/src/runtime/reorg.ts`, via `block-processor.ts`'s\n * `reorgRewind` mode), which is safe from the cross-process race this\n * function reintroduces because it holds a transaction-scoped Postgres\n * advisory lock (`pg_advisory_xact_lock`) for the whole\n * delete+reprocess+rewind sequence — no other writer can interleave a\n * forward write between the rewind and the fork block's reprocess. Do not\n * call this from the live catch-up path. */\nexport async function rewindLiveProgress(\n\tdb: Kysely<Database>,\n\tname: string,\n\tlastProcessedBlock: number,\n\tblockHash?: string,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tlast_processed_block: lastProcessedBlock,\n\t\t\t...cursorHash(blockHash),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"name\", \"=\", name)\n\t\t.where(\"status\", \"=\", \"active\")\n\t\t.execute();\n}\n",
|
|
5
|
+
"import { type Kysely, sql } from \"kysely\";\nimport { isPlatformMode } from \"../../mode.ts\";\nimport {\n\tSUBGRAPH_STATES,\n\ttype SubgraphStatus,\n\ttype SubgraphVerification,\n} from \"../../schemas/subgraphs.ts\";\nimport { jsonb } from \"../jsonb.ts\";\nimport { type Machine, casTransition, defineMachine } from \"../transition.ts\";\nimport type { Database, Subgraph } from \"../types.ts\";\n\n/**\n * Subgraph lifecycle. `error` is sticky: a live walk never clears it, only a\n * redeploy (`error -> active`) or a reindex (`error -> reindexing`) does.\n * Every status write goes through {@link transitionSubgraph}; the live\n * progress writes below touch the cursor only and are gated on the status\n * they are valid for.\n */\nexport const subgraphMachine: Machine<SubgraphStatus> = defineMachine({\n\tstates: SUBGRAPH_STATES,\n\ttransitions: {\n\t\tactive: [\"reindexing\", \"error\"],\n\t\treindexing: [\"active\", \"error\"],\n\t\terror: [\"reindexing\", \"active\"],\n\t},\n});\n\n/**\n * Move a subgraph from one of `from` to `to`, writing `set` in the same\n * statement. Returns the row, or `null` when it was not in a `from` state\n * (something else, a halt or a redeploy, decided first): log and stop, never\n * retry. Staying in the same state (`reindexing -> reindexing`) is a plain\n * conditional write, not a transition.\n */\nexport function transitionSubgraph(\n\tdb: Kysely<Database>,\n\tname: string,\n\tfrom: readonly SubgraphStatus[],\n\tto: SubgraphStatus,\n\tset?: Record<string, unknown>,\n): Promise<Subgraph | null> {\n\tfor (const state of from) {\n\t\tif (state !== to) subgraphMachine.assert(state, to);\n\t}\n\treturn casTransition<SubgraphStatus, Subgraph>(db, {\n\t\ttable: \"subgraphs\",\n\t\tkey: \"name\",\n\t\tid: name,\n\t\tfrom,\n\t\tto,\n\t\tset,\n\t});\n}\n\n/** Convert a subgraph name to its PostgreSQL schema name. */\nexport function pgSchemaName(subgraphName: string): string {\n\tconst safeName = subgraphName.replace(/-/g, \"_\");\n\treturn `subgraph_${safeName}`;\n}\n\n/** OSS writes empty account_id — name is the local unique key. */\nexport function localSubgraphAccountId(accountId?: string): string {\n\tif (!isPlatformMode()) return \"\";\n\treturn accountId ?? \"\";\n}\n\nexport async function registerSubgraph(\n\tdb: Kysely<Database>,\n\tdata: {\n\t\tname: string;\n\t\tversion: string;\n\t\tdefinition: Record<string, unknown>;\n\t\tschemaHash: string;\n\t\thandlerPath: string;\n\t\tapiKeyId?: string;\n\t\taccountId?: string;\n\t\tschemaName?: string;\n\t\tstartBlock?: number;\n\t\thandlerCode?: string;\n\t\tsourceCode?: string;\n\t\tpin?: string | null;\n\t\tpinPreimage?: string | null;\n\t\tverification?: SubgraphVerification | null;\n\t},\n): Promise<Subgraph> {\n\tconst accountId = localSubgraphAccountId(data.accountId);\n\tconst values = {\n\t\tname: data.name,\n\t\tversion: data.version,\n\t\tdefinition: jsonb<Record<string, unknown>>(data.definition),\n\t\tschema_hash: data.schemaHash,\n\t\thandler_path: data.handlerPath,\n\t\taccount_id: accountId,\n\t\thandler_code: data.handlerCode ?? null,\n\t\tsource_code: data.sourceCode ?? null,\n\t\tschema_name: data.schemaName ?? null,\n\t\tstart_block: data.startBlock ?? 0,\n\t\tpin: data.pin ?? null,\n\t\tpin_preimage: data.pinPreimage ?? null,\n\t\tverification: data.verification\n\t\t\t? jsonb<SubgraphVerification>(data.verification)\n\t\t\t: null,\n\t};\n\tconst updateSet = {\n\t\tversion: data.version,\n\t\tdefinition: jsonb<Record<string, unknown>>(data.definition),\n\t\tschema_hash: data.schemaHash,\n\t\thandler_path: data.handlerPath,\n\t\thandler_code: data.handlerCode ?? null,\n\t\tsource_code: data.sourceCode ?? null,\n\t\tschema_name: data.schemaName ?? null,\n\t\tstart_block: data.startBlock ?? 0,\n\t\tpin: values.pin,\n\t\tpin_preimage: values.pin_preimage,\n\t\tverification: values.verification,\n\t\tupdated_at: new Date(),\n\t};\n\n\t// OSS: name is unique. Upsert by name so leftover rows with a non-empty\n\t// account_id (pre-local-namespace deploys) don't insert a second row.\n\tif (!isPlatformMode()) {\n\t\tconst existing = await db\n\t\t\t.selectFrom(\"subgraphs\")\n\t\t\t.select(\"id\")\n\t\t\t.where(\"name\", \"=\", data.name)\n\t\t\t.executeTakeFirst();\n\t\tif (existing) {\n\t\t\treturn await db\n\t\t\t\t.updateTable(\"subgraphs\")\n\t\t\t\t.set({ ...updateSet, account_id: \"\" })\n\t\t\t\t.where(\"id\", \"=\", existing.id)\n\t\t\t\t.returningAll()\n\t\t\t\t.executeTakeFirstOrThrow();\n\t\t}\n\t\treturn await db\n\t\t\t.insertInto(\"subgraphs\")\n\t\t\t.values(values)\n\t\t\t.returningAll()\n\t\t\t.executeTakeFirstOrThrow();\n\t}\n\n\treturn await db\n\t\t.insertInto(\"subgraphs\")\n\t\t.values(values)\n\t\t.onConflict((oc) =>\n\t\t\toc.columns([\"name\", \"account_id\"]).doUpdateSet(updateSet),\n\t\t)\n\t\t.returningAll()\n\t\t.executeTakeFirstOrThrow();\n}\n\nexport async function getSubgraph(\n\tdb: Kysely<Database>,\n\tname: string,\n\taccountId?: string,\n): Promise<Subgraph | null> {\n\tlet query = db.selectFrom(\"subgraphs\").selectAll().where(\"name\", \"=\", name);\n\n\tif (isPlatformMode() && accountId !== undefined) {\n\t\tquery = query.where(\"account_id\", \"=\", accountId);\n\t}\n\n\treturn (await query.executeTakeFirst()) ?? null;\n}\n\nexport async function listSubgraphs(\n\tdb: Kysely<Database>,\n\taccountId?: string,\n): Promise<Subgraph[]> {\n\tlet query = db.selectFrom(\"subgraphs\").selectAll();\n\tif (isPlatformMode() && accountId !== undefined) {\n\t\tquery = query.where(\"account_id\", \"=\", accountId);\n\t}\n\treturn query.execute();\n}\n\n/** The hash half of a cursor write. Absent when the caller has none; the\n * `subgraphs_clear_stale_block_hash` trigger (0197) then clears the stored hash\n * for a moved cursor instead of leaving one that names another block. */\nfunction cursorHash(blockHash: string | undefined) {\n\treturn blockHash === undefined\n\t\t? {}\n\t\t: { last_processed_block_hash: blockHash };\n}\n\n/**\n * Reindex progress: moves the cursor of a subgraph that is still\n * `reindexing`, and nothing else. Returns `false` when the subgraph left that\n * state (halted, cancelled, redeployed): the walk must not write on, and its\n * progress never revives a halt.\n */\nexport async function setReindexCursor(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n\tlastProcessedBlock: number,\n\tblockHash?: string,\n): Promise<boolean> {\n\tconst result = await db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tlast_processed_block: lastProcessedBlock,\n\t\t\t...cursorHash(blockHash),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"id\", \"=\", subgraphId)\n\t\t.where(\"status\", \"=\", \"reindexing\")\n\t\t.executeTakeFirst();\n\treturn Number(result.numUpdatedRows ?? 0n) > 0;\n}\n\n/** Live-walk ERROR write (f069): a block whose handlers ALL failed\n * (`processed === 0 && errors > 0`, `block-processor.ts`'s `applyProgress`)\n * moves an `active` subgraph to 'error' and records its height as processed;\n * the cursor half goes through the same conditional `<` guard as\n * {@link recordLiveProgress}. A reindexing or already-halted subgraph is left\n * alone. Marking a subgraph 'error' is not\n * itself replay-sensitive, but it shares the `last_processed_block` column\n * with the replay guard: an unconditional write here could regress the\n * cursor a racing (successful) writer already advanced past, which is\n * exactly the regress-then-re-walk loop this guard exists to close. In\n * practice `ctx.rollbackTo` (`runner.ts`) means an all-failed block never\n * flushes writes, so a lost race here is always a silent no-op, never a\n * case that needs `CursorRaceLostError`-style tx abort. Returns whether\n * the write applied. Live path only: reindex/backfill halts go through\n * {@link transitionSubgraph}. */\nexport async function recordLiveError(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n\tblockHeight: number,\n\tblockHash?: string,\n): Promise<boolean> {\n\tconst result = await db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tstatus: \"error\",\n\t\t\tlast_processed_block: blockHeight,\n\t\t\t...cursorHash(blockHash),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"id\", \"=\", subgraphId)\n\t\t.where(\"status\", \"=\", \"active\")\n\t\t.where(\"last_processed_block\", \"<\", blockHeight)\n\t\t.executeTakeFirst();\n\treturn Number(result.numUpdatedRows ?? 0n) > 0;\n}\n\nexport async function recordSubgraphProcessed(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n\tprocessed: number,\n\terrors: number,\n\tlastError?: string,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\ttotal_processed: sql`total_processed + ${processed}`,\n\t\t\ttotal_errors: sql`total_errors + ${errors}`,\n\t\t\t...(lastError\n\t\t\t\t? { last_error: lastError, last_error_at: new Date() }\n\t\t\t\t: {}),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"id\", \"=\", subgraphId)\n\t\t.execute();\n}\n\n/** Record a billing pause. Status, cursor, counters and `last_error` are\n * untouched: a paused subgraph is healthy, just waiting on its account. */\nexport async function markSubgraphBillingPaused(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n\tcode: string,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tbilling_paused_at: sql`COALESCE(billing_paused_at, now())`,\n\t\t\tbilling_paused_code: code,\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"id\", \"=\", subgraphId)\n\t\t.execute();\n}\n\n/** Clear a billing pause once reads succeed again. */\nexport async function clearSubgraphBillingPaused(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tbilling_paused_at: null,\n\t\t\tbilling_paused_code: null,\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"id\", \"=\", subgraphId)\n\t\t.where(\"billing_paused_at\", \"is not\", null)\n\t\t.execute();\n}\n\nexport async function updateSubgraphHandlerPath(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n\thandlerPath: string,\n\topts?: {\n\t\thandlerCode?: string;\n\t\tsourceCode?: string;\n\t\tpin?: string | null;\n\t\tpinPreimage?: string | null;\n\t\tverification?: SubgraphVerification | null;\n\t},\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\thandler_path: handlerPath,\n\t\t\t...(opts?.handlerCode != null ? { handler_code: opts.handlerCode } : {}),\n\t\t\t...(opts?.sourceCode != null ? { source_code: opts.sourceCode } : {}),\n\t\t\t...(opts?.pin !== undefined ? { pin: opts.pin } : {}),\n\t\t\t...(opts?.pinPreimage !== undefined\n\t\t\t\t? { pin_preimage: opts.pinPreimage }\n\t\t\t\t: {}),\n\t\t\t...(opts?.verification !== undefined\n\t\t\t\t? {\n\t\t\t\t\t\tverification: opts.verification\n\t\t\t\t\t\t\t? jsonb<SubgraphVerification>(opts.verification)\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"id\", \"=\", subgraphId)\n\t\t.execute();\n}\n\nexport async function deleteSubgraph(\n\tdb: Kysely<Database>,\n\tname: string,\n\taccountId?: string,\n): Promise<Subgraph | null> {\n\tconst subgraph = await getSubgraph(db, name, accountId);\n\tif (!subgraph) return null;\n\n\t// Use stored schema_name if available, otherwise compute\n\tconst schemaName = subgraph.schema_name ?? pgSchemaName(name);\n\n\t// One transaction: DDL is transactional in Postgres, so a failed row delete\n\t// leaves the schema in place instead of a registered subgraph with no tables.\n\tconst remove = async (trx: Kysely<Database>) => {\n\t\t// Drop the subgraph's schema (CASCADE drops all tables within).\n\t\tawait sql`DROP SCHEMA IF EXISTS ${sql.raw(`\"${schemaName}\"`)} CASCADE`.execute(\n\t\t\ttrx,\n\t\t);\n\t\t// Remove from registry\n\t\tawait trx.deleteFrom(\"subgraphs\").where(\"id\", \"=\", subgraph.id).execute();\n\t};\n\tif (db.isTransaction) await remove(db);\n\telse await db.transaction().execute(remove);\n\n\treturn subgraph;\n}\n\n/** Live-walk progress write: advances the cursor of an `active` subgraph and\n * never touches status. A `reindexing` or `error` subgraph is a no-op here:\n * the old promote-toward-active CASE let a live commit undo a halt and flap\n * a parked subgraph back into catch-up against its own reindex op.\n *\n * `last_processed_block` is now written CONDITIONALLY — `WHERE\n * last_processed_block < lastProcessedBlock`, mirroring\n * `advanceOperationCursor`'s (`subgraph-operations.ts`) comparison shape —\n * and returns whether THIS call actually advanced it. This used to be\n * unconditional by design, on the premise that the only two writers able to\n * advance/rewind a given subgraph's cursor concurrently (the catch-up walk\n * and the reorg handler) serialize on an in-process per-subgraph lock +\n * reorg epoch guard (`packages/subgraphs/src/runtime/catchup.ts`,\n * `subgraphBlockLockHeld` / `reorgEpoch`; f057). That guard is in-process\n * only. The f068 investigation\n * (`docs/internal/audits/asset-holdings-unreproducible-balances-f068.md`)\n * found a cross-process sequence it does not cover: a catch-up leader that\n * loses its advisory-lock connection mid-walk keeps writing (leadership is\n * checked only at walk entry, not per-iteration) while a new leader takes\n * over and walks the same range — both commit increments for overlapping\n * heights, and every regressed cursor write from the laggard re-triggers a\n * full re-walk, growing per-height application without bound. The\n * conditional advance here (paired with the fast-path replay guard armed on\n * the live path in `block-processor.ts`) is now the cross-process\n * guarantee: a block at/below the current cursor can never re-advance it,\n * so a laggard's commits can no longer regress-then-retrigger.\n *\n * This conditionality is why the reorg rewind can no longer go through this\n * function — a rewind's whole point is to move the cursor *backward*, which\n * the `<` guard would silently refuse. Reorg mode calls\n * {@link rewindLiveProgress} instead, which keeps the old unconditional\n * semantics and is safe specifically because the reorg path takes a\n * transaction-scoped advisory lock (`reorg.ts`) other writers can't cross. */\nexport async function recordLiveProgress(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n\tlastProcessedBlock: number,\n\tblockHash?: string,\n): Promise<boolean> {\n\tconst result = await db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tlast_processed_block: lastProcessedBlock,\n\t\t\t...cursorHash(blockHash),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"id\", \"=\", subgraphId)\n\t\t.where(\"status\", \"=\", \"active\")\n\t\t.where(\"last_processed_block\", \"<\", lastProcessedBlock)\n\t\t.executeTakeFirst();\n\treturn Number(result.numUpdatedRows ?? 0n) > 0;\n}\n\n/** Reorg-rewind progress write: the OLD unconditional `recordLiveProgress`\n * semantics, verbatim — moves `last_processed_block` to the fork height\n * regardless of its current value, because that is by definition a\n * backward move the conditional `<` guard in `recordLiveProgress` would\n * refuse. Cursor only, `active` subgraphs only.\n *\n * Callers: exclusively the subgraph-reorg path\n * (`packages/subgraphs/src/runtime/reorg.ts`, via `block-processor.ts`'s\n * `reorgRewind` mode), which is safe from the cross-process race this\n * function reintroduces because it holds a transaction-scoped Postgres\n * advisory lock (`pg_advisory_xact_lock`) for the whole\n * delete+reprocess+rewind sequence — no other writer can interleave a\n * forward write between the rewind and the fork block's reprocess. Do not\n * call this from the live catch-up path. */\nexport async function rewindLiveProgress(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n\tlastProcessedBlock: number,\n\tblockHash?: string,\n): Promise<void> {\n\tawait db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({\n\t\t\tlast_processed_block: lastProcessedBlock,\n\t\t\t...cursorHash(blockHash),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"id\", \"=\", subgraphId)\n\t\t.where(\"status\", \"=\", \"active\")\n\t\t.execute();\n}\n",
|
|
6
6
|
"/**\n * Instance modes for the Secondlayer platform.\n *\n * - `oss`: self-hosted, single-tenant. No auth middleware, no platform routes\n * (projects, admin). Everything runs against a single `DATABASE_URL`.\n * Intended for `docker compose up`.\n *\n * - `platform`: the metered archive deployment. Magic-link auth, API keys,\n * accounts, credits, and metered `/v1` reads (Index + Streams + subgraphs)\n * against a single shared DB. No paid tier ladder — one metered `free`\n * tier plus first-party internal service credentials.\n */\n\nexport type InstanceMode = \"oss\" | \"platform\";\n\n/** What the operator wrote in the env — `archive` is the honest name for the\n * metered public-archive deployment and aliases `platform` behaviorally. */\nexport type DeclaredInstanceMode = InstanceMode | \"archive\";\n\nconst VALID_MODES: readonly DeclaredInstanceMode[] = [\n\t\"oss\",\n\t\"platform\",\n\t\"archive\",\n];\n\nfunction declaredMode(): DeclaredInstanceMode {\n\tconst raw = process.env.INSTANCE_MODE?.trim().toLowerCase();\n\tif (raw && (VALID_MODES as readonly string[]).includes(raw)) {\n\t\treturn raw as DeclaredInstanceMode;\n\t}\n\treturn \"oss\";\n}\n\n/**\n * Resolve the active instance mode from `process.env.INSTANCE_MODE`.\n * Defaults to `\"oss\"` — the safest default for self-hosters who deploy\n * without setting the variable. `archive` normalizes to `platform` here so\n * every behavioral branch stays a two-way choice; use\n * `getDeclaredInstanceMode()` for display surfaces.\n */\nexport function getInstanceMode(): InstanceMode {\n\tconst declared = declaredMode();\n\treturn declared === \"archive\" ? \"platform\" : declared;\n}\n\n/** The mode as declared in the env, for status/identity surfaces. */\nexport function getDeclaredInstanceMode(): DeclaredInstanceMode {\n\treturn declaredMode();\n}\n\n/**\n * True when public reads are credit-metered (the free window, retention, and\n * credits gates arm). Platform/archive deployments meter by default;\n * self-host never does unless the operator explicitly sets\n * `METERED_READS=true`. `METERED_READS=false` disarms a metered deployment.\n */\nexport function isMeteredReads(): boolean {\n\tconst override = process.env.METERED_READS?.trim().toLowerCase();\n\tif (override === \"true\") return true;\n\tif (override === \"false\") return false;\n\treturn getInstanceMode() === \"platform\";\n}\n\n/** True when the active mode is `\"platform\"` (shared multi-tenant). */\nexport function isPlatformMode(): boolean {\n\treturn getInstanceMode() === \"platform\";\n}\n\n/** True when the active mode is `\"oss\"` (self-hosted). */\nexport function isOssMode(): boolean {\n\treturn getInstanceMode() === \"oss\";\n}\n\n/** The one shared testnet webhook stack (hosted). Off everywhere else. */\nexport function isTestnetWebhookStack(): boolean {\n\treturn process.env.TESTNET_WEBHOOK_STACK === \"true\";\n}\n\n/** Webhook rows are per-account: platform, or the shared testnet stack. */\nexport function isWebhookAccountScoped(): boolean {\n\treturn isPlatformMode() || isTestnetWebhookStack();\n}\n",
|
|
7
7
|
"import { z } from \"zod\";\n\n// ── Deploy Subgraph Request ─────────────────────────────────────────────────\n\n/** The body for deploying a subgraph: sources, schema, and handler code. */\nexport interface DeploySubgraphRequest {\n\tname: string;\n\tdescription?: string;\n\tsources: Record<string, Record<string, unknown>>;\n\tschema: Record<string, unknown>;\n\thandlerCode: string;\n\t/** Override the definition's startBlock for this deploy only. */\n\tstartBlock?: number;\n\t/** Original TypeScript source, persisted so chat can read/diff/edit later. */\n\tsourceCode?: string;\n\t/** Validate the definition + print the DDL plan without deploying. */\n\tdryRun?: boolean;\n}\n\nexport const DeploySubgraphRequestSchema: z.ZodType<DeploySubgraphRequest> =\n\tz.object({\n\t\tname: z\n\t\t\t.string()\n\t\t\t.regex(/^[a-z0-9-]+$/, \"lowercase alphanumeric + hyphens only\")\n\t\t\t// `subgraph_<name>` must fit Postgres' 63-byte identifier limit.\n\t\t\t.max(54),\n\t\tdescription: z.string().optional(),\n\t\tsources: z\n\t\t\t.record(z.string(), z.record(z.string(), z.unknown()))\n\t\t\t.refine(\n\t\t\t\t(s) => Object.keys(s).length > 0,\n\t\t\t\t\"Must have at least one source\",\n\t\t\t),\n\t\tschema: z.record(z.string(), z.unknown()),\n\t\thandlerCode: z.string().max(1_048_576, \"handler code exceeds 1MB limit\"),\n\t\tstartBlock: z.number().int().nonnegative().optional(),\n\t\tsourceCode: z\n\t\t\t.string()\n\t\t\t.max(1_048_576, \"source code exceeds 1MB limit\")\n\t\t\t.optional(),\n\t\tdryRun: z.boolean().optional(),\n\t});\n\n/**\n * How far a subgraph's rows can be checked without trusting the server,\n * derived from its sources and a scan of its handler. Never configured.\n *\n * - `state`: every input is a named state write, provable from block headers.\n * Handlers run in the deterministic realm. A deployed `state` subgraph is\n * verifiable: one with any reason is refused at deploy.\n * - `events`: an input (events, prints, tx results, `ctx.client`) needs\n * re-execution proofs, which are not served yet.\n * - `none`: a source can never be proven as written (trait scope, tip-first\n * backfill).\n */\nexport interface SubgraphVerification {\n\tlevel: \"state\" | \"events\" | \"none\";\n\t/** What stands between the subgraph and checkable rows, e.g.\n\t * `print_event source \"swaps\" needs event proofs` or\n\t * `subgraph.ts:41:12 Date: wall-clock time differs per run`. */\n\treasons: string[];\n\t/** What stays unproven even at this level, e.g. tx attribution of writes. */\n\tunproven: string[];\n}\n\n/** What a deploy did, the version, and where indexing starts. */\nexport interface DeploySubgraphResponse {\n\taction: \"created\" | \"unchanged\" | \"handler_updated\" | \"updated\" | \"reindexed\";\n\tsubgraphId: string;\n\tversion: string;\n\tmessage: string;\n\t/** Effective indexing start height. */\n\tstart_block?: number;\n\toperationId?: string;\n\treindexStarted?: boolean;\n\t/** Bounded candidate-event denominator for the reindex just started, when the\n\t * op was classifiable as sparse/light. Absent for heavy ops (no upfront estimate\n\t * possible) — check `sl subgraphs status` after ~30s for a rate-based ETA instead. */\n\testimatedEvents?: number;\n\t/** Non-blocking deploy lints (e.g. handler reads a print field never observed on-chain). */\n\twarnings?: string[];\n\t/** sha256 identity of what was deployed; absent on unbundled deploys. */\n\tpin?: string;\n\tverification?: SubgraphVerification;\n\tdiff?: {\n\t\taddedTables: string[];\n\t\tremovedTables: string[];\n\t\taddedColumns: Record<string, string[]>;\n\t\tbreakingChanges: string[];\n\t};\n}\n\n// Subgraph API response types\n\n/** Every state `subgraphs.status` can hold; mirrored by the\n * `subgraphs_status_check` CHECK (migration 0189). */\nexport const SUBGRAPH_STATES = [\"active\", \"reindexing\", \"error\"] as const;\nexport type SubgraphStatus = (typeof SUBGRAPH_STATES)[number];\n\n/** What an operator sees: `synced` and `catching_up` are both `active` rows. */\nexport type SubgraphSyncState =\n\t| \"synced\"\n\t| \"catching_up\"\n\t| \"reindexing\"\n\t| \"error\";\n\n/**\n * The one answer to \"is this subgraph caught up?\". `tip` is the chain tip the\n * subgraph is measured against (its reindex target while reindexing is the\n * caller's concern: a reindexing subgraph is `reindexing` whatever its cursor).\n */\nexport function syncState(\n\tsubgraph: {\n\t\tstatus: string;\n\t\tlastProcessedBlock: number | string;\n\t},\n\ttip: number,\n): SubgraphSyncState {\n\tif (subgraph.status === \"reindexing\") return \"reindexing\";\n\tif (subgraph.status === \"error\") return \"error\";\n\treturn Number(subgraph.lastProcessedBlock) < tip ? \"catching_up\" : \"synced\";\n}\n\n/** A subgraph's name, status, and indexing progress. */\nexport interface SubgraphSummary {\n\tname: string;\n\tversion: string;\n\tstatus: string;\n\tlastProcessedBlock: number;\n\ttotalProcessed: number;\n\ttotalRows?: number;\n\ttotalErrors: number;\n\ttables: string[];\n\tchainTip: number;\n\tsourceChainTip?: number;\n\ttargetBlock?: number;\n\tprogress: number;\n\tblocksRemaining?: number;\n\tsyncMode?: \"sync\" | \"reindex\";\n\tgapCount: number;\n\t/** history_filling = expected gaps while a tip-first backfill op runs. */\n\tintegrity: \"complete\" | \"gaps_detected\" | \"history_filling\";\n\t/** Most recent indexing error reason + when it occurred, if any. */\n\tlastError?: string | null;\n\tlastErrorAt?: string | null;\n\t/** Billing code (`spend_cap_reached`, `insufficient_credits`) while reads\n\t * are refused for the account; null otherwise. */\n\tbillingPausedCode?: string | null;\n\t/** Last row mutation timestamp; powers per-card freshness. */\n\tupdatedAt?: string | null;\n\tcreatedAt: string;\n}\n\nexport interface SubgraphGapRange {\n\tstart: number;\n\tend: number;\n\tsize: number;\n\treason: string;\n}\n\nexport interface SubgraphSyncInfo {\n\tstatus: SubgraphSyncState;\n\tmode?: \"sync\" | \"reindex\";\n\tstartBlock: number;\n\tlastProcessedBlock: number;\n\t/**\n\t * Backward-compatible denominator for progress displays. During reindexing,\n\t * this is the reindex target block rather than the live source chain tip.\n\t */\n\tchainTip: number;\n\tsourceChainTip?: number;\n\ttargetBlock?: number;\n\tblocksRemaining: number;\n\tprocessedBlocks?: number;\n\ttotalBlocks?: number;\n\tprogress: number;\n\t/** Present while the populating operation is queued: approximate claim\n\t * position + honest event denominator + naive start estimate. */\n\tqueue?: {\n\t\tposition: number | null;\n\t\testimatedEvents: number | null;\n\t\testimatedStartSeconds: number | null;\n\t};\n\t/** Event-based progress for sparse syncs (block pct is meaningless when\n\t * most heights are skipped). */\n\testimatedEvents?: number;\n\tprocessedEvents?: number;\n\tetaSeconds?: number | null;\n\tgaps: {\n\t\tcount: number;\n\t\ttotalMissingBlocks: number;\n\t\tranges: SubgraphGapRange[];\n\t};\n\t/** history_filling = expected gaps while a tip-first backfill op runs. */\n\tintegrity: \"complete\" | \"gaps_detected\" | \"history_filling\";\n}\n\n/** A subgraph's version, pin, status, tables, and sources. */\nexport interface SubgraphDetail {\n\tname: string;\n\tversion: string;\n\tschemaHash?: string;\n\t/** sha256 over schema, handler bundle, startBlock, network and runtime.\n\t * Null for subgraphs deployed before pins existed. */\n\tpin?: string | null;\n\t/** Null for subgraphs deployed before levels were derived. */\n\tverification?: SubgraphVerification | null;\n\tstatus: string;\n\tlastProcessedBlock: number;\n\tdescription?: string;\n\tsources?: Record<string, unknown>;\n\tdefinition?: Record<string, unknown>;\n\thealth: {\n\t\ttotalProcessed: number;\n\t\ttotalErrors: number;\n\t\terrorRate: number;\n\t\tlastError: string | null;\n\t\tlastErrorAt: string | null;\n\t\t/** Billing code while the account's reads are refused; null otherwise. */\n\t\tbillingPausedCode?: string | null;\n\t\t/** True after the processor matched work but user tables still have 0 rows. */\n\t\temptyMapping: boolean;\n\t};\n\tsync: SubgraphSyncInfo;\n\ttables: Record<\n\t\tstring,\n\t\t{\n\t\t\tendpoint: string;\n\t\t\tcolumns: Record<\n\t\t\t\tstring,\n\t\t\t\t{\n\t\t\t\t\ttype: string;\n\t\t\t\t\tnullable?: boolean;\n\t\t\t\t\tindexed?: boolean;\n\t\t\t\t\tsearchable?: boolean;\n\t\t\t\t\tdefault?: string | number | boolean;\n\t\t\t\t}\n\t\t\t>;\n\t\t\trowCount: number;\n\t\t\texample: string;\n\t\t\tindexes?: readonly (readonly string[])[];\n\t\t\tuniqueKeys?: readonly (readonly string[])[];\n\t\t}\n\t>;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface SubgraphGapEntry {\n\tstart: number;\n\tend: number;\n\tsize: number;\n\treason: string;\n\tdetectedAt: string;\n\tresolvedAt: string | null;\n}\n\n/** Missing block ranges in a subgraph, with totals. */\nexport interface SubgraphGapsResponse {\n\tdata: SubgraphGapEntry[];\n\tmeta: {\n\t\ttotal: number;\n\t\ttotalMissingBlocks: number;\n\t\tlimit: number;\n\t\toffset: number;\n\t};\n}\n\n/** A queued reindex and the block range it covers. */\nexport interface ReindexResponse {\n\tmessage: string;\n\tfromBlock: number;\n\ttoBlock: number | string;\n\toperationId?: string;\n\tstatus?: \"queued\" | \"running\" | \"cancel_requested\";\n}\n\nexport interface SubgraphQueryParams {\n\tsort?: string;\n\torder?: string;\n\tlimit?: number;\n\toffset?: number;\n\tfields?: string;\n\tfilters?: Record<string, string>;\n}\n\n/**\n * Request shape for `GET /v1/subgraphs/:subgraphName/:tableName/aggregate`.\n * `filters` reuses the list/count where-surface; the rest name the columns to\n * aggregate. SUM/MIN/MAX columns must be numeric (uint/int, plus `_block_height`).\n */\nexport interface SubgraphAggregateParams {\n\tfilters?: Record<string, string>;\n\tcount?: boolean;\n\tcountDistinct?: string[];\n\tsum?: string[];\n\tmin?: string[];\n\tmax?: string[];\n}\n\n/**\n * Aggregate response. Keys are present only for requested aggregates.\n * `count`/`countDistinct` are JSON numbers (counts << 2^53); `sum`/`min`/`max`\n * are lossless strings (NUMERIC `::text`). `sum` of an empty set is `\"0\"`;\n * `min`/`max` are `null` when the filtered set is empty or all-null.\n */\nexport interface SubgraphAggregateResponse {\n\tcount?: number;\n\tcountDistinct?: Record<string, number>;\n\tsum?: Record<string, string>;\n\tmin?: Record<string, string | null>;\n\tmax?: Record<string, string | null>;\n}\n",
|
|
8
8
|
"import { type RawBuilder, sql } from \"kysely\";\n\n/**\n * Safely encode a JS value as a JSONB literal for Kysely inserts/updates.\n * Kysely + postgres.js double-encodes JSON when using parameterized queries\n * with ::jsonb casts. This uses sql.raw to inline a properly escaped literal.\n *\n * Generic parameter lets callers set the RawBuilder's output type so they\n * don't need to cast at the insert site. Default is `unknown` — widen at\n * the call site when the column type is narrower, e.g. `jsonb<MyShape>(...)`.\n */\nexport function jsonb<T = unknown>(value: T): RawBuilder<T> {\n\tconst escaped = JSON.stringify(value, (_k, v) =>\n\t\ttypeof v === \"bigint\" ? v.toString() : v,\n\t).replace(/'/g, \"''\");\n\treturn sql`${sql.raw(`'${escaped}'::jsonb`)}`;\n}\n\n/**\n * Safely parse a JSONB value from the database.\n * Handles double-encoded strings where postgres.js returns a JSON string\n * instead of a parsed object.\n */\nexport function parseJsonb<T = unknown>(value: unknown): T {\n\tif (typeof value === \"string\") {\n\t\ttry {\n\t\t\treturn JSON.parse(value) as T;\n\t\t} catch {\n\t\t\treturn value as T;\n\t\t}\n\t}\n\treturn (value ?? {}) as T;\n}\n",
|
|
9
9
|
"import { type Kysely, sql } from \"kysely\";\n\n/**\n * The one convention for state machines: states are a const array (mirrored by\n * a DB CHECK), transitions are a table next to the states, and every status\n * write goes through `casTransition`.\n */\n\nexport interface Machine<S extends string> {\n\treadonly states: readonly S[];\n\tcanTransition(from: S, to: S): boolean;\n\t/** Throws on an illegal move. */\n\tassert(from: S, to: S): void;\n}\n\n/** Pure transition table. `transitions` lists, per state, the states it may move to. */\nexport function defineMachine<const S extends string>(def: {\n\tstates: readonly S[];\n\ttransitions: { readonly [K in S]?: readonly S[] };\n}): Machine<S> {\n\tconst canTransition = (from: S, to: S) =>\n\t\tdef.transitions[from]?.includes(to) ?? false;\n\treturn {\n\t\tstates: def.states,\n\t\tcanTransition,\n\t\tassert(from, to) {\n\t\t\tif (!canTransition(from, to)) {\n\t\t\t\tthrow new Error(`illegal transition ${from} -> ${to}`);\n\t\t\t}\n\t\t},\n\t};\n}\n\nexport interface CasTransition<S extends string> {\n\ttable: string;\n\t/** Value of the row key. */\n\tid: string | number;\n\t/** Row key column, `id` unless the table is addressed by another unique column (`name`). */\n\tkey?: string;\n\t/** Status column, `status` unless the machine lives in another column. */\n\tcolumn?: string;\n\t/** The row moves only if it is currently in one of these states. */\n\tfrom: readonly S[];\n\tto: S;\n\t/** Extra columns written in the same statement. Wrap jsonb values with `jsonb()`. */\n\tset?: Record<string, unknown>;\n\t/** Stamp `updated_at = now()`. Pass `false` for tables without that column. */\n\tstampUpdatedAt?: boolean;\n\t/** Columns to return, `*` unless the row carries a large payload (`[\"sequence\"]`). */\n\treturning?: readonly string[];\n}\n\n/**\n * Compare-and-swap a status column: `UPDATE ... WHERE key = ? AND column = ANY(from)`.\n * Returns the updated row (or the `returning` columns), or `null` when the row was missing or not in a `from`\n * state (a lost race). The caller decides what `null` means; usually log and stop.\n * Works with `db` and inside a transaction (`trx`).\n */\nexport async function casTransition<\n\tS extends string,\n\t// biome-ignore lint/suspicious/noExplicitAny: dynamic table name, row shape is the caller's\n\tRow = Record<string, any>,\n>(\n\t// biome-ignore lint/suspicious/noExplicitAny: accepts Kysely<Database> and Transaction<Database>\n\tdb: Kysely<any>,\n\tt: CasTransition<S>,\n): Promise<Row | null> {\n\tconst column = sql.id(t.column ?? \"status\");\n\tconst assignments = [sql`${column} = ${t.to}`];\n\tif (t.stampUpdatedAt !== false) assignments.push(sql`updated_at = now()`);\n\tfor (const [key, value] of Object.entries(t.set ?? {})) {\n\t\tassignments.push(sql`${sql.id(key)} = ${value}`);\n\t}\n\n\tconst returning = t.returning\n\t\t? sql.join(t.returning.map((c) => sql.id(c)))\n\t\t: sql.raw(\"*\");\n\n\tconst { rows } = await sql<Row>`\n\t\tUPDATE ${sql.table(t.table)}\n\t\tSET ${sql.join(assignments)}\n\t\tWHERE ${sql.id(t.key ?? \"id\")} = ${t.id} AND ${column} = ANY(${sql.val([...t.from])})\n\t\tRETURNING ${returning}\n\t`.execute(db);\n\treturn rows[0] ?? null;\n}\n"
|
|
10
10
|
],
|
|
11
|
-
"mappings": ";AAAA,gBAAsB;;;ACmBtB,IAAM,cAA+C;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACD;AAEA,SAAS,YAAY,GAAyB;AAAA,EAC7C,MAAM,MAAM,QAAQ,IAAI,eAAe,KAAK,EAAE,YAAY;AAAA,EAC1D,IAAI,OAAQ,YAAkC,SAAS,GAAG,GAAG;AAAA,IAC5D,OAAO;AAAA,EACR;AAAA,EACA,OAAO;AAAA;AAUD,SAAS,eAAe,GAAiB;AAAA,EAC/C,MAAM,WAAW,aAAa;AAAA,EAC9B,OAAO,aAAa,YAAY,aAAa;AAAA;AAIvC,SAAS,uBAAuB,GAAyB;AAAA,EAC/D,OAAO,aAAa;AAAA;AASd,SAAS,cAAc,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;AAAA,IACvB,YAAY,IAAI;AAAA,EACjB,CAAC,EACA,MAAM,MAAM,KAAK,UAAU,EAC3B,MAAM,UAAU,KAAK,QAAQ,EAC7B,MAAM,wBAAwB,KAAK,kBAAkB,EACrD,iBAAiB;AAAA,EACnB,OAAO,OAAO,OAAO,kBAAkB,EAAE,IAAI;AAAA;AAiB9C,eAAsB,kBAAkB,CACvC,IACA,YACA,oBACA,WACgB;AAAA,EAChB,MAAM,GACJ,YAAY,WAAW,EACvB,IAAI;AAAA,IACJ,sBAAsB;AAAA,OACnB,WAAW,SAAS;AAAA,IACvB,YAAY,IAAI;AAAA,EACjB,CAAC,EACA,MAAM,MAAM,KAAK,UAAU,EAC3B,MAAM,UAAU,KAAK,QAAQ,EAC7B,QAAQ;AAAA;",
|
|
12
|
+
"debugId": "53B116467828D4A264756E2164756E21",
|
|
13
13
|
"names": []
|
|
14
14
|
}
|
|
@@ -268,6 +268,7 @@ interface SubgraphGapsTable {
|
|
|
268
268
|
/** Print-validate skips persisted for the authed violations GET. Cap 100/subgraph. */
|
|
269
269
|
interface SubgraphViolationsTable {
|
|
270
270
|
id: Generated<string>;
|
|
271
|
+
subgraph_id: string;
|
|
271
272
|
subgraph_name: string;
|
|
272
273
|
source_name: string;
|
|
273
274
|
block_height: number;
|
|
@@ -377,6 +378,7 @@ interface MagicLinksTable {
|
|
|
377
378
|
}
|
|
378
379
|
interface SubgraphProcessingStatsTable {
|
|
379
380
|
id: Generated<string>;
|
|
381
|
+
subgraph_id: string;
|
|
380
382
|
subgraph_name: string;
|
|
381
383
|
api_key_id: string | null;
|
|
382
384
|
bucket_start: Date | null;
|
|
@@ -405,6 +407,7 @@ interface SubgraphHealthSnapshotsTable {
|
|
|
405
407
|
/** Handler errors grouped by fingerprint. Cap 50/subgraph. */
|
|
406
408
|
interface SubgraphErrorGroupsTable {
|
|
407
409
|
id: Generated<string>;
|
|
410
|
+
subgraph_id: string;
|
|
408
411
|
subgraph_name: string;
|
|
409
412
|
fingerprint: string;
|
|
410
413
|
source_name: string;
|
|
@@ -278,6 +278,7 @@ interface SubgraphGapsTable {
|
|
|
278
278
|
/** Print-validate skips persisted for the authed violations GET. Cap 100/subgraph. */
|
|
279
279
|
interface SubgraphViolationsTable {
|
|
280
280
|
id: Generated<string>;
|
|
281
|
+
subgraph_id: string;
|
|
281
282
|
subgraph_name: string;
|
|
282
283
|
source_name: string;
|
|
283
284
|
block_height: number;
|
|
@@ -387,6 +388,7 @@ interface MagicLinksTable {
|
|
|
387
388
|
}
|
|
388
389
|
interface SubgraphProcessingStatsTable {
|
|
389
390
|
id: Generated<string>;
|
|
391
|
+
subgraph_id: string;
|
|
390
392
|
subgraph_name: string;
|
|
391
393
|
api_key_id: string | null;
|
|
392
394
|
bucket_start: Date | null;
|
|
@@ -415,6 +417,7 @@ interface SubgraphHealthSnapshotsTable {
|
|
|
415
417
|
/** Handler errors grouped by fingerprint. Cap 50/subgraph. */
|
|
416
418
|
interface SubgraphErrorGroupsTable {
|
|
417
419
|
id: Generated<string>;
|
|
420
|
+
subgraph_id: string;
|
|
418
421
|
subgraph_name: string;
|
|
419
422
|
fingerprint: string;
|
|
420
423
|
source_name: string;
|
|
@@ -269,6 +269,7 @@ interface SubgraphGapsTable {
|
|
|
269
269
|
/** Print-validate skips persisted for the authed violations GET. Cap 100/subgraph. */
|
|
270
270
|
interface SubgraphViolationsTable {
|
|
271
271
|
id: Generated<string>;
|
|
272
|
+
subgraph_id: string;
|
|
272
273
|
subgraph_name: string;
|
|
273
274
|
source_name: string;
|
|
274
275
|
block_height: number;
|
|
@@ -378,6 +379,7 @@ interface MagicLinksTable {
|
|
|
378
379
|
}
|
|
379
380
|
interface SubgraphProcessingStatsTable {
|
|
380
381
|
id: Generated<string>;
|
|
382
|
+
subgraph_id: string;
|
|
381
383
|
subgraph_name: string;
|
|
382
384
|
api_key_id: string | null;
|
|
383
385
|
bucket_start: Date | null;
|
|
@@ -406,6 +408,7 @@ interface SubgraphHealthSnapshotsTable {
|
|
|
406
408
|
/** Handler errors grouped by fingerprint. Cap 50/subgraph. */
|
|
407
409
|
interface SubgraphErrorGroupsTable {
|
|
408
410
|
id: Generated<string>;
|
|
411
|
+
subgraph_id: string;
|
|
409
412
|
subgraph_name: string;
|
|
410
413
|
fingerprint: string;
|
|
411
414
|
source_name: string;
|
package/dist/src/db/schema.d.ts
CHANGED
|
@@ -257,6 +257,7 @@ interface SubgraphGapsTable {
|
|
|
257
257
|
/** Print-validate skips persisted for the authed violations GET. Cap 100/subgraph. */
|
|
258
258
|
interface SubgraphViolationsTable {
|
|
259
259
|
id: Generated<string>;
|
|
260
|
+
subgraph_id: string;
|
|
260
261
|
subgraph_name: string;
|
|
261
262
|
source_name: string;
|
|
262
263
|
block_height: number;
|
|
@@ -366,6 +367,7 @@ interface MagicLinksTable {
|
|
|
366
367
|
}
|
|
367
368
|
interface SubgraphProcessingStatsTable {
|
|
368
369
|
id: Generated<string>;
|
|
370
|
+
subgraph_id: string;
|
|
369
371
|
subgraph_name: string;
|
|
370
372
|
api_key_id: string | null;
|
|
371
373
|
bucket_start: Date | null;
|
|
@@ -394,6 +396,7 @@ interface SubgraphHealthSnapshotsTable {
|
|
|
394
396
|
/** Handler errors grouped by fingerprint. Cap 50/subgraph. */
|
|
395
397
|
interface SubgraphErrorGroupsTable {
|
|
396
398
|
id: Generated<string>;
|
|
399
|
+
subgraph_id: string;
|
|
397
400
|
subgraph_name: string;
|
|
398
401
|
fingerprint: string;
|
|
399
402
|
source_name: string;
|