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

Merge ShelleyLedgerEra and CardanoLedgerEra to a single type family LedgerEra #361

Closed
wants to merge 1 commit into from

Conversation

newhoggy
Copy link
Collaborator

@newhoggy newhoggy commented Nov 9, 2023

Changelog

- description: |
    Merge `ShelleyLedgerEra` and `CardanoLedgerEra` to a single type family `LedgerEra`
  type:
  # - feature        # introduces a new feature
  - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
  - improvement    # QoL changes e.g. refactoring
  # - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

We previously defined two separate type families ShelleyLedgerEra and CardanoLedgerEra but never use CardanoLedgerEra anywhere.

ShelleyLedgerEra is basically the same as CardanoLedgerEra except Byron is missing.

There is no reason to have two type families because CardanoLedgerEra works everywhere ShelleyLedgerEra currently does.

This PR merges the two type families into the one LedgerEra type family (which includes Byron) which shortens the commonly used name.

Doing this opens the possibility of unifying Byron with the other eras for the minimal set of operations we care to maintain for hard forking purposes.

How to trust this PR

Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behaviour, describe them.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

@newhoggy newhoggy marked this pull request as ready for review November 9, 2023 15:48
ShelleyLedgerEra MaryEra = Consensus.StandardMary
ShelleyLedgerEra AlonzoEra = Consensus.StandardAlonzo
ShelleyLedgerEra BabbageEra = Consensus.StandardBabbage
ShelleyLedgerEra ConwayEra = Consensus.StandardConway
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Delete this. Use LedgerEra instead.

LedgerEra MaryEra = L.MaryEra L.StandardCrypto
LedgerEra AlonzoEra = L.AlonzoEra L.StandardCrypto
LedgerEra BabbageEra = L.BabbageEra L.StandardCrypto
LedgerEra ConwayEra = L.ConwayEra L.StandardCrypto
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Rename CardanoLedgerEra which is never used to LedgerEra which we use everywhere in place of ShelleyLedgerEra.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the change is pretty harmless, but can you check if anything breaks in cardano-cli?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep. Already checked.

@newhoggy newhoggy force-pushed the newhoggy/ShelleyLedgerEra-related-refactoring branch from 22599ef to 2c209ce Compare November 10, 2023 07:49
Copy link
Contributor

@smelc smelc left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@newhoggy newhoggy added this pull request to the merge queue Nov 10, 2023
@Jimbo4350 Jimbo4350 removed this pull request from the merge queue due to a manual request Nov 10, 2023
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

This is not the direction we are taking cardano-api in. We do not care about all the eras, only mainnet and the upcoming era. The first step in this is to factor out the Byron era and only be concerned with shelley based eras. Consolidating the shelley based eras with cardano eras is moving in the wrong direction and prolongs this eventual separation.

@newhoggy
Copy link
Collaborator Author

newhoggy commented Nov 11, 2023

It's worth noting that this PR doesn't commit us to a particular direction. On it's own it serves as a straightforward simplification. with the only impact on the rest of the code being a rename to a shorter one and removing a type we don't use anywhere.

@newhoggy newhoggy force-pushed the newhoggy/ShelleyLedgerEra-related-refactoring branch from 2c209ce to 7f48bfa Compare November 16, 2023 10:19
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

This is an unnecessary change. It is also incorrect because it implies the existence of types in Byron that do no exist. We will be able to simply things further after the Byron related code is isolated.

@newhoggy
Copy link
Collaborator Author

What type is Byron type is being implied that doesn't exist?

@newhoggy newhoggy closed this Nov 16, 2023
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.

4 participants