Migrate to EraBasedProtocolParametersUpdate#1373
Open
Jimbo4350 wants to merge 5 commits into
Open
Conversation
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).
7fa5ac0 to
69c471d
Compare
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.
Added in the migration commit but no {..} patterns use it.
There was a problem hiding this comment.
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-apidependency and adjust code to use era-indexed protocol parameter update types. - Rewrite
friendlyProtocolParametersUpdateto render from ledgerPParamsUpdateproduced fromEraBasedProtocolParametersUpdate. - 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) | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog
Context
Companion to cardano-api PR #1103, which removed the deprecated
ProtocolParametersUpdatetype. The replacement (EraBasedProtocolParametersUpdate era) shipped incardano-api-11.1.0.0on CHaP, so this PR resolves cleanly against the published release — nosource-repository-packagestanza needed.Dependency-side changes:
cabal.project— bump CHaPindex-stateto2026-05-08T13:26:45Z(whencardano-api-11.1.0.0was indexed on CHaP).cardano-cli/cardano-cli.cabal— widencardano-api ^>=11.0(which is>=11.0 && <11.1under PVP caret-equality) to^>=11.1so the solver picks the new release.flake.lock— bump the nix-side CHaP input in lockstep, perCONTRIBUTING.md(nix flake lock --update-input CHaP).Migration-side changes:
cardano-cli/src/Cardano/CLI/Read.hs—readTxUpdateProposalnow usesshelleyToBabbageEraConstraints w $ ...to bringIsShelleyBasedEra erainto scope, satisfying theHasTextEnvelopeinstance on the now era-indexedUpdateProposal era. The exposed signature is unchanged, so callers are unaffected.cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs—friendlyProtocolParametersUpdaterewritten to takeLedger.PParamsUpdate (ShelleyLedgerEra era)directly and dispatch onShelleyBasedEraconstructors. 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 infriendlyUpdateProposaldoes thecreateEraBasedProtocolParamUpdateconversion.cardano-cli/src/Cardano/CLI/Compatible/Governance/Run.hs— drop the redundantcreateEraBasedProtocolParamUpdate sbe ... |> fromLedgerPParamsUpdate sbe ...round-trip inshelleyToBabbageProtocolParametersUpdate. The newmakeShelleyUpdateProposaltakesEraBasedProtocolParametersUpdate eradirectly.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:
alCostModels/Alonzo-onwards cost models)Neither was emitted by the old
friendlyProtocolParametersUpdateeither. 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
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:cabal build cardano-cli -j4resolves againstcardano-api-11.1.0.0from CHaP and builds library,cardano-cli-test, andcardano-cli-goldenend-to-end.Read.hschange is mechanical: existing callers see the same type signature.Checklist