Skip to content

Conversation

carbolymer
Copy link
Contributor

@carbolymer carbolymer commented Apr 3, 2025

Changelog

- description: |
    Better reporting of negative balance in transaction balancing. Remove redundant `Either` from `evaluateTransactionExecutionUnits` and `evaluateTransactionExecutionUnitsShelley` signatures.

# uncomment types applicable to the change:
  type:
  # - feature        # introduces a new feature
   - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
   - refactoring    # QoL changes
   - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

Fixes: #789 . Now instead of runtime exception, TxBodyErrorBalanceNegative is returned.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

@carbolymer carbolymer force-pushed the mgalazyn/fix/better-reporting-of-negative-balance-in-autobalancing branch 2 times, most recently from 2f12867 to 7f277ba Compare April 3, 2025 13:45
@carbolymer carbolymer self-assigned this Apr 3, 2025
@carbolymer carbolymer force-pushed the mgalazyn/fix/better-reporting-of-negative-balance-in-autobalancing branch from 7f277ba to 2c1c371 Compare April 4, 2025 17:14
@carbolymer carbolymer marked this pull request as ready for review April 4, 2025 17:17
@carbolymer carbolymer force-pushed the mgalazyn/fix/better-reporting-of-negative-balance-in-autobalancing branch from 2c1c371 to b36cb5c Compare April 4, 2025 17:23
@carbolymer
Copy link
Contributor Author

@Unisay FYI

@carbolymer carbolymer force-pushed the mgalazyn/fix/better-reporting-of-negative-balance-in-autobalancing branch from b36cb5c to 98cb118 Compare April 11, 2025 07:28
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

LGTM! A couple comments.

-> Either
(TransactionValidityError era)
(Map ScriptWitnessIndex (Either ScriptExecutionError (EvalTxExecutionUnitsLog, ExecutionUnits)))
-> Map ScriptWitnessIndex (Either ScriptExecutionError (EvalTxExecutionUnitsLog, ExecutionUnits))
Copy link
Contributor

Choose a reason for hiding this comment

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

💪

TxBodyScriptBadScriptValidity
| -- | There is not enough ada to cover both the outputs and the fees.
-- The transaction should be changed to provide more input ada, or
| -- | There is not enough ada and non-ada to cover both the outputs and the fees.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why non-ada? Multi-asset would be the correct term but even then multi-assets do not count towards the tx fee. I think you're trying to say the transaction is unbalanced with respect to multi-assets.

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 mean ada and non-ada assets here as well. Previously this error was used for ada balancing only. Now it's returned when the multi-assets balance is negative as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was referencing the term "non-ada" itself. Substituting "non-ada" with "multi-assets" is what I was suggesting.

onlyAda = null . toList . filterValue isNotAda
balanceCheck sbe bpparams txout@(TxOut _ balance _ _) = do
let outValue@(L.MaryValue coin multiAsset) = toMaryValue $ txOutValueToValue balance
isPositiveValue = L.pointwise (>) outValue mempty
Copy link
Contributor

Choose a reason for hiding this comment

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

💪

@carbolymer carbolymer force-pushed the mgalazyn/fix/better-reporting-of-negative-balance-in-autobalancing branch from 98cb118 to 857f03d Compare April 11, 2025 15:53
@carbolymer carbolymer added this pull request to the merge queue Apr 14, 2025
Merged via the queue into master with commit 09c7498 Apr 14, 2025
29 checks passed
@carbolymer carbolymer deleted the mgalazyn/fix/better-reporting-of-negative-balance-in-autobalancing branch April 14, 2025 15:58
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.

[BUG] - Add error reporting of not enough value in makeTransactionBodyAutoBalance when there's not enough inputs

2 participants