Repository navigation
feat(backend): diagnostic XDR error parser and ledger-partitioned eve… - #706
Merged
PeterOche merged 1 commit intoSep 27, 2026
Conversation
…nt_logs BE-004: Soroban RPC diagnostic event & XDR error code parser - DiagnosticParserService decodes diagnostic events, TransactionResult, TransactionMeta and simulation error strings into structured reports (contract error variant, auth failure, footprint/budget exhaustion, archived entries); never throws on malformed XDR - contract error registry generated from packages/contracts/*/src/errors.rs (20 contracts, 290 codes) with a sync test against the Rust sources - failed transactions are logged, persisted to failed_transactions and the submitting user is notified once (TRANSACTION_FAILED) BE-003: range partitioning of event_logs by ledger sequence - PartitionEventStore migration: 100k-ledger partitions, default partition, (contractId, topic0, ledger) composite index, verified zero-loss copy of existing rows and a lossless down() - event_logs_maintain_partitions() run by EventLogPartitionService on boot and every 10 minutes (and pg_cron when installed) - event_logs_max_ledger() helper keeps the indexer's latest-ledger lookup fast on the partitioned table - EventStoreService.getRawEventsByLedgerRange() range scan with keyset pagination; reconciliation now pushes its ledger range into SQL Also fixes resolveStartLedger concatenating the bigint ledger string. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
@feyishola 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! 🚀 |
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.
closes #620
closes #621
closes #622
closes #623
(Soroban RPC Diagnostic Event & XDR Error Code Parser) and BE-003 (Event Store Range Partitioning by Ledger Sequence). All changes are in
packages/backend.BE-004 — Diagnostic & XDR error parser
src/indexer/diagnostic-parser.service.tsdecodes diagnostic events,TransactionResult,TransactionMetaand simulation error strings into a structured report: contract error variant, authorization failures, footprint/budget exhaustion, archived entries, call stack.scripts/generate-contract-errors.jsbuildssrc/indexer/contract-errors.generated.tsfrompackages/contracts/*/src/errors.rs(20 contracts, 290 codes). A test asserts every code has a message and that the registry matches the Rust sources (pnpm --filter backend check:contract-errors).#6has 18 meanings), so contract IDs map to contracts viaSOROBAN_CONTRACT_ID+SOROBAN_CONTRACT_KIND(defaultcall_registry),OUTCOME_MANAGER_CONTRACT_ADDRESS, andSOROBAN_CONTRACT_ERROR_MAP="CID:contract,...". Unmapped contracts get a list of the possible variants.submitTransactionERROR responses andindexFailedTransaction(txHash)) get structured logging via the NestJS Logger, are stored in a newfailed_transactionstable, and the submitting user receives oneTRANSACTION_FAILEDnotification.Note:
ContractError::MarketExpired/StakeBelowMinimumfrom the issue don't exist in the contracts. The nearest real ones areCallRegistryError::CallEndedandMarketError::RolloverInsufficientAmount.BE-003 —
event_logsrange partitioning1760000070000-PartitionEventStore:PARTITION BY RANGE (ledger)with 100,000-ledger partitions, a DEFAULT partition as a safety net, and a(contractId, topic0, ledger)composite B-Tree index. It adds atopic0column.event_logs_maintain_partitions()pre-creates partitions ahead of the newest ledger and moves any stray rows out of the default partition.EventLogPartitionServiceruns it on boot and every 10 min; the migration also schedules it inpg_cronwhen installed.down()is lossless.event_logs_max_ledger()keeps the indexer's latest-ledger lookup fast (a plainORDER BY ledger DESC LIMIT 1would scan every partition).EventStoreService.getRawEventsByLedgerRange()does range scans with keyset pagination. Reconciliation now filters by ledger range in SQL instead of loading a contract's whole history into memory.resolveStartLedgertreating the bigint ledger as a string ("100" + 1→"1001").Query plan evidence
Postgres 16, 5M rows across 20M ledgers (204 partitions), 20 contracts, 8 topics. Latency measured with
pgbench(warm connection, extended protocol).event_logs_max_ledger())The reconciliation fetch is limited by reading the rows themselves; an extra
(contractId, ledger, txOrder)index made no difference, so none was added. Buffer reads for the 1M-ledger count dropped from 8,902 to 290.Migration checks on real Postgres: fresh DB, a table created by TypeORM
synchronize, a 5M-row table (up → down → up, counts verified), out-of-range inserts parked in the default partition and moved by maintenance. TypeORMsynchronizeproduces 0 statements against the partitioned table.Testing
pnpm --filter backend test: 64 suites, 907 tests passing.indexer.service.tscoverage is 98% lines / 85% branches.pnpm --filter backend buildpasses.Notes for reviewers
CreateFollowsTable1760000000000(missingwalletAddresscolumn). This predates the PR; the new migrations were tested on their own.SOROBAN_CONTRACT_KIND,SOROBAN_CONTRACT_ERROR_MAP,EVENT_LOG_PARTITION_LOOKAHEAD(default 2).