-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement and use distributeSurplus in balanceTx
- Factors out fee-minimisation logic such that it can be made more sophisticated and tested separately from balanceTransaction - Fee- and change-related padding before fee-minimisation is increased. - The padding after fee-minimisation is (in most cases) removed (see goldens; we are no longer overpaying the fee with 176 lovelace) - The fee minimisation is more robust, and should work regardless of ProtocolParameters, whether a 5 ada fee is required, or a 21 lovelace one. I ended up dropping the sanity check that any burned fee was less than 20 ada. I considered replacing the hard-coded limit with the following: ``` -- Increasing the fee by much should only happen if coin-selection is unable -- to construct a change output respecting the minUTxOValue. guardReasonableExcessFee :: TxFeeAndChange -> TxFeeAndChange guardReasonableExcessFee fc@(TxFeeAndChange feeToBurn _) | feeToBurn > limit = error $ unwords [ "final redundant safety check in balanceTransaction:" , "burning more than 2 * minUTxOValue in fees is unreasonable" ] | otherwise = fc where -- We let 2*minAda be the limit rather than just minAda to account -- for overestimations in coin-selection etc. Precision doesn't -- matter here. limit = minAda <> minAda <> Coin (ceiling $ 16 * perByteFee) -- NOTE: The change output we've failed to create would only have -- contained ada, so passing 'TokenMap.empty' should be reasonable. minAda = txOutputMinimumAdaQuantity (view #constraints tl pp) TokenMap.empty LinearFee LinearFunction {slope = perByteFee} = view (#txParameters . #getFeePolicy) pp ``` but decided it was too complex to be worth it.
- Loading branch information
Showing
10 changed files
with
365 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.