-
Notifications
You must be signed in to change notification settings - Fork 16
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 cost models file to protocol parameter update command #405
Conversation
-- | New parameters to be proposed. From Alonzo onwards, the type | ||
-- 'EraBasedProtocolParametersUpdate' also contains cost models. Since all | ||
-- other protocol parameters are read from command line arguments, whereas | ||
-- the cost models are read from a file, we separate the cost models from | ||
-- the rest of the protocol parameters to ease parsing. | ||
, uppNewPParams :: !(EraBasedProtocolParametersUpdate era) | ||
-- | The new cost models proposed. See the comment at 'uppNewPParams' for | ||
-- why this is a separate field. | ||
, uppCostModelsFile :: !(Maybe (CostModelsFile era)) |
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.
This is the core of the PR: I'm adding a separate field for the cost models. Notice that CostmodelsFile
contains an AlonzoEraOnwards
witness.
pCostModelsFile :: ShelleyBasedEra era -> Parser (Maybe (Cmd.CostModelsFile era)) | ||
pCostModelsFile = | ||
caseShelleyToMaryOrAlonzoEraOnwards | ||
(const $ pure Nothing) | ||
(\alonzoOnwards -> fmap (fmap $ Cmd.CostModelsFile alonzoOnwards . File) . optional $ pCostModels (Just "new")) |
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.
This is the era-sensitive parser for the cost models file. Compare the golden files for the help texts of Alonzo and Mary, say.
cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs
Outdated
Show resolved
Hide resolved
cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs
Outdated
Show resolved
Hide resolved
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'm not so sure about prefixes to the CLI parameters - I'm leaving the final approval to the others. Otherwise, LGTM, good work!
0f3e1cb
to
4baa562
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.
A couple of comments
cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs
Outdated
Show resolved
Hide resolved
@@ -302,6 +320,26 @@ runGovernanceActionCreateProtocolParametersUpdateCmd eraBasedPParams' = do | |||
) | |||
sbe | |||
|
|||
addCostModelsToEraBasedProtocolParametersUpdate |
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 write a round trip property test for this.
4a81c6c
to
2e034e9
Compare
bf5523f
to
038547c
Compare
With #463 merged, we can now use the generators from |
"blake2b_224-cpu-arguments-slope": 1, | ||
"blake2b_224-memory-arguments": 1 | ||
} | ||
} |
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.
Where did this file come from?
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 made it, because I couldn't find a valid Plutus V3 cost model anywhere. There's no valid PlutusV3 cost model in the book, and the one in the one here (which @CarlosLopezDeLara pointed me to) doesn't deserialise. So I had a look here to find the right ordering of the parameters and then just set each of them to 1
.
For sure, this is sub-optimal.
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.
Nice. Ledger can support the "old" cost model style :) https://github.com/input-output-hk/cardano-ledger/pull/3367/files#diff-f481d9eb9f793235d9fc4a1965ec1e0a01bed313f90adb11dcd9aa099a4cd738R348
343754f
to
b8cd44a
Compare
The requested property tests are now implemented
cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels.json
Show resolved
Hide resolved
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.
Nice work 👍. This one looked a little finicky 😁.
cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs
Outdated
Show resolved
Hide resolved
"blake2b_224-cpu-arguments-slope": 1, | ||
"blake2b_224-memory-arguments": 1 | ||
} | ||
} |
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.
Nice. Ledger can support the "old" cost model style :) https://github.com/input-output-hk/cardano-ledger/pull/3367/files#diff-f481d9eb9f793235d9fc4a1965ec1e0a01bed313f90adb11dcd9aa099a4cd738R348
…pdate Use whole cost models in the roundtrip test
98e5fbe
to
0498486
Compare
Changelog
Context
This PR closes #386, by adding a
--new-cost-model-file
to thecardano-cli * governance action create-protocol-parameters-update
and thecardano-cli [legacy] governance create-update-proposal
commands. The option only appears from Alonzo era onwards.I also disambiguated the flags of these commands, because there was a collision:
--governance-action-deposit
is required for every governance action, and thus the name of the flag to specify a proposed change in that parameter has to have a different name. I chose let all flags for proposed changes have the format--new-*
.There is a test that the proposal is generated correctly in Conway era.
I couldn't find a validI couldn't find a valid Plutus V3 cost model anywhere. There's no PlutusV3 cost model in the book, and the one in the one here (which @CarlosLopezDeLara pointed me to) doesn't deserialise. So, I built my own V3 cost model to use as input for the tests: I had a look here to find the right ordering of the parameters and then just set each of them to 1.PlutusV3
cost model to add to my tests, though. So, the test currently only coversPlutusV1
andPlutusV2
. @CarlosLopezDeLara do you know where I could find such a thing?How to trust this PR
I realise this is a big diff, so I'll leave some pointers in separate comments below.
Checklist