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

Convert CertState to a type family #4861

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

Lucsanszky
Copy link
Contributor

@Lucsanszky Lucsanszky commented Jan 30, 2025

Description

Checklist

  • Commits in meaningful sequence and with useful messages
  • Tests added or updated when needed
  • CHANGELOG.md files updated for packages with externally visible changes

    New section is never added with the code changes. (See RELEASING.md)
  • Versions updated in .cabal and CHANGELOG.md files when necessary, according to the
    versioning process.
  • Version bounds in .cabal files updated when necessary

    If you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)
  • Code formatted (use scripts/fourmolize.sh)
  • Cabal files formatted (use scripts/cabal-format.sh)
  • hie.yaml updated (use scripts/gen-hie.sh)
  • Self-reviewed the diff

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 did a quick skim over the PR and it looks awesome.
There is one important point that I made that will need to be address that has to do with a common issue of changes getting lost during rebasing, but that shouldn't be too hard.
I'll do a proper review once the PR is out of the Draft state.

where
type CertState era = (r :: Type) | r -> era

mkCertState :: VState era -> PState era -> DState era -> CertState era
Copy link
Collaborator

Choose a reason for hiding this comment

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

For this PR this is totally fine, but just heads up for the future adjustments that we'll need to make we won't be able to construct it like that because VState will not be available.

This isn't really a problem since we can always construct it from an empty CertState, eg:

mkShelleyCertState pState dState = 
  def & certPStateL .~ pState
      & certDStateL .~ dState
mkConwayCertState pState dState vState = 
  mkConwayCertState pState dState & certVStateL .~ vState

Moreover in ledger rules we can always get away with modifying CertState, instead of constructing a new one.

Again, for this PR it will be fine to keep it as is, I am just giving you a heads up for the follow up work that we'll have to do.

eras/shelley/impl/src/Cardano/Ledger/Shelley/CertState.hs Outdated Show resolved Hide resolved
eras/alonzo/impl/cardano-ledger-alonzo.cabal Show resolved Hide resolved
eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Translation.hs Outdated Show resolved Hide resolved
eras/mary/impl/src/Cardano/Ledger/Mary/Translation.hs Outdated Show resolved Hide resolved
@Lucsanszky Lucsanszky force-pushed the ldan/certstate-type-family branch 22 times, most recently from 6abc35a to ea8e6b9 Compare February 14, 2025 23:15
@Lucsanszky Lucsanszky force-pushed the ldan/certstate-type-family branch from ea8e6b9 to dc553dd Compare February 15, 2025 01:29
@Lucsanszky Lucsanszky marked this pull request as ready for review February 15, 2025 01:42
@Lucsanszky Lucsanszky requested a review from a team as a code owner February 15, 2025 01:42
@Lucsanszky
Copy link
Contributor Author

Finally, this is now ready for review. I opted not to detail every little change in the changelogs but rather indicate the affected packages that CertState was converted to a type family.

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