Skip to content

cardano-testnet | Remove old era casing functions#6551

Open
carbolymer wants to merge 1 commit intomasterfrom
mgalazyn/refactor/testnet-remove-old-witness-conjuring
Open

cardano-testnet | Remove old era casing functions#6551
carbolymer wants to merge 1 commit intomasterfrom
mgalazyn/refactor/testnet-remove-old-witness-conjuring

Conversation

@carbolymer
Copy link
Copy Markdown
Contributor

@carbolymer carbolymer commented Apr 24, 2026

Description

cardano-testnet | Remove old era casing functions

Requires:

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. These may include:
    • golden tests
    • property tests
    • roundtrip tests
    • integration tests
      See Running tests for more details
  • Any changes are noted in the CHANGELOG.md for affected package
  • The version bounds in .cabal files are updated
  • CI passes. See note on CI. The following CI checks are required:
    • Code is linted with hlint. See .github/workflows/check-hlint.yml to get the hlint version
    • Code is formatted with stylish-haskell. See .github/workflows/stylish-haskell.yml to get the stylish-haskell version
    • Code builds on Linux, MacOS and Windows for ghc-9.6 and ghc-9.12
  • Self-reviewed the diff

Note on CI

If your PR is from a fork, the necessary CI jobs won't trigger automatically for security reasons.
You will need to get someone with write privileges. Please contact IOG node developers to do this
for you.

@carbolymer carbolymer requested a review from a team as a code owner April 24, 2026 09:30
@carbolymer carbolymer self-assigned this Apr 24, 2026
@carbolymer carbolymer force-pushed the mgalazyn/refactor/testnet-remove-old-witness-conjuring branch 2 times, most recently from 9a4ef15 to 2742da4 Compare April 24, 2026 10:15
@carbolymer carbolymer force-pushed the mgalazyn/refactor/testnet-remove-old-witness-conjuring branch from 2742da4 to cc230e1 Compare April 24, 2026 10:19
-- | Unsafely convert a 'ShelleyBasedEra' witness to an experimental 'Era' witness.
-- Throws an 'error' for deprecated (pre-Conway) eras.
unsafeEraFromSbe :: HasCallStack => ShelleyBasedEra era -> Era era
unsafeEraFromSbe = either (error . show) id . sbeToEra
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
unsafeEraFromSbe = either (error . show) id . sbeToEra
unsafeEraFromSbe = withFrozenCallStack $ either (error . show) id . sbeToEra

Copy link
Copy Markdown
Contributor

@palas palas Apr 24, 2026

Choose a reason for hiding this comment

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

Claude suggested:

unsafeEraFromSbe = either (error . prettyToString . prettyError) id . sbeToEra

Copy link
Copy Markdown
Contributor

@palas palas 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, pretty much a refactoring 👍

Copy link
Copy Markdown
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.

LGTM but have a look at my comment as it's something we should consider.

Map.foldlWithKey' (compareWithTxId txid) Nothing (L.proposalsActionsMap proposals)
)
sbe
obtainCommonConstraints (unsafeEraFromSbe sbe) $ do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

unsafeEraFromSbe is partial but cardano-testnet only ever runs Conway, so the error branch is never hit in practice.

We should consider a parallel AnyNewEpochStateLatest (parameterized on Exp.Era era) in cardano-api for consumers like cardano-testnet who are only interested in testing the latest eras. This keeps AnyNewEpochState intact for foldBlocks from genesis, eliminates the partial helper, and rules out pre-Conway at the type level.

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