Skip to content

cardano-rpc: Fix TxOutput.address and Datum.hash wire encoding#1258

Merged
carbolymer merged 1 commit into
masterfrom
mgalazyn/fix-grpc-bytes-fields
Jul 25, 2026
Merged

cardano-rpc: Fix TxOutput.address and Datum.hash wire encoding#1258
carbolymer merged 1 commit into
masterfrom
mgalazyn/fix-grpc-bytes-fields

Conversation

@carbolymer

@carbolymer carbolymer commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Context

An audit of the proto bytes fields populated by the UTxO RPC server found two fields carrying the wrong encoding.
TxOutput.address was populated with human-readable address text (bech32 for Shelley, base58 for Byron) instead of raw ledger address bytes.
Datum.hash was populated with the datum's CBOR instead of its blake2b-256 hash when the datum was inline.
Both diverged from the other UTxO RPC implementations (Dolos via pallas-utxorpc, Blink Labs cardano-node-api) and, for the address, from our own predicate and reward-account encoding.
The server is unreleased, so the wire format can still change without breaking clients.

Fixes #1246

Stacked on #1222 - only the last two commits belong to this PR.

How to trust this PR

txOutToUtxoRpcTxOutput now uses serialiseToRawBytes for the address (raw header plus payload bytes, Byron included) and hashScriptDataBytes for the inline datum hash, and utxoRpcTxOutputToTxOut decodes the address with deserialiseFromRawBytes in lockstep.
Address serialisation is now uniform across cardano-rpc: transaction outputs, exact_address predicates and reward accounts all use raw on-chain bytes in both directions, so a client can echo TxOutput.address into a SearchUtxos predicate and get matches.
The new hprop_tx_output_wire_format property pins the wire format directly; the existing round-trip property cannot catch the inline datum bug because decoding never reads Datum.hash when original_cbor is present.
Run cabal test cardano-rpc:cardano-rpc-test to verify; all 78 tests pass.
The cardano-node E2E test Cardano.Testnet.Test.Rpc.FetchBlock asserts the same encoding and changes in lockstep (branch mgalazyn/fix-grpc-bytes-fields in cardano-node).

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 changed the base branch from master to mgalazyn/feature/fetchBlock-tx-bodies July 20, 2026 14:48
@carbolymer carbolymer self-assigned this Jul 20, 2026
@carbolymer carbolymer changed the title Mgalazyn/fix grpc bytes fields cardano-rpc: Fix TxOutput.address and Datum.hash wire encoding Jul 20, 2026
@carbolymer
carbolymer force-pushed the mgalazyn/fix-grpc-bytes-fields branch from a848339 to 7688714 Compare July 20, 2026 14:50
@carbolymer
carbolymer marked this pull request as ready for review July 20, 2026 14:58
@carbolymer
carbolymer marked this pull request as draft July 20, 2026 15:00
@carbolymer
carbolymer force-pushed the mgalazyn/fix-grpc-bytes-fields branch 2 times, most recently from 97908ba to b4ffb7d Compare July 20, 2026 15:39
@carbolymer
carbolymer marked this pull request as ready for review July 20, 2026 15:43

@Jimbo4350 Jimbo4350 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.

LGTM

@carbolymer
carbolymer force-pushed the mgalazyn/fix-grpc-bytes-fields branch from b4ffb7d to 4f93e0b Compare July 21, 2026 15:45
@carbolymer carbolymer mentioned this pull request Jul 21, 2026
4 tasks
@carbolymer
carbolymer force-pushed the mgalazyn/feature/fetchBlock-tx-bodies branch from ddec16c to 792f6ae Compare July 21, 2026 16:21
@carbolymer
carbolymer requested a review from a team as a code owner July 21, 2026 16:21
@carbolymer
carbolymer force-pushed the mgalazyn/fix-grpc-bytes-fields branch 2 times, most recently from a7ec745 to 2112d60 Compare July 22, 2026 09:29
@carbolymer
carbolymer force-pushed the mgalazyn/feature/fetchBlock-tx-bodies branch 3 times, most recently from 3e02b01 to d8f1beb Compare July 24, 2026 16:19
@carbolymer
carbolymer force-pushed the mgalazyn/fix-grpc-bytes-fields branch from 2112d60 to ac30652 Compare July 24, 2026 16:26
Base automatically changed from mgalazyn/feature/fetchBlock-tx-bodies to master July 24, 2026 17:31
@carbolymer
carbolymer added this pull request to the merge queue Jul 25, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 25, 2026
@carbolymer
carbolymer added this pull request to the merge queue Jul 25, 2026
Merged via the queue into master with commit eb8491a Jul 25, 2026
28 checks passed
@carbolymer
carbolymer deleted the mgalazyn/fix-grpc-bytes-fields branch July 25, 2026 09:45
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.

gRPC: bytes fields encoded as text or wrong payload (TxOutput.address, Datum.hash)

2 participants