feat: add extensible QueryLedgerState RPC with stake pool distribution#200
Open
feat: add extensible QueryLedgerState RPC with stake pool distribution#200
Conversation
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>
- 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>
Mercurial
approved these changes
May 1, 2026
Contributor
|
LGTM too |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
QueryLedgerStateRPC to the v1betaQueryService, usingAnyChainLedgerQuery/AnyChainLedgerQueryResultenvelopes so future queries can be added without changing the service surface.LedgerStateQuery/LedgerStateQueryResultoneofenvelopes that mirror the Ouroboros node-to-clientLocalStateQuerymini-protocol.GetStakePoolDistribution(with optionalpool_keyhashesfilter) returningPoolStakeShare { pool_keyhash, stake_fraction, vrf_keyhash }— matches OuroborosGetPoolDistr/IndividualPoolStake.Why this shape
QueryLedgerStatesignature stays stable as new ledger-state queries are added — they become new variants on the chain-sideoneofs, which is non-breaking under proto3.AnyChainParams,AnyChainBlock,AnyUtxoDataconvention.ledger_tip(consistent withReadParamsResponse/ReadUtxosResponse) since a point-in-time query is only meaningful with its snapshot's tip.Test plan
buf build protopasses (verified locally).gen/rust/once CI publishes:QueryLedgerStateis exposed on theQueryServiceclient/server traits and theoneofenvelopes round-trip.Follow-ups (not in this PR)
GetStakePoolParams,GetStakeSnapshots,GetEpochNo,GetCurrentEra,GetRewardInfoPools) as newLedgerStateQuery/LedgerStateQueryResultvariants.🤖 Generated with Claude Code