Fail on collateral without Plutus script instead of dropping collateral - #1274
Open
palas wants to merge 2 commits into
Open
Fail on collateral without Plutus script instead of dropping collateral#1274palas wants to merge 2 commits into
palas wants to merge 2 commits into
Conversation
palas
requested review from
CarlosLopezDeLara,
Jimbo4350,
carbolymer,
disassembler and
erikd
as code owners
July 31, 2026 01:26
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes transaction balancing to fail (rather than silently normalizing) when collateral inputs are provided for a transaction that has no Plutus script witnesses, aligning behavior with ledger semantics and avoiding surprising collateral stripping.
Changes:
- Introduces a new
CollateralWithoutPlutusScriptserror and enforces it in bothmakeTransactionBodyAutoBalanceandestimateBalancedTxBody(traditional + experimental). - Adds/updates golden coverage for the new error message and adds targeted regression tests for the new failure behavior and related collateral scenarios.
- Refactors collateral-related tests/utilities into dedicated test modules.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
cardano-api/src/Cardano/Api/Tx/Internal/Fee.hs |
Adds checkCollateralOnlyWithPlutusScripts and the new CollateralWithoutPlutusScripts constructor + error message; balancing now fails instead of dropping collateral. |
cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Fee.hs |
Applies the same collateral-without-Plutus check to experimental balancing/estimation paths. |
cardano-api/test/cardano-api-golden/Test/Golden/ErrorsSpec.hs |
Registers the new TxBodyErrorCollateralWithoutPlutusScripts golden test case. |
cardano-api/test/cardano-api-golden/files/errors/Cardano.Api.Tx.Internal.Fee.TxBodyErrorAutoBalance/TxBodyErrorCollateralWithoutPlutusScripts.txt |
Adds the golden error-message output for the new collateral error. |
cardano-api/test/cardano-api-test/Test/Cardano/Api/Transaction/Collateral.hs |
Adds traditional-API regression tests asserting failure on collateral-without-Plutus and related collateral behaviors. |
cardano-api/test/cardano-api-test/Test/Cardano/Api/Transaction/Utils.hs |
Extracts shared transaction test utilities from Autobalance into a reusable module. |
cardano-api/test/cardano-api-test/Test/Cardano/Api/Transaction/Autobalance.hs |
Removes collateral-focused tests/utilities moved into dedicated modules. |
cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental/Collateral.hs |
Adds experimental-API regression tests mirroring the new failure semantics and collateral behaviors. |
cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental/Fee.hs |
Removes collateral-focused tests now covered by Experimental.Collateral. |
cardano-api/test/cardano-api-test/cardano-api-test.hs |
Wires new collateral test modules into the test runner. |
cardano-api/cardano-api.cabal |
Registers new test modules (Transaction.Collateral, Transaction.Utils, Experimental.Collateral) in the test-suite stanza. |
.changes/20260730_cardano_api_collateral_without_plutus_fails.yml |
Adds a breaking-change changelog fragment describing the behavior/API change. |
The ledger requires collateral only for transactions that run Plutus scripts. Since #1265, makeTransactionBodyAutoBalance and estimateBalancedTxBody (traditional and experimental API) silently remove the collateral inputs from transactions without Plutus scripts. Silently dropping parts of the provided transaction is surprising, and collateral inputs on a transaction without Plutus scripts are most likely a mistake, so fail with the new CollateralWithoutPlutusScripts error instead of removing them. The error message points at the fix: remove the collateral inputs; a transaction that should become invalid when some UTxO is spent can use a reference input for that purpose. Requested by @Jimbo4350 in: #1265 (comment)
Move the collateral tests out of Test.Cardano.Api.Transaction.Autobalance and Test.Cardano.Api.Experimental.Fee into new modules, split by API flavor: Test.Cardano.Api.Transaction.Collateral for the traditional API and Test.Cardano.Api.Experimental.Collateral for the experimental API. The utilities shared by the two traditional-API test modules move to Test.Cardano.Api.Transaction.Utils. The tests themselves are unchanged. Suggested by @carbolymer in: #1265 (review)
palas
force-pushed
the
1261-post-merge-reviews
branch
from
July 31, 2026 02:15
83c813c to
934e3fc
Compare
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.
Context
This is a follow-up PR to address the following two reviews:
How to trust this PR
Look at the two commits independently:
Checklist
.changes/