Skip to content

fix: account for ref script size in tx fee - #3646

Merged
mkoura merged 1 commit into
masterfrom
fix/ref_script_fee_size
Aug 21, 2026
Merged

fix: account for ref script size in tx fee#3646
mkoura merged 1 commit into
masterfrom
fix/ref_script_fee_size

Conversation

@mkoura

@mkoura mkoura commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

test_spend_reference_script spends the UTxO that holds the reference script, so the ledger charges minFeeRefScriptCostPerByte for the script size. The fee was computed with reference_script_size left at its default 0, so the manual fee paths underpaid and the submit failed with FeeTooSmallUTxO.

This stayed hidden on local testnets, where
minFeeRefScriptCostPerByte is 0. On Preview, where it is 15, the fee was short by exactly 32 * 15 for the simple_v1 script and by 167 * 15 for the simple_v2 one. Only build_raw and build_estimate were affected; build lets the node balance the tx, and the byron variants were saved by the padding that the extra Byron witness adds to the estimate.

Add clusterlib_utils.get_reference_script_size, which serializes a simple script the way the ledger does and unwraps the text envelope of a Plutus script, and pass its result to build_and_submit_tx.

`test_spend_reference_script` spends the UTxO that holds the reference
script, so the ledger charges `minFeeRefScriptCostPerByte` for the
script size. The fee was computed with `reference_script_size` left at
its default 0, so the manual fee paths underpaid and the submit failed
with `FeeTooSmallUTxO`.

This stayed hidden on local testnets, where
`minFeeRefScriptCostPerByte` is 0. On Preview, where it is 15, the fee
was short by exactly 32 * 15 for the `simple_v1` script and by
167 * 15 for the `simple_v2` one. Only `build_raw` and `build_estimate`
were affected; `build` lets the node balance the tx, and the `byron`
variants were saved by the padding that the extra Byron witness adds to
the estimate.

Add `clusterlib_utils.get_reference_script_size`, which serializes a
simple script the way the ledger does and unwraps the text envelope of
a Plutus script, and pass its result to `build_and_submit_tx`.
@mkoura
mkoura requested a review from saratomaz as a code owner August 21, 2026 09:55
@mkoura
mkoura merged commit 3a40169 into master Aug 21, 2026
3 checks passed
@mkoura
mkoura deleted the fix/ref_script_fee_size branch August 21, 2026 09: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.

1 participant