Skip to content

Balancing overhaul#514

Merged
mmontin merged 109 commits intomainfrom
mm/balancing
Apr 13, 2026
Merged

Balancing overhaul#514
mmontin merged 109 commits intomainfrom
mm/balancing

Conversation

@mmontin
Copy link
Copy Markdown
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
Base automatically changed from mm/effectful to main April 13, 2026 14:13
@mmontin mmontin merged commit 016a9ae into main Apr 13, 2026
8 checks passed
@mmontin mmontin deleted the mm/balancing branch April 13, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant