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] - Incorrect change output computation inside makeTransactionBodyAutoBalance #714

Open
sourabhxyz opened this issue Dec 30, 2024 · 2 comments · May be fixed by #718
Open

[BUG] - Incorrect change output computation inside makeTransactionBodyAutoBalance #714

sourabhxyz opened this issue Dec 30, 2024 · 2 comments · May be fixed by #718
Assignees

Comments

@sourabhxyz
Copy link

sourabhxyz commented Dec 30, 2024

External

Area
Tx balancing.

Summary

makeTransactionBodyAutoBalance tries to compute change output by considering only inputs, minted value & outputs here but ada source could also come from stake/drep credential unregistration as well. This can cause the makeUnsignedTx function called shortly afterwards to fail as this computed change could be negative. This was not the case for cardano-api-9.1.0.0 where such a conversion was not being performed at least before the ada value in change output was set to maximum word limit.

Also, the utxo parameter expected by makeTransactionBodyAutoBalance is suppose to include reference inputs, collateral inputs as well and not just spending inputs but totalValueAtSpendableUTxO seems to suggest that it's only spending inputs. This is not a big deal if our goal is just to overestimate but thought I'd also mention this misnomer.

Version
Using tag cardano-api-10.1.0.0.

@carbolymer carbolymer self-assigned this Dec 30, 2024
@sourabhxyz
Copy link
Author

Fwiw, I did this change upon cardano-api-10.1.0.0 and it now again works with our tx building tool, Atlas.

@carbolymer
Copy link
Contributor

Thank you for the detailed analysis and a proposed fix! I confirm that GHC exception is being thrown at the beginning of makeTransactionBodyAutoBalance when the calculated change is negative.

@carbolymer carbolymer linked a pull request Jan 8, 2025 that will close this issue
3 tasks
@carbolymer carbolymer linked a pull request Jan 14, 2025 that will close this issue
3 tasks
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 a pull request may close this issue.

2 participants