Skip to content

feat: add extensible QueryLedgerState RPC with stake pool distribution#200

Open
scarmuega wants to merge 4 commits intomainfrom
feat/query-ledger-state
Open

feat: add extensible QueryLedgerState RPC with stake pool distribution#200
scarmuega wants to merge 4 commits intomainfrom
feat/query-ledger-state

Conversation

@scarmuega
Copy link
Copy Markdown
Member

Summary

  • Adds a chain-agnostic QueryLedgerState RPC to the v1beta QueryService, using AnyChainLedgerQuery / AnyChainLedgerQueryResult envelopes so future queries can be added without changing the service surface.
  • On the Cardano side, introduces LedgerStateQuery / LedgerStateQueryResult oneof envelopes that mirror the Ouroboros node-to-client LocalStateQuery mini-protocol.
  • First concrete query: GetStakePoolDistribution (with optional pool_keyhashes filter) returning PoolStakeShare { pool_keyhash, stake_fraction, vrf_keyhash } — matches Ouroboros GetPoolDistr / IndividualPoolStake.
  • Changes are scoped to v1beta only; v1alpha is intentionally left untouched.

Why this shape

  • QueryLedgerState signature stays stable as new ledger-state queries are added — they become new variants on the chain-side oneofs, which is non-breaking under proto3.
  • Envelope pattern matches the existing AnyChainParams, AnyChainBlock, AnyUtxoData convention.
  • Response carries ledger_tip (consistent with ReadParamsResponse / ReadUtxosResponse) since a point-in-time query is only meaningful with its snapshot's tip.

Test plan

  • buf build proto passes (verified locally).
  • CI codegen workflows succeed across Rust / Go / Node / .NET / Python / Haskell / docs.
  • Spot-check generated Rust under gen/rust/ once CI publishes: QueryLedgerState is exposed on the QueryService client/server traits and the oneof envelopes round-trip.
  • Manual review that no v1alpha files were modified.

Follow-ups (not in this PR)

  • Wire additional Ouroboros queries (GetStakePoolParams, GetStakeSnapshots, GetEpochNo, GetCurrentEra, GetRewardInfoPools) as new LedgerStateQuery / LedgerStateQueryResult variants.
  • Decide whether to mirror this addition into v1alpha.

🤖 Generated with Claude Code

scarmuega and others added 2 commits April 27, 2026 11:28
Introduces a chain-agnostic QueryLedgerState method on the v1beta
QueryService backed by AnyChainLedgerQuery / AnyChainLedgerQueryResult
envelopes. Cardano-side queries live in cardano.proto under
LedgerStateQuery / LedgerStateQueryResult oneof envelopes, mirroring the
Ouroboros node-to-client LocalStateQuery mini-protocol. Future queries
can be added as new oneof variants without changing the service surface.

The first concrete query is GetStakePoolDistribution (with optional
pool_keyhashes filter), returning PoolStakeShare entries that match
Ouroboros GetPoolDistr / IndividualPoolStake.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Aligns the new RPC with the existing Read* naming convention on
QueryService (ReadParams, ReadUtxos, ReadData, ReadTx, ReadGenesis,
ReadEraSummary).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@carbolymer carbolymer left a comment

Choose a reason for hiding this comment

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

LGTM so far

scarmuega and others added 2 commits May 1, 2026 09:08
- AnyChainLedgerQuery        -> AnyChainStateQuery
- AnyChainLedgerQueryResult  -> AnyChainStateResult
- LedgerStateQuery           -> StateQuery
- LedgerStateQueryResult     -> StateResult

Aligns with the ReadState RPC name and trims redundancy in the type
names while keeping the envelope structure intact.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Continues the type-name shortening; "Data" reads more naturally than
"Result" since the response carries the state payload itself rather
than a yes/no outcome.

- AnyChainStateResult -> AnyChainStateData
- StateResult         -> StateData

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@scarmuega scarmuega marked this pull request as ready for review May 1, 2026 12:31
@Mercurial
Copy link
Copy Markdown
Contributor

LGTM too

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