Skip to content

Remove ConwayNewEpochPredFailure #5007

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

Merged
merged 3 commits into from
May 16, 2025

Conversation

aniketd
Copy link
Contributor

@aniketd aniketd commented Apr 23, 2025

Description

Closes #4662

Checklist

  • Commits in meaningful sequence and with useful messages.
  • Tests added or updated when needed.
  • CHANGELOG.md files updated for packages with externally visible changes.
    NOTE: New section is never added with the code changes. (See RELEASING.md).
  • Versions updated in .cabal and CHANGELOG.md files when necessary, according to the
    versioning process.
  • Version bounds in .cabal files updated when necessary.
    NOTE: If bounds change in a cabal file, that package itself must have a version increase. (See RELEASING.md).
  • Code formatted (use scripts/fourmolize.sh).
  • Cabal files formatted (use scripts/cabal-format.sh).
  • CDDL files are up to date (use scripts/gen-cddl.sh)
  • hie.yaml updated (use scripts/gen-hie.sh).
  • Self-reviewed the diff.

@aniketd aniketd requested a review from a team as a code owner April 23, 2025 14:56
@aniketd aniketd force-pushed the aniketd/remove-conwaynewepochpredfailure branch from 697448d to e1e3b92 Compare April 23, 2025 15:00
@Soupstraw
Copy link
Contributor

Soupstraw commented Apr 24, 2025

I guess you can turn that check into an assertion, that way we'll be able to notice if something's wrong with the reward update in one of our tests. It seems like too expensive of a check to keep it in the production version of ledger and run it every epoch boundary.

Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

Removal itself looks good, but it would be nice not to loose the invariant check, so STS assertion seems like the most logical choice.

Also, could you please apply all of the exact same changes to the Shelley NEWEPOCH rule. It suffers from all the same problems.

@aniketd aniketd force-pushed the aniketd/remove-conwaynewepochpredfailure branch 2 times, most recently from 8afcdd3 to 6c32856 Compare May 2, 2025 14:55
@aniketd aniketd requested a review from lehins May 2, 2025 14:55
@aniketd aniketd force-pushed the aniketd/remove-conwaynewepochpredfailure branch from 6c32856 to c0bf2ca Compare May 2, 2025 14:56
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

STS Assertion is not the same as assert provided by GHC

@aniketd aniketd force-pushed the aniketd/remove-conwaynewepochpredfailure branch from c0bf2ca to aca97f2 Compare May 7, 2025 14:54
@aniketd aniketd requested a review from lehins May 8, 2025 11:24
Copy link
Collaborator

@lehins lehins 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 definitely unacceptable.
Test values have no business being used in production code. Not ever!

@aniketd aniketd force-pushed the aniketd/remove-conwaynewepochpredfailure branch 2 times, most recently from 003d1be to c8b89a0 Compare May 12, 2025 11:11
@aniketd aniketd requested a review from lehins May 12, 2025 11:38
@lehins lehins force-pushed the aniketd/remove-conwaynewepochpredfailure branch from c8b89a0 to ba80316 Compare May 14, 2025 15:46
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

Beautiful! Thank you!

@lehins
Copy link
Collaborator

lehins commented May 15, 2025

FYI the test failure that you see on CI in cardano-ledger-shelley-test could have been avoided if we had an STS assertion instead. In any case, it is a poorly written test anyways, since it starts with a totally arbitrary NewEpochState and it only executed for Shelley. Feel free to remove this test, I've created a ticket to bring it back with a more reasonable approach: #5047

@aniketd
Copy link
Contributor Author

aniketd commented May 15, 2025

I guess you can turn that check into an assertion, that way we'll be able to notice if something's wrong with the reward update in one of our tests.

@Soupstraw @lehins reverting the blooper of the STS assertion to a GHC assert does indeed reveal in cabal test cardano-ledger-shelley-test --test-options '-p TICKF' that the assert is triggered. This failure was earlier being discarded by the test, which it cannot now, because I turned it into an exception.

-- | This property test checks the correctness of the TICKF transation.
-- TICKF is used by the consensus layer to get a ledger view in a computationally
-- cheaper way than using the TICK rule.
-- Therefore TICKF and TICK need to compute the same ledger view.
propTickfPerservesLedgerView :: NewEpochState ShelleyEra -> Property
propTickfPerservesLedgerView nes =
  let (EpochNo e) = nesEL nes
      slot = slotFromEpoch (EpochNo $ e + 1)
      nes' = setDepositsToObligation (filterEmptyRewards nes)
      tickNes = runShelleyBase $ applySTSTest @(ShelleyTICK ShelleyEra) (TRC ((), nes', slot))
      tickFNes = runShelleyBase $ applySTSTest @(ShelleyTICKF ShelleyEra) (TRC ((), nes', slot))
   in fromMaybe discard $ do
        Right tickNes' <- pure tickNes
        Right tickFNes' <- pure tickFNes
        pure $ currentLedgerView tickNes' === currentLedgerView tickFNes'

testTickF :: TestTree
testTickF = testProperty "TICKF properties" propTickfPerservesLedgerView

I think that the removal of this predicate failure is dependent on refactoring of the pulser. What do you guys think? Is there another way?


I didn't see your comment earlier @lehins. 👍

@aniketd aniketd force-pushed the aniketd/remove-conwaynewepochpredfailure branch from ba80316 to edf0098 Compare May 15, 2025 12:39
aniketd and others added 3 commits May 16, 2025 15:45
Replace the corresponding check with an assertion.
Replace the corresponding check with an assertion.
@aniketd aniketd force-pushed the aniketd/remove-conwaynewepochpredfailure branch from edf0098 to 5a93279 Compare May 16, 2025 10:15
@lehins lehins merged commit d351b26 into master May 16, 2025
125 of 262 checks passed
@lehins lehins deleted the aniketd/remove-conwaynewepochpredfailure branch May 16, 2025 11:32
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.

Remove ConwayNewEpochPredFailure
3 participants