feat(indexer): postgresql connection pooling and graphql query comple… - #1118
Merged
Conversation
…xity limits Closes SoroLabs#1064 Closes SoroLabs#1066
|
@melvilmz Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
@melvilmz is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel. A member of the Team first needs to authorize it. |
…g and GraphQL complexity from PR SoroLabs#1118 alongside main's webhook dispatcher, parallel parser, and auth-route additions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request implements PostgreSQL 16+ & TimescaleDB persistent storage with segregated connection pooling (#1064) and GraphQL query complexity analysis, depth limiting, and bounded pagination (#1066).
These changes eliminate SQLite write-lock contention under heavy ledger indexing workloads (verified at 1,000+ writes/sec with zero lock blocking), harden the GraphQL endpoint against nested DoS / resource exhaustion attacks, and provide Relay-compliant cursor pagination.
Linked Issues
Key Architecture & Feature Details
1. PostgreSQL 16+ & TimescaleDB Persistent Engine (Issue #1064)
pg-pool/pg.Pool):transaction()helper withBEGIN/COMMIT/ROLLBACK).normalizePgQuery()to transparently translate legacy SQLite parameter markers (?$1, $2, ...) and JSON functions (json_extract(data_json, '$.key')(data_json->>'key')).004_timescaledb_executions_hypertable.sql: Converts theexecutionstable into a 7-day chunk hypertable with a 14-day automatic compression policy segmenting by(task_id, keeper_address, status).002_timescaledb_raw_events_retention.down.sqland004_timescaledb_executions_hypertable.down.sql).indexer/knexfile.jswith pooled database configurations fordevelopment,test, andproduction.2. GraphQL Security & Query Complexity Protection (Issue #1066)
createDepthRule(5)viagraphql-depth-limit), blocking cyclic and maliciously deep nested queries before execution.createComplexityLimitRule(1000)viagraphql-query-complexity).paginationComplexityEstimator()dynamically calculates AST cost proportional to requested item limits (first/limit).createPaginationBoundsRule(50)) and resolver runtime (validatePaginationBounds()).< 1or> 50items return immediate400 Bad Requestvalidation errors.3. Relay Cursor Connections & Schema Enhancements
PageInfo,TaskConnection,TaskEdge,EventConnection, andEventEdgetoschema.js.tasksConnection(first, after)andeventsConnection(task_id, first, after)query fields.encodeCursor,decodeCursor).Task.events(first, limit),Task.executions(first, limit),Event.task, andExecutionHistory.task.File Changes Breakdown
indexer/src/graphql/complexity.jsindexer/src/graphql/db.jsindexer/src/dbRouter.jsindexer/src/graphql/schema.jsPageInfo, Relay connection types, bounded query signatures, and nested relations.indexer/src/graphql/resolvers.jsindexer/src/api.jsindexer/src/index.jsindexer/knexfile.jsindexer/migrations/004_timescaledb_executions_hypertable.sqlindexer/migrations/*.down.sqlindexer/test/graphqlComplexity.test.jsindexer/test/postgresPoolBenchmark.test.jsindexer/test/migrations.test.jsBenchmark & Concurrency Verification