Skip to content

Add optimized RPC ledger backends#561

Open
aditya1702 wants to merge 5 commits intoparallel-copy-insertsfrom
ledger-backend-optimize
Open

Add optimized RPC ledger backends#561
aditya1702 wants to merge 5 commits intoparallel-copy-insertsfrom
ledger-backend-optimize

Conversation

@aditya1702
Copy link
Copy Markdown
Contributor

No description provided.

Introduce an optimized RPC-based LedgerBackend for internal/ingest that targets wallet-backend's single-consumer access pattern. Adds optimizedRPCBackend with reduced synchronization, accumulated buffering, and tip tracking (avoids per-fetch GetHealth calls), plus comprehensive unit tests covering buffer hits/misses, retries, eviction, ranges, context cancellation and closing. Wire the new backend into newRPCLedgerBackend to use rpc.NewClient and newOptimizedRPCBackend, and update logging accordingly.
Detect RPC JSON-RPC "out of range" errors when fetching ledgers and treat them as beyond-latest conditions instead of returning a generic error. Adds isRPCOutOfRangeError (string-match on the server message) and uses it in getBufferedLedger to return a beyondLatestError, avoiding an extra GetHealth RPC round-trip on successful fetches. Also adds a unit test that simulates the RPC out-of-range response and verifies the backend retries and does not call GetHealth. Minor imports (strings, fmt) updated for these changes.
@aditya1702 aditya1702 force-pushed the parallel-copy-inserts branch from 1ebaffc to 340b684 Compare April 2, 2026 15:01
@aditya1702 aditya1702 force-pushed the ledger-backend-optimize branch from f1fe9cd to dc0e663 Compare April 2, 2026 15:02
Replace use of SDK BufferedStorageBackend with a new optimizedStorageBackend tailored for single-consumer ledger ingestion. The new backend (newOptimizedStorageBackend) moves decompression/XDR decode into worker goroutines, streams S3 reads through the decoder to avoid intermediate allocations, and removes unnecessary mutexes on the backend struct. Integration updates in ledger_backend.go call the new constructor and improve the startup log. A comprehensive test suite (storage_backend_test.go) was added to cover defaults, validation, sequential reads, cache hits, cross-file boundaries, re-preparation, close behavior, and worker retry semantics.
@aditya1702 aditya1702 changed the title Add optimized RPC ledger backend Add optimized RPC ledger backends Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant