Skip to content

Migrate to EraBasedProtocolParametersUpdate#1373

Draft
Jimbo4350 wants to merge 2 commits intomasterfrom
jordan/migrate-EraBasedProtocolParametersUpdate
Draft

Migrate to EraBasedProtocolParametersUpdate#1373
Jimbo4350 wants to merge 2 commits intomasterfrom
jordan/migrate-EraBasedProtocolParametersUpdate

Conversation

@Jimbo4350
Copy link
Copy Markdown
Contributor

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:
   - compatible     # the API has changed but is non-breaking
   - refactoring    # QoL changes

Context

Companion to cardano-api PR IntersectMBO/cardano-api#1103 (branch jordan/remove-ProtocolParametersUpdate), which removes the deprecated ProtocolParametersUpdate type. This PR adapts cardano-cli to the era-indexed replacement and drops a redundant round-trip in the Shelley-to-Babbage governance flow.

This PR is draft because it depends on the cardano-api PR landing first — CI here will only go green once the api change is merged and pinned in cabal.project. Locally I built it against the cardano-api worktree.

Three files touched:

  • cardano-cli/src/Cardano/CLI/Read.hsreadTxUpdateProposal now uses shelleyToBabbageEraConstraints w $ ... to bring IsShelleyBasedEra era into scope (required by the HasTextEnvelope instance on the now era-indexed UpdateProposal era). The exposed signature is unchanged, which avoids cascading constraints into callers.
  • cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hsfriendlyProtocolParametersUpdate rewritten to take EraBasedProtocolParametersUpdate era and dispatch on the GADT, with one helper per sub-record (commonPairs, deprecatedAfterMaryPairs, deprecatedAfterBabbagePairs, shelleyToAlonzoPairs, alonzoOnwardsPairs, introducedInBabbagePairs). JSON output remains flat with the original key names preserved ("max block body size", "min UTxO value", etc.). Ledger-side coercions: Ledger.fromCompact for CoinPerByte, Ledger.unboundRational for UnitInterval/NonNegativeInterval, fromAlonzoExUnits and fromAlonzoPrices to map back to the API types whose ToJSON instances match the prior output shape.
  • 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. The other createEraBasedProtocolParamUpdate call in conwayOnwardsProtocolParametersUpdate is genuine (feeds the result into Ledger.UpdatePParams) and is left intact.

Deliberate omissions in JSON output

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

  • alCostModels from AlonzoOnwardsPParams
  • All of IntroducedInConwayPParams (voting thresholds, governance deposits, committee parameters, etc.)

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

How to trust this PR

  • Build against the companion cardano-api branch by adding to cabal.project.local:
    packages: <path-to-cardano-api>/cardano-api
    
    then cabal build cardano-cli -j4. The library, cardano-cli-test, and cardano-cli-golden all link cleanly.
  • Confirm the JSON shape parity by inspecting friendlyProtocolParametersUpdate against the original (the flat key list is preserved verbatim — pull diff and look at the commonPairs / *Pairs helpers vs. the original case branches).
  • 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

{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}
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
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.

2 participants