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

Update experimental api and propagate #604

Merged
merged 7 commits into from
Aug 23, 2024

Conversation

Jimbo4350
Copy link
Contributor

@Jimbo4350 Jimbo4350 commented Jul 31, 2024

Changelog

- description: |
    Introduce new `newtype UnsignedTx` type which aims to eventually replace `data TxBody`
    Introduce new `data Era` type which reduces the number of eras cardano-api exposes. It is only concerned with mainnet and the upcoming era
    Update experimental api and propagate 
    `BalancedTxBody` now returns `UnsignedTx` which is a wrapped cardano-ledger `Tx`. 
# 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

Additional context for the PR goes here. If the PR fixes a particular issue please provide a link to the issue.

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 behavior, 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

@Jimbo4350 Jimbo4350 force-pushed the jordan/adjust-new-api-and-propagate-to-tx branch 8 times, most recently from b0c6dd0 to d943abd Compare July 31, 2024 14:20
@Jimbo4350 Jimbo4350 marked this pull request as ready for review July 31, 2024 14:21
Copy link
Contributor

@carbolymer carbolymer left a comment

Choose a reason for hiding this comment

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

Blocking to have more time to review. I'd like to to play with it a bit.

@Jimbo4350 Jimbo4350 force-pushed the jordan/adjust-new-api-and-propagate-to-tx branch 3 times, most recently from da2fbe0 to e242232 Compare August 2, 2024 10:30
cardano-api/internal/Cardano/Api/Experimental/Eras.hs Outdated Show resolved Hide resolved
Comment on lines 45 to 47
data BabbageEra

data ConwayEra
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not reuse uninhabited types from Cardano.Api.Eras.Core? They're uninhabited types as well these, so they're not very useful on their own nor they are related to each other.

We could reexport them here for convenience.

Or the other way around, define them here, and reexport in old Api (might require moving to another module).
I think reusing type level tags will be much cleaner than introducing additional type families.

Copy link
Contributor Author

@Jimbo4350 Jimbo4350 Aug 9, 2024

Choose a reason for hiding this comment

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

I don't want to do this to avoid confusion with the api we are deprecating. I want to keep the types separate.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same concern as @carbolymer 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think reusing type level tags will be much cleaner than introducing additional type families.

How will this avoid introducing additional type families?

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that my comment was unrelated to the need/avoidance for additional type families. I'm concerned by symbols having the exact same name, that are going to be disambiguated with different imports; and I suspect this will confuse both us and users (even more for the latter).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking about it some more I agree. We can re-use the types.

Comment on lines 51 to 63
type family AvailableErasToSbe era = (r :: Type) | r -> era where
AvailableErasToSbe BabbageEra = Api.BabbageEra
AvailableErasToSbe ConwayEra = Api.ConwayEra
Copy link
Contributor

Choose a reason for hiding this comment

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

The type on the right hand side isn't really ShelleyBasedEra but just type level tag. I'd drop the Sbe part. For example:

Suggested change
type family AvailableErasToSbe era = (r :: Type) | r -> era where
AvailableErasToSbe BabbageEra = Api.BabbageEra
AvailableErasToSbe ConwayEra = Api.ConwayEra
type family FromExperimentalApiEra era = (r :: Type) | r -> era where
FromExperimentalApiEra BabbageEra = Api.BabbageEra
FromExperimentalApiEra ConwayEra = Api.ConwayEra

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 59 to 71
type family ToConstrainedLedgerEra era = (r :: Type) | r -> era where
ToConstrainedLedgerEra BabbageEra = Ledger.Babbage
ToConstrainedLedgerEra ConwayEra = Ledger.Conway
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the naming here. Maybe something more obvious:

Suggested change
type family ToConstrainedLedgerEra era = (r :: Type) | r -> era where
ToConstrainedLedgerEra BabbageEra = Ledger.Babbage
ToConstrainedLedgerEra ConwayEra = Ledger.Conway
type family LedgerEra era = (r :: Type) | r -> era where
LedgerEra BabbageEra = Ledger.Babbage
LedgerEra ConwayEra = Ledger.Conway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cardano-api/internal/Cardano/Api/Experimental/Eras.hs Outdated Show resolved Hide resolved
cardano-api/internal/Cardano/Api/Experimental/Eras.hs Outdated Show resolved Hide resolved
cardano-api/internal/Cardano/Api/Experimental/Tx.hs Outdated Show resolved Hide resolved
cardano-api/internal/Cardano/Api/Experimental/Tx.hs Outdated Show resolved Hide resolved
cardano-api/internal/Cardano/Api/Experimental/Eras.hs Outdated Show resolved Hide resolved
@Jimbo4350 Jimbo4350 force-pushed the jordan/adjust-new-api-and-propagate-to-tx branch from e242232 to 5f4f93a Compare August 12, 2024 16:48
@Jimbo4350 Jimbo4350 force-pushed the jordan/adjust-new-api-and-propagate-to-tx branch 2 times, most recently from db22ace to 2fe093e Compare August 22, 2024 18:03
This module exposes a new api for accessible cardano eras.
It focuses on the current mainnet era and the upcoming era if there is
one. It differs from the previous api in that it does not concern
itself with any era prior to what is currently on mainnet.
Deprecated Shelley era to Alonzo era in makeTransactionBodyAutoBalance
This module introduces the UnsignedTx type. This is meant to replace
cardano-api's TxBody type
UnsignedTx type has the benefit of being a thin wrapper around the
ledger's Tx type which allows us to easily leverage the lenses and type
classes exposed by ledger
Moving to this type also reduces the maintenance burden of cardano-api
as we will eventually deprecate the TxBody type
@Jimbo4350 Jimbo4350 force-pushed the jordan/adjust-new-api-and-propagate-to-tx branch from 2fe093e to 09b9d3c Compare August 23, 2024 15:14
@Jimbo4350 Jimbo4350 added this pull request to the merge queue Aug 23, 2024
Merged via the queue into main with commit 323f576 Aug 23, 2024
26 checks passed
@Jimbo4350 Jimbo4350 deleted the jordan/adjust-new-api-and-propagate-to-tx branch August 23, 2024 15:37
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