Skip to content

Migrate to EraBasedProtocolParametersUpdate#1373

Open
Jimbo4350 wants to merge 5 commits into
masterfrom
jordan/migrate-EraBasedProtocolParametersUpdate
Open

Migrate to EraBasedProtocolParametersUpdate#1373
Jimbo4350 wants to merge 5 commits into
masterfrom
jordan/migrate-EraBasedProtocolParametersUpdate

Conversation

@Jimbo4350
Copy link
Copy Markdown
Contributor

@Jimbo4350 Jimbo4350 commented May 5, 2026

Changelog

- description: |
    Migrate cardano-cli to the cardano-api removal of `ProtocolParametersUpdate`
    in favour of `EraBasedProtocolParametersUpdate era`. JSON output of
    `friendlyProtocolParametersUpdate` keeps the original flat shape and key
    names; cost models and Conway-only governance fields are not emitted (parity
    with prior behaviour) and can be surfaced in a follow-up.
# uncomment types applicable to the change:
  type:
   - refactoring    # QoL changes
   - maintenance    # not directly related to the code

Context

Companion to cardano-api PR #1103, which removed the deprecated ProtocolParametersUpdate type. The replacement (EraBasedProtocolParametersUpdate era) shipped in cardano-api-11.1.0.0 on CHaP, so this PR resolves cleanly against the published release — no source-repository-package stanza needed.

Dependency-side changes:

  • cabal.project — bump CHaP index-state to 2026-05-08T13:26:45Z (when cardano-api-11.1.0.0 was indexed on CHaP).
  • cardano-cli/cardano-cli.cabal — widen cardano-api ^>=11.0 (which is >=11.0 && <11.1 under PVP caret-equality) to ^>=11.1 so the solver picks the new release.
  • flake.lock — bump the nix-side CHaP input in lockstep, per CONTRIBUTING.md (nix flake lock --update-input CHaP).

Migration-side changes:

  • cardano-cli/src/Cardano/CLI/Read.hsreadTxUpdateProposal now uses shelleyToBabbageEraConstraints w $ ... to bring IsShelleyBasedEra era into scope, satisfying the HasTextEnvelope instance on the now era-indexed UpdateProposal era. The exposed signature is unchanged, so callers are unaffected.
  • cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hsfriendlyProtocolParametersUpdate rewritten to take Ledger.PParamsUpdate (ShelleyLedgerEra era) directly and dispatch on ShelleyBasedEra constructors. Helper functions per field group (commonPairs, minUTxOValuePair, decentralizationAndEntropyPairs, protocolVersionPair, alonzoOnwardsPairs, babbageOnwardsPairs) carry their own ledger constraints (EraPParams, ProtVerAtMost N, AlonzoEraPParams, BabbageEraPParams), and the case branches resolve them via instance lookup once the era is concrete — no eon witnesses needed. The caller in friendlyUpdateProposal does the createEraBasedProtocolParamUpdate conversion.
  • cardano-cli/src/Cardano/CLI/Compatible/Governance/Run.hs — drop the redundant createEraBasedProtocolParamUpdate sbe ... |> fromLedgerPParamsUpdate sbe ... round-trip in shelleyToBabbageProtocolParametersUpdate. The new makeShelleyUpdateProposal takes EraBasedProtocolParametersUpdate era directly.

Deliberate omissions in JSON output

To preserve the prior flat output exactly, two groups of fields available in the new type are deliberately not emitted:

  • cost models (alCostModels / Alonzo-onwards cost models)
  • Conway-only governance fields (voting thresholds, governance deposits, committee parameters, etc.)

Neither was emitted by the old friendlyProtocolParametersUpdate either. Both can be added under new keys in a follow-up if we want Conway-era updates to fully round-trip in the friendly view.

How to trust this PR

  • Pre-migration golden test. The first commit on this branch (Add golden test for friendlyProtocolParametersUpdate) pins the rendered YAML for an alonzo-era update proposal exercising every renderable field. The migration commit preserves that golden byte-for-byte. Run:
    cd cardano-cli && cabal run cardano-cli-golden -- -p '$NF == "golden view alonzo update proposal yaml"'
  • Build: cabal build cardano-cli -j4 resolves against cardano-api-11.1.0.0 from CHaP and builds library, cardano-cli-test, and cardano-cli-golden end-to-end.
  • The Read.hs change is mechanical: existing callers see the same type signature.

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

