@secondlayer/shared 11.21.0 → 11.22.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 +26 -0
- package/dist/src/archive/semantic-digest-builder.d.ts +26 -0
- package/dist/src/coverage/index.d.ts +26 -0
- package/dist/src/db/index.d.ts +26 -0
- package/dist/src/db/queries/chain-reorgs.d.ts +26 -0
- package/dist/src/db/queries/contracts.d.ts +26 -0
- package/dist/src/db/queries/instance.d.ts +26 -0
- package/dist/src/db/queries/integrity.d.ts +26 -0
- package/dist/src/db/queries/subgraph-gaps.d.ts +26 -0
- package/dist/src/db/queries/subgraph-operations.d.ts +26 -0
- package/dist/src/db/queries/subgraphs.d.ts +30 -0
- package/dist/src/db/queries/subgraphs.js +10 -2
- package/dist/src/db/queries/subgraphs.js.map +4 -4
- package/dist/src/db/queries/sync-scope.d.ts +26 -0
- package/dist/src/db/queries/webhooks.d.ts +26 -0
- package/dist/src/db/schema.d.ts +26 -0
- package/dist/src/index.d.ts +243 -208
- package/dist/src/index.js +4 -1
- package/dist/src/index.js.map +4 -4
- package/dist/src/node/local-client.d.ts +26 -0
- package/dist/src/schemas/index.d.ts +30 -1
- package/dist/src/schemas/index.js.map +2 -2
- package/dist/src/schemas/subgraphs.d.ts +30 -1
- package/dist/src/schemas/subgraphs.js.map +2 -2
- package/dist/src/subgraphs/spec.d.ts +27 -0
- package/dist/src/subgraphs/spec.js +4 -1
- package/dist/src/subgraphs/spec.js.map +3 -3
- package/migrations/0157_subgraph_pin_verification.ts +35 -0
- package/package.json +1 -1
|
@@ -19,6 +19,27 @@ type FailureClass = (typeof FAILURE_CLASSES)[number];
|
|
|
19
19
|
declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
|
|
20
20
|
type RetryState = (typeof RETRY_STATES)[number];
|
|
21
21
|
type BootstrapSource = "archive" | "genesis" | "import";
|
|
22
|
+
/**
|
|
23
|
+
* How far a subgraph's rows can be checked without trusting the server,
|
|
24
|
+
* derived from its sources and a scan of its handler. Never configured.
|
|
25
|
+
*
|
|
26
|
+
* - `state`: every input is a named state write, provable from block headers.
|
|
27
|
+
* Handlers run in the deterministic realm. A deployed `state` subgraph is
|
|
28
|
+
* verifiable: one with any reason is refused at deploy.
|
|
29
|
+
* - `events`: an input (events, prints, tx results, `ctx.client`) needs
|
|
30
|
+
* re-execution proofs, which are not served yet.
|
|
31
|
+
* - `none`: a source can never be proven as written (trait scope, tip-first
|
|
32
|
+
* backfill).
|
|
33
|
+
*/
|
|
34
|
+
interface SubgraphVerification {
|
|
35
|
+
level: "state" | "events" | "none";
|
|
36
|
+
/** What stands between the subgraph and checkable rows, e.g.
|
|
37
|
+
* `print_event source "swaps" needs event proofs` or
|
|
38
|
+
* `subgraph.ts:41:12 Date: wall-clock time differs per run`. */
|
|
39
|
+
reasons: string[];
|
|
40
|
+
/** What stays unproven even at this level, e.g. tx attribution of writes. */
|
|
41
|
+
unproven: string[];
|
|
42
|
+
}
|
|
22
43
|
interface BlocksTable {
|
|
23
44
|
height: number;
|
|
24
45
|
hash: string;
|
|
@@ -179,6 +200,11 @@ interface SubgraphsTable {
|
|
|
179
200
|
expires_at: Date | null;
|
|
180
201
|
/** (event type, contract) probe pairs persisted at deploy for weight classification. */
|
|
181
202
|
sparse_probe_targets: unknown | null;
|
|
203
|
+
/** sha256 over everything that shapes rows (schema, handler bundle,
|
|
204
|
+
* startBlock, network, runtime). NULL for unbundled or older deploys. */
|
|
205
|
+
pin: string | null;
|
|
206
|
+
/** Level derived at deploy. NULL (older deploys) = not verifiable. */
|
|
207
|
+
verification: SubgraphVerification | null;
|
|
182
208
|
created_at: Generated<Date>;
|
|
183
209
|
updated_at: Generated<Date>;
|
|
184
210
|
}
|
|
@@ -19,6 +19,27 @@ type FailureClass = (typeof FAILURE_CLASSES)[number];
|
|
|
19
19
|
declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
|
|
20
20
|
type RetryState = (typeof RETRY_STATES)[number];
|
|
21
21
|
type BootstrapSource = "archive" | "genesis" | "import";
|
|
22
|
+
/**
|
|
23
|
+
* How far a subgraph's rows can be checked without trusting the server,
|
|
24
|
+
* derived from its sources and a scan of its handler. Never configured.
|
|
25
|
+
*
|
|
26
|
+
* - `state`: every input is a named state write, provable from block headers.
|
|
27
|
+
* Handlers run in the deterministic realm. A deployed `state` subgraph is
|
|
28
|
+
* verifiable: one with any reason is refused at deploy.
|
|
29
|
+
* - `events`: an input (events, prints, tx results, `ctx.client`) needs
|
|
30
|
+
* re-execution proofs, which are not served yet.
|
|
31
|
+
* - `none`: a source can never be proven as written (trait scope, tip-first
|
|
32
|
+
* backfill).
|
|
33
|
+
*/
|
|
34
|
+
interface SubgraphVerification {
|
|
35
|
+
level: "state" | "events" | "none";
|
|
36
|
+
/** What stands between the subgraph and checkable rows, e.g.
|
|
37
|
+
* `print_event source "swaps" needs event proofs` or
|
|
38
|
+
* `subgraph.ts:41:12 Date: wall-clock time differs per run`. */
|
|
39
|
+
reasons: string[];
|
|
40
|
+
/** What stays unproven even at this level, e.g. tx attribution of writes. */
|
|
41
|
+
unproven: string[];
|
|
42
|
+
}
|
|
22
43
|
interface BlocksTable {
|
|
23
44
|
height: number;
|
|
24
45
|
hash: string;
|
|
@@ -179,6 +200,11 @@ interface SubgraphsTable {
|
|
|
179
200
|
expires_at: Date | null;
|
|
180
201
|
/** (event type, contract) probe pairs persisted at deploy for weight classification. */
|
|
181
202
|
sparse_probe_targets: unknown | null;
|
|
203
|
+
/** sha256 over everything that shapes rows (schema, handler bundle,
|
|
204
|
+
* startBlock, network, runtime). NULL for unbundled or older deploys. */
|
|
205
|
+
pin: string | null;
|
|
206
|
+
/** Level derived at deploy. NULL (older deploys) = not verifiable. */
|
|
207
|
+
verification: SubgraphVerification | null;
|
|
182
208
|
created_at: Generated<Date>;
|
|
183
209
|
updated_at: Generated<Date>;
|
|
184
210
|
}
|
|
@@ -336,6 +336,27 @@ declare function cursorIsBeforeBlock(cursor: StreamsCursor, height: number): boo
|
|
|
336
336
|
declare function planDecoderReceipts(input: DecoderClockInput): DecoderClockResult;
|
|
337
337
|
import { Kysely } from "kysely";
|
|
338
338
|
import { ColumnType, Generated } from "kysely";
|
|
339
|
+
/**
|
|
340
|
+
* How far a subgraph's rows can be checked without trusting the server,
|
|
341
|
+
* derived from its sources and a scan of its handler. Never configured.
|
|
342
|
+
*
|
|
343
|
+
* - `state`: every input is a named state write, provable from block headers.
|
|
344
|
+
* Handlers run in the deterministic realm. A deployed `state` subgraph is
|
|
345
|
+
* verifiable: one with any reason is refused at deploy.
|
|
346
|
+
* - `events`: an input (events, prints, tx results, `ctx.client`) needs
|
|
347
|
+
* re-execution proofs, which are not served yet.
|
|
348
|
+
* - `none`: a source can never be proven as written (trait scope, tip-first
|
|
349
|
+
* backfill).
|
|
350
|
+
*/
|
|
351
|
+
interface SubgraphVerification {
|
|
352
|
+
level: "state" | "events" | "none";
|
|
353
|
+
/** What stands between the subgraph and checkable rows, e.g.
|
|
354
|
+
* `print_event source "swaps" needs event proofs` or
|
|
355
|
+
* `subgraph.ts:41:12 Date: wall-clock time differs per run`. */
|
|
356
|
+
reasons: string[];
|
|
357
|
+
/** What stays unproven even at this level, e.g. tx attribution of writes. */
|
|
358
|
+
unproven: string[];
|
|
359
|
+
}
|
|
339
360
|
interface BlocksTable {
|
|
340
361
|
height: number;
|
|
341
362
|
hash: string;
|
|
@@ -496,6 +517,11 @@ interface SubgraphsTable {
|
|
|
496
517
|
expires_at: Date | null;
|
|
497
518
|
/** (event type, contract) probe pairs persisted at deploy for weight classification. */
|
|
498
519
|
sparse_probe_targets: unknown | null;
|
|
520
|
+
/** sha256 over everything that shapes rows (schema, handler bundle,
|
|
521
|
+
* startBlock, network, runtime). NULL for unbundled or older deploys. */
|
|
522
|
+
pin: string | null;
|
|
523
|
+
/** Level derived at deploy. NULL (older deploys) = not verifiable. */
|
|
524
|
+
verification: SubgraphVerification | null;
|
|
499
525
|
created_at: Generated<Date>;
|
|
500
526
|
updated_at: Generated<Date>;
|
|
501
527
|
}
|
package/dist/src/db/index.d.ts
CHANGED
|
@@ -20,6 +20,27 @@ type FailureClass = (typeof FAILURE_CLASSES)[number];
|
|
|
20
20
|
declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
|
|
21
21
|
type RetryState = (typeof RETRY_STATES)[number];
|
|
22
22
|
type BootstrapSource = "archive" | "genesis" | "import";
|
|
23
|
+
/**
|
|
24
|
+
* How far a subgraph's rows can be checked without trusting the server,
|
|
25
|
+
* derived from its sources and a scan of its handler. Never configured.
|
|
26
|
+
*
|
|
27
|
+
* - `state`: every input is a named state write, provable from block headers.
|
|
28
|
+
* Handlers run in the deterministic realm. A deployed `state` subgraph is
|
|
29
|
+
* verifiable: one with any reason is refused at deploy.
|
|
30
|
+
* - `events`: an input (events, prints, tx results, `ctx.client`) needs
|
|
31
|
+
* re-execution proofs, which are not served yet.
|
|
32
|
+
* - `none`: a source can never be proven as written (trait scope, tip-first
|
|
33
|
+
* backfill).
|
|
34
|
+
*/
|
|
35
|
+
interface SubgraphVerification {
|
|
36
|
+
level: "state" | "events" | "none";
|
|
37
|
+
/** What stands between the subgraph and checkable rows, e.g.
|
|
38
|
+
* `print_event source "swaps" needs event proofs` or
|
|
39
|
+
* `subgraph.ts:41:12 Date: wall-clock time differs per run`. */
|
|
40
|
+
reasons: string[];
|
|
41
|
+
/** What stays unproven even at this level, e.g. tx attribution of writes. */
|
|
42
|
+
unproven: string[];
|
|
43
|
+
}
|
|
23
44
|
interface BlocksTable {
|
|
24
45
|
height: number;
|
|
25
46
|
hash: string;
|
|
@@ -180,6 +201,11 @@ interface SubgraphsTable {
|
|
|
180
201
|
expires_at: Date | null;
|
|
181
202
|
/** (event type, contract) probe pairs persisted at deploy for weight classification. */
|
|
182
203
|
sparse_probe_targets: unknown | null;
|
|
204
|
+
/** sha256 over everything that shapes rows (schema, handler bundle,
|
|
205
|
+
* startBlock, network, runtime). NULL for unbundled or older deploys. */
|
|
206
|
+
pin: string | null;
|
|
207
|
+
/** Level derived at deploy. NULL (older deploys) = not verifiable. */
|
|
208
|
+
verification: SubgraphVerification | null;
|
|
183
209
|
created_at: Generated<Date>;
|
|
184
210
|
updated_at: Generated<Date>;
|
|
185
211
|
}
|
|
@@ -19,6 +19,27 @@ type FailureClass = (typeof FAILURE_CLASSES)[number];
|
|
|
19
19
|
declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
|
|
20
20
|
type RetryState = (typeof RETRY_STATES)[number];
|
|
21
21
|
type BootstrapSource = "archive" | "genesis" | "import";
|
|
22
|
+
/**
|
|
23
|
+
* How far a subgraph's rows can be checked without trusting the server,
|
|
24
|
+
* derived from its sources and a scan of its handler. Never configured.
|
|
25
|
+
*
|
|
26
|
+
* - `state`: every input is a named state write, provable from block headers.
|
|
27
|
+
* Handlers run in the deterministic realm. A deployed `state` subgraph is
|
|
28
|
+
* verifiable: one with any reason is refused at deploy.
|
|
29
|
+
* - `events`: an input (events, prints, tx results, `ctx.client`) needs
|
|
30
|
+
* re-execution proofs, which are not served yet.
|
|
31
|
+
* - `none`: a source can never be proven as written (trait scope, tip-first
|
|
32
|
+
* backfill).
|
|
33
|
+
*/
|
|
34
|
+
interface SubgraphVerification {
|
|
35
|
+
level: "state" | "events" | "none";
|
|
36
|
+
/** What stands between the subgraph and checkable rows, e.g.
|
|
37
|
+
* `print_event source "swaps" needs event proofs` or
|
|
38
|
+
* `subgraph.ts:41:12 Date: wall-clock time differs per run`. */
|
|
39
|
+
reasons: string[];
|
|
40
|
+
/** What stays unproven even at this level, e.g. tx attribution of writes. */
|
|
41
|
+
unproven: string[];
|
|
42
|
+
}
|
|
22
43
|
interface BlocksTable {
|
|
23
44
|
height: number;
|
|
24
45
|
hash: string;
|
|
@@ -179,6 +200,11 @@ interface SubgraphsTable {
|
|
|
179
200
|
expires_at: Date | null;
|
|
180
201
|
/** (event type, contract) probe pairs persisted at deploy for weight classification. */
|
|
181
202
|
sparse_probe_targets: unknown | null;
|
|
203
|
+
/** sha256 over everything that shapes rows (schema, handler bundle,
|
|
204
|
+
* startBlock, network, runtime). NULL for unbundled or older deploys. */
|
|
205
|
+
pin: string | null;
|
|
206
|
+
/** Level derived at deploy. NULL (older deploys) = not verifiable. */
|
|
207
|
+
verification: SubgraphVerification | null;
|
|
182
208
|
created_at: Generated<Date>;
|
|
183
209
|
updated_at: Generated<Date>;
|
|
184
210
|
}
|
|
@@ -19,6 +19,27 @@ type FailureClass = (typeof FAILURE_CLASSES)[number];
|
|
|
19
19
|
declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
|
|
20
20
|
type RetryState = (typeof RETRY_STATES)[number];
|
|
21
21
|
type BootstrapSource = "archive" | "genesis" | "import";
|
|
22
|
+
/**
|
|
23
|
+
* How far a subgraph's rows can be checked without trusting the server,
|
|
24
|
+
* derived from its sources and a scan of its handler. Never configured.
|
|
25
|
+
*
|
|
26
|
+
* - `state`: every input is a named state write, provable from block headers.
|
|
27
|
+
* Handlers run in the deterministic realm. A deployed `state` subgraph is
|
|
28
|
+
* verifiable: one with any reason is refused at deploy.
|
|
29
|
+
* - `events`: an input (events, prints, tx results, `ctx.client`) needs
|
|
30
|
+
* re-execution proofs, which are not served yet.
|
|
31
|
+
* - `none`: a source can never be proven as written (trait scope, tip-first
|
|
32
|
+
* backfill).
|
|
33
|
+
*/
|
|
34
|
+
interface SubgraphVerification {
|
|
35
|
+
level: "state" | "events" | "none";
|
|
36
|
+
/** What stands between the subgraph and checkable rows, e.g.
|
|
37
|
+
* `print_event source "swaps" needs event proofs` or
|
|
38
|
+
* `subgraph.ts:41:12 Date: wall-clock time differs per run`. */
|
|
39
|
+
reasons: string[];
|
|
40
|
+
/** What stays unproven even at this level, e.g. tx attribution of writes. */
|
|
41
|
+
unproven: string[];
|
|
42
|
+
}
|
|
22
43
|
interface BlocksTable {
|
|
23
44
|
height: number;
|
|
24
45
|
hash: string;
|
|
@@ -179,6 +200,11 @@ interface SubgraphsTable {
|
|
|
179
200
|
expires_at: Date | null;
|
|
180
201
|
/** (event type, contract) probe pairs persisted at deploy for weight classification. */
|
|
181
202
|
sparse_probe_targets: unknown | null;
|
|
203
|
+
/** sha256 over everything that shapes rows (schema, handler bundle,
|
|
204
|
+
* startBlock, network, runtime). NULL for unbundled or older deploys. */
|
|
205
|
+
pin: string | null;
|
|
206
|
+
/** Level derived at deploy. NULL (older deploys) = not verifiable. */
|
|
207
|
+
verification: SubgraphVerification | null;
|
|
182
208
|
created_at: Generated<Date>;
|
|
183
209
|
updated_at: Generated<Date>;
|
|
184
210
|
}
|
|
@@ -19,6 +19,27 @@ type FailureClass = (typeof FAILURE_CLASSES)[number];
|
|
|
19
19
|
declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
|
|
20
20
|
type RetryState = (typeof RETRY_STATES)[number];
|
|
21
21
|
type BootstrapSource = "archive" | "genesis" | "import";
|
|
22
|
+
/**
|
|
23
|
+
* How far a subgraph's rows can be checked without trusting the server,
|
|
24
|
+
* derived from its sources and a scan of its handler. Never configured.
|
|
25
|
+
*
|
|
26
|
+
* - `state`: every input is a named state write, provable from block headers.
|
|
27
|
+
* Handlers run in the deterministic realm. A deployed `state` subgraph is
|
|
28
|
+
* verifiable: one with any reason is refused at deploy.
|
|
29
|
+
* - `events`: an input (events, prints, tx results, `ctx.client`) needs
|
|
30
|
+
* re-execution proofs, which are not served yet.
|
|
31
|
+
* - `none`: a source can never be proven as written (trait scope, tip-first
|
|
32
|
+
* backfill).
|
|
33
|
+
*/
|
|
34
|
+
interface SubgraphVerification {
|
|
35
|
+
level: "state" | "events" | "none";
|
|
36
|
+
/** What stands between the subgraph and checkable rows, e.g.
|
|
37
|
+
* `print_event source "swaps" needs event proofs` or
|
|
38
|
+
* `subgraph.ts:41:12 Date: wall-clock time differs per run`. */
|
|
39
|
+
reasons: string[];
|
|
40
|
+
/** What stays unproven even at this level, e.g. tx attribution of writes. */
|
|
41
|
+
unproven: string[];
|
|
42
|
+
}
|
|
22
43
|
interface BlocksTable {
|
|
23
44
|
height: number;
|
|
24
45
|
hash: string;
|
|
@@ -179,6 +200,11 @@ interface SubgraphsTable {
|
|
|
179
200
|
expires_at: Date | null;
|
|
180
201
|
/** (event type, contract) probe pairs persisted at deploy for weight classification. */
|
|
181
202
|
sparse_probe_targets: unknown | null;
|
|
203
|
+
/** sha256 over everything that shapes rows (schema, handler bundle,
|
|
204
|
+
* startBlock, network, runtime). NULL for unbundled or older deploys. */
|
|
205
|
+
pin: string | null;
|
|
206
|
+
/** Level derived at deploy. NULL (older deploys) = not verifiable. */
|
|
207
|
+
verification: SubgraphVerification | null;
|
|
182
208
|
created_at: Generated<Date>;
|
|
183
209
|
updated_at: Generated<Date>;
|
|
184
210
|
}
|
|
@@ -19,6 +19,27 @@ type FailureClass = (typeof FAILURE_CLASSES)[number];
|
|
|
19
19
|
declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
|
|
20
20
|
type RetryState = (typeof RETRY_STATES)[number];
|
|
21
21
|
type BootstrapSource = "archive" | "genesis" | "import";
|
|
22
|
+
/**
|
|
23
|
+
* How far a subgraph's rows can be checked without trusting the server,
|
|
24
|
+
* derived from its sources and a scan of its handler. Never configured.
|
|
25
|
+
*
|
|
26
|
+
* - `state`: every input is a named state write, provable from block headers.
|
|
27
|
+
* Handlers run in the deterministic realm. A deployed `state` subgraph is
|
|
28
|
+
* verifiable: one with any reason is refused at deploy.
|
|
29
|
+
* - `events`: an input (events, prints, tx results, `ctx.client`) needs
|
|
30
|
+
* re-execution proofs, which are not served yet.
|
|
31
|
+
* - `none`: a source can never be proven as written (trait scope, tip-first
|
|
32
|
+
* backfill).
|
|
33
|
+
*/
|
|
34
|
+
interface SubgraphVerification {
|
|
35
|
+
level: "state" | "events" | "none";
|
|
36
|
+
/** What stands between the subgraph and checkable rows, e.g.
|
|
37
|
+
* `print_event source "swaps" needs event proofs` or
|
|
38
|
+
* `subgraph.ts:41:12 Date: wall-clock time differs per run`. */
|
|
39
|
+
reasons: string[];
|
|
40
|
+
/** What stays unproven even at this level, e.g. tx attribution of writes. */
|
|
41
|
+
unproven: string[];
|
|
42
|
+
}
|
|
22
43
|
interface BlocksTable {
|
|
23
44
|
height: number;
|
|
24
45
|
hash: string;
|
|
@@ -179,6 +200,11 @@ interface SubgraphsTable {
|
|
|
179
200
|
expires_at: Date | null;
|
|
180
201
|
/** (event type, contract) probe pairs persisted at deploy for weight classification. */
|
|
181
202
|
sparse_probe_targets: unknown | null;
|
|
203
|
+
/** sha256 over everything that shapes rows (schema, handler bundle,
|
|
204
|
+
* startBlock, network, runtime). NULL for unbundled or older deploys. */
|
|
205
|
+
pin: string | null;
|
|
206
|
+
/** Level derived at deploy. NULL (older deploys) = not verifiable. */
|
|
207
|
+
verification: SubgraphVerification | null;
|
|
182
208
|
created_at: Generated<Date>;
|
|
183
209
|
updated_at: Generated<Date>;
|
|
184
210
|
}
|
|
@@ -19,6 +19,27 @@ type FailureClass = (typeof FAILURE_CLASSES)[number];
|
|
|
19
19
|
declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
|
|
20
20
|
type RetryState = (typeof RETRY_STATES)[number];
|
|
21
21
|
type BootstrapSource = "archive" | "genesis" | "import";
|
|
22
|
+
/**
|
|
23
|
+
* How far a subgraph's rows can be checked without trusting the server,
|
|
24
|
+
* derived from its sources and a scan of its handler. Never configured.
|
|
25
|
+
*
|
|
26
|
+
* - `state`: every input is a named state write, provable from block headers.
|
|
27
|
+
* Handlers run in the deterministic realm. A deployed `state` subgraph is
|
|
28
|
+
* verifiable: one with any reason is refused at deploy.
|
|
29
|
+
* - `events`: an input (events, prints, tx results, `ctx.client`) needs
|
|
30
|
+
* re-execution proofs, which are not served yet.
|
|
31
|
+
* - `none`: a source can never be proven as written (trait scope, tip-first
|
|
32
|
+
* backfill).
|
|
33
|
+
*/
|
|
34
|
+
interface SubgraphVerification {
|
|
35
|
+
level: "state" | "events" | "none";
|
|
36
|
+
/** What stands between the subgraph and checkable rows, e.g.
|
|
37
|
+
* `print_event source "swaps" needs event proofs` or
|
|
38
|
+
* `subgraph.ts:41:12 Date: wall-clock time differs per run`. */
|
|
39
|
+
reasons: string[];
|
|
40
|
+
/** What stays unproven even at this level, e.g. tx attribution of writes. */
|
|
41
|
+
unproven: string[];
|
|
42
|
+
}
|
|
22
43
|
interface BlocksTable {
|
|
23
44
|
height: number;
|
|
24
45
|
hash: string;
|
|
@@ -179,6 +200,11 @@ interface SubgraphsTable {
|
|
|
179
200
|
expires_at: Date | null;
|
|
180
201
|
/** (event type, contract) probe pairs persisted at deploy for weight classification. */
|
|
181
202
|
sparse_probe_targets: unknown | null;
|
|
203
|
+
/** sha256 over everything that shapes rows (schema, handler bundle,
|
|
204
|
+
* startBlock, network, runtime). NULL for unbundled or older deploys. */
|
|
205
|
+
pin: string | null;
|
|
206
|
+
/** Level derived at deploy. NULL (older deploys) = not verifiable. */
|
|
207
|
+
verification: SubgraphVerification | null;
|
|
182
208
|
created_at: Generated<Date>;
|
|
183
209
|
updated_at: Generated<Date>;
|
|
184
210
|
}
|
|
@@ -19,6 +19,27 @@ type FailureClass = (typeof FAILURE_CLASSES)[number];
|
|
|
19
19
|
declare const RETRY_STATES: readonly ["open", "retrying", "halted", "resolved"];
|
|
20
20
|
type RetryState = (typeof RETRY_STATES)[number];
|
|
21
21
|
type BootstrapSource = "archive" | "genesis" | "import";
|
|
22
|
+
/**
|
|
23
|
+
* How far a subgraph's rows can be checked without trusting the server,
|
|
24
|
+
* derived from its sources and a scan of its handler. Never configured.
|
|
25
|
+
*
|
|
26
|
+
* - `state`: every input is a named state write, provable from block headers.
|
|
27
|
+
* Handlers run in the deterministic realm. A deployed `state` subgraph is
|
|
28
|
+
* verifiable: one with any reason is refused at deploy.
|
|
29
|
+
* - `events`: an input (events, prints, tx results, `ctx.client`) needs
|
|
30
|
+
* re-execution proofs, which are not served yet.
|
|
31
|
+
* - `none`: a source can never be proven as written (trait scope, tip-first
|
|
32
|
+
* backfill).
|
|
33
|
+
*/
|
|
34
|
+
interface SubgraphVerification {
|
|
35
|
+
level: "state" | "events" | "none";
|
|
36
|
+
/** What stands between the subgraph and checkable rows, e.g.
|
|
37
|
+
* `print_event source "swaps" needs event proofs` or
|
|
38
|
+
* `subgraph.ts:41:12 Date: wall-clock time differs per run`. */
|
|
39
|
+
reasons: string[];
|
|
40
|
+
/** What stays unproven even at this level, e.g. tx attribution of writes. */
|
|
41
|
+
unproven: string[];
|
|
42
|
+
}
|
|
22
43
|
interface BlocksTable {
|
|
23
44
|
height: number;
|
|
24
45
|
hash: string;
|
|
@@ -179,6 +200,11 @@ interface SubgraphsTable {
|
|
|
179
200
|
expires_at: Date | null;
|
|
180
201
|
/** (event type, contract) probe pairs persisted at deploy for weight classification. */
|
|
181
202
|
sparse_probe_targets: unknown | null;
|
|
203
|
+
/** sha256 over everything that shapes rows (schema, handler bundle,
|
|
204
|
+
* startBlock, network, runtime). NULL for unbundled or older deploys. */
|
|
205
|
+
pin: string | null;
|
|
206
|
+
/** Level derived at deploy. NULL (older deploys) = not verifiable. */
|
|
207
|
+
verification: SubgraphVerification | null;
|
|
182
208
|
created_at: Generated<Date>;
|
|
183
209
|
updated_at: Generated<Date>;
|
|
184
210
|
}
|
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
import { Kysely } from "kysely";
|
|
2
|
+
/**
|
|
3
|
+
* How far a subgraph's rows can be checked without trusting the server,
|
|
4
|
+
* derived from its sources and a scan of its handler. Never configured.
|
|
5
|
+
*
|
|
6
|
+
* - `state`: every input is a named state write, provable from block headers.
|
|
7
|
+
* Handlers run in the deterministic realm. A deployed `state` subgraph is
|
|
8
|
+
* verifiable: one with any reason is refused at deploy.
|
|
9
|
+
* - `events`: an input (events, prints, tx results, `ctx.client`) needs
|
|
10
|
+
* re-execution proofs, which are not served yet.
|
|
11
|
+
* - `none`: a source can never be proven as written (trait scope, tip-first
|
|
12
|
+
* backfill).
|
|
13
|
+
*/
|
|
14
|
+
interface SubgraphVerification {
|
|
15
|
+
level: "state" | "events" | "none";
|
|
16
|
+
/** What stands between the subgraph and checkable rows, e.g.
|
|
17
|
+
* `print_event source "swaps" needs event proofs` or
|
|
18
|
+
* `subgraph.ts:41:12 Date: wall-clock time differs per run`. */
|
|
19
|
+
reasons: string[];
|
|
20
|
+
/** What stays unproven even at this level, e.g. tx attribution of writes. */
|
|
21
|
+
unproven: string[];
|
|
22
|
+
}
|
|
2
23
|
import { ColumnType, Generated, Selectable } from "kysely";
|
|
3
24
|
/**
|
|
4
25
|
* Coverage-kernel constraints. SQL CHECKs in migration 0116 must stay
|
|
@@ -179,6 +200,11 @@ interface SubgraphsTable {
|
|
|
179
200
|
expires_at: Date | null;
|
|
180
201
|
/** (event type, contract) probe pairs persisted at deploy for weight classification. */
|
|
181
202
|
sparse_probe_targets: unknown | null;
|
|
203
|
+
/** sha256 over everything that shapes rows (schema, handler bundle,
|
|
204
|
+
* startBlock, network, runtime). NULL for unbundled or older deploys. */
|
|
205
|
+
pin: string | null;
|
|
206
|
+
/** Level derived at deploy. NULL (older deploys) = not verifiable. */
|
|
207
|
+
verification: SubgraphVerification | null;
|
|
182
208
|
created_at: Generated<Date>;
|
|
183
209
|
updated_at: Generated<Date>;
|
|
184
210
|
}
|
|
@@ -1110,6 +1136,8 @@ declare function registerSubgraph(db: Kysely<Database>, data: {
|
|
|
1110
1136
|
startBlock?: number
|
|
1111
1137
|
handlerCode?: string
|
|
1112
1138
|
sourceCode?: string
|
|
1139
|
+
pin?: string | null
|
|
1140
|
+
verification?: SubgraphVerification | null
|
|
1113
1141
|
}): Promise<Subgraph>;
|
|
1114
1142
|
declare function getSubgraph(db: Kysely<Database>, name: string, accountId?: string): Promise<Subgraph | null>;
|
|
1115
1143
|
declare function listSubgraphs(db: Kysely<Database>, accountId?: string): Promise<Subgraph[]>;
|
|
@@ -1140,6 +1168,8 @@ declare function clearSubgraphBillingPaused(db: Kysely<Database>, name: string):
|
|
|
1140
1168
|
declare function updateSubgraphHandlerPath(db: Kysely<Database>, name: string, handlerPath: string, opts?: {
|
|
1141
1169
|
handlerCode?: string
|
|
1142
1170
|
sourceCode?: string
|
|
1171
|
+
pin?: string | null
|
|
1172
|
+
verification?: SubgraphVerification | null
|
|
1143
1173
|
}): Promise<void>;
|
|
1144
1174
|
declare function deleteSubgraph(db: Kysely<Database>, name: string, accountId?: string): Promise<Subgraph | null>;
|
|
1145
1175
|
/** Set or clear a paid subgraph's expiry (NULL = no expiry, e.g. on claim). */
|
|
@@ -92,7 +92,9 @@ async function registerSubgraph(db, data) {
|
|
|
92
92
|
handler_code: data.handlerCode ?? null,
|
|
93
93
|
source_code: data.sourceCode ?? null,
|
|
94
94
|
schema_name: data.schemaName ?? null,
|
|
95
|
-
start_block: data.startBlock ?? 0
|
|
95
|
+
start_block: data.startBlock ?? 0,
|
|
96
|
+
pin: data.pin ?? null,
|
|
97
|
+
verification: data.verification ? jsonb(data.verification) : null
|
|
96
98
|
};
|
|
97
99
|
const updateSet = {
|
|
98
100
|
version: data.version,
|
|
@@ -103,6 +105,8 @@ async function registerSubgraph(db, data) {
|
|
|
103
105
|
source_code: data.sourceCode ?? null,
|
|
104
106
|
schema_name: data.schemaName ?? null,
|
|
105
107
|
start_block: data.startBlock ?? 0,
|
|
108
|
+
pin: values.pin,
|
|
109
|
+
verification: values.verification,
|
|
106
110
|
updated_at: new Date
|
|
107
111
|
};
|
|
108
112
|
if (!isPlatformMode()) {
|
|
@@ -166,6 +170,10 @@ async function updateSubgraphHandlerPath(db, name, handlerPath, opts) {
|
|
|
166
170
|
handler_path: handlerPath,
|
|
167
171
|
...opts?.handlerCode != null ? { handler_code: opts.handlerCode } : {},
|
|
168
172
|
...opts?.sourceCode != null ? { source_code: opts.sourceCode } : {},
|
|
173
|
+
...opts?.pin !== undefined ? { pin: opts.pin } : {},
|
|
174
|
+
...opts?.verification !== undefined ? {
|
|
175
|
+
verification: opts.verification ? jsonb(opts.verification) : null
|
|
176
|
+
} : {},
|
|
169
177
|
updated_at: new Date
|
|
170
178
|
}).where("name", "=", name).execute();
|
|
171
179
|
}
|
|
@@ -220,5 +228,5 @@ export {
|
|
|
220
228
|
updateSubgraphStatus
|
|
221
229
|
};
|
|
222
230
|
|
|
223
|
-
//# debugId=
|
|
231
|
+
//# debugId=C8FA24B029BE8C5164756E2164756E21
|
|
224
232
|
//# sourceMappingURL=subgraphs.js.map
|