Skip to content

Fix supplemental datum propagation in transaction build#1341

Open
Jimbo4350 wants to merge 1 commit intomasterfrom
jordan/supplemental-datum-fix
Open

Fix supplemental datum propagation in transaction build#1341
Jimbo4350 wants to merge 1 commit intomasterfrom
jordan/supplemental-datum-fix

Conversation

@Jimbo4350
Copy link
Contributor

Summary

  • Collects supplemental datums from transaction outputs and return collateral, then passes them through to the transaction body content via Exp.setTxSupplementalDatums
  • Updates toTxOutInEra and toTxOutInShelleyBasedEra to return supplemental datums alongside the TxOut
  • Applies the fix to all three transaction build commands: build, build-estimate, and build-raw
  • Pins cardano-api to a commit that includes the setTxSupplementalDatums API

Context

Previously, supplemental datums (datum hashes referenced in transaction outputs) were not being propagated into the transaction body. This meant that when a transaction output included a datum hash, the corresponding datum was not included in the transaction's supplemental data map, causing validation failures for consumers expecting to resolve those datum hashes.

Test plan

  • Golden test updated for build-raw-tx-body-out-6.json to reflect the new CBOR encoding with supplemental datums
  • Verify existing golden and unit tests pass
  • Test transaction build commands with outputs containing datum hashes

Copilot AI review requested due to automatic review settings February 25, 2026 13:10
Copy link

Copilot AI left a comment

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 fixes a bug where supplemental datums (datum hashes referenced in transaction outputs) were not being propagated into the transaction body during transaction construction. The fix collects datums from both transaction outputs and return collateral, then passes them to the transaction body via Exp.setTxSupplementalDatums.

Changes:

  • Modified toTxOutInEra and toTxOutInShelleyBasedEra to return supplemental datums alongside the TxOut
  • Applied the fix to all three transaction build commands: build, build-estimate, and build-raw
  • Pinned cardano-api to a specific commit that includes the setTxSupplementalDatums API

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
cardano-cli/test/cardano-cli-golden/files/golden/shelley/build-raw-tx-body-out-6.json Updated golden test CBOR encoding to reflect new supplemental datum inclusion
cardano-cli/src/Cardano/CLI/EraBased/Transaction/Run.hs Core implementation: collects supplemental datums from outputs/collateral and passes them through transaction body construction
cabal.project Pins cardano-api to specific commit with required API support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import Cardano.Api.Experimental.AnyScriptWitness qualified as Exp
import Cardano.Api.Experimental.Tx qualified as Exp
import Cardano.Api.Ledger qualified as L
import Cardano.Ledger.Hashes (DataHash)
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

The new import for DataHash is inserted between two qualified imports with different prefixes (Cardano.Api.Experimental.Tx as Exp and Cardano.Api.Network as Consensus), breaking the grouping pattern. Consider placing this import with other Cardano.Ledger imports or in a separate unqualified import group to maintain consistency with the existing import organization.

Copilot uses AI. Check for mistakes.
fromExceptTCli @ProtocolParamsError
(obtainCommonConstraints era $ readProtocolParameters protocolParamsFile)
out <- obtainCommonConstraints era $ toTxOutInShelleyBasedEra txOut
(out, _suppDatums :: Map.Map DataHash (L.Data (Exp.LedgerEra era))) <-
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

The variable name _suppDatums uses an underscore prefix typically reserved for intentionally unused variables in Haskell, but includes an explicit type annotation. If the datums are truly unused here, remove the type annotation. If they might be used in the future, use a name without the underscore prefix like suppDatums.

Suggested change
(out, _suppDatums :: Map.Map DataHash (L.Data (Exp.LedgerEra era))) <-
(out, _suppDatums) <-

Copilot uses AI. Check for mistakes.
@carbolymer
Copy link
Contributor

Your PR is not using description template

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