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

Add Inject instances for Eons. Deprecate old eons conversion functions. #636

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

carbolymer
Copy link
Contributor

@carbolymer carbolymer commented Sep 13, 2024

Changelog

- description: |
    Deprecate eons conversion functions like `conwayEraOnwardsToBabbageEraOnwards`. Add [`Inject`](https://cardano-ledger.cardano.intersectmbo.org/cardano-ledger-core/Cardano-Ledger-BaseTypes.html#t:Inject) instances for eon conversions. See the PR description for migration aid.
# uncomment types applicable to the change:
  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
   - refactoring    # QoL changes
  # - 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

Use Inject for eons conversion instead of specialised and hard to remember functions.

You can migrate your codebase using this snippet:

find . -type f -name "*.hs" -exec sed -i \
  -e 's/allegraEraOnwardsToShelleyBasedEra/inject/g' \
  -e 's/alonzoEraOnwardsToShelleyBasedEra/inject/g' \
  -e 's/babbageEraOnwardsToShelleyBasedEra/inject/g' \
  -e 's/conwayEraOnwardsToShelleyBasedEra/inject/g' \
  -e 's/conwayEraOnwardsToBabbageEraOnwards/inject/g' \
  -e 's/maryEraOnwardsToShelleyBasedEra/inject/g' \
  -e 's/shelleyEraOnlyToShelleyBasedEra/inject/g' \
  -e 's/shelleyToAllegraEraToShelleyBasedEra/inject/g' \
  -e 's/shelleyToBabbageEraToShelleyBasedEra/inject/g' \
  -e 's/shelleyToMaryEraToShelleyBasedEra/inject/g' \
  -e 's/babbageEraOnwardsToEra/inject/g' \
  -e 's/eraToBabbageEraOnwards/inject/g' {} +

Corresponding CLI PR: IntersectMBO/cardano-cli#969

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

@carbolymer carbolymer force-pushed the mgalazyn/refactor/add-inject-instances branch 4 times, most recently from c2dee39 to 353db1b Compare September 13, 2024 08:13
@carbolymer carbolymer marked this pull request as ready for review September 13, 2024 08:14
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.

Nice QoL change 👍

cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs Outdated Show resolved Hide resolved
cardano-api/internal/Cardano/Api/Query/Expr.hs Outdated Show resolved Hide resolved
cardano-api/internal/Cardano/Api/Query/Expr.hs Outdated Show resolved Hide resolved
cardano-api/internal/Cardano/Api/Query/Expr.hs Outdated Show resolved Hide resolved
cardano-api/internal/Cardano/Api/Tx/Body.hs Outdated Show resolved Hide resolved
cardano-api/internal/Cardano/Api/Tx/Body.hs Outdated Show resolved Hide resolved
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.

We are adding an additional step to the deprecation of these era conversion functions where what we should be doing is figuring out how to change the interface then deprecating and eventually remove the functions. Creating Inject instances for them seems to be an additional unnecessary step.

@carbolymer
Copy link
Contributor Author

carbolymer commented Sep 16, 2024

@Jimbo4350 the goal of this PR is to make the codebase more pleasant to work with until we get rid of Eons. There's still significant amount of work left to do, before we arrive there.

I disagree that it adds an additional step in deprecation, I see Inject as a general purpose tool for total conversions from one to the another type. Those Inject instances would be gone together with Eons as well.

If you think this PR is changing too much, what do you think of just using inject in the glue code for experimental API. I mean the changes in cardano-api/internal/Cardano/Api/Experimental/Eras.hs ?

@carbolymer carbolymer force-pushed the mgalazyn/refactor/add-inject-instances branch 2 times, most recently from e12204a to 5d03c61 Compare November 14, 2024 21:29
@carbolymer carbolymer enabled auto-merge November 14, 2024 21:31
@carbolymer carbolymer force-pushed the mgalazyn/refactor/add-inject-instances branch from 5d03c61 to 2e81c81 Compare November 14, 2024 21:34
@carbolymer carbolymer added this pull request to the merge queue Nov 14, 2024
Merged via the queue into master with commit aa2a852 Nov 14, 2024
29 checks passed
@carbolymer carbolymer deleted the mgalazyn/refactor/add-inject-instances branch November 14, 2024 22:23
@carbolymer carbolymer mentioned this pull request Nov 14, 2024
2 tasks
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.

3 participants