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

Isolation of Byron era 1/n #362

Merged
merged 8 commits into from
Nov 15, 2023
Merged

Isolation of Byron era 1/n #362

merged 8 commits into from
Nov 15, 2023

Conversation

Jimbo4350
Copy link
Contributor

@Jimbo4350 Jimbo4350 commented Nov 9, 2023

Changelog

- description: |
    Isolation of Byron era 1/n. Changes made to cardano-api where Byron era was never being called in the first place.
# 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
  # - 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

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

@@ -2010,8 +2009,11 @@ createAndValidateTransactionBody :: ()
=> CardanoEra era
-> TxBodyContent BuildTx era
-> Either TxBodyError (TxBody era)
createAndValidateTransactionBody =
caseByronOrShelleyBasedEra makeByronTransactionBody makeShelleyTransactionBody
createAndValidateTransactionBody era txBodyContent =
Copy link
Contributor Author

@Jimbo4350 Jimbo4350 Nov 9, 2023

Choose a reason for hiding this comment

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

This is just a stop gap. We would have a separate function for Byron basic txs and parameterize createAndValidateTransactionBody on ShelleyBasedEra era instead.

@@ -69,8 +69,7 @@ data TxInMode where
-- delegation certs.
--
TxInByronSpecial
:: ByronEraOnly era
-> Consensus.GenTx Consensus.ByronBlock
:: Consensus.GenTx Consensus.ByronBlock
Copy link
Contributor Author

@Jimbo4350 Jimbo4350 Nov 9, 2023

Choose a reason for hiding this comment

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

The evidence is no longer necessary. We are already constructing Consensus.GenTx Consensus.ByronBlock

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 think it was necessary in the first place, but it was a matter of convenience. Before you could write

eon <- forEraMaybeEon
pure $ TxInByronSpecial eon foo

and after the change:

_ :: ByronEraOnly <- forEarMaybeEon
pure $ TxInByronSpecial foo

so now you need to say twice that you're in byron.

Copy link
Contributor Author

@Jimbo4350 Jimbo4350 Nov 15, 2023

Choose a reason for hiding this comment

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

Can you show me where you now have to say twice that we are in Byron? This is only called in Byron specific code in the cli.

Copy link
Contributor

Choose a reason for hiding this comment

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

In the current usages you don't have to, because byron was hardcoded everywhere. My remark was about general usage, where you could create an era-specific value, mentioning era just once: in the value constructor.
If we're going to isolate and hardcode byron code, I guess it won't matter much.

@@ -27,27 +27,27 @@ prop_json_roundtrip_alonzo_genesis = H.property $ do

prop_json_roundtrip_utxo :: Property
prop_json_roundtrip_utxo = H.property $ do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are only calling Babbage.

@Jimbo4350 Jimbo4350 force-pushed the jordan/basic-tx branch 2 times, most recently from a81c5f9 to 6492b07 Compare November 10, 2023 17:48
@Jimbo4350 Jimbo4350 changed the title Jordan/basic tx Separation of Byron era 1/n Nov 10, 2023
@Jimbo4350 Jimbo4350 changed the title Separation of Byron era 1/n Isolation of Byron era 1/n Nov 10, 2023
@Jimbo4350 Jimbo4350 marked this pull request as ready for review November 10, 2023 20:23
Update FromJSON (TxOutValue era) to be constrained by IsShelleyBasedEra era
Parameterize lovelaceToTxOutValue on ShelleyBasedEra era instead of
CardanoEra era
…lly makeTransactionBodyAutoBalance

Note makeTransactionBodyAutoBalance accepts ShelleyBasedEra era and not
CardanoEra era
@@ -711,12 +710,46 @@ genTxTotalCollateral =
genTxFee :: CardanoEra era -> Gen (TxFee era)
genTxFee =
caseByronOrShelleyBasedEra
(pure . TxFeeImplicit)
undefined -- (pure . TxFeeImplicit)
Copy link
Contributor

@carbolymer carbolymer Nov 15, 2023

Choose a reason for hiding this comment

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

a comment explaining why someone sees an exception from here would be nice

Copy link
Contributor

@carbolymer carbolymer Nov 15, 2023

Choose a reason for hiding this comment

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

or maybe something like error "not supported" would be better here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a mistake

@@ -30,21 +30,21 @@ import Test.Tasty.Hedgehog (testProperty)

prop_roundtrip_txbody_CBOR :: Property
prop_roundtrip_txbody_CBOR = H.property $ do
AnyCardanoEra era <- H.forAll $ Gen.element [minBound..AnyCardanoEra BabbageEra]
AnyShelleyBasedEra era <- H.forAll $ Gen.element [minBound..maxBound]
Copy link
Contributor

@carbolymer carbolymer Nov 15, 2023

Choose a reason for hiding this comment

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

Nice! I wonder why it was only until babbage before

@Jimbo4350 Jimbo4350 added this pull request to the merge queue Nov 15, 2023
Merged via the queue into main with commit afa7d7c Nov 15, 2023
20 checks passed
@Jimbo4350 Jimbo4350 deleted the jordan/basic-tx branch November 15, 2023 13:35
@@ -838,8 +840,7 @@ deriving instance Show (TxInsReference build era)
data TxOutValue era where

TxOutValueByron
:: ByronEraOnly era
-> Lovelace
:: Lovelace
Copy link
Collaborator

@newhoggy newhoggy Nov 16, 2023

Choose a reason for hiding this comment

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

If we're going the path of pushing Byron to legacy status and have it separate we should move this constructor to its own type and then to a Byron-specific legacy module so users of our API never have to see/worry/handle it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely. This is my eventual goal but I'm doing it in small chunks.

newhoggy pushed a commit that referenced this pull request Mar 11, 2024
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