-
Notifications
You must be signed in to change notification settings - Fork 23
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
Fix transaction autobalancing when deregistering credential #718
base: master
Are you sure you want to change the base?
Fix transaction autobalancing when deregistering credential #718
Conversation
b70d25e
to
65f7e5b
Compare
LGTM. Ask me for approval when this is ready 👍 |
6577cbc
to
45c03e1
Compare
e0d4049
to
8642abb
Compare
8642abb
to
c6bba1b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some more details as to exactly how you fixed this? It's not obvious to me what changes are the fix as they are overlapped with formatting changes.
Add a test case for that. Co-authored-by: sourabhxyz <[email protected]>
c6bba1b
to
5416989
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still unclear. Separate the formatting changes and the semantic changes with I understand the change now after reading the PR description. However we need to confirm that the change value does not influence the execution units calculation. I think it may as a larger change value means a larger script context. Confirm this with the plutus team.git add --patch
-- UTXO inputs, which inclue also non-ada assets | ||
let totalValueAtUTxO = | ||
fromLedgerValue sbe . calculateIncomingUTxOValue . Map.elems $ unUTxO utxo | ||
-- this is a partial change: it does not include deposits, but we need to have non-ada assets in it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to have non-ada assets in it?
Changelog
Context
The first step of autobalancing was not considering ADA inflow from deregistering a credential, so the resulting change could get negative and it was blowing up in ledger code.
Detailed cause explanation
The negative intermediate change value could be a result of the first call to:
calculateChangeValue
considers only:so if there's not enough input value, meaning
tx outs > tx ins
, the calculated intermediate change gets negative. Note, that's a valid scenario if enough funds are coming in from certificate deposit return.If that change is then used as a new transaction output (the change output), it will throw an exception in the ledger code.
The fix
Instead of precisely calculating the change in the first step of balancing, we can just use
2^64 Lovelace
for the ada output (leaving minted assets as they were provided). This value can be arbitrary, because it's only used for the execution units and fees estimation, which do not depend on the exact change value.The exact change is calculated in the last step of the autobalancing.
Checklist