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] - min required UTxO reported by CLI is not correct #4061

Closed
mkoura opened this issue Jun 17, 2022 · 7 comments
Closed

[BUG] - min required UTxO reported by CLI is not correct #4061

mkoura opened this issue Jun 17, 2022 · 7 comments
Assignees
Labels
comp: cardano-cli era: babbage priority low Issues/RPs that are low priority issues/PRs in relation to a minimum Shelley testnet and Shelley mai type: regression A feature that worked before stoped working user type: internal Created by an IOG employee Vasil

Comments

@mkoura
Copy link
Contributor

mkoura commented Jun 17, 2022

Internal

Area
Other Any other topic (Delegation, Ranking, ...).

Summary
In Babbage, both transaction build and transaction calculate-min-required-utxo report 857690 Lovelace to be minimum required UTxO for Lovelace-only output with no datum. However I am able to create UTxO with just 849070 Lovelace (using transaction build-raw).

Expected behavior
CLI reports precise minimum required UTxO.

System info:

  • OS Name: Fedora 35
  • Node version: 1.35.0-rc3
@mkoura mkoura added bug Something isn't working Vasil labels Jun 17, 2022
@gitmachtl
Copy link
Contributor

gitmachtl commented Jun 18, 2022

The transaction calculate-min-required-utxo is a bit strange, because how to query the real minimum value with this function? In the past i used --tx-out ADDRESS+0 because of the word boundary it didn't make a difference in the outcome and the result was the minUTXO that must be used. But now that the calculation is done down to the bytelevel, the result of a minUTXO request depends on the amount you're doing the request for??? Thats strange. Examples:

./cardano-cli transaction calculate-min-required-utxo --babbage-era \
     --protocol-params-file <(cat babbage-protocol-parameters.tmp) \
     --tx-out "addr_test1vpfwv0ezc5g8a4mkku8hhy3y3vp92t7s3ul8g778g5yegsgalc6gc+0"
Lovelace 840450

the value above is wrong, because if you try to send 840450 lovelaces it really is

./cardano-cli transaction calculate-min-required-utxo --babbage-era \
     --protocol-params-file <(cat babbage-protocol-parameters.tmp) \
     --tx-out "addr_test1vpfwv0ezc5g8a4mkku8hhy3y3vp92t7s3ul8g778g5yegsgalc6gc+840450"
Lovelace 857690

the value above is accepted by the chain

./cardano-cli transaction calculate-min-required-utxo --babbage-era \
     --protocol-params-file <(cat babbage-protocol-parameters.tmp) \
     --tx-out "addr_test1vpfwv0ezc5g8a4mkku8hhy3y3vp92t7s3ul8g778g5yegsgalc6gc+10000000000"
Lovelace 874930

the value above is too high

so why is the amount of the minUTXO depending on the amount i wanna send, that makes no sense IMO. or do i miss something? there is only ONE real minUTXO value on the chain, not a gliding value?

there should be an integrated iteration within cardano-cli to get to the real min value with a starting lovelace amount of zero.

same goes for sending out assets, requesting the minUTXO for
--tx-out ADDR+0+1 POLICY.ASSETNAME (example)
should return the right amount of lovelaces, but if you request it that way, the returned value is too low because of the wrong lower boundary for the lovelaces part.

@JaredCorduan
Copy link
Contributor

JaredCorduan commented Jun 18, 2022

The build command might be overestimating the size needed, perhaps using maxBound somewhere.

The min value depends (linearly) on the number of bytes of the output. You cannot therefore figure it out precisely by substituting zero for the value you want. See this CIP: https://github.com/cardano-foundation/CIPs/pull/265/files

But I guess the suggestion is for the CLI to take an output with zero ada, and compute the fix point?

@gitmachtl
Copy link
Contributor

But I guess the suggestion is for the CLI to take an output with zero ada, and compute the fix point?

Yes exactly, like its now working in the alonzo-era. Otherwise external tools would need to do at least two or three requests with different lovelaces values to get the amount that really works for sending it out with that value.

@CarlosLopezDeLara CarlosLopezDeLara added the priority medium issues/PRs that SHOULD be addressed. This should be done for the release, but acceptable if it doesn label Jun 21, 2022
@JaredCorduan JaredCorduan assigned lehins and unassigned JaredCorduan Jun 22, 2022
@JaredCorduan
Copy link
Contributor

@lehins has kindly volunteered to make an era-generic function for computing the fixed point for a given transaction output, in the ledger code. After we have that, we figure out how to hook it into the build and build-raw commands.

@Jimbo4350
Copy link
Contributor

Jimbo4350 commented Jun 26, 2022

In Babbage, both transaction build and transaction calculate-min-required-utxo report 857690 Lovelace to be minimum required UTxO for Lovelace-only output with no datum. However I am able to create UTxO with just 849070 Lovelace (using transaction build-raw).

So this is complaining about the change output. We purposely overestimate the size of the change output because we want to avoid recursively solving for the tx fee (i.e evaluate tx fee, put fee in tx, evaluate the fee again, put the fee in the tx etc). This is expected.

@CarlosLopezDeLara CarlosLopezDeLara added the 1.35.1 Include in 1.35.1 label Jun 30, 2022
@CarlosLopezDeLara
Copy link
Contributor

Removing from 1.35.1. As @Jimbo4350 mentioned, current behavior is intended and expected.

@CarlosLopezDeLara CarlosLopezDeLara added priority low Issues/RPs that are low priority issues/PRs in relation to a minimum Shelley testnet and Shelley mai and removed 1.35.1 Include in 1.35.1 priority medium issues/PRs that SHOULD be addressed. This should be done for the release, but acceptable if it doesn labels Jul 6, 2022
@CarlosLopezDeLara CarlosLopezDeLara removed the bug Something isn't working label Jul 19, 2022
@lehins
Copy link
Contributor

lehins commented Sep 12, 2022

@Jimbo4350 we now have a function setMinCoinTxOut in cardano-ledger-api (which is a new packahge tha twe started that will provide all the useful functionality for downstream users of ledger).

That function will calculate the true minimum lovelace for any TxOut in any era precisely by finding the fixpoint:

https://github.com/input-output-hk/cardano-ledger/blob/1176affe9b2a7a3b50c1ceda00cc92f237ea6360/libs/cardano-ledger-api/src/Cardano/Ledger/Api/Tx/Out.hs#L32-L40

@CarlosLopezDeLara You maybe want to consider reopening this ticket, since now it will be very easy to adopt this in cardano-node thus minimize the amount and make everyone happy

@dorin100 dorin100 added type: bug Something is not working type: regression A feature that worked before stoped working user type: internal Created by an IOG employee era: babbage comp: cardano-cli and removed type: bug Something is not working labels Oct 21, 2022
mkoura added a commit to IntersectMBO/cardano-node-tests that referenced this issue Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: cardano-cli era: babbage priority low Issues/RPs that are low priority issues/PRs in relation to a minimum Shelley testnet and Shelley mai type: regression A feature that worked before stoped working user type: internal Created by an IOG employee Vasil
Projects
None yet
Development

No branches or pull requests

7 participants