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

Addition of new minFeeRefScriptCoinsPerByte protocol parameter #3952

Closed
lehins opened this issue Dec 21, 2023 · 11 comments · Fixed by #3983
Closed

Addition of new minFeeRefScriptCoinsPerByte protocol parameter #3952

lehins opened this issue Dec 21, 2023 · 11 comments · Fixed by #3983
Assignees
Labels

Comments

@lehins
Copy link
Collaborator

lehins commented Dec 21, 2023

Fee calculation need to be adjusted in Conway. It has been decided that size of reference scripts should contribute to the fee amount charged in a transaction.

  • Addition of new protocol parameter: minFeeRefScripts :: NonNegativeInterval
  • Adding UTxO argument to getMinFeeTx:
getMinFeeTx :: UTxO era -> PParams era -> Tx era -> Coin
  • Adding another factor to the calculation in Babbage, along the lines of:
  ...
  <+> Coin (round ((refScriptsTotalSize % 1) * unboundRational (pp ^. ppMinFeeRefScriptsL)))
  where
    refSciptsTotalSize =
      maybe 0 (toInteger . getSum) $ foldMap (fmap Sum . getPlutusScriptSize) refScripts
    txBody = tx ^. bodyTxL
    ins = (txBody ^. referenceInputsTxBodyL) `Set.union` (txBody ^. inputsTxBodyL)
    refScripts = getReferenceScripts utxo ins

Where getPlutusScriptSize :: Script era -> Maybe Int is a function that calculates the size of a plutus script for any Script

@Quantumplation
Copy link

@lehins I see this was created before my CIP, meaning this was already in the works. Can you provide any insight into how and why this decision was made?

@lehins lehins changed the title Addition of new minFeeRefScripts protocol parameter Addition of new minFeeRefScriptCoinsPerByte protocol parameter Jan 3, 2024
@michaelpj
Copy link
Contributor

I thought we were just going to add it to the transaction size for the purposes of fee calculation?

@lehins
Copy link
Collaborator Author

lehins commented Jan 3, 2024

Can you provide any insight into how and why this decision was made?

Certainly. Using reference scripts does not come for free from the point of view of SPOs. The node has to spend resources looking up the reference input (which is not being spent) in the UTxO, but most importantly a script needs to be deserialized. Therefore it is almost as much work for the node to process a script as if it was part of the transaction, but there is less
incentive for SPOs to do that work. That being said, it is definitely less work, and for that reason we want to be able to tune this lever by a parameter that is different from minFeeA

I thought we were just going to add it to the transaction size for the purposes of fee calculation?

@michaelpj Yeah, that will still sort of going to be the case. As I said above, it will just be adjusted with a separate paramter. So, for example if minFeeRefScriptCoinsPerByte would be set to minFeeA value, then it would be as if the size of a reference scripts was added to the size of the transaction. The argument @WhatisRT presented in favor of a separate protocol parameter was that the user is paying for adding the transaction on chain (reaching consensus, network overhead etc.) and the work is proportional to the size of the transaction, while using a reference script is also proportional to the size, but it requires less work than for the full transaction. Thus the community might want to have some freedom in tuning that parameter separately.

@Quantumplation
Copy link

Ok thanks! Appreciate the insight.

To me, it seems like the deserialization work should logically add to the execution units rather than the tx size (so that something like partial deserialization could save on ex units), but I can understand it being easier to use the existing and much simpler tool to achieve a similar result.

@gitmachtl
Copy link

gitmachtl commented Jan 4, 2024

So if this is a SC execution, shouldn't that be covered by SC related "fees"? As @Quantumplation said, shouldn't this be covered by the execution units?

As we have currently the discussion about the correct minFee calculation over here IntersectMBO/cardano-cli#534 , that would need an extra input parameter for the fee calculation function on cardano-cli to provide the size of the reference script or the script itself? But correct me if i am wrong.

@KtorZ
Copy link
Contributor

KtorZ commented Jan 4, 2024

Is the intention to make that parameter as high as if the script had been included in the witness? Or is the intent to rather create a new incentives, without increasing the cost as much?

@MicroProofs
Copy link

Can you provide any insight into how and why this decision was made?

Certainly. Using reference scripts does not come for free from the point of view of SPOs. The node has to spend resources looking up the reference input (which is not being spent) in the UTxO, but most importantly a script needs to be deserialized. Therefore it is almost as much work for the node to process a script as if it was part of the transaction, but there is less incentive for SPOs to do that work. That being said, it is definitely less work, and for that reason we want to be able to tune this lever by a parameter that is different from minFeeA

I thought we were just going to add it to the transaction size for the purposes of fee calculation?

@michaelpj Yeah, that will still sort of going to be the case. As I said above, it will just be adjusted with a separate paramter. So, for example if minFeeRefScriptCoinsPerByte would be set to minFeeA value, then it would be as if the size of a reference scripts was added to the size of the transaction. The argument @WhatisRT presented in favor of a separate protocol parameter was that the user is paying for adding the transaction on chain (reaching consensus, network overhead etc.) and the work is proportional to the size of the transaction, while using a reference script is also proportional to the size, but it requires less work than for the full transaction. Thus the community might want to have some freedom in tuning that parameter separately.

Do we have an idea on what minFeeRefScriptCoinsPerByte value is going to be in relation to minFeeA. I was assuming less due to the smaller tx size and less bytes being sent over the wire. But I would like to see what gets recommended.

@lehins
Copy link
Collaborator Author

lehins commented Jan 4, 2024

Is the intention to make that parameter as high as if the script had been included in the witness? Or is the intent to rather create a new incentives, without increasing the cost as much?

Do we have an idea on what minFeeRefScriptCoinsPerByte value is going to be in relation to minFeeA

Honestly, I have no idea what the initial value for this parameter will be. The intent of this issue is to provide the functionality for making this possible.

I was assuming less due to the smaller tx size and less bytes being sent over the wire.

I'd assume so as well.

@KtorZ
Copy link
Contributor

KtorZ commented Jan 5, 2024

Sounds like a good first question for IntersectMBO to work on :)

@vsubhuman
Copy link

vsubhuman commented Jan 30, 2024

I thought we were just going to add it to the transaction size for the purposes of fee calculation?

@michaelpj , ignoring the direct topic of the issue itself, your comment is very concerning. Is it mentioned somewhere in documentation that this plan exists to add ref script size to the size of the tx that references it?

@lehins
Copy link
Collaborator Author

lehins commented Jan 30, 2024

Is it mentioned somewhere in documentation that this plan exists to add ref script size to the size of the tx that references it?

This was discussed in a meeting as a potential solution, but instead we decided to add a new protocol parameter that will be a multiplier for the size of reference scripts. Which is what this ticket is about. It is a strictly more powerful solution since it gives fine control over how much ref scripts will contribute to the fee of a transaction.

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.

8 participants