Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Cardano-cli computes wrong collateral return output for multiple occurrences of collateral inputs #4744

Closed
nielstron opened this issue Jan 1, 2023 · 4 comments · Fixed by #4749
Labels
comp: cardano-cli type: bug Something is not working user type: external Created by an external user

Comments

@nielstron
Copy link
Contributor

nielstron commented Jan 1, 2023

Internal/External
External otherwise.

Area
Plutus Related to Plutus Scripts (Alonzo).
Other Any other topic (Delegation, Ranking, ...).

Summary
When adding collateral inputs multiple times, the cardano-cli builds an erroneous transaction with too much collateral output (the sum of the collateral inputs).
This is especially problematic as for example the default behaviour of the cardano clusterlib for multiple script invocations with the same collateral is mentioning it several times in the built transaction.

Steps to reproduce
Steps to reproduce the behavior:

Building the following transaction

cardano-cli query protocol-parameters --mainnet --out-file pparams.json
cardano-cli transaction build \
--tx-in 298e94029f7d360e3758c455594b8192c2399a6cb1177800c0650f0ad211ec41\#0 \
--tx-in-script-file cancel_contract.plutus \
--tx-in-datum-file datum.txt \
--tx-in-redeemer-file redeemer.txt \
--tx-in-collateral dd9cf832fc8a8bf15f56484584bf2b247a6a3374cc9686f38af058953e66ab89\#0 \
--tx-in 298e94029f7d360e3758c455594b8192c2399a6cb1177800c0650f0ad211ec41\#1 \
--tx-in-script-file cancel_contract.plutus \
--tx-in-datum-file datum.txt \
--tx-in-redeemer-file redeemer.txt \
--tx-in-collateral dd9cf832fc8a8bf15f56484584bf2b247a6a3374cc9686f38af058953e66ab89\#0 \
--required-signer-hash ee7f0b86d6bebb19dd0a07ecd6b16d7ac67913a18a255e808284970b \
--change-address addr1vx5tzxy5ue4l4xqpdgz9gcyv67rzlnlcd96e3cpazlut0lcdcy8wv \
--out-file tx.body \
--babbage-era \
--protocol-params-file pparams.json \
--mainnet
cardano-cli transaction view --tx-body-file tx.body

The following files need to be present for this transaction:
datum.txt

{"bytes": "ee7f0b86d6bebb19dd0a07ecd6b16d7ac67913a18a255e808284970b"}

redeemer.txt

{
   "constructor": 0,
   "fields": []
}

cancel_contract.plutus

{
    "type": "PlutusScriptV1",
    "description": "",
    "cborHex": "58cf58cd0100003232323232323232323232323222232323253335734002293099b9c649010146003300a00500137586600a90070009980224000002446600e004600600246aae78dd500091aab9e001235573a0024601244a666ae68c0240045280a999ab9a3375e006600c00229444c008c014004c01c8894ccd5cd18040008a4c2a666ae68cdc3801240002600a00226600666e040092002300400123574400246ae84004dd62610180002233574000400246ae8c004888c00cc0080048c8c0088cc0080080048c0088cc0080080041"
}

Produces the following output

auxiliary scripts: null
certificates: null
collateral inputs:
- dd9cf832fc8a8bf15f56484584bf2b247a6a3374cc9686f38af058953e66ab89#0
era: Babbage
fee: 203654 Lovelace
inputs:
- 298e94029f7d360e3758c455594b8192c2399a6cb1177800c0650f0ad211ec41#0
- 298e94029f7d360e3758c455594b8192c2399a6cb1177800c0650f0ad211ec41#1
metadata: null
mint: null
outputs:
- address: addr1vx5tzxy5ue4l4xqpdgz9gcyv67rzlnlcd96e3cpazlut0lcdcy8wv
  address era: Shelley
  amount:
    lovelace: 2796346
  datum: null
  network: Mainnet
  payment credential key hash: a8b11894e66bfa98016a0454608cd7862fcff8697598e03d17f8b7ff
  reference script: null
  stake reference: null
reference inputs: []
required signers (payment key hashes needed for scripts):
- ee7f0b86d6bebb19dd0a07ecd6b16d7ac67913a18a255e808284970b
return collateral:
  address: addr1vx5tzxy5ue4l4xqpdgz9gcyv67rzlnlcd96e3cpazlut0lcdcy8wv
  address era: Shelley
  amount:
    lovelace: 12753115
  datum: null
  network: Mainnet
  payment credential key hash: a8b11894e66bfa98016a0454608cd7862fcff8697598e03d17f8b7ff
  reference script: null
  stake reference: null
total collateral: 305481
update proposal: null
validity range:
  lower bound: null
  upper bound: null
withdrawals: null

Clearly, there is only one collateral in put (with around 6 ADA), being mentioned twice when building the transaction.
However the computed collateral return output is 12 ADA.

Expected behavior
The cli should detect that the collateral is mentioned several times and filter out duplicates.
The same procedure as above does NOT produce errors on cardano-cli version 1.35.3 and before.

System info (please complete the following information):

  • OS Name: [e.g. Ubuntu] Ubuntu
  • OS Version [e.g. 20.04] 20.04
  • Node version (output of cardano-node --version)
cardano-cli 1.35.4 - linux-x86_64 - ghc-8.10
git rev ebc7be471b30e5931b35f9bbc236d21c375b91bb
  • CLI version (output of cardano-cli --version)
cardano-cli 1.35.4 - linux-x86_64 - ghc-8.10
git rev 950c4e222086fed5ca53564e642434ce9307b0b9
@nielstron nielstron added the type: bug Something is not working label Jan 1, 2023
@nielstron
Copy link
Contributor Author

nielstron commented Jan 1, 2023

There does not appear to be an option to turn the general behavior of computing a collateral return output off.

@nielstron nielstron changed the title [BUG] - Cardano-cli builds erroneous collateral output for multiple occurrences of collateral inputs [BUG] - Cardano-cli builds erroneous collateral return output for multiple occurrences of collateral inputs Jan 1, 2023
@nielstron nielstron changed the title [BUG] - Cardano-cli builds erroneous collateral return output for multiple occurrences of collateral inputs [BUG] - Cardano-cli computes wrong collateral return output for multiple occurrences of collateral inputs Jan 1, 2023
@nielstron
Copy link
Contributor Author

nielstron commented Jan 1, 2023

@mkoura This might also be something that the clusterlib directly addresses by filtering out duplicate collateral inputs when building transactions.

@mkoura
Copy link
Contributor

mkoura commented Jan 18, 2023

@nielstron Thanks for suggestion, I created input-output-hk/cardano-clusterlib-py#156 for filtering out duplicate collaterals in clusterlib (so it can be used with node releases that don't have this change).

@nielstron
Copy link
Contributor Author

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: cardano-cli type: bug Something is not working user type: external Created by an external user
Projects
None yet
3 participants