fix: account for ref script size in tx fee - #3646
Merged
Merged
Conversation
`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`.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_spend_reference_scriptspends the UTxO that holds the reference script, so the ledger chargesminFeeRefScriptCostPerBytefor the script size. The fee was computed withreference_script_sizeleft at its default 0, so the manual fee paths underpaid and the submit failed withFeeTooSmallUTxO.This stayed hidden on local testnets, where
minFeeRefScriptCostPerByteis 0. On Preview, where it is 15, the fee was short by exactly 32 * 15 for thesimple_v1script and by 167 * 15 for thesimple_v2one. Onlybuild_rawandbuild_estimatewere affected;buildlets the node balance the tx, and thebyronvariants 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 tobuild_and_submit_tx.