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

Babbage / Conway PParams JSON serialization #3953

Merged
merged 8 commits into from
Dec 22, 2023
Merged

Conversation

ch1bo
Copy link
Contributor

@ch1bo ch1bo commented Dec 21, 2023

Description

This adds JSON deserialization for Babbage and Conway PParams and is an extension of #3949.

  • Creates Test.Cardano.Ledger.Core.JSON with a ToJSON -> FromJSON roundtrip

  • Fixes the ToJSON instance of BabbagePParams which was missing a protocolVersion

  • Adds JSON roundtrip tests to Alonzo, Babbage and Conway PParams.

  • Adds protocolVersion also to Conway PParams serialization.

  • Updated the golden genesis-conway.json as FromJSON instances are non-derived now and match the ToJSON instances for PoolVotingThresholds and DRepVotingThresholds

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
  • When applicable, versions are updated in .cabal and CHANGELOG.md files according to the
    versioning process.
  • The version bounds in .cabal files for all affected packages are updated. If you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)
  • All visible changes are prepended to the latest section of a CHANGELOG.md for the affected packages. New section is never added with the code changes. (See RELEASING.md)
  • Code is formatted with fourmolu (use scripts/fourmolize.sh)
  • Cabal files are formatted (use scripts/cabal-format.sh)
  • hie.yaml has been updated (use scripts/gen-hie.sh)
  • Self-reviewed the diff

@ch1bo ch1bo requested a review from lehins December 21, 2023 15:45
@ch1bo ch1bo force-pushed the babbage-pparams-json branch 3 times, most recently from a48ec37 to 140a523 Compare December 21, 2023 16:31
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be nice to add to Babbage changelog that protocolVersion issue is fixed.

Two issues on CI:

Golden test for ConwayGenesis

The conway-genesis.json need to change, since FromJSON was wrongfully derived for threasholds and you fixed it in the code (thank you!):

{
  "poolVotingThresholds": {
-    "pvtCommitteeNormal": 0,
-    "pvtCommitteeNoConfidence": 0,
-    "pvtHardForkInitiation": 0,
-    "pvtMotionNoConfidence": 0
+    "committeeNormal": 0,
+    "committeeNoConfidence": 0,
+    "hardForkInitiation": 0,
+    "motionNoConfidence": 0
  },
  "dRepVotingThresholds": {
-    "dvtMotionNoConfidence": 0,
-    "dvtCommitteeNormal": 0,
-    "dvtCommitteeNoConfidence": 0,
-    "dvtUpdateToConstitution": 0,
-    "dvtHardForkInitiation": 0,
-    "dvtPPNetworkGroup": 0,
-    "dvtPPEconomicGroup": 0,
-    "dvtPPTechnicalGroup": 0,
-    "dvtPPGovGroup": 0,
-    "dvtTreasuryWithdrawal": 0
+    "motionNoConfidence": 0,
+    "committeeNormal": 0,
+    "committeeNoConfidence": 0,
+    "updateToConstitution": 0,
+    "hardForkInitiation": 0,
+    "ppNetworkGroup": 0,
+    "ppEconomicGroup": 0,
+    "ppTechnicalGroup": 0,
+    "ppGovGroup": 0,
+    "treasuryWithdrawal": 0
  },

CostModels in PParams

We need to adjust how we deal with problematic CostModels, since currently they do not roundtrip. I have an idea on what we can do about this, so I'll submit a separate PR that fixes that.

@ch1bo
Copy link
Contributor Author

ch1bo commented Dec 22, 2023

@lehins Fixed the golden genesis-conway file and added changelog entries. I also disabled the Conway PParams JSON roundtrip tests as I do understand that you will fix the that in another PR.

@ch1bo ch1bo requested a review from lehins December 22, 2023 10:24
ch1bo and others added 8 commits December 22, 2023 11:33
This will also be useful to test other JSON roundtrips.
This also adds a JSON PParams roundtrip test for Alonzo.
When adding a FromJSON for Conway PParams and testing the roundtrip, it
turned out that the JSON instances were not aligned correctly.
This fixes most of the roundtrips for Conway PParams, but seemingly
something changed on the cost models still.
Co-authored-by: Alexey Kuleshevich <alexey.kuleshevich@iohk.io>
This was using the field names from the haskell type and are fixed now
to be roundtripping without the prefixes.
The serialization of included cost models is problematic.
@lehins lehins force-pushed the babbage-pparams-json branch from 9e70706 to 1bad44d Compare December 22, 2023 10:33
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's perfect. Thank you!

@lehins lehins merged commit 94efc6b into master Dec 22, 2023
10 of 27 checks passed
@neilmayhew neilmayhew deleted the babbage-pparams-json branch March 8, 2024 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants