Migrate transaction read path to use views - #962
Conversation
54e5c5f to
ad1862d
Compare
ad1862d to
69794fc
Compare
|
I was looking into rpcv2 perf for getTransactions and ended up building essentially this same migration before spotting your PR — so I'm dropping my branch in favor of yours. A few things I discovered that you should fold in:
FWIW, measured on my branch (same migration, borrow accessor): getTransactions limit=50 over the wire went p50 100ms → 5.8ms (~17×), responses byte-identical. The handler is shared, so v1 should see a similar improvement. |
49fa209 to
f21a36c
Compare
There was a problem hiding this comment.
Pull request overview
Migrates transaction reads to zero-copy XDR views, reducing full-ledger decoding and re-marshalling.
Changes:
- Adds view-based ledger reads for SQLite and RPC v2.
- Extracts individual transactions or paginated ranges from ledger views.
- Updates mocks and fixtures for view-backed transaction metadata.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
internal/store/transaction.go |
Reshapes transaction views into store records. |
internal/store/ledger.go |
Adds GetLedgerView to the transaction reader. |
internal/rpcv2/adapters/ledger_reader.go |
Implements shared view/decoded ledger walking. |
internal/rpcv1/sqlitedb/transaction.go |
Reads transactions directly from ledger views. |
internal/rpcv1/sqlitedb/mocks.go |
Updates transaction mock extraction. |
internal/rpcv1/sqlitedb/ledger.go |
Implements SQLite ledger-view reads. |
internal/methods/mocks.go |
Extends ledger-reader mocks. |
internal/methods/get_transactions.go |
Migrates pagination to transaction view ranges. |
internal/methods/get_transactions_test.go |
Updates fixtures and view-backed test reader. |
internal/methods/get_transaction_test.go |
Corrects Soroban transaction metadata fixtures. |
internal/methods/get_ledgers_test.go |
Updates encoded metadata expectations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| ledger, found, err := readTx.GetLedger(ctx, ledgerSeq) | ||
| if err != nil { | ||
| return ledger, &jrpc2.Error{ | ||
| // readLedgerPage borrows ledgerSeq's raw LedgerCloseMeta and runs the page |
There was a problem hiding this comment.
attribution: @tamirms loan-shaped pager design from tamirms/gettransactions-view-walk
d67207a to
026974d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
cmd/stellar-rpc/internal/methods/get_events.go:278
- This removes
inSuccessfulContractCallfrom the public v1getEventswire response, but the Unreleased changelog does not announce the breaking removal; it only retains the old v23 deprecation notice. Since the dependency change deliberately performs the consumer-side removal, please add an Unreleased breaking-change entry so API consumers are warned.
EventType: eventType,
Ledger: int32(ledger),
LedgerClosedAt: ledgerClosedAt,
ID: cursor.String(),
TransactionHash: txHash,
580301c to
14814e4
Compare
What
This PR migrates the transaction read paths to ledger bytes/views, following #945.
getTransaction(by hash) andgetTransactionsno longer decode an entire multi-MB LCM to read a handful of per-transaction fields back out of it. Here is what's modified:getTransactionByHash: the row's meta blob is scanned into a view and exactly one transaction is extracted viaingest.LedgerTransactionViewRangeNewLedgerTransactionReaderFromLedgerCloseMeta+Seekover a fully decoded LCM.getTransactions: each ledger in the page walk is borrowed as raw bytes (readLedgerPage) and walked through views (processTransactionsInLedger)transactionInfo, shared with the differential suite below.store.ParseTransactionViewtakes aningest.LedgerTransactionViewand just reshapes itstore.LedgerReaderTxgains loan-shapedWithLedgerRaw: fn borrows the marshaled LCM, valid only inside the call.GetLedgerand lends the step's scratch bytes w/o copy.Two related correctness fixes were made:
Note that an exhaustive test suite relating to this work exists as a fast-follow PR, #976. Both should be merged around the same time.
Minor behavior changes to note
TestTransactionsWithLegacyV0MetagetTransactionsnow returnsjrpc2.InternalErrorinstead ofjrpc2.InvalidParamswhen it is unable to read a transaction out of a ledgerWhy
See #732. This is a component of adopting ledger views in RPC for query-path performance purposes.
Known Limitations
N/A
Attribution
Substantial parts of this PR are @tamirms's work, cherry-picked from
tamirms/gettransactions-view-walk:WithLedgerRawaccessor onLedgerReaderTxand its contractgetTransactionsand the sharedtransactionInforendererWithLedgerRawtestsSorobanMetaevent-arity wire bug, + its upstream fix (stellar/go-stellar-sdk#5997)