Skip to content

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

Open
carbolymer wants to merge 1 commit into
mgalazyn/feature/fetchBlock-tx-bodiesfrom
mgalazyn/fix-grpc-bytes-fields
Open

cardano-rpc: Fix TxOutput.address and Datum.hash wire encoding#1258
carbolymer wants to merge 1 commit into
mgalazyn/feature/fetchBlock-tx-bodiesfrom
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 from 4f93e0b to a7ec745 Compare July 22, 2026 09:23
@carbolymer
carbolymer force-pushed the mgalazyn/fix-grpc-bytes-fields branch from a7ec745 to 2112d60 Compare July 22, 2026 09:29
@carbolymer
carbolymer force-pushed the mgalazyn/feature/fetchBlock-tx-bodies branch from 792f6ae to 1af9cd2 Compare July 22, 2026 09:29
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.

2 participants