-
Notifications
You must be signed in to change notification settings - Fork 721
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
Add utxoCostPerByte protocol parameter #4141
Add utxoCostPerByte protocol parameter #4141
Conversation
10c8fbb
to
26176ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for doing this change, that is exactly what I was advocating for. There are two more things need to be done, I believe, to make this change complete:
- Json field name needs to be adjusted:
and
I don't know if it is OK to break backwards compatibility when it comes to json representation, but just renaming the field naturally will break it
ProtocolParametersUpdate
also needs the rename:
eb9ff82
to
c0cfc27
Compare
Thanks @lehins . I did another pass through the code and identified a lot more cases that needed changing. |
c0cfc27
to
a66e638
Compare
5f4fb59
to
d1eb9ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make this change backwards compatible
@@ -312,7 +312,7 @@ instance FromJSON ProtocolParameters where | |||
<*> o .: "poolPledgeInfluence" | |||
<*> o .: "monetaryExpansion" | |||
<*> o .: "treasuryCut" | |||
<*> o .:? "utxoCostPerWord" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we have a problem. We are breaking backwards compatibility here. We should parse for both "utxoCostPerWord" and "utxoCostPerByte" in the event somebody is running an Alonzo only network. There is also a typo: utxoCostPerBytes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be wrong, but I think it could be sufficient to keep backwards compatibility at the JSON deserialization level. Something along the lines:
maybePerWord <- o .:? "utxoCostPerWord"
maybePerByte <- o .:? "utxoCostPerByte"
utxoCostPerByte <-
case maybePerWord of
Nothing -> pure maybePerByte
Just _ | Just _ <- maybePerByte <- fail "Cannot supply both utxoCostPerWord and utxoCostPerByte"
Just perWord -> pure $ coinsPerUTxOWordToCoinsPerUTxOByte perWord
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would work but it would be confusing when looking at the ProtocolParameters
type. It's better to make the changes obvious rather than having it only at the JSON deserialization level.
-- | ||
-- /Introduced in Alonzo/ | ||
protocolUpdateUTxOCostPerWord :: Maybe Lovelace, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the proper way to do this would not be to modify existing Alonzo fields, but to add a new protocolUpdateUTxOCostPerByte
field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment, maybe we can get away with renaming. After Babbage is released creating PPUpdates for Alonzo doesn't make much sense, or does it?
In retrospective we should not have renamed it ledger. In particular using the binary flag 17
for perWord and perByte was a mistake, IMHO. But that ship have sailed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might for chains other than mainnet
if we care about those?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can get away with renaming.
If we were already in Babbage maybe but keeping backwards compatibility also makes it clear to whoever is looking at the code that this particular field was renamed at the Alonzo -> Babbage boundary which is useful. This has always been the approach in the api.
@@ -795,6 +795,7 @@ genProtocolParametersUpdate = do | |||
protocolUpdateMaxValueSize <- Gen.maybe genNat | |||
protocolUpdateCollateralPercent <- Gen.maybe genNat | |||
protocolUpdateMaxCollateralInputs <- Gen.maybe genNat | |||
protocolUpdateUTxOCostPerByte <- Gen.maybe genLovelace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to generate both the protocolUpdateUTxOCostPerWord
and the protocolUpdateUTxOCostPerByte
in the same update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now yeah
435ae33
to
66ce20d
Compare
305e182
to
8138352
Compare
8138352
to
705fc3c
Compare
705fc3c
to
79df3c5
Compare
cardano-api/src/Cardano/Api/Fees.hs
Outdated
-- | The 'ProtocolParameters' must provide the value for the cost per | ||
-- byte parameter, for eras that use this parameter. | ||
| TxBodyErrorMissingParamCostPerByte | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both TxBodyErrorMissingParamCostPerWord
and TxBodyErrorMissingParamCostPerByte
appear to be unused. Should I delete @Jimbo4350? Or is a change needed to ensure they are used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted
cardano-api/src/Cardano/Api/Fees.hs
Outdated
@@ -1260,6 +1267,7 @@ calculateMinimumUTxO era txout@(TxOut _ v _ _) pparams' = | |||
data MinimumUTxOError = | |||
PParamsMinUTxOMissing | |||
| PParamsUTxOCostPerWordMissing | |||
| PParamsUTxOCostPerByteMissing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both PParamsUTxOCostPerWordMissing
and PParamsUTxOCostPerByteMissing
appear to be unused. Should I delete @Jimbo4350? Or is a change needed to ensure they are used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove them both 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted
45801c4
to
2343b86
Compare
@@ -1460,7 +1483,8 @@ toAlonzoPParams ProtocolParameters { | |||
(Ledger.boundRational protocolParamTreasuryCut) | |||
|
|||
-- New params in Alonzo: | |||
, Alonzo._coinsPerUTxOWord = toShelleyLovelace utxoCostPerWord | |||
, Alonzo._coinsPerUTxOWord = -- adapted from babbage protocol parameter field |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the comment? I don't understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left over comment from when I previously did the byte to work conversion. Deleting.
@@ -1506,7 +1530,7 @@ toBabbagePParams ProtocolParameters { | |||
protocolParamPoolPledgeInfluence, | |||
protocolParamMonetaryExpansion, | |||
protocolParamTreasuryCut, | |||
protocolParamUTxOCostPerWord = Just utxoCostPerWord, | |||
protocolParamUTxOCostPerByte = Just utxoCostPerByte, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -1693,6 +1717,7 @@ fromAlonzoPParams | |||
, protocolParamMaxValueSize = Just _maxValSize | |||
, protocolParamCollateralPercent = Just _collateralPercentage | |||
, protocolParamMaxCollateralInputs = Just _maxCollateralInputs | |||
, protocolParamUTxOCostPerByte = Nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a comment here explaining this is deprecated in Babbage would be useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comment.
@@ -262,14 +263,16 @@ friendlyProtocolParametersUpdate | |||
("monetary expansion" .=) . friendlyRational | |||
, protocolUpdateTreasuryCut <&> ("treasury expansion" .=) . friendlyRational | |||
, protocolUpdateUTxOCostPerWord <&> | |||
("UTxO storage cost per unit" .=) . friendlyLovelace | |||
("UTxO storage cost per word" .=) . friendlyLovelace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
cardano-api/src/Cardano/Api/Fees.hs
Outdated
@@ -1260,6 +1267,7 @@ calculateMinimumUTxO era txout@(TxOut _ v _ _) pparams' = | |||
data MinimumUTxOError = | |||
PParamsMinUTxOMissing | |||
| PParamsUTxOCostPerWordMissing | |||
| PParamsUTxOCostPerByteMissing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove them both 👍
LGTM, minor suggestions |
2343b86
to
f6d5ada
Compare
@@ -18,7 +18,7 @@ update proposal: | |||
updates: | |||
- genesis key hash: 1bafa294233a5a7ffbf539ae798da0943aa83d2a19398c2d0e5af114 | |||
update: | |||
UTxO storage cost per unit: 194 Lovelace | |||
UTxO storage cost per word: 194 Lovelace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note this golden file has changed.
f6d5ada
to
7193afe
Compare
bors r+ |
4141: Add utxoCostPerByte protocol parameter r=newhoggy a=newhoggy Resolves #4052 See cardano-foundation/CIPs#265 Co-authored-by: John Ky <[email protected]>
Timed out. |
bors r+ |
Build succeeded: |
tested latest master. ok so the protocol parameters query will introduce the utxoCostPerWord parameter on the switch to alonzo-era like
and will remove or set the parameter again in babbage-era like
Will this behaviour stay for a while? Because Tools are looking out for those parameters in the protocol to do the minUtxo calculation based on it (not using the inbuilt cli function). |
@Jimbo4350 why was this PR not included in the tag 1.35.2 ? whats the plan for the release version? we have external tools depending on the cli protocol-parameters output. with "utxoCostPerByte" present its clear that the minOutUtxo must be calculated with the new perByte method. or is the plan to not show this parameter at all and use the new method if a protocolVersion.major>=7 is present? thx |
@gitmachtl From what I understand 1.35.2 only includes an important bug fix that is necessary for the upcoming hard fork. All other minor bug fixes and features, which applies to |
Resolves #4052
See cardano-foundation/CIPs#265