Skip to content

gRPC: Update to the latest UTxO RPC v1beta spec - #1303

Open
carbolymer wants to merge 8 commits into
masterfrom
mgalazyn/utxorpc-spec-update
Open

gRPC: Update to the latest UTxO RPC v1beta spec#1303
carbolymer wants to merge 8 commits into
masterfrom
mgalazyn/utxorpc-spec-update

Conversation

@carbolymer

@carbolymer carbolymer commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Context

This PR syncs the vendored UTxO RPC v1beta proto definitions with the latest upstream utxorpc/spec (v0.19.2 plus the post-release EvalReport optionality fix), regenerates the proto-lens code, and implements the newly available surface:

  • Governance votes (upstream #193): the Vote/VotingProcedure/VoterVotes messages are vendored and the new Tx.votes field is populated for Conway-onwards transactions.
    DRep and constitutional committee voters map to stake credentials, SPO voters to their pool key hash, each with their votes, governance action ids and optional anchors.
  • TxOutput.original_cbor (upstream #201): populated with the era-encoded CBOR of the output.
    Note this is a canonical re-encoding, not guaranteed to be byte-identical to the on-chain encoding: the ledger does not memoise TxOut and its decoders accept non-canonical input.
    No protocol hash uses a standalone TxOut as preimage, and the memoised components inside it (inline datums, plutus scripts) keep their original bytes, so datum and script hashes remain verifiable.
    The caveat is documented at the computation site.
  • Ledger-state query machinery (upstream #200): the ReadState/StateQuery/StakePoolDistribution messages are vendored, schema-only for now.
  • All v1beta service methods are now exposed.
    The unimplemented ones (ReadData, ReadTx, ReadEraSummary, ReadState, ReadMempool, WaitForTx, WatchMempool, DumpHistory) are declared with grapesy's UnsupportedMethod, which makes the server respond with the UNIMPLEMENTED gRPC status; the previous hand-rolled dumpHistory stub is converted to the same mechanism.
    The README support matrix documents this behaviour and gains the ReadState row.

Breaking: FetchBlock is reset to the upstream v1beta shape with repeated request refs and response blocks, and the handler now fetches every referenced block.
The previous single-item variant has moved to the upcoming utxorpc v1 (utxorpc/spec#208 was retargeted there), so v1beta stays with the repeated form.
Clients built against the single-item shape (e.g. cardano-node's RPC integration tests) need adapting when they pick up this version.

How to trust this PR

  • The proto files are upstream-verbatim: diffing proto/utxorpc/v1beta against upstream main shows no differences.
  • The grapesy method tables must list handlers in the alphabetically sorted ServiceMethods order, not proto declaration order; each table in Cardano/Rpc/Server.hs documents its expected order in the haddock.
  • cabal test cardano-rpc-test: all 98 tests pass, including new coverage: injected DRep/SPO votes with exact content assertions at Conway, vote-count projections, pre-Conway votes == [] totality arms, an original_cbor decode-back round-trip, and Byron empty-field assertions.
  • To observe the stub behaviour against a running node: grpcurl -plaintext localhost:<rpc-port> utxorpc.v1beta.query.QueryService/ReadData responds with the Unimplemented status.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff
  • Changelog fragment added in .changes/

@carbolymer carbolymer self-assigned this Aug 19, 2026
@carbolymer carbolymer moved this to In Progress in DevTools roadmap Aug 19, 2026
@carbolymer carbolymer changed the title Mgalazyn/utxorpc spec update gRPC: Update to the latest UTxO RPC v1beta spec Aug 19, 2026
@carbolymer
carbolymer force-pushed the mgalazyn/utxorpc-spec-update branch from 8d38d97 to b6cf60a Compare August 20, 2026 14:43
@carbolymer carbolymer linked an issue Aug 20, 2026 that may be closed by this pull request
@carbolymer
carbolymer force-pushed the mgalazyn/utxorpc-spec-update branch from b6cf60a to a7c0ece Compare August 27, 2026 13:32
Sync the vendored proto definitions with utxorpc/spec main (v0.19.2 plus
unreleased EvalReport tweaks): governance vote messages and Tx.votes,
TxOutput.original_cbor, the ReadState ledger-state query machinery, and
all upstream service methods restored in the service blocks.
Regenerate the proto-lens code with buf.
The new AnyChainStateQuery/AnyChainStateData oneofs in query.proto
generate maybe'query/maybe'result lenses that collide with the ones from
cardano.proto's StateQuery/StateData envelopes, making the wholesale
re-export of both Fields modules ambiguous. Hide the Cardano_Fields
copies, following the module's existing convention.
Wire every method of QueryService, SubmitService and SyncService into
the grapesy method tables. Methods without an implementation (ReadData,
ReadEraSummary, ReadState, ReadTx, ReadMempool, WaitForTx, WatchMempool,
DumpHistory) are declared with UnsupportedMethod, which makes the server
respond with the UNIMPLEMENTED gRPC status; the previous hand-rolled
dumpHistory stub is converted to the same mechanism. Document the
behaviour and the new ReadState method in the README support matrix.
@carbolymer
carbolymer force-pushed the mgalazyn/utxorpc-spec-update branch from 5213a15 to d0d5314 Compare August 27, 2026 14:46
@carbolymer
carbolymer marked this pull request as ready for review August 27, 2026 14:46
@carbolymer
carbolymer requested a review from Jimbo4350 as a code owner August 27, 2026 14:46
Copilot AI lite review requested due to automatic review settings August 27, 2026 14:46
Convert the voting procedures of Conway-onwards transactions to the
UTxO RPC VoterVotes messages: DRep and constitutional committee voters
map to stake credentials, stake pool voters to their pool key hash, each
with their votes, gov action ids and optional anchors. Read through the
any-era getter, so earlier eras yield the empty list.
Fill the field with the era-encoded CBOR of the output. This is a
canonical re-encoding, not guaranteed to be the original on-chain bytes:
the ledger does not memoise TxOut and its decoders accept non-canonical
encodings, so decode-then-encode may differ for historical outputs. No
protocol hash uses a standalone TxOut as preimage, and the memoised
components inside it (inline datums, plutus scripts) keep their original
bytes, so datum and script hashes remain verifiable.
The single-item FetchBlock variant moved to the upcoming utxorpc v1
(utxorpc/spec#208 was retargeted there), so v1beta keeps the repeated
request refs and response blocks. Regenerate the proto-lens Sync
modules and make the handler fetch every referenced block, failing the
whole call with NOT_FOUND naming the first missing ref's slot and
header hash, matching Dolos's all-or-nothing behaviour. Mark the
changelog fragment as breaking accordingly.
ReadData and ReadTx need a whole-chain index (datum by hash,
transaction by hash) that cardano-node does not maintain, so they
cannot be implemented without building an external chain indexer into
the node. Distinguish them from the methods that are merely not yet
implemented.
@carbolymer
carbolymer force-pushed the mgalazyn/utxorpc-spec-update branch from d0d5314 to 670894e Compare August 27, 2026 14:48

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.

Pull request overview

This PR updates cardano-rpc to the latest upstream UTxO RPC v1beta spec by syncing the vendored .proto definitions, regenerating the proto-lens Haskell bindings, and wiring new/changed fields and service surfaces into the server and tests (notably governance votes, TxOutput.original_cbor, and the repeated-shape FetchBlock).

Changes:

  • Sync vendored UTxO RPC v1beta protos to upstream and regenerate proto-lens output (new query/state messages, updated service method sets, repeated FetchBlock request/response shape).
  • Implement newly available surfaces: populate Tx.votes (Conway+) and TxOutput.original_cbor (canonical re-encoding), and expose all v1beta service methods with grapesy UnsupportedMethod for unimplemented RPCs.
  • Extend tests and docs to cover votes/original CBOR behavior and document UNIMPLEMENTED exposure in the README; add a Herald changelog fragment marking the breaking FetchBlock shape reset.

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated no comments.

Show a summary per file
File Description
cardano-rpc/test/cardano-rpc-test/Test/Cardano/Rpc/TxOutput.hs Adds a property asserting original_cbor decodes back to the ledger TxOut.
cardano-rpc/test/cardano-rpc-test/Test/Cardano/Rpc/FetchBlockTx.hs Extends tx projection tests to cover Conway voting procedures and vote counts/contents.
cardano-rpc/test/cardano-rpc-test/Test/Cardano/Rpc/ByronTx.hs Asserts Byron-era defaults for new fields (original_cbor empty, votes empty).
cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/TxOutput.hs Populates TxOutput.originalCbor via canonical ledger serialization (with caveat).
cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Tx.hs Populates Tx.votes from Conway voting procedures (era-gated).
cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Governance.hs Introduces mapping from ledger voters/votes to v1beta VoterVotes / VotingProcedure.
cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Sync.hs Updates FetchBlock handler to process repeated block refs and return repeated blocks.
cardano-rpc/src/Cardano/Rpc/Server.hs Exposes all v1beta methods and uses UnsupportedMethod for unimplemented endpoints (ordered per ServiceMethods).
cardano-rpc/src/Cardano/Rpc/Proto/Api/UtxoRpc/Query.hs Adjusts field-lens imports/hiding for newly generated maybe'query / maybe'result.
cardano-rpc/README.md Documents UNIMPLEMENTED exposure semantics and updates QueryService support matrix (incl. ReadState).
cardano-rpc/proto/utxorpc/v1beta/sync/sync.proto Resets FetchBlock to upstream repeated request/response shape.
cardano-rpc/proto/utxorpc/v1beta/submit/submit.proto Updates SubmitService to include the full upstream v1beta method set/order.
cardano-rpc/proto/utxorpc/v1beta/query/query.proto Vendors new ledger-state query envelope/messages and updated QueryService method set.
cardano-rpc/proto/utxorpc/v1beta/cardano/cardano.proto Vendors new TxOutput.original_cbor, governance vote messages, and state query messages; tweaks EvalReport index docs.
cardano-rpc/gen/Proto/Utxorpc/V1beta/Sync/Sync.hs Regenerated proto-lens code for Sync service/messages (notably repeated ref/block).
cardano-rpc/gen/Proto/Utxorpc/V1beta/Sync/Sync_Fields.hs Regenerated field lenses reflecting repeated ref and new vector lens names.
cardano-rpc/gen/Proto/Utxorpc/V1beta/Submit/Submit.hs Regenerated Submit service methods/order and streaming signatures.
cardano-rpc/gen/Proto/Utxorpc/V1beta/Query/Query.hs Regenerated Query service/messages including state query/data envelopes and ReadState request/response.
cardano-rpc/gen/Proto/Utxorpc/V1beta/Query/Query_Fields.hs Regenerated field lenses for query/state-related additions.
cardano-rpc/gen/Proto/Utxorpc/V1beta/Cardano/Cardano_Fields.hs Regenerated field lenses for governance votes and state query/distribution additions.
.changes/20260819_160000_cardano-rpc_carbolymer_utxorpc_spec_update.yml Herald changelog fragment marking the update as feature + breaking and describing the API reset.

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

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

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Update proto definitions to 0.18.1

3 participants