-
Notifications
You must be signed in to change notification settings - Fork 23
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
Fix reading of Plutus V2 cost models with different lengths in AlonzoGenesis in different eras #564
Fix reading of Plutus V2 cost models with different lengths in AlonzoGenesis in different eras #564
Conversation
0369191
to
0f7383e
Compare
0f7383e
to
f7d91b4
Compare
3868745
to
8b5577b
Compare
FYI: Because we now enforce the use of |
3b81f26
to
b298536
Compare
FYI: I have rebased your branch because we have done changes to the formatting. I have made a copy of the unrebased branch here: backup/mgalazyn/fix/allow-reading-plutus-v2-175-param-costmodel |
b298536
to
1636dbf
Compare
{-# LANGUAGE GeneralisedNewtypeDeriving #-} | ||
{-# LANGUAGE LambdaCase #-} |
Check warning
Code scanning / HLint
Unused LANGUAGE pragma Warning
Found:
{-# LANGUAGE LambdaCase #-}
Perhaps you should remove it.
{-# LANGUAGE GeneralisedNewtypeDeriving #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TupleSections #-} |
Check warning
Code scanning / HLint
Unused LANGUAGE pragma Warning
Found:
{-# LANGUAGE TupleSections #-}
Perhaps you should remove it.
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TupleSections #-} | ||
{-# LANGUAGE TypeApplications #-} |
Check warning
Code scanning / HLint
Unused LANGUAGE pragma Warning
Found:
{-# LANGUAGE TypeApplications #-}
Perhaps you should remove it.
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TupleSections #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE TypeOperators #-} |
Check warning
Code scanning / HLint
Unused LANGUAGE pragma Warning
Found:
{-# LANGUAGE TypeOperators #-}
Perhaps you should remove it.
Note: may require {-# LANGUAGE ExplicitNamespaces #-} adding to the top of the file
a0311c6
to
6faa4c4
Compare
2116359
to
5a49ca6
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.
I think there is a significantly simpler way to approach this.
Parameterize cardano-api
's alonzoGenesisDefaults
on the era. If conway era is specified, add in the additional cost model parameters. If not don't add them. This should result in minimal changes. This will generate the appropriate cost model when using create-testnet-data
and we should't have any issues so long as we generate an array instead of a json object. We should add a cli command that renders the array cost model as JSON. In future I want to switch to the array to avoid this issue.
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.
LGTM however this code will disappear when we hardfork to Conway. In future we should avoid this situation completely by using an array in the genesis file and having a mechanism to pretty print the cost models (makes debugging easier).
When supplying an array, ledger calls mkCostModel
which always retains the original values supplied. Plutus's mkEvaluationContext
will then automatically adjust the cost model (either filling in missing values or truncating them).
Our pretty printing function can potentially do some validation and suggest to the user if they are missing parameters from their particular cost model. However I want to avoid us manually doing the validation as much as possible, to the point of requesting ledger/plutus to expose additional functions if needed.
Can you confirm with @mgmeier and @mkoura that this fixes their issue?
The problem occurs when we provide alonzo genesis specification from a file. We're not using
That's correct. The whole purpose of this fix was to support flexible map format.
I don't understand which pretty printing function are you referring to. |
Hmm. Micheal said "When I create genesis, and then manually remove 10 list entries from the V2 cost model, the pparam query in Babbage works" so I was under the assumption they were not supplying a cost model file. @mgmeier?
We would have to implement it.
Yes but this requires us to maintain code that we should not be maintaining. Benchmarking wants to be able to view the cost model as a json map. We can give them that whilst avoiding the additional gymnastics around decoding the cost model from a json map. In the future its possible for this situation to arise again and we can (and should) avoid it. We would unfortunately have to enforce cost models being supplied as arrays. |
I completely agree. I'll gladly remove this code when we won't need to support this edge case anymore.
I understood that the use case is to be able to define and inspect cost model in JSON and not just only view it. I guess we could provide separate translation layer for them doing pretty much what's done in this decoding function. It still means that we have to fix ledger bugs in |
FYI: I have rebased your branch because we have done changes to the formatting. I have made a copy of the unrebased branch here: https://github.com/IntersectMBO/cardano-api/tree/backup2/mgalazyn/fix/allow-reading-plutus-v2-175-param-costmodel |
e2124ac
to
ca59f40
Compare
ca59f40
to
e2124ac
Compare
e2124ac
to
6dd96c6
Compare
1e9c1a8
to
1774476
Compare
1774476
to
2468b1f
Compare
2468b1f
to
e289988
Compare
Changelog
Context
Part of the fix for:
Plutus V2 cost model for Babbage and for Conway have a different number of parameters. Ledger's JSON decoder for a map format of the cost model is unaware about this fact and just tries to validate for all parameters and load all 185 parameters no matter the era. This in order makes a problem for CBOR decoder, which is era-aware and will fail for a cost model with 185 parameters in Babbage.
This PR adds a function for how we decoding the cost model from JSON, which makes an adjustment in loaded parameters count depending on an era.