Skip to content

RPCv1 XDR views: migrate getEvents - #978

Merged
cjonas9 merged 22 commits into
feature/full-historyfrom
migrate-getEvents-views
Sep 17, 2026
Merged

cjonas9 merged 22 commits into
feature/full-historyfrom
migrate-getEvents-views

Conversation

@cjonas9

@cjonas9 cjonas9 commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

What

Moves RPCv1 getEvents onto XDR views. The filter loop and the response renderer both paid for Unmarshals of every scanned xdr.DiagnosticEvent; now nothing in the query path decodes an event.

Handler-local matcher (methods/event_filter.go): a view port of the SDK's GetEventsRequest.Matches. Filters compile once per request into wire-form comparison values (decoded contract ids, marshaled topic segments, a trailing ** as an arity flag) and match against the raw bytes the view hands back. rpcv2's stores/event and its v1Filters shim are untouched.

RPCv1 query path:

  • store.ScanFunction -> store.ViewScanFunction: takes xdr.DiagnosticEventView, returns (bool, error).
  • sqlitedb.GetEvents reads rows as sql.RawBytes and wraps them as views; scanner errors abort the scan.
  • methods/get_events.go locates each event's fields once via Fields(), matches, and renders matches inside the scan callback. Topics are read only after type and contract id pass. The callback's own error is captured and returned unchanged, as getTransactions does, so a render failure keeps its system error code.

Shared renderer: methods.EventInfoFromView replaces both eventInfoForEvent and the rpcv2 eventInfoV2 body. ev.Fields() and v0.Fields() locate type, contract id, topics and data in one pass each and return trimmed views, so their bytes are used directly with no Raw() re-walks. The type name comes from a switch instead of the SDK's per-call map. rpcv2 wraps it and rejects non contract/system types on the returned name. Wire output is byte-identical.

Why

See epic #732.

🤖 Generated with Claude Code

@cjonas9 cjonas9 self-assigned this Sep 4, 2026
@cjonas9 cjonas9 linked an issue Sep 4, 2026 that may be closed by this pull request
@cjonas9
cjonas9 force-pushed the migrate-getEvents-views branch from fbb8fc8 to 8e36958 Compare September 8, 2026 17:50
@cjonas9
cjonas9 force-pushed the migrate-getEvents-views branch from 8e36958 to a9530b3 Compare September 8, 2026 19:51
@cjonas9
cjonas9 force-pushed the migrate-getEvents-views branch from a9530b3 to 1b33011 Compare September 8, 2026 19:57
@cjonas9
cjonas9 force-pushed the migrate-getEvents-views branch from 1b33011 to c1300ff Compare September 8, 2026 22:18
@cjonas9
cjonas9 force-pushed the migrate-getEvents-views branch 2 times, most recently from 334d228 to 12499f9 Compare September 11, 2026 07:27
@cjonas9
cjonas9 force-pushed the migrate-getEvents-views branch from 12499f9 to 2368950 Compare September 11, 2026 17:40
@cjonas9
cjonas9 marked this pull request as ready for review September 11, 2026 17:53
Copilot AI balanced review requested due to automatic review settings September 11, 2026 17:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates RPCv1 event filtering and response generation to zero-copy XDR views while sharing matching logic with RPCv2.

Changes:

  • Adds shared view-based event filter compilation and matching.
  • Updates SQLite scanning and RPC response construction to use XDR views.
  • Updates RPCv2 integration, tests, and SQLite dependency.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
go.mod Updates SQLite dependency.
go.sum Updates SQLite checksums.
internal/store/event.go Defines view-based scanner API.
internal/store/event_match.go Adds shared event matching logic.
rpcv2/stores/event/match.go Reuses shared matcher types and functions.
rpcv2/stores/event/match_test.go Updates matcher tests.
rpcv2/stores/event/extract_test.go Adapts extraction tests to views.
rpcv2/eventsapi/get_events_v2.go Builds responses from event views.
rpcv2/eventsapi/get_events_v1.go Delegates shared filtering and conversion.
rpcv1/sqlitedb/migration_test.go Updates scanner callback signature.
rpcv1/sqlitedb/event.go Scans stored events as views.
rpcv1/sqlitedb/event_test.go Updates view-based scanner tests.
methods/get_events.go Uses shared filters and view-based responses.

Note

Copilot is running an experiment and ran this review at Balanced.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 11, 2026 20:07
@cjonas9
cjonas9 force-pushed the migrate-getEvents-views branch from 2368950 to fa7cc42 Compare September 11, 2026 20:07
@cjonas9
cjonas9 force-pushed the migrate-getEvents-views branch from fa7cc42 to da49b8a Compare September 11, 2026 20:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Note

Copilot is running an experiment and ran this review at Balanced.

Comment thread cmd/stellar-rpc/internal/store/event_match.go Outdated
Copilot AI review requested due to automatic review settings September 11, 2026 20:11
@cjonas9
cjonas9 force-pushed the migrate-getEvents-views branch from e424d09 to d7630df Compare September 16, 2026 04:37
Copilot AI review requested due to automatic review settings September 17, 2026 21:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The hot response path lost its page-size preallocation and now repeatedly reallocates and copies results.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 12/12 changed files
  • Comments generated: 1
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.

Comment thread cmd/stellar-rpc/internal/methods/get_events.go
@cjonas9
cjonas9 merged commit 36ac502 into feature/full-history Sep 17, 2026
17 checks passed
@cjonas9
cjonas9 deleted the migrate-getEvents-views branch September 17, 2026 22:10
tamirms added a commit that referenced this pull request Sep 18, 2026
#978 changed the v1 event reader's callback to store.ViewScanFunction,
which hands the fixture a DiagnosticEventView valid only for the call. The
fixture takes the event's raw XDR from the view and copies it out.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

Adopt XDR Views: View-based event filtering + response

3 participants