Skip to content

Balancing overhaul#514

Open
mmontin wants to merge 12 commits intomm/effectfulfrom
mm/balancing
Open

Balancing overhaul#514
mmontin wants to merge 12 commits intomm/effectfulfrom
mm/balancing

Conversation

@mmontin
Copy link
Collaborator

@mmontin mmontin commented Feb 14, 2026

This improves balancing in several ways:

  1. This adds a TxSkel option to defer validation failures occurring during balancing.

As a consequence, the balancing succeeds even when running the script to assign execution units fails, and thus the balanced TxSkel can be traced.

As a downside, this drastically decreases performances (as scripts are run several more times, even if we know they fail) and thus is only made available as an option, disabled by default.

  1. This add another TxSkel option to cap the maximum amount of UTxOs that can be used for balancing purposes.

This idea is that in the rare case where there are many candidate UTxOs, the algorithm would be too greedy, and thus some constraints need to be applied. This is now possible.

  1. This reworks the main balancing function reachValue

The idea is that it now optimizes the solutions depending on how much overhead in terms of size, rather than by the minAda required for the extra payment. For instance, if a solution generates a very small extra payment, but with many additional inputs, and another generates a bigger extra output, but with fewers added inputs, then the latter will likely be picked.

  1. This makes it so that the body generated during fee computation is not lost

The body is given back as a result of the balancing, and is directly used when submitting the transaction for validation in our main validation function.

  1. This fixes an optimization bug in the fee computation

  2. This improves the handling and generation of collaterals

Fixes #435
Fixes #494
Fixes #500
Fixes #503

@mmontin mmontin changed the title Defer validatation failures raised during balancing Balancing overhaul Feb 19, 2026
@mmontin mmontin marked this pull request as ready for review February 19, 2026 15:33
@mmontin mmontin force-pushed the mm/effectful branch 2 times, most recently from 2fe561b to 6fe064d Compare February 20, 2026 11:31
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.

1 participant