Comment thread cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs Fixed
Jimbo4350 added 2 commits May 5, 2026 16:29
Pins the rendered YAML shape of an alonzo-era transaction whose update
proposal exercises every field that friendlyProtocolParametersUpdate is
expected to render. This locks down the flat-key output (preserving keys
like "max block body size", "execution prices", "min UTxO value", "min
pool cost", etc.) so any subsequent rewrite of the renderer cannot
silently change the JSON shape.

The proposal is built via `compatible alonzo governance action
create-protocol-parameters-update`, embedded into a tx via `compatible
alonzo transaction signed-transaction --update-proposal-file`, and
viewed via `debug transaction view --output-yaml`.
Adapt cardano-cli to the cardano-api removal of ProtocolParametersUpdate
in favour of EraBasedProtocolParametersUpdate era.

- Read.hs: bring IsShelleyBasedEra era into scope via
  shelleyToBabbageEraConstraints, satisfying the HasTextEnvelope instance
  for the now era-indexed UpdateProposal era without changing the
  function's exposed type.

- Friendly.hs: rewrite friendlyProtocolParametersUpdate to take a
  ledger PParamsUpdate directly (caller in friendlyUpdateProposal does
  the createEraBasedProtocolParamUpdate conversion) and dispatch on
  ShelleyBasedEra constructors to determine which fields apply per era.
  Helper functions per field group carry their own ledger constraints
  (EraPParams, ProtVerAtMost N, AlonzoEraPParams, BabbageEraPParams)
  and the case branches resolve them via instance lookup once the era
  is concrete - no eon witnesses required.

  Output preserves the prior JSON shape exactly (verified by
  hprop_golden_view_alonzo_update_proposal_yaml). Cost models and
  Conway-only governance fields are deliberately not emitted, matching
  prior behaviour.

- Compatible/Governance/Run.hs: drop the redundant
  createEraBasedProtocolParamUpdate / fromLedgerPParamsUpdate round-trip
  in shelleyToBabbageProtocolParametersUpdate; makeShelleyUpdateProposal
  now takes EraBasedProtocolParametersUpdate era directly.

- cardano-cli.cabal: add cardano-ledger-binary dep for getVersion
  (used to render the protocol-version major component).
@Jimbo4350 Jimbo4350 force-pushed the jordan/migrate-EraBasedProtocolParametersUpdate branch from 7fa5ac0 to 69c471d Compare May 5, 2026 20:39
Jimbo4350 added 2 commits May 11, 2026 16:03
cardano-api 11.1.0.0 is the first published release containing the
EraBasedProtocolParametersUpdate migration this branch depends on
(cardano-api PR #1103). Bump the CHaP index-state past its publication
and widen the cardano-cli library constraint from ^>=11.0 (which means
>=11.0 && <11.1 under PVP caret-equality) to ^>=11.1 so the solver
picks the new release.
The previous commit bumped cabal.project's cardano-haskell-packages
index-state to 2026-05-08T13:26:45Z, but the nix-side CHaP pin in
flake.lock was still at 2026-04-30. haskell.nix-driven CI checks
(actionlint, check-formatting, check-cabal-files, check-cabal-gild,
test-hls-works, shellcheck) all failed with Cabal-7159 "Latest known
index-state for 'cardano-haskell-packages' (2026-04-30T13:08:25Z) is
older than the requested index-state (2026-05-08T13:26:45Z)".

Updated via `nix flake lock --update-input CHaP` per CONTRIBUTING.md.
@Jimbo4350 Jimbo4350 marked this pull request as ready for review May 11, 2026 20:26
Copilot AI review requested due to automatic review settings May 11, 2026 20:26
Added in the migration commit but no {..} patterns use it.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates cardano-cli to match cardano-api’s removal of ProtocolParametersUpdate, switching rendering and governance flows to the era-indexed replacement while keeping the existing “friendly” JSON/YAML output shape for protocol parameter updates.

Changes:

  • Bump cardano-api dependency and adjust code to use era-indexed protocol parameter update types.
  • Rewrite friendlyProtocolParametersUpdate to render from ledger PParamsUpdate produced from EraBasedProtocolParametersUpdate.
  • Add a golden test + fixtures to pin the YAML output shape for an Alonzo update proposal embedded in a transaction.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
flake.lock Updates pinned CHaP revision/hash to align with dependency changes.
cabal.project Advances CHaP index-state to pick up the newer package set.
cardano-cli/cardano-cli.cabal Bumps cardano-api bound and adds cardano-ledger-binary dependency for version rendering.
cardano-cli/src/Cardano/CLI/Read.hs Adds shelleyToBabbageEraConstraints to satisfy new era-indexed UpdateProposal envelope constraints.
cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs Refactors protocol-parameter-update rendering to dispatch by era and emit the legacy flat key set.
cardano-cli/src/Cardano/CLI/Compatible/Governance/Run.hs Removes a redundant conversion round-trip when building Shelley-to-Babbage update proposals.
cardano-cli/test/cardano-cli-golden/Test/Golden/TxView.hs Adds a new golden test that generates and views an Alonzo tx with an update proposal and compares YAML output.
cardano-cli/test/cardano-cli-golden/files/input/genesis1.vkey Adds a genesis verification key fixture used by the new golden test.
cardano-cli/test/cardano-cli-golden/files/golden/alonzo/transaction-view-update-proposal.yaml Adds the expected YAML output for the new golden test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

protocolVersionPair ppu =
[ ( \(Ledger.ProtVer major minor) ->
"protocol version" .= (textShow (getVersion major :: Word) <> "." <> textShow minor)
)
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