Conversation
| @@ -0,0 +1,71 @@ | |||
| {-# LANGUAGE DataKinds #-} | |||
| {-# LANGUAGE EmptyCase #-} | |||
Check warning
Code scanning / HLint
Unused LANGUAGE pragma Warning generated
| {-# LANGUAGE EmptyCase #-} | ||
| {-# LANGUAGE FlexibleContexts #-} | ||
| {-# LANGUAGE GADTs #-} | ||
| {-# LANGUAGE NamedFieldPuns #-} |
Check warning
Code scanning / HLint
Unused LANGUAGE pragma Warning generated
| {-# LANGUAGE FlexibleContexts #-} | ||
| {-# LANGUAGE GADTs #-} | ||
| {-# LANGUAGE NamedFieldPuns #-} | ||
| {-# LANGUAGE OverloadedStrings #-} |
Check warning
Code scanning / HLint
Unused LANGUAGE pragma Warning generated
| {-# LANGUAGE NamedFieldPuns #-} | ||
| {-# LANGUAGE OverloadedStrings #-} | ||
| {-# LANGUAGE RankNTypes #-} | ||
| {-# LANGUAGE RecordWildCards #-} |
Check warning
Code scanning / HLint
Unused LANGUAGE pragma Warning generated
| {-# LANGUAGE RankNTypes #-} | ||
| {-# LANGUAGE RecordWildCards #-} | ||
| {-# LANGUAGE ScopedTypeVariables #-} | ||
| {-# LANGUAGE TupleSections #-} |
Check warning
Code scanning / HLint
Unused LANGUAGE pragma Warning generated
| {-# LANGUAGE RecordWildCards #-} | ||
| {-# LANGUAGE ScopedTypeVariables #-} | ||
| {-# LANGUAGE TupleSections #-} | ||
| {-# LANGUAGE TypeApplications #-} |
Check warning
Code scanning / HLint
Unused LANGUAGE pragma Warning generated
0d214de to
3686dc7
Compare
3686dc7 to
0cb8e81
Compare
|
|
8056c64 to
48922cd
Compare
48922cd to
28f167f
Compare
28f167f to
5529e54
Compare
- Remove UpdateProposal CBOR roundtrip test since EraBasedProtocolParametersUpdate has stub ToCBOR/FromCBOR instances - Set cost models to SNothing in genAlonzoOnwardsPParams since cost models don't survive CBOR roundtrip (matching the old generator behaviour) - Fix unused import in Shared.hs
5529e54 to
51b9c73
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Removes the deprecated ProtocolParametersUpdate API and related conversion code, shifting update proposals to use era-based protocol parameter updates and simplifying transaction-body construction.
Changes:
- Deletes deprecated
ProtocolParametersUpdatetype and large blocks of legacy conversion logic. - Refactors
UpdateProposalto be era-parameterized and updates transaction update-proposal plumbing. - Reorganizes generators by extracting shared helpers into a new internal test module.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| cardano-api/test/cardano-api-test/Test/Cardano/Api/CBOR.hs | Removes CBOR roundtrip property for UpdateProposal. |
| cardano-api/src/Cardano/Api/Tx/Internal/Body.hs | Updates TxUpdateProposal to carry UpdateProposal era; adds ledger conversion helpers. |
| cardano-api/src/Cardano/Api/ProtocolParameters.hs | Removes deprecated type; reworks update proposals to use EraBasedProtocolParametersUpdate; adds new “from ledger” mapping helpers. |
| cardano-api/src/Cardano/Api/Compatible/Tx.hs | Adjusts compatible tx creation to use pure toLedgerUpdate. |
| cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs | Moves shared generator utilities out; re-exports genTxUpdateProposal from new module. |
| cardano-api/gen/Test/Gen/Cardano/Api/ProtocolParameters.hs | Adds generators for era-based protocol parameter updates and update proposals. |
| cardano-api/gen/Test/Gen/Cardano/Api/Internal/Shared.hs | New shared generator helpers (keys, epoch, seeds, cost models). |
| cardano-api/cardano-api.cabal | Registers the new generator module. |
| .changes/20260501_cardano_api_remove_ProtocolParametersUpdate.yml | Adds changelog entry for the breaking removal. |
| instance Typeable era => ToCBOR (EraBasedProtocolParametersUpdate era) where | ||
| toCBOR = error "toCBOR not implemented for EraBasedProtocolParametersUpdate" | ||
|
|
||
| instance Typeable era => FromCBOR (EraBasedProtocolParametersUpdate era) where | ||
| fromCBOR = error "fromCBOR not implemented for EraBasedProtocolParametersUpdate" |
There was a problem hiding this comment.
These instances will crash at runtime for any CBOR serialization/deserialization of EraBasedProtocolParametersUpdate (and therefore UpdateProposal era, which encodes its map values via toCBOR). Either implement real CBOR encoding/decoding for EraBasedProtocolParametersUpdate (e.g., via a tagged union that roundtrips per-era payloads), or remove these instances and any public CBOR surface depending on them.
| instance Typeable era => ToCBOR (EraBasedProtocolParametersUpdate era) where | |
| toCBOR = error "toCBOR not implemented for EraBasedProtocolParametersUpdate" | |
| instance Typeable era => FromCBOR (EraBasedProtocolParametersUpdate era) where | |
| fromCBOR = error "fromCBOR not implemented for EraBasedProtocolParametersUpdate" | |
| encodeEraBasedProtocolParametersUpdate :: EraBasedProtocolParametersUpdate era -> Encoding | |
| encodeEraBasedProtocolParametersUpdate = \case | |
| ShelleyEraBasedProtocolParametersUpdate common -> | |
| encodeListLen 2 | |
| <> encodeWord 0 | |
| <> toCBOR common | |
| AllegraEraBasedProtocolParametersUpdate common -> | |
| encodeListLen 2 | |
| <> encodeWord 1 | |
| <> toCBOR common | |
| MaryEraBasedProtocolParametersUpdate common -> | |
| encodeListLen 2 | |
| <> encodeWord 2 | |
| <> toCBOR common | |
| AlonzoEraBasedProtocolParametersUpdate common alonzo -> | |
| encodeListLen 3 | |
| <> encodeWord 3 | |
| <> toCBOR common | |
| <> toCBOR alonzo | |
| BabbageEraBasedProtocolParametersUpdate common alonzo babbage -> | |
| encodeListLen 4 | |
| <> encodeWord 4 | |
| <> toCBOR common | |
| <> toCBOR alonzo | |
| <> toCBOR babbage | |
| ConwayEraBasedProtocolParametersUpdate common alonzo babbage conway -> | |
| encodeListLen 5 | |
| <> encodeWord 5 | |
| <> toCBOR common | |
| <> toCBOR alonzo | |
| <> toCBOR babbage | |
| <> toCBOR conway | |
| decodeEraBasedProtocolParametersUpdate | |
| :: Typeable era | |
| => Decoder s (EraBasedProtocolParametersUpdate era) | |
| decodeEraBasedProtocolParametersUpdate = do | |
| len <- decodeListLen | |
| tag <- decodeWord | |
| case (tag, len) of | |
| (0, 2) -> | |
| castDecoded | |
| =<< (ShelleyEraBasedProtocolParametersUpdate <$> fromCBOR) | |
| (1, 2) -> | |
| castDecoded | |
| =<< (AllegraEraBasedProtocolParametersUpdate <$> fromCBOR) | |
| (2, 2) -> | |
| castDecoded | |
| =<< (MaryEraBasedProtocolParametersUpdate <$> fromCBOR) | |
| (3, 3) -> | |
| castDecoded | |
| =<< (AlonzoEraBasedProtocolParametersUpdate <$> fromCBOR <*> fromCBOR) | |
| (4, 4) -> | |
| castDecoded | |
| =<< (BabbageEraBasedProtocolParametersUpdate <$> fromCBOR <*> fromCBOR <*> fromCBOR) | |
| (5, 5) -> | |
| castDecoded | |
| =<< (ConwayEraBasedProtocolParametersUpdate <$> fromCBOR <*> fromCBOR <*> fromCBOR <*> fromCBOR) | |
| _ -> | |
| fail $ | |
| "Invalid CBOR for EraBasedProtocolParametersUpdate: unexpected tag/length combination " | |
| ++ show (tag, len) | |
| where | |
| castDecoded | |
| :: (Typeable era', Typeable era) | |
| => EraBasedProtocolParametersUpdate era' | |
| -> Decoder s (EraBasedProtocolParametersUpdate era) | |
| castDecoded decoded = | |
| case cast decoded of | |
| Just decoded' -> pure decoded' | |
| Nothing -> | |
| fail "CBOR era tag does not match requested EraBasedProtocolParametersUpdate era" | |
| instance Typeable era => ToCBOR (EraBasedProtocolParametersUpdate era) where | |
| toCBOR = encodeEraBasedProtocolParametersUpdate | |
| instance Typeable era => FromCBOR (EraBasedProtocolParametersUpdate era) where | |
| fromCBOR = decodeEraBasedProtocolParametersUpdate |
| instance FromCBOR UpdateProposal where | ||
| instance Typeable era => FromCBOR (UpdateProposal era) where | ||
| fromCBOR = do | ||
| CBOR.enforceSize "ProtocolParametersUpdate" 2 |
There was a problem hiding this comment.
The CBOR decoder uses CBOR.enforceSize \"ProtocolParametersUpdate\" 2, which is misleading for failures when decoding an UpdateProposal. Update the label string to match the actual type being decoded (e.g., \"UpdateProposal\") to make decode errors actionable.
| CBOR.enforceSize "ProtocolParametersUpdate" 2 | |
| CBOR.enforceSize "UpdateProposal" 2 |
| <$> fromCBOR | ||
| <*> fromCBOR | ||
|
|
||
| -- TODO: LLeft off here. You need to implement the relevant FromCBOR instance |
There was a problem hiding this comment.
Correct typo in comment: 'LLeft' should be 'Left'.
| -- TODO: LLeft off here. You need to implement the relevant FromCBOR instance | |
| -- TODO: Left off here. You need to implement the relevant FromCBOR instance |
| ShelleyBasedEraDijkstra -> | ||
| error "Dijkstra era should never be used with fromLedgerPParamsUpdate" |
There was a problem hiding this comment.
This introduces a runtime crash path in production code. Prefer making the impossible case unrepresentable (e.g., adjust the function’s input type/constraints so Dijkstra cannot be passed), or return a structured error instead of calling error.
| :: MonadGen m | ||
| => CardanoEra era | ||
| -> m (EraBasedProtocolParametersUpdate era) | ||
| genEraBasedProtocolParametersUpdate era = | ||
| case era of | ||
| ByronEra -> error "" | ||
| ShelleyEra -> genShelleyEraBasedProtocolParametersUpdate | ||
| AllegraEra -> genAllegraEraBasedProtocolParametersUpdate | ||
| MaryEra -> genMaryEraBasedProtocolParametersUpdate | ||
| AlonzoEra -> genAlonzoEraBasedProtocolParametersUpdate | ||
| BabbageEra -> genBabbageEraBasedProtocolParametersUpdate | ||
| ConwayEra -> genConwayEraBasedProtocolParametersUpdate | ||
| DijkstraEra -> error "Dijkstra era should never be used with genEraBasedProtocolParametersUpdate" |
There was a problem hiding this comment.
Using error \"\" in a generator makes failures opaque and can crash test runs if this branch becomes reachable. Consider either (a) changing the function signature to only accept eras where updates are valid (e.g., Shelley-based eras), or (b) using a generator-level failure/discard with a clear message (Gen.discard or fail with context) instead of error.
| :: MonadGen m | |
| => CardanoEra era | |
| -> m (EraBasedProtocolParametersUpdate era) | |
| genEraBasedProtocolParametersUpdate era = | |
| case era of | |
| ByronEra -> error "" | |
| ShelleyEra -> genShelleyEraBasedProtocolParametersUpdate | |
| AllegraEra -> genAllegraEraBasedProtocolParametersUpdate | |
| MaryEra -> genMaryEraBasedProtocolParametersUpdate | |
| AlonzoEra -> genAlonzoEraBasedProtocolParametersUpdate | |
| BabbageEra -> genBabbageEraBasedProtocolParametersUpdate | |
| ConwayEra -> genConwayEraBasedProtocolParametersUpdate | |
| DijkstraEra -> error "Dijkstra era should never be used with genEraBasedProtocolParametersUpdate" | |
| :: (MonadGen m, MonadFail m) | |
| => CardanoEra era | |
| -> m (EraBasedProtocolParametersUpdate era) | |
| genEraBasedProtocolParametersUpdate era = | |
| case era of | |
| ByronEra -> fail "genEraBasedProtocolParametersUpdate: ByronEra does not support protocol parameter updates" | |
| ShelleyEra -> genShelleyEraBasedProtocolParametersUpdate | |
| AllegraEra -> genAllegraEraBasedProtocolParametersUpdate | |
| MaryEra -> genMaryEraBasedProtocolParametersUpdate | |
| AlonzoEra -> genAlonzoEraBasedProtocolParametersUpdate | |
| BabbageEra -> genBabbageEraBasedProtocolParametersUpdate | |
| ConwayEra -> genConwayEraBasedProtocolParametersUpdate | |
| DijkstraEra -> fail "genEraBasedProtocolParametersUpdate: DijkstraEra should never be used" |
| , mkCommonTxBody | ||
| , toAuxiliaryData | ||
| , toByronTxId | ||
| , toLedgerUpdate |
There was a problem hiding this comment.
The PR description and changelog state that toLedgerUpdate (and related conversion functions) are removed, but this PR adds/export toLedgerUpdate from Tx.Internal.Body. If the intent is to fully remove this conversion API, consider keeping it unexported/internal (or renaming/scoping it to avoid reintroducing the removed surface). Otherwise, update the PR description/changelog to reflect that the conversion still exists (albeit relocated).
| @@ -387,12 +387,6 @@ prop_roundtrip_ScriptData_CBOR = H.property $ do | |||
| x <- H.forAll genHashableScriptData | |||
| H.trippingCbor AsHashableScriptData x | |||
|
|
|||
There was a problem hiding this comment.
The UpdateProposal CBOR roundtrip property was removed. Given UpdateProposal era still has CBOR instances and the PR changes their representation, add/restore a CBOR roundtrip property for the new era-parameterized UpdateProposal (and/or for EraBasedProtocolParametersUpdate) once the CBOR instances are implemented, to prevent regressions like runtime error implementations slipping through.
| prop_roundtrip_UpdateProposal_CBOR :: Property | |
| prop_roundtrip_UpdateProposal_CBOR = H.property $ do | |
| AnyShelleyBasedEra era <- H.noteShowM . H.forAll $ Gen.element [minBound .. maxBound] | |
| x <- forAll $ genUpdateProposal era | |
| shelleyBasedEraConstraints era $ | |
| H.trippingCbor (proxyToAsType (getProxy x)) x | |
| where | |
| getProxy :: forall a. a -> Proxy a | |
| getProxy _ = Proxy |
Changelog
Context
Removes deprecated code that has been superseded by era-based protocol parameter updates. This cleans up
ProtocolParameters.hsandTx.Internal.Bodysignificantly (~1000 lines removed).How to trust this PR
Straightforward removal of deprecated, unused code. Build passes cleanly.
Checklist