Skip to content

Move definitions for all eras into a special place in cardano-ledger-core #5069

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

Closed
lehins opened this issue May 21, 2025 · 0 comments · Fixed by #5089
Closed

Move definitions for all eras into a special place in cardano-ledger-core #5069

lehins opened this issue May 21, 2025 · 0 comments · Fixed by #5089
Assignees
Labels
💳 technical-debt Issues related to technical debt we introduced

Comments

@lehins
Copy link
Collaborator

lehins commented May 21, 2025

There is at least one limitation in GHC which requires to have access to the era type before the era type is actually defined, namely for definition of COMPLETE pragmas for native scripts and certificates (see #4613)

The only solution I can think of is to move all definitions of ShelleyEra, AllegraEra, ... to cardano-ledger-core. That, however is quite dangerous, because:

  • it would allow creation of instances for era types in era packages that preceded such era, eg. it would make it possible to create an instance TranslateEra AllegraEra DState in cardano-ledger-shelley package.
  • it would allow for orphan instances to leak into the outside world. Today we protect such leakage through exporting era type together with all the relevant instances, despite that they were defined as orphans.

For these reasons we need to stash those definitions in a special place and allow access to them only under extreme circumstances. There is no automated mechanism that would provide such protection for us, so we'll need to:

  • Put them into a new internal sub-library in the cardano-ledger-core:internal:Cardano.Ledger.Internal.Era module, thus describing the internal nature.
  • Provide explicit and clear documentation for Ledger team developers that warns them about the dangers that come from direct access to those types from the internal location.
  • Provide explicit documentation that forbids usage of this internal sub-library for external developers, There is never a reason for any external package to directly import those definitions from the internal sub-library, since they will still be available from their respective modules where they are exported from today, namely Cardano.Ledger.[Era] module.
  • Enforce restricted access to this sub library in PR reviews
@lehins lehins added the 💳 technical-debt Issues related to technical debt we introduced label May 21, 2025
Lucsanszky added a commit that referenced this issue May 31, 2025
Move era definitions to `core:internal`

Resolves #5069
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💳 technical-debt Issues related to technical debt we introduced
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants