Skip to content

XDR view extractors: events, tx-hashes, tx-details, tx-pages from LedgerCloseMetaView #764

Description

@tamirms

TL;DR

Implement four extractor functions that derive the data shapes RPC v2 needs from an xdr.LedgerCloseMetaView, using zero-copy aliasing into the source LCM. The perf benefits of zero-copy XDR views were validated on rpc-hack, so v2 will adopt them. Most of this code exists on rpc-hack already; the task is largely promoting it from bench-quality into a production package.

What to build

Four extractors over xdr.LedgerCloseMetaView:

  • events — yields events-index payloads.
  • tx-hashes — yields the txHash for each transaction in the LCM.
  • tx-details by hash — given an LCM + target txhash, returns the transaction's envelope / result / meta.
  • tx-pages — yields transactions in order with cursor support for the paginated getTransactions API.

All outputs zero-copy, aliasing into the source LCM buffer.

The stellar-rpc-side code lives in cmd/stellar-rpc/internal/fullhistory/views/ (or similar).

Determine the SDK vs stellar-rpc split

Part of this task: decide which pieces belong in go-stellar-sdk (alongside the view types) versus stellar-rpc. Rule of thumb — low-level XDR navigation primitives go to the SDK; RPC-specific data shapes (e.g., events.Payload, pagination cursors) stay here.

Source material on rpc-hack

Most of this code exists on rpc-hack already and can be cleaned up rather than written from scratch:

  • eventscmd/stellar-rpc/internal/events/ingest_view.go (production-ready; originally in PR events,eventstore: concurrent index; migrate off membitmaps #756, will be scoped out of that PR and land via this task instead).
  • tx-hashes / tx-details by hashcmd/stellar-rpc/scripts/bench-fullhistory/tx_hash_helpers.go, extract_views.go, bench_cold_txhash.go (bench-quality; needs promotion).
  • tx-pagesbench_cold_txpage.go / bench_hot_txpage.go for reference; reusability TBD.

Tests + benchmarks

  • Per-extractor unit tests.
  • Per-extractor go test -bench benchmarks so perf regressions are catchable.
  • Differential correctness against the full-decode (UnmarshalBinary → derive) path on a checked-in fixture set covering recent ledgers, protocol-transition ledgers, and known edge cases (empty / sponsorship / large tx / V0/V1/V2 variants).
  • Follow-up (separate issue): a harness that walks every ledger in history and asserts view-extraction matches full-decode. Not blocking the initial PR.

Acceptance

  • Four extractors implemented with zero-copy outputs.
  • SDK vs stellar-rpc split decided.
  • Tests + benchmarks present for each.
  • Fixture-set differential tests passing.
  • Follow-up issue filed for the full-history sweep harness.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions