Skip to content

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

Closed
@lehins

Description

@lehins

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

Metadata

Metadata

Assignees

Labels

💳 technical-debtIssues related to technical debt we introduced

Type

Projects

Status

Done

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions