Skip to content

Replace caseShelleyToBabbageOrConwayEraOnwards with inEonForShelleyBasedEra - #1438

Merged
Jimbo4350 merged 3 commits into
masterfrom
jordan/replace-era-case-combinators
Sep 4, 2026
Merged

Replace caseShelleyToBabbageOrConwayEraOnwards with inEonForShelleyBasedEra#1438
Jimbo4350 merged 3 commits into
masterfrom
jordan/replace-era-case-combinators

Conversation

@Jimbo4350

@Jimbo4350 Jimbo4350 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Context

IntersectMBO/cardano-api#1326 removes the era case combinators, including caseShelleyToBabbageOrConwayEraOnwards. This migrates the call sites here ahead of that.

Most sites ignored one or both of the witnesses that combinator hands out, so they become inEonForShelleyBasedEra.

pUpdateProtocolParametersCmd was the awkward one: it matched on all seven ShelleyBasedEra constructors, but only to build a ShelleyToBabbageEra for the eon field of UpdateProtocolParametersPreConway — a field nothing ever read. Dropping the field removes the match. Its two branches then differ only in which optional payload they fill, so the shared scaffolding moves into mkCmd.

inEonForShelleyBasedEra is already in the released cardano-api, so this can merge before or after the cardano-api PR.

How to trust this PR

No change to the CLI's interface — same commands, same help output, which the golden tests cover.

cabal build cardano-cli -j4
cabal test cardano-cli-golden cardano-cli-test -j4

Locally: clean build, cardano-cli-golden 815/815, cardano-cli-test 73/73, no new hlint hints.

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
  • Changelog fragment added in .changes/

Copilot AI lite review requested due to automatic review settings September 3, 2026 16:19

Copilot AI left a comment

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.

🟢 Approval recommended

The changes are a mechanical refactor that appears to preserve the same era gating and parser behavior while improving forward compatibility with upcoming cardano-api changes.

Pull request overview

This PR refactors cardano-cli to replace uses of cardano-api’s soon-to-be-removed era case combinator (caseShelleyToBabbageOrConwayEraOnwards) with inEonForShelleyBasedEra (or explicit ShelleyBasedEra matching where both branches need distinct witnesses), preserving the existing era-partitioning logic.

Changes:

  • Migrates compatible transaction and governance option parsers to inEonForShelleyBasedEra (including targeted @ConwayEraOnwards selection where the eon would otherwise be ambiguous).
  • Simplifies the governance parser by removing an unnecessary convert in the obtainCommonConstraints path.
  • Rewrites pUpdateProtocolParametersCmd to explicitly branch on ShelleyBasedEra constructors to retain access to both required witnesses.
File summaries
File Description
cardano-cli/src/Cardano/CLI/Compatible/Transaction/Run.hs Replaces the legacy era case combinator with inEonForShelleyBasedEra for protocol-update/vote parsing.
cardano-cli/src/Cardano/CLI/Compatible/Transaction/Option.hs Uses inEonForShelleyBasedEra @ConwayEraOnwards for reference-script and vote-file parsers; adds TypeApplications.
cardano-cli/src/Cardano/CLI/Compatible/Governance/Option.hs Switches governance command gating to inEonForShelleyBasedEra, removes redundant convert, and explicitly matches ShelleyBasedEra for protocol-parameter update command parsing.
.changes/replace-era-case-combinators.yml Adds a changelog fragment documenting the refactor.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Jimbo4350
Jimbo4350 force-pushed the jordan/replace-era-case-combinators branch 5 times, most recently from 283480b to 1b26bde Compare September 3, 2026 20:11

@palas palas left a comment

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.

I am pretty confident this is a pure refactoring (from the point of view of the client). Just a minor comment/suggestion

, pGovernanceGenesisKeyDelegationCertificate
, fmap CreateCompatibleProtocolParametersUpdateCmd <$> pGovernanceActionCmds sbe
]
[ inEonForShelleyBasedEra

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.

Because of the use of inEonForShelleyBasedEra, when Conway goes out of Era, then it will lose the conway related commands (like drep), and we won't get any compilation error that warns about it here.
So maybe we should do something like postConway below.

…sedEra

`caseShelleyToBabbageOrConwayEraOnwards` hands both branches an era witness, which
most call sites did not need. Where a branch ignored its witness, this replaces the
combinator with `inEonForShelleyBasedEra`.

`pUpdateProtocolParametersCmd` looked like it needed both witnesses, but the pre-Conway
one was not load-bearing: it only fed a `ShelleyToBabbageEra` into the `eon` field of
`UpdateProtocolParametersPreConway`, and nothing ever read that field — the only
consumer, `shelleyToBabbageProtocolParametersUpdate`, bound it as `_stB`. The field is
dropped, which removes the seven-way match on the `ShelleyBasedEra` constructors that
existed only to conjure the witness.

The Conway branch keeps its `ConwayEraOnwards`, since `pUpdateProtocolParametersPostConway`
needs the `Exp.IsEra` constraint and neither `ShelleyBasedEra` nor
`conwayEraOnwardsConstraints` can supply it.

With the pre-Conway witness gone the branches are identical apart from which of the two
optional payloads they populate, so the shared command scaffolding moves into `mkCmd`.
Also folds away the no-op `forShelleyBasedEraMaybeEon` lookup in
`pGovernanceActionProtocolParametersUpdateCmd`, and drops the `DataKinds`, `GADTs` and
`ScopedTypeVariables` pragmas, which the module no longer needs.

No change to the executable's interface: `create-protocol-parameters-update` is still
registered for all five pre-Conway eras and for Conway onwards, with identical help
output.
…tructors

inEonForShelleyBasedEra infers its eon from the branch that consumes the
witness. In pCompatibleGovernanceCmds that was the experimental Era, whose
membership shrinks as eras are retired: once Conway leaves it, Conway would
silently take the pre-Conway branch and lose its governance commands, with no
compilation error.

Match on the ShelleyBasedEra constructors instead. The branches refine era to a
concrete one, so IsEra resolves directly and no experimental witness needs to be
threaded through this compatible module. pUpdateProtocolParametersCmd gets the
same treatment, dropping its ConwayEraOnwards witness and the convert round trip
to the experimental Era.
@Jimbo4350
Jimbo4350 force-pushed the jordan/replace-era-case-combinators branch from e102781 to 8f890fb Compare September 4, 2026 16:58
Replaces the shared mkCmd helper, which forced both branches to pass a
'pure Nothing' for the payload they do not populate.
@Jimbo4350
Jimbo4350 force-pushed the jordan/replace-era-case-combinators branch from 8fc3adf to 1722e58 Compare September 4, 2026 17:15
@Jimbo4350
Jimbo4350 added this pull request to the merge queue Sep 4, 2026
Merged via the queue into master with commit 891de44 Sep 4, 2026
25 checks passed
@Jimbo4350
Jimbo4350 deleted the jordan/replace-era-case-combinators branch September 4, 2026 19:25
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