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

Test that UTxO tables are updated correctly on era transitions #4073

Merged
merged 11 commits into from
Nov 2, 2022

Conversation

bartfrenk
Copy link
Contributor

@bartfrenk bartfrenk commented Oct 13, 2022

Description

Test that UTxO tables are computed correctly on era transitions, for all era transitions.

Closes #4043.

Checklist

  • Branch
    • Commit sequence broadly makes sense
    • Commits have useful messages
    • New tests are added if needed and existing tests are updated
  • Pull Request
    • Self-reviewed the diff
    • Useful pull request description at least containing the following information:
      • What does this PR change?
      • Why these changes were needed?
      • How does this affect downstream repositories and/or end-users?
      • Which ticket does this PR close (if any)? If it does, is it linked?
    • Reviewer requested

@bartfrenk bartfrenk changed the base branch from master to feature/utxo-hd October 13, 2022 08:18
Copy link
Member

@dnadales dnadales left a comment

Choose a reason for hiding this comment

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

Looks good so far.

(fixedEpochInfo (sgEpochLength shelleyGenesis) tpraosSlotLength)
(MaxMajorProtVer 1000)

shelleyGenesis :: ShelleyGenesis era
Copy link
Member

Choose a reason for hiding this comment

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

If we use a fixed Shelley genesis we should justify why. I think in this case the justification might be that we are interested in the initial UTxO set, which is not affected by the genesis config. But we need to confirm this.

@bartfrenk bartfrenk force-pushed the bartfrenk/4043/era-transition-tests branch 2 times, most recently from aa80b45 to 12effd8 Compare October 18, 2022 15:01
@bartfrenk bartfrenk force-pushed the bartfrenk/4043/era-transition-tests branch from 2f08815 to 280e92c Compare October 19, 2022 10:21
@bartfrenk bartfrenk requested a review from jasagredo October 19, 2022 10:29
@bartfrenk bartfrenk marked this pull request as ready for review October 19, 2022 10:30
tests = testGroup "UpdateTablesOnEraTransition" $ toTestTrees predicates tls
where
tls = translateLedgerState hardForkEraTranslation
predicates :: InPairs TranslationPredicate (CardanoEras Crypto)
Copy link
Member

Choose a reason for hiding this comment

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

Why not define a [TestTree] directly? Is toTestTrees necessary?

Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect this can be indeed reshaped to just define a [TestTree] and avoid having to re-zip the InPairss. Was there a specific reason to not do so?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I couldn't do 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.

To define the properties I need to have access to the appropriate TranslateEra x y values. I chose the direction of zipping the predicates with what is loosely, InPairs TranslateEra (CardanoEras c).

Copy link
Member

Choose a reason for hiding this comment

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

What do you guys think about b762d98

@bartfrenk feel free to discard this commit and force push if you prefer to keep toTestTree.

If the commit above makes sense, we should probably address this:

-- | TODO: we should simply expose 'translateLedgerStateByronToShelleyWrapper'
-- and other translations in ' Ouroboros.Consensus.Cardano.CanHardFork'.

If we discard this commit we should remove the "boom" string and use a more appropriate label.

, Show (LedgerConfig dest)
, Show (LedgerState src EmptyMK)) => Show (TestSetup src dest)

-- todo: Useful to merge some of these instances?
Copy link
Member

Choose a reason for hiding this comment

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

I don't see how we could merge the Byron to Shelley instances. I'm not sure about the others. Do you know what prevents us from defining a:

instance Arbitrary (TestSetup (ShelleyBlock p era0) (ShelleyBlock p era1))

Copy link
Contributor

Choose a reason for hiding this comment

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

Even further

instance Arbitrary (TestSetup (ShelleyBlock p (PreviousEra era)) (ShelleyBlock p era))

Although the protos don't need to be equal...

@dnadales
Copy link
Member

dnadales commented Oct 20, 2022

I forgot to add these remaining tasks:

  • Add to the AddingAnEra.md document instructions to add a new era translation test when adding a new era.
  • Use quickcheck's cover to check that we're testing important cases.

Copy link
Contributor

@jasagredo jasagredo left a comment

Choose a reason for hiding this comment

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

Looks good overall! I would do some cosmetic changes as proposed but overall it looks nice

Constraints
-------------------------------------------------------------------------------}

type family AllPairs
Copy link
Contributor

Choose a reason for hiding this comment

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

I always have trouble deciding if these should be classes or closed type families...

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 is adapted from Maguire's Thinking with types. I can kind-of see how to do it with classes, but I like the terseness of this definition, and I think, but do not know, the class-one will be more convoluted.

, Show (LedgerConfig dest)
, Show (LedgerState src EmptyMK)) => Show (TestSetup src dest)

-- todo: Useful to merge some of these instances?
Copy link
Contributor

Choose a reason for hiding this comment

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

Even further

instance Arbitrary (TestSetup (ShelleyBlock p (PreviousEra era)) (ShelleyBlock p era))

Although the protos don't need to be equal...

tests = testGroup "UpdateTablesOnEraTransition" $ toTestTrees predicates tls
where
tls = translateLedgerState hardForkEraTranslation
predicates :: InPairs TranslationPredicate (CardanoEras Crypto)
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect this can be indeed reshaped to just define a [TestTree] and avoid having to re-zip the InPairss. Was there a specific reason to not do so?

@bartfrenk
Copy link
Contributor Author

bors r+

iohk-bors bot added a commit that referenced this pull request Oct 26, 2022
4073: Test that UTxO tables are updated correctly on era transitions r=bartfrenk a=bartfrenk

# Description

Test that UTxO tables are computed correctly on era transitions, for all era transitions.

Closes #4043.



Co-authored-by: Bart Frenk <bart.frenk@gmail.com>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 26, 2022

Timed out.

@bartfrenk
Copy link
Contributor Author

bors r+

iohk-bors bot added a commit that referenced this pull request Oct 26, 2022
4073: Test that UTxO tables are updated correctly on era transitions r=bartfrenk a=bartfrenk

# Description

Test that UTxO tables are computed correctly on era transitions, for all era transitions.

Closes #4043.



Co-authored-by: Bart Frenk <bart.frenk@gmail.com>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 26, 2022

Timed out.

@dnadales
Copy link
Member

We should also test with empty UTxO, shouldn't we?

      +++ OK, passed 100 tests (100% UTxO set is not empty).

It seems we aren't at the moment.

@dnadales dnadales merged commit ac3ff43 into feature/utxo-hd Nov 2, 2022
@iohk-bors iohk-bors bot deleted the bartfrenk/4043/era-transition-tests branch November 2, 2022 11:00
jasagredo pushed a commit that referenced this pull request Nov 17, 2022
Co-authored-by: Damian Nadales <damian.only@gmail.com>
jasagredo pushed a commit that referenced this pull request Dec 2, 2022
Co-authored-by: Damian Nadales <damian.only@gmail.com>
jasagredo pushed a commit that referenced this pull request Dec 2, 2022
Co-authored-by: Damian Nadales <damian.only@gmail.com>
jasagredo pushed a commit that referenced this pull request Jan 18, 2023
Co-authored-by: Damian Nadales <damian.only@gmail.com>
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.

Cardano eras transitions tests
3 participants