Skip to content

Use views in getProtocolVersion - #1035

Merged
cjonas9 merged 1 commit into
feature/full-historyfrom
readProtocolVersion-views
Sep 25, 2026
Merged

cjonas9 merged 1 commit into
feature/full-historyfrom
readProtocolVersion-views

Conversation

@cjonas9

@cjonas9 cjonas9 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What

Swaps helper function getProtocolVersion to use views instead of ledger decoding. In particular, getNetwork and getVersionInfo stop decoding the whole ~2 MB ledger for one 4-byte field that can instead be read off the header view of a LedgerCloseMetaView.

See comments of #1003 for the speedup from this round of optimizations, and #1018 for what the original speeds are pre-optimization + pre-views-adoption.

Why

Performance reasons. In line with recent XDR views changes.

Benchmarks done locally on M4 Mac Pro:

time B/op allocs/op
before 4.2 ms / 4.4 ms 10.5 MB / 9.2 MB 103,000
header view read 175 µs / 264 µs 1.5 MB / 8.7 KB ~200

Known limitations

N/A

@cjonas9
cjonas9 added this pull request to stack #1038 September 24, 2026 15:24
@cjonas9 cjonas9 changed the title use views in getProtocolVersion Use views in getProtocolVersion Sep 25, 2026
@cjonas9
cjonas9 force-pushed the readProtocolVersion-views branch from d6b3da1 to 49a3d4f Compare September 25, 2026 17:59
@cjonas9
cjonas9 marked this pull request as ready for review September 25, 2026 18:02
Copilot AI balanced review requested due to automatic review settings September 25, 2026 18:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused optimization preserves existing behavior while avoiding an unnecessary full-ledger decode.

Review effort: Balanced
Findings: None

What changed in this PR

Optimizes protocol-version lookup by reading the latest ledger header through an XDR view instead of decoding the complete ledger metadata.

Changes:

  • Replaces full ledger decoding with LedgerCloseMetaView.
  • Preserves missing-ledger handling and adds contextual parsing errors.
File Description
cmd/​stellar-rpc/​internal/​methods/​util.go Reads the protocol version directly from raw ledger header bytes.

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

Base automatically changed from scanledgers-iterator to feature/full-history September 25, 2026 19:42
@cjonas9
cjonas9 force-pushed the readProtocolVersion-views branch from 49a3d4f to b320f39 Compare September 25, 2026 19:42
@cjonas9
cjonas9 merged commit c61988d into feature/full-history Sep 25, 2026
16 checks passed
@cjonas9
cjonas9 deleted the readProtocolVersion-views branch September 25, 2026 20:03
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.

3 participants