Skip to content

Commit

Permalink
Remove crypto paramtrization
Browse files Browse the repository at this point in the history
We only retain KES and VRF parametrization, which is applicable to block
headers. This means that HASH, ADDRHASH and DSIGN were switched from a
type family to a type synonym for a concrete algorithm. This allowed us
to remove crypto paramterization from all eras and ledger related types.
  • Loading branch information
lehins committed Dec 14, 2024
1 parent 81330ef commit 5a75b75
Show file tree
Hide file tree
Showing 559 changed files with 8,497 additions and 10,358 deletions.
5 changes: 5 additions & 0 deletions eras/allegra/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Version history for `cardano-ledger-allegra`

## 1.7.0.0

* Deprecate `Allegra` type synonym
* Remove crypto parametrization from `AllegraEra`

## 1.6.1.0

* Use `Mismatch` to clarify predicate failures. #4711
Expand Down
4 changes: 1 addition & 3 deletions eras/allegra/impl/cardano-ledger-allegra.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: cardano-ledger-allegra
version: 1.6.1.0
version: 1.7.0.0
license: Apache-2.0
maintainer: operations@iohk.io
author: IOHK
Expand Down Expand Up @@ -66,7 +66,6 @@ library
aeson,
base >=4.14 && <5,
bytestring,
cardano-crypto-class,
cardano-ledger-binary >=1.4,
cardano-ledger-core >=1.17 && <1.18,
cardano-ledger-shelley ^>=1.15,
Expand Down Expand Up @@ -108,7 +107,6 @@ library testlib
QuickCheck,
base,
bytestring,
cardano-crypto-class,
cardano-ledger-allegra,
cardano-ledger-core:{cardano-ledger-core, testlib},
cardano-ledger-shelley:{cardano-ledger-shelley, testlib},
Expand Down
15 changes: 5 additions & 10 deletions eras/allegra/impl/src/Cardano/Ledger/Allegra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,16 @@ import Cardano.Ledger.Allegra.Translation ()
import Cardano.Ledger.Allegra.Tx ()
import Cardano.Ledger.Allegra.TxSeq ()
import Cardano.Ledger.Allegra.UTxO ()
import Cardano.Ledger.Core
import Cardano.Ledger.Crypto (Crypto, StandardCrypto)
import Cardano.Ledger.Keys (DSignable, Hash)
import Cardano.Ledger.Shelley.API (ApplyBlock, ApplyTx)

type Allegra = AllegraEra StandardCrypto
type Allegra = AllegraEra

{-# DEPRECATED Allegra "In favor of `AllegraEra`" #-}

--------------------------------------------------------------------------------
-- Mempool instances
--------------------------------------------------------------------------------

instance
(Crypto c, DSignable c (Hash c EraIndependentTxBody)) =>
ApplyTx (AllegraEra c)
instance ApplyTx AllegraEra

instance
(Crypto c, DSignable c (Hash c EraIndependentTxBody)) =>
ApplyBlock (AllegraEra c)
instance ApplyBlock AllegraEra
56 changes: 27 additions & 29 deletions eras/allegra/impl/src/Cardano/Ledger/Allegra/Era.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,77 +12,75 @@ module Cardano.Ledger.Allegra.Era (
) where

import Cardano.Ledger.Coin (Coin)
import Cardano.Ledger.Crypto (Crypto)
import Cardano.Ledger.Genesis (EraGenesis, NoGenesis)
import Cardano.Ledger.Shelley (ShelleyEra)
import Cardano.Ledger.Shelley.Core
import Cardano.Ledger.Shelley.Rules

-- | The Allegra era
data AllegraEra c
data AllegraEra

instance Crypto c => Era (AllegraEra c) where
type PreviousEra (AllegraEra c) = ShelleyEra c
type EraCrypto (AllegraEra c) = c
type ProtVerLow (AllegraEra c) = 3
instance Era AllegraEra where
type PreviousEra AllegraEra = ShelleyEra
type ProtVerLow AllegraEra = 3

eraName = "Allegra"

instance Crypto c => EraGenesis (AllegraEra c)
instance EraGenesis AllegraEra

--------------------------------------------------------------------------------
-- Core instances
--------------------------------------------------------------------------------

-- | No context is needed to translate from Shelley to Allegra.
type instance TranslationContext (AllegraEra c) = NoGenesis (AllegraEra c)
type instance TranslationContext AllegraEra = NoGenesis AllegraEra

type instance Value (AllegraEra _) = Coin
type instance Value AllegraEra = Coin

-- These rules are all inherited from Shelley

type instance EraRule "BBODY" (AllegraEra c) = ShelleyBBODY (AllegraEra c)
type instance EraRule "BBODY" AllegraEra = ShelleyBBODY AllegraEra

type instance EraRule "DELEG" (AllegraEra c) = ShelleyDELEG (AllegraEra c)
type instance EraRule "DELEG" AllegraEra = ShelleyDELEG AllegraEra

type instance EraRule "DELEGS" (AllegraEra c) = ShelleyDELEGS (AllegraEra c)
type instance EraRule "DELEGS" AllegraEra = ShelleyDELEGS AllegraEra

type instance EraRule "DELPL" (AllegraEra c) = ShelleyDELPL (AllegraEra c)
type instance EraRule "DELPL" AllegraEra = ShelleyDELPL AllegraEra

type instance EraRule "EPOCH" (AllegraEra c) = ShelleyEPOCH (AllegraEra c)
type instance EraRule "EPOCH" AllegraEra = ShelleyEPOCH AllegraEra

type instance EraRule "LEDGER" (AllegraEra c) = ShelleyLEDGER (AllegraEra c)
type instance EraRule "LEDGER" AllegraEra = ShelleyLEDGER AllegraEra

type instance EraRule "LEDGERS" (AllegraEra c) = ShelleyLEDGERS (AllegraEra c)
type instance EraRule "LEDGERS" AllegraEra = ShelleyLEDGERS AllegraEra

type instance EraRule "MIR" (AllegraEra c) = ShelleyMIR (AllegraEra c)
type instance EraRule "MIR" AllegraEra = ShelleyMIR AllegraEra

type instance EraRule "NEWEPOCH" (AllegraEra c) = ShelleyNEWEPOCH (AllegraEra c)
type instance EraRule "NEWEPOCH" AllegraEra = ShelleyNEWEPOCH AllegraEra

type instance EraRule "NEWPP" (AllegraEra c) = ShelleyNEWPP (AllegraEra c)
type instance EraRule "NEWPP" AllegraEra = ShelleyNEWPP AllegraEra

type instance EraRule "POOL" (AllegraEra c) = ShelleyPOOL (AllegraEra c)
type instance EraRule "POOL" AllegraEra = ShelleyPOOL AllegraEra

type instance EraRule "POOLREAP" (AllegraEra c) = ShelleyPOOLREAP (AllegraEra c)
type instance EraRule "POOLREAP" AllegraEra = ShelleyPOOLREAP AllegraEra

type instance EraRule "PPUP" (AllegraEra c) = ShelleyPPUP (AllegraEra c)
type instance EraRule "PPUP" AllegraEra = ShelleyPPUP AllegraEra

type instance EraRule "RUPD" (AllegraEra c) = ShelleyRUPD (AllegraEra c)
type instance EraRule "RUPD" AllegraEra = ShelleyRUPD AllegraEra

type instance EraRule "SNAP" (AllegraEra c) = ShelleySNAP (AllegraEra c)
type instance EraRule "SNAP" AllegraEra = ShelleySNAP AllegraEra

type instance EraRule "TICK" (AllegraEra c) = ShelleyTICK (AllegraEra c)
type instance EraRule "TICK" AllegraEra = ShelleyTICK AllegraEra

type instance EraRule "TICKF" (AllegraEra c) = ShelleyTICKF (AllegraEra c)
type instance EraRule "TICKF" AllegraEra = ShelleyTICKF AllegraEra

type instance EraRule "UPEC" (AllegraEra c) = ShelleyUPEC (AllegraEra c)
type instance EraRule "UPEC" AllegraEra = ShelleyUPEC AllegraEra

-- These rules are defined anew in the Allegra era

data AllegraUTXO era

type instance EraRule "UTXO" (AllegraEra c) = AllegraUTXO (AllegraEra c)
type instance EraRule "UTXO" AllegraEra = AllegraUTXO AllegraEra

data AllegraUTXOW era

type instance EraRule "UTXOW" (AllegraEra c) = AllegraUTXOW (AllegraEra c)
type instance EraRule "UTXOW" AllegraEra = AllegraUTXOW AllegraEra
13 changes: 6 additions & 7 deletions eras/allegra/impl/src/Cardano/Ledger/Allegra/PParams.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ module Cardano.Ledger.Allegra.PParams () where

import Cardano.Ledger.Allegra.Era (AllegraEra)
import Cardano.Ledger.Core
import Cardano.Ledger.Crypto
import Cardano.Ledger.Shelley.Governance
import Cardano.Ledger.Shelley.PParams
import Data.Coerce
import Lens.Micro

instance Crypto c => EraPParams (AllegraEra c) where
type PParamsHKD f (AllegraEra c) = ShelleyPParams f (AllegraEra c)
instance EraPParams AllegraEra where
type PParamsHKD f AllegraEra = ShelleyPParams f AllegraEra

type UpgradePParams f (AllegraEra c) = ()
type DowngradePParams f (AllegraEra c) = ()
type UpgradePParams f AllegraEra = ()
type DowngradePParams f AllegraEra = ()

emptyPParamsIdentity = emptyShelleyPParams
emptyPParamsStrictMaybe = emptyShelleyPParamsUpdate
Expand All @@ -41,8 +40,8 @@ instance Crypto c => EraPParams (AllegraEra c) where
hkdMinUTxOValueL = lens sppMinUTxOValue $ \pp x -> pp {sppMinUTxOValue = x}
hkdMinPoolCostL = lens sppMinPoolCost $ \pp x -> pp {sppMinPoolCost = x}

instance Crypto c => EraGov (AllegraEra c) where
type GovState (AllegraEra c) = ShelleyGovState (AllegraEra c)
instance EraGov AllegraEra where
type GovState AllegraEra = ShelleyGovState AllegraEra
emptyGovState = emptyShelleyGovState

getProposedPPUpdates = Just . sgsCurProposals
Expand Down
2 changes: 1 addition & 1 deletion eras/allegra/impl/src/Cardano/Ledger/Allegra/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ import Cardano.Ledger.Allegra.Rules.Utxo
import Cardano.Ledger.Allegra.Rules.Utxow
import Cardano.Ledger.Shelley.Rules (ShelleyTickEvent)

type instance EraRuleEvent "TICK" (AllegraEra c) = ShelleyTickEvent (AllegraEra c)
type instance EraRuleEvent "TICK" AllegraEra = ShelleyTickEvent AllegraEra
22 changes: 11 additions & 11 deletions eras/allegra/impl/src/Cardano/Ledger/Allegra/Rules/Bbody.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,33 @@ import Cardano.Ledger.Shelley.Rules (
ShelleyUtxowPredFailure,
)

type instance EraRuleFailure "BBODY" (AllegraEra c) = ShelleyBbodyPredFailure (AllegraEra c)
type instance EraRuleFailure "BBODY" AllegraEra = ShelleyBbodyPredFailure AllegraEra

instance InjectRuleFailure "BBODY" ShelleyBbodyPredFailure (AllegraEra c)
instance InjectRuleFailure "BBODY" ShelleyBbodyPredFailure AllegraEra

instance InjectRuleFailure "BBODY" ShelleyLedgersPredFailure (AllegraEra c) where
instance InjectRuleFailure "BBODY" ShelleyLedgersPredFailure AllegraEra where
injectFailure = LedgersFailure

instance InjectRuleFailure "BBODY" ShelleyLedgerPredFailure (AllegraEra c) where
instance InjectRuleFailure "BBODY" ShelleyLedgerPredFailure AllegraEra where
injectFailure = LedgersFailure . injectFailure

instance InjectRuleFailure "BBODY" ShelleyUtxowPredFailure (AllegraEra c) where
instance InjectRuleFailure "BBODY" ShelleyUtxowPredFailure AllegraEra where
injectFailure = LedgersFailure . injectFailure

instance InjectRuleFailure "BBODY" ShelleyUtxoPredFailure (AllegraEra c) where
instance InjectRuleFailure "BBODY" ShelleyUtxoPredFailure AllegraEra where
injectFailure = LedgersFailure . injectFailure

instance InjectRuleFailure "BBODY" ShelleyPpupPredFailure (AllegraEra c) where
instance InjectRuleFailure "BBODY" ShelleyPpupPredFailure AllegraEra where
injectFailure = LedgersFailure . injectFailure

instance InjectRuleFailure "BBODY" ShelleyDelegsPredFailure (AllegraEra c) where
instance InjectRuleFailure "BBODY" ShelleyDelegsPredFailure AllegraEra where
injectFailure = LedgersFailure . injectFailure

instance InjectRuleFailure "BBODY" ShelleyDelplPredFailure (AllegraEra c) where
instance InjectRuleFailure "BBODY" ShelleyDelplPredFailure AllegraEra where
injectFailure = LedgersFailure . injectFailure

instance InjectRuleFailure "BBODY" ShelleyPoolPredFailure (AllegraEra c) where
instance InjectRuleFailure "BBODY" ShelleyPoolPredFailure AllegraEra where
injectFailure = LedgersFailure . injectFailure

instance InjectRuleFailure "BBODY" ShelleyDelegPredFailure (AllegraEra c) where
instance InjectRuleFailure "BBODY" ShelleyDelegPredFailure AllegraEra where
injectFailure = LedgersFailure . injectFailure
4 changes: 2 additions & 2 deletions eras/allegra/impl/src/Cardano/Ledger/Allegra/Rules/Deleg.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ import Cardano.Ledger.Shelley.Rules (
ShelleyDelegPredFailure,
)

type instance EraRuleFailure "DELEG" (AllegraEra c) = ShelleyDelegPredFailure (AllegraEra c)
type instance EraRuleFailure "DELEG" AllegraEra = ShelleyDelegPredFailure AllegraEra

instance InjectRuleFailure "DELEG" ShelleyDelegPredFailure (AllegraEra c)
instance InjectRuleFailure "DELEG" ShelleyDelegPredFailure AllegraEra
10 changes: 5 additions & 5 deletions eras/allegra/impl/src/Cardano/Ledger/Allegra/Rules/Delegs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import Cardano.Ledger.Shelley.Rules (
ShelleyPoolPredFailure,
)

type instance EraRuleFailure "DELEGS" (AllegraEra c) = ShelleyDelegsPredFailure (AllegraEra c)
type instance EraRuleFailure "DELEGS" AllegraEra = ShelleyDelegsPredFailure AllegraEra

instance InjectRuleFailure "DELEGS" ShelleyDelegsPredFailure (AllegraEra c)
instance InjectRuleFailure "DELEGS" ShelleyDelegsPredFailure AllegraEra

instance InjectRuleFailure "DELEGS" ShelleyDelplPredFailure (AllegraEra c) where
instance InjectRuleFailure "DELEGS" ShelleyDelplPredFailure AllegraEra where
injectFailure = DelplFailure

instance InjectRuleFailure "DELEGS" ShelleyPoolPredFailure (AllegraEra c) where
instance InjectRuleFailure "DELEGS" ShelleyPoolPredFailure AllegraEra where
injectFailure = DelplFailure . injectFailure

instance InjectRuleFailure "DELEGS" ShelleyDelegPredFailure (AllegraEra c) where
instance InjectRuleFailure "DELEGS" ShelleyDelegPredFailure AllegraEra where
injectFailure = DelplFailure . injectFailure
8 changes: 4 additions & 4 deletions eras/allegra/impl/src/Cardano/Ledger/Allegra/Rules/Delpl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import Cardano.Ledger.Shelley.Rules (
ShelleyPoolPredFailure,
)

type instance EraRuleFailure "DELPL" (AllegraEra c) = ShelleyDelplPredFailure (AllegraEra c)
type instance EraRuleFailure "DELPL" AllegraEra = ShelleyDelplPredFailure AllegraEra

instance InjectRuleFailure "DELPL" ShelleyDelplPredFailure (AllegraEra c)
instance InjectRuleFailure "DELPL" ShelleyDelplPredFailure AllegraEra

instance InjectRuleFailure "DELPL" ShelleyPoolPredFailure (AllegraEra c) where
instance InjectRuleFailure "DELPL" ShelleyPoolPredFailure AllegraEra where
injectFailure = PoolFailure

instance InjectRuleFailure "DELPL" ShelleyDelegPredFailure (AllegraEra c) where
instance InjectRuleFailure "DELPL" ShelleyDelegPredFailure AllegraEra where
injectFailure = DelegFailure
20 changes: 10 additions & 10 deletions eras/allegra/impl/src/Cardano/Ledger/Allegra/Rules/Ledger.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ import Cardano.Ledger.Shelley.Rules (
ShelleyUtxowPredFailure,
)

type instance EraRuleFailure "LEDGER" (AllegraEra c) = ShelleyLedgerPredFailure (AllegraEra c)
type instance EraRuleFailure "LEDGER" AllegraEra = ShelleyLedgerPredFailure AllegraEra

instance InjectRuleFailure "LEDGER" ShelleyLedgerPredFailure (AllegraEra c)
instance InjectRuleFailure "LEDGER" ShelleyLedgerPredFailure AllegraEra

instance InjectRuleFailure "LEDGER" ShelleyUtxowPredFailure (AllegraEra c) where
instance InjectRuleFailure "LEDGER" ShelleyUtxowPredFailure AllegraEra where
injectFailure = UtxowFailure

instance InjectRuleFailure "LEDGER" ShelleyUtxoPredFailure (AllegraEra c) where
instance InjectRuleFailure "LEDGER" ShelleyUtxoPredFailure AllegraEra where
injectFailure = UtxowFailure . injectFailure

instance InjectRuleFailure "LEDGER" ShelleyPpupPredFailure (AllegraEra c) where
instance InjectRuleFailure "LEDGER" ShelleyPpupPredFailure AllegraEra where
injectFailure = UtxowFailure . injectFailure

instance InjectRuleFailure "LEDGER" ShelleyDelegsPredFailure (AllegraEra c) where
instance InjectRuleFailure "LEDGER" ShelleyDelegsPredFailure AllegraEra where
injectFailure = DelegsFailure

instance InjectRuleFailure "LEDGER" ShelleyDelplPredFailure (AllegraEra c) where
instance InjectRuleFailure "LEDGER" ShelleyDelplPredFailure AllegraEra where
injectFailure = DelegsFailure . injectFailure

instance InjectRuleFailure "LEDGER" ShelleyPoolPredFailure (AllegraEra c) where
instance InjectRuleFailure "LEDGER" ShelleyPoolPredFailure AllegraEra where
injectFailure = DelegsFailure . injectFailure

instance InjectRuleFailure "LEDGER" ShelleyDelegPredFailure (AllegraEra c) where
instance InjectRuleFailure "LEDGER" ShelleyDelegPredFailure AllegraEra where
injectFailure = DelegsFailure . injectFailure

type instance EraRuleEvent "LEDGER" (AllegraEra c) = ShelleyLedgerEvent (AllegraEra c)
type instance EraRuleEvent "LEDGER" AllegraEra = ShelleyLedgerEvent AllegraEra
20 changes: 10 additions & 10 deletions eras/allegra/impl/src/Cardano/Ledger/Allegra/Rules/Ledgers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,30 @@ import Cardano.Ledger.Shelley.Rules (
ShelleyUtxowPredFailure,
)

type instance EraRuleFailure "LEDGERS" (AllegraEra c) = ShelleyLedgersPredFailure (AllegraEra c)
type instance EraRuleFailure "LEDGERS" AllegraEra = ShelleyLedgersPredFailure AllegraEra

instance InjectRuleFailure "LEDGERS" ShelleyLedgersPredFailure (AllegraEra c)
instance InjectRuleFailure "LEDGERS" ShelleyLedgersPredFailure AllegraEra

instance InjectRuleFailure "LEDGERS" ShelleyLedgerPredFailure (AllegraEra c) where
instance InjectRuleFailure "LEDGERS" ShelleyLedgerPredFailure AllegraEra where
injectFailure = LedgerFailure

instance InjectRuleFailure "LEDGERS" ShelleyUtxowPredFailure (AllegraEra c) where
instance InjectRuleFailure "LEDGERS" ShelleyUtxowPredFailure AllegraEra where
injectFailure = LedgerFailure . injectFailure

instance InjectRuleFailure "LEDGERS" ShelleyUtxoPredFailure (AllegraEra c) where
instance InjectRuleFailure "LEDGERS" ShelleyUtxoPredFailure AllegraEra where
injectFailure = LedgerFailure . injectFailure

instance InjectRuleFailure "LEDGERS" ShelleyPpupPredFailure (AllegraEra c) where
instance InjectRuleFailure "LEDGERS" ShelleyPpupPredFailure AllegraEra where
injectFailure = LedgerFailure . injectFailure

instance InjectRuleFailure "LEDGERS" ShelleyDelegsPredFailure (AllegraEra c) where
instance InjectRuleFailure "LEDGERS" ShelleyDelegsPredFailure AllegraEra where
injectFailure = LedgerFailure . injectFailure

instance InjectRuleFailure "LEDGERS" ShelleyDelplPredFailure (AllegraEra c) where
instance InjectRuleFailure "LEDGERS" ShelleyDelplPredFailure AllegraEra where
injectFailure = LedgerFailure . injectFailure

instance InjectRuleFailure "LEDGERS" ShelleyPoolPredFailure (AllegraEra c) where
instance InjectRuleFailure "LEDGERS" ShelleyPoolPredFailure AllegraEra where
injectFailure = LedgerFailure . injectFailure

instance InjectRuleFailure "LEDGERS" ShelleyDelegPredFailure (AllegraEra c) where
instance InjectRuleFailure "LEDGERS" ShelleyDelegPredFailure AllegraEra where
injectFailure = LedgerFailure . injectFailure
4 changes: 2 additions & 2 deletions eras/allegra/impl/src/Cardano/Ledger/Allegra/Rules/Pool.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import Cardano.Ledger.Allegra.Era (AllegraEra)
import Cardano.Ledger.Core
import Cardano.Ledger.Shelley.Rules (ShelleyPoolPredFailure)

type instance EraRuleFailure "POOL" (AllegraEra c) = ShelleyPoolPredFailure (AllegraEra c)
type instance EraRuleFailure "POOL" AllegraEra = ShelleyPoolPredFailure AllegraEra

instance InjectRuleFailure "POOL" ShelleyPoolPredFailure (AllegraEra c)
instance InjectRuleFailure "POOL" ShelleyPoolPredFailure AllegraEra
4 changes: 2 additions & 2 deletions eras/allegra/impl/src/Cardano/Ledger/Allegra/Rules/Ppup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import Cardano.Ledger.Allegra.Era (AllegraEra)
import Cardano.Ledger.Core
import Cardano.Ledger.Shelley.Rules (ShelleyPpupPredFailure)

type instance EraRuleFailure "PPUP" (AllegraEra c) = ShelleyPpupPredFailure (AllegraEra c)
type instance EraRuleFailure "PPUP" AllegraEra = ShelleyPpupPredFailure AllegraEra

instance InjectRuleFailure "PPUP" ShelleyPpupPredFailure (AllegraEra c)
instance InjectRuleFailure "PPUP" ShelleyPpupPredFailure AllegraEra
Loading

0 comments on commit 5a75b75

Please sign in to comment.