@secondlayer/shared 11.16.0 → 11.17.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 +8 -0
- package/dist/src/archive/semantic-digest-builder.d.ts +8 -0
- package/dist/src/coverage/index.d.ts +8 -0
- package/dist/src/db/index.d.ts +11 -1
- package/dist/src/db/index.js +2 -1
- package/dist/src/db/index.js.map +3 -3
- package/dist/src/db/queries/chain-reorgs.d.ts +8 -0
- package/dist/src/db/queries/chain-reorgs.js +2 -1
- package/dist/src/db/queries/chain-reorgs.js.map +3 -3
- package/dist/src/db/queries/contracts.d.ts +8 -0
- package/dist/src/db/queries/instance.d.ts +8 -0
- package/dist/src/db/queries/integrity.d.ts +8 -0
- package/dist/src/db/queries/subgraph-gaps.d.ts +8 -0
- package/dist/src/db/queries/subgraph-operations.d.ts +8 -0
- package/dist/src/db/queries/subgraphs.d.ts +8 -0
- package/dist/src/db/queries/sync-scope.d.ts +8 -0
- package/dist/src/db/queries/webhooks.d.ts +8 -0
- package/dist/src/db/queries/webhooks.js +25 -1
- package/dist/src/db/queries/webhooks.js.map +3 -3
- package/dist/src/db/schema.d.ts +10 -1
- package/dist/src/index.d.ts +11 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +3 -3
- package/dist/src/node/local-client.d.ts +8 -0
- package/dist/src/queue/listener.js +2 -1
- package/dist/src/queue/listener.js.map +3 -3
- package/migrations/0149_webhook_deliveries_outbox_id_idx.ts +38 -0
- package/migrations/0150_sentinel_accounts.ts +27 -0
- package/package.json +1 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
|
+
import { onControlPlane } from "../src/db/migration-role.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `webhook_deliveries.outbox_id` has referenced `webhook_outbox` since 0057
|
|
6
|
+
* (`ON DELETE SET NULL` since 0077) and never had an index. Postgres does
|
|
7
|
+
* not index the referencing side of a foreign key. Deleting an outbox row
|
|
8
|
+
* therefore sequential-scans `webhook_deliveries` to null `outbox_id`.
|
|
9
|
+
*
|
|
10
|
+
* A chain webhook on a high-volume event accumulates ~1e5 outbox rows.
|
|
11
|
+
* `DELETE FROM webhooks` cascades to those rows, and each one scans the
|
|
12
|
+
* whole deliveries heap — including rows already deleted in the same
|
|
13
|
+
* statement, which stay visible until vacuum. That runs past the API's
|
|
14
|
+
* 90s idle timeout: the client gets a 502 and the next attempt queues
|
|
15
|
+
* behind the same lock.
|
|
16
|
+
*
|
|
17
|
+
* `deliveries_sub_idx (webhook_id, dispatched_at)` does not serve
|
|
18
|
+
* `WHERE outbox_id = $1`.
|
|
19
|
+
*/
|
|
20
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
21
|
+
await sql`SET lock_timeout = '30s'`.execute(db);
|
|
22
|
+
await onControlPlane(async () => {
|
|
23
|
+
await sql`SET LOCAL statement_timeout = 0`.execute(db);
|
|
24
|
+
await sql`
|
|
25
|
+
CREATE INDEX IF NOT EXISTS webhook_deliveries_outbox_id_idx
|
|
26
|
+
ON webhook_deliveries (outbox_id)
|
|
27
|
+
`.execute(db);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
32
|
+
await sql`SET lock_timeout = '30s'`.execute(db);
|
|
33
|
+
await onControlPlane(async () => {
|
|
34
|
+
await sql`
|
|
35
|
+
DROP INDEX IF EXISTS webhook_deliveries_outbox_id_idx
|
|
36
|
+
`.execute(db);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
|
+
import { onControlPlane } from "../src/db/migration-role.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Which accounts Sentinel's service key may touch. A row exists only for an
|
|
6
|
+
* account Sentinel created (`via = 'created'`) or one whose owner opted in
|
|
7
|
+
* from Sentinel's UI (`via = 'consent'`). Every `/internal/sentinel/*` call
|
|
8
|
+
* (and Sentinel-key `/internal/meters` items) beyond resolve/link requires a
|
|
9
|
+
* row, so a leaked key can't spend from or credit an arbitrary account.
|
|
10
|
+
*/
|
|
11
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
12
|
+
await onControlPlane(async () => {
|
|
13
|
+
await sql`
|
|
14
|
+
CREATE TABLE sentinel_accounts (
|
|
15
|
+
account_id uuid PRIMARY KEY REFERENCES accounts(id) ON DELETE CASCADE,
|
|
16
|
+
linked_at timestamptz NOT NULL DEFAULT now(),
|
|
17
|
+
via text NOT NULL CHECK (via IN ('created', 'consent'))
|
|
18
|
+
)
|
|
19
|
+
`.execute(db);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
24
|
+
await onControlPlane(async () => {
|
|
25
|
+
await sql`DROP TABLE IF EXISTS sentinel_accounts`.execute(db);
|
|
26
|
+
});
|
|
27
|
+
}
|