-
Notifications
You must be signed in to change notification settings - Fork 29
Remove ProtocolParametersUpdate #1103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| project: cardano-api | ||
| pr: 1103 | ||
| kind: | ||
| - breaking | ||
| description: | | ||
| Remove the deprecated `ProtocolParametersUpdate` type and its associated conversion functions (`toLedgerUpdate`, `toLedgerProposedPPUpdates`, `fromLedgerProposedPPUpdates`, `toLedgerPParamsUpdate`, `fromLedgerPParamsUpdate`). Use `EraBasedProtocolParametersUpdate` instead. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| {-# LANGUAGE DataKinds #-} | ||
| {-# LANGUAGE EmptyCase #-} | ||
| {-# LANGUAGE FlexibleContexts #-} | ||
| {-# LANGUAGE GADTs #-} | ||
| {-# LANGUAGE NamedFieldPuns #-} | ||
Check warningCode scanning / HLint Unused LANGUAGE pragma Warning generated
cardano-api/gen/Test/Gen/Cardano/Api/Internal/Shared.hs:5:1-31: Warning: Unused LANGUAGE pragma
Found: {-# LANGUAGE NamedFieldPuns #-} Perhaps you should remove it. |
||
| {-# LANGUAGE OverloadedStrings #-} | ||
Check warningCode scanning / HLint Unused LANGUAGE pragma Warning generated
cardano-api/gen/Test/Gen/Cardano/Api/Internal/Shared.hs:6:1-34: Warning: Unused LANGUAGE pragma
Found: {-# LANGUAGE OverloadedStrings #-} Perhaps you should remove it. |
||
| {-# LANGUAGE RankNTypes #-} | ||
| {-# LANGUAGE RecordWildCards #-} | ||
Check warningCode scanning / HLint Unused LANGUAGE pragma Warning generated
cardano-api/gen/Test/Gen/Cardano/Api/Internal/Shared.hs:8:1-32: Warning: Unused LANGUAGE pragma
Found: {-# LANGUAGE RecordWildCards #-} Perhaps you should remove it. Note: may require {-# LANGUAGE DisambiguateRecordFields #-} adding to the top of the file |
||
| {-# LANGUAGE ScopedTypeVariables #-} | ||
| {-# LANGUAGE TupleSections #-} | ||
Check warningCode scanning / HLint Unused LANGUAGE pragma Warning generated
cardano-api/gen/Test/Gen/Cardano/Api/Internal/Shared.hs:10:1-30: Warning: Unused LANGUAGE pragma
Found: {-# LANGUAGE TupleSections #-} Perhaps you should remove it. |
||
| {-# LANGUAGE TypeApplications #-} | ||
Check warningCode scanning / HLint Unused LANGUAGE pragma Warning generated
cardano-api/gen/Test/Gen/Cardano/Api/Internal/Shared.hs:11:1-33: Warning: Unused LANGUAGE pragma
Found: {-# LANGUAGE TypeApplications #-} Perhaps you should remove it. |
||
| {-# OPTIONS_GHC -Wno-deprecations #-} | ||
|
|
||
| module Test.Gen.Cardano.Api.Internal.Shared | ||
| ( genCostModels | ||
| , genEpochNo | ||
| , genSeed | ||
| , genSigningKey | ||
| , genVerificationKey | ||
| , genVerificationKeyHash | ||
| ) | ||
| where | ||
|
|
||
| import Cardano.Api | ||
| import Cardano.Api.Ledger () | ||
|
|
||
| import Cardano.Crypto.DSIGN.Class qualified as Crypto | ||
| import Cardano.Crypto.Seed qualified as Crypto | ||
| import Cardano.Ledger.Alonzo.Scripts qualified as Alonzo | ||
|
|
||
| import Test.Cardano.Ledger.Alonzo.Arbitrary () | ||
| import Test.Cardano.Ledger.Conway.Arbitrary () | ||
|
|
||
| import Hedgehog | ||
| import Hedgehog.Gen as Gen | ||
| import Hedgehog.Gen.QuickCheck qualified as Q | ||
| import Hedgehog.Range as Range | ||
|
|
||
| genEpochNo :: Gen EpochNo | ||
| genEpochNo = EpochNo <$> Gen.word64 (Range.linear 0 10) | ||
|
|
||
| genCostModels :: MonadGen m => m Alonzo.CostModels | ||
| genCostModels = Q.arbitrary | ||
|
|
||
| genVerificationKeyHash | ||
| :: () | ||
| => HasTypeProxy keyrole | ||
| => Key keyrole | ||
| => AsType keyrole | ||
| -> Gen (Hash keyrole) | ||
| genVerificationKeyHash roletoken = | ||
| verificationKeyHash <$> genVerificationKey roletoken | ||
|
|
||
| genVerificationKey | ||
| :: () | ||
| => HasTypeProxy keyrole | ||
| => Key keyrole | ||
| => AsType keyrole | ||
| -> Gen (VerificationKey keyrole) | ||
| genVerificationKey roletoken = getVerificationKey <$> genSigningKey roletoken | ||
|
|
||
| genSigningKey :: Key keyrole => AsType keyrole -> Gen (SigningKey keyrole) | ||
| genSigningKey roletoken = do | ||
| seed <- genSeed (fromIntegral seedSize) | ||
| let sk = deterministicSigningKey roletoken seed | ||
| return sk | ||
| where | ||
| seedSize :: Word | ||
| seedSize = deterministicSigningKeySeedSize roletoken | ||
|
|
||
| genSeed :: Int -> Gen Crypto.Seed | ||
| genSeed n = Crypto.mkSeedFromBytes <$> Gen.bytes (Range.singleton n) | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,16 +1,21 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {-# LANGUAGE GADTs #-} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| module Test.Gen.Cardano.Api.ProtocolParameters where | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Cardano.Api | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Cardano.Api.Ledger | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Test.Gen.Cardano.Api.Typed (genCostModels) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Data.Maybe | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Test.Gen.Cardano.Api.Internal.Shared | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Test.Cardano.Ledger.Alonzo.Arbitrary () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Test.Cardano.Ledger.Conway.Arbitrary () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Hedgehog (MonadGen) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Hedgehog (Gen, MonadGen) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Hedgehog.Gen qualified as Gen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Hedgehog.Gen.QuickCheck qualified as Q | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Hedgehog.Range qualified as Range | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| genStrictMaybe :: MonadGen m => m a -> m (StrictMaybe a) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| genStrictMaybe gen = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -52,7 +57,7 @@ genShelleyToAlonzoPParams = | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| genAlonzoOnwardsPParams :: MonadGen m => m (AlonzoOnwardsPParams era) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| genAlonzoOnwardsPParams = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AlonzoOnwardsPParams | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <$> genStrictMaybe genCostModels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <$> pure SNothing -- Cost models don't roundtrip through CBOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <*> genStrictMaybe Q.arbitrary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <*> genStrictMaybe Q.arbitrary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <*> genStrictMaybe Q.arbitrary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -76,6 +81,41 @@ genIntroducedInConwayPParams = | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| <*> genStrictMaybe Q.arbitrary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <*> genStrictMaybe Q.arbitrary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| genTxUpdateProposal :: CardanoEra era -> Gen (TxUpdateProposal era) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| genTxUpdateProposal sbe = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Gen.choice $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| catMaybes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ Just $ pure TxUpdateProposalNone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , forEraInEon sbe Nothing $ \w -> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Just $ TxUpdateProposal w <$> genUpdateProposal (toCardanoEra w) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| genUpdateProposal :: CardanoEra era -> Gen (UpdateProposal era) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| genUpdateProposal era = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UpdateProposal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <$> Gen.map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (Range.constant 1 3) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ( (,) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <$> genVerificationKeyHash AsGenesisKey | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <*> genEraBasedProtocolParametersUpdate era | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <*> genEpochNo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| genEraBasedProtocolParametersUpdate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :: 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" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+105
to
+117
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :: 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" |
Check warning
Code scanning / HLint
Unused LANGUAGE pragma Warning generated