Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the type of minFeeRefScriptCoinsPerByte #4052

Closed
4 tasks done
lehins opened this issue Feb 6, 2024 · 1 comment · Fixed by #4055
Closed
4 tasks done

Change the type of minFeeRefScriptCoinsPerByte #4052

lehins opened this issue Feb 6, 2024 · 1 comment · Fixed by #4055
Assignees
Labels

Comments

@lehins
Copy link
Collaborator

lehins commented Feb 6, 2024

In a recent PR #3983 a new protocol parameter has been added. One oversigt was that the type that was used does not allow for a more fine grain tuning of the fee, because it is backed by an CoinPerByte, which is essentially a Coin. In other words it only allows one lovelace per byte granularity, which might not be enough in the future.

In order to allow us to be as precise as necessary, we need to:

  • - We need to change the type to NonNegativeInterval
  • - Change the formula to use rounding
  • - Rename the parameter to minFeeRefScriptCostPerByte
  • - Adjust CDDL

Here is the implementation of the fee calculation:

alonzoMinFeeTx pp tx <+> (refScriptsSize <×> refScriptFee)
where
CoinPerByte refScriptFee = pp ^. ppMinFeeRefScriptCoinsPerByteL

Which should be changed to this new calculation:

 alonzoMinFeeTx pp tx <+> refScriptsFee
 where 
   refScriptFee = unboundRational (pp ^. ppMinFeeRefScriptCoinsPerByteL)
   refScriptsFee = Coin (floor (fromIntegral @Int @Rational refScriptsSize * refScriptFee)) 
@aniketd
Copy link
Contributor

aniketd commented Feb 7, 2024

@lehins Thank you for such a detailed write up here ❤️ 🙌 🙇 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants