Skip to content

Conversation

@MitchyCola
Copy link
Contributor

This PR resolves issue #71

@MitchyCola MitchyCola requested a review from mikekeke August 14, 2022 20:14
@mikekeke mikekeke requested review from IAmPara0x and szg251 August 17, 2022 12:15
calculateMinUtxo pabConf datums txOut = do
let outs = txOutOpts pabConf datums [txOut]
case outs of
[] -> pure $ Left "When constructing the transaction, no output values were specified."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this check should also be in buildTx.
Additional thing to consider, is that there will be no calculateMinUtxo in Vasil compliant version, so check here will be no more and build-raw in buildTx will start to fail.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the check for empty list is redundant because, when we call calculateMinUtxo from calculateMinUtxos (present in Balance.hs) there's always some value present in the txOut. But it nevertheless make sense to handle this case, in case anyone tries to call calculateMinUtxo where the txOutValue is not always non-zero. But after vasil compliance of BPI this function would be redundant, and so would be the need to check for if txOutValue is non-zero.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IAmPara0x

Currently, the check for empty list is redundant because, when we call calculateMinUtxo from calculateMinUtxos (present in Balance.hs) there's always some value present in the txOut.

Why does it always have some value there? Because of minimum Ada adjustment?

Copy link
Contributor

@IAmPara0x IAmPara0x Aug 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to call calculateMinUtxo when we want to get minimum amount of lovelace that should be present in a TxOut of a Tx, this is required during balancing. But, if there's a TxOut with zero value then we don't need to consider it as an actual output to a Tx, hence don't need to call calculateMinUtxo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree that this check should be moved to buildTx.

@IAmPara0x This check was added for the specific case in which a transaction would only contain a zero Value as the output. Which would result in an empty list from the changes that I made here:

txOutOpts :: PABConfig -> Map DatumHash Datum -> [TxOut] -> [Text]
 txOutOpts pabConf datums =
   concatMap
     ( \TxOut {txOutAddress, txOutValue, txOutDatumHash} ->
         if Value.isZero txOutValue
           then []
           else

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MitchyCola oh, I get it now. Thanks for pointing it out!.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the error is originating from the use of calculateMinUtxos inside of balanceTxLoop (in Balance.hs), the error gets thrown before the use of buildTx. Therefore, I decided to move the check into preBalancedTx.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if just put check in both calculateMinUtxos and buildTx? It will keep this commit in working state, and vasil update will just remove calculateMinUtxos.

It feels like omitting check that result of txOutOpts can return [] will shoot one day.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@MitchyCola MitchyCola requested a review from mikekeke August 23, 2022 13:52
@mikekeke mikekeke linked an issue Aug 24, 2022 that may be closed by this pull request
@mikekeke mikekeke merged commit 11db995 into master Aug 25, 2022
mikekeke added a commit that referenced this pull request Aug 25, 2022
mikekeke added a commit that referenced this pull request Aug 25, 2022
Revert "Merge pull request #141 from mlabs-haskell/mitch/error-messages"
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 this pull request may close these issues.

Misleading error when minting value is 0

4 participants