Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eras/allegra/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.9.0.0

* Add `AllegraApplyTxError` constructor for `ApplyTxError era`
* Add `cddl` sub-library, and `generate-cddl` executable.
* Remove deprecated type `Allegra`
* Remove deprecated type `TimelockConstr`
Expand Down
15 changes: 14 additions & 1 deletion eras/allegra/impl/src/Cardano/Ledger/Allegra.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Cardano.Ledger.Allegra (
AllegraEra,
Tx (..),
ApplyTxError (..),
) where

import Cardano.Ledger.Allegra.BlockBody ()
Expand All @@ -20,13 +24,22 @@ import Cardano.Ledger.Allegra.Transition ()
import Cardano.Ledger.Allegra.Translation ()
import Cardano.Ledger.Allegra.Tx (Tx (..))
import Cardano.Ledger.Allegra.UTxO ()
import Cardano.Ledger.Binary (DecCBOR, EncCBOR)
import Cardano.Ledger.Shelley.API
import Cardano.Ledger.Shelley.Rules (ShelleyLedgerPredFailure)
import Data.Bifunctor (Bifunctor (first))
import Data.List.NonEmpty (NonEmpty)

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

instance ApplyTx AllegraEra where
applyTxValidation = ruleApplyTxValidation @"LEDGER"
newtype ApplyTxError AllegraEra = AllegraApplyTxError (NonEmpty (ShelleyLedgerPredFailure AllegraEra))
deriving (Eq, Show)
deriving newtype (EncCBOR, DecCBOR)
applyTxValidation validationPolicy globals env state tx =
first AllegraApplyTxError $
ruleApplyTxValidation @"LEDGER" validationPolicy globals env state tx

instance ApplyBlock AllegraEra
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Test.Cardano.Ledger.Allegra.Arbitrary (
maxTimelockDepth,
) where

import Cardano.Ledger.Allegra (AllegraEra, Tx (..))
import Cardano.Ledger.Allegra (AllegraEra, ApplyTxError (..), Tx (..))
import Cardano.Ledger.Allegra.Rules (AllegraUtxoPredFailure)
import Cardano.Ledger.Allegra.Scripts (
AllegraEraScript (..),
Expand Down Expand Up @@ -132,3 +132,5 @@ instance Arbitrary ValidityInterval where
deriving newtype instance Arbitrary (TransitionConfig AllegraEra)

deriving newtype instance Arbitrary (Tx TopTx AllegraEra)

deriving newtype instance Arbitrary (ApplyTxError AllegraEra)
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import Test.Cardano.Ledger.Shelley.Examples (
mkWitnessesPreAlonzo,
)

ledgerExamples :: LedgerExamples AllegraEra
ledgerExamples :: LedgerExamples "LEDGER" AllegraEra
ledgerExamples =
mkLedgerExamples
(mkWitnessesPreAlonzo (Proxy @AllegraEra))
Expand Down
1 change: 1 addition & 0 deletions eras/alonzo/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.15.0.0

* Add `AlonzoApplyTxError` constructor for `ApplyTxError era`
* Changed the type of `dappMinUTxOValue` to `CompactForm Coin` in `DowngradeAlonzoPParams`
* Changed the type of the following fields to `CompactForm Coin` in `AlonzoPParams`:
- `appMinFeeA`
Expand Down
15 changes: 14 additions & 1 deletion eras/alonzo/impl/src/Cardano/Ledger/Alonzo.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}

Expand All @@ -15,6 +18,7 @@ module Cardano.Ledger.Alonzo (
AlonzoScript,
AlonzoTxAuxData,
Tx (..),
ApplyTxError (..),
) where

import Cardano.Ledger.Alonzo.BlockBody ()
Expand All @@ -31,13 +35,22 @@ import Cardano.Ledger.Alonzo.TxAuxData (AlonzoTxAuxData)
import Cardano.Ledger.Alonzo.TxBody (AlonzoTxOut, TxBody (AlonzoTxBody))
import Cardano.Ledger.Alonzo.TxWits ()
import Cardano.Ledger.Alonzo.UTxO ()
import Cardano.Ledger.Binary (DecCBOR, EncCBOR)
import Cardano.Ledger.Mary.Value (MaryValue)
import Cardano.Ledger.Plutus.Data ()
import Cardano.Ledger.Shelley.API
import Cardano.Ledger.Shelley.Rules (ShelleyLedgerPredFailure)
import Data.Bifunctor (Bifunctor (first))
import Data.List.NonEmpty (NonEmpty)

-- =====================================================

instance ApplyTx AlonzoEra where
applyTxValidation = ruleApplyTxValidation @"LEDGER"
newtype ApplyTxError AlonzoEra = AlonzoApplyTxError (NonEmpty (ShelleyLedgerPredFailure AlonzoEra))
deriving (Eq, Show)
deriving newtype (EncCBOR, DecCBOR)
applyTxValidation validationPolicy globals env state tx =
first AlonzoApplyTxError $
ruleApplyTxValidation @"LEDGER" validationPolicy globals env state tx

instance ApplyBlock AlonzoEra
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module Test.Cardano.Ledger.Alonzo.Arbitrary (
genAlonzoPlutusPurposePointer,
) where

import Cardano.Ledger.Alonzo (AlonzoEra, Tx (..))
import Cardano.Ledger.Alonzo (AlonzoEra, ApplyTxError (..), Tx (..))
import Cardano.Ledger.Alonzo.Core
import Cardano.Ledger.Alonzo.Genesis (AlonzoExtraConfig (..), AlonzoGenesis (..))
import Cardano.Ledger.Alonzo.PParams (
Expand Down Expand Up @@ -468,6 +468,8 @@ instance Arbitrary (TransitionConfig AlonzoEra) where

deriving newtype instance Arbitrary (Tx TopTx AlonzoEra)

deriving newtype instance Arbitrary (ApplyTxError AlonzoEra)

instance
( EraBlockBody era
, AlonzoEraTx era
Expand Down
21 changes: 12 additions & 9 deletions eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Examples.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import Cardano.Ledger.Mary.Value (MaryValue (..))
import Cardano.Ledger.Plutus.Data (Data (..), hashData)
import Cardano.Ledger.Plutus.Language (Language (..))
import Cardano.Ledger.Shelley.API (
ApplyTxError (..),
Credential (..),
Network (..),
NewEpochState (..),
Expand All @@ -42,11 +41,16 @@ import Cardano.Ledger.Shelley.API (
TxId (..),
Update (..),
)
import Cardano.Ledger.Shelley.Rules (ShelleyDelegsPredFailure (..), ShelleyLedgerPredFailure (..))
import Cardano.Ledger.Shelley.Rules (
PredicateFailure,
ShelleyDelegsPredFailure (..),
ShelleyLedgerPredFailure (..),
)
import Cardano.Ledger.Shelley.Scripts
import Cardano.Ledger.TxIn (mkTxInPartial)
import Cardano.Slotting.Slot (EpochNo (..), SlotNo (..))
import Data.Default (def)
import Data.List.NonEmpty (NonEmpty)
import qualified Data.Map.Strict as Map
import qualified Data.Sequence.Strict as StrictSeq
import qualified Data.Set as Set
Expand All @@ -72,13 +76,12 @@ import Test.Cardano.Ledger.Shelley.Examples (
testShelleyGenesis,
)

ledgerExamples :: LedgerExamples AlonzoEra
ledgerExamples :: LedgerExamples "LEDGER" AlonzoEra
ledgerExamples =
mkLedgerExamples
( ApplyTxError $
pure $
DelegsFailure $
DelegateeNotRegisteredDELEG @AlonzoEra (mkKeyHash 1)
( pure $
DelegsFailure $
DelegateeNotRegisteredDELEG @AlonzoEra (mkKeyHash 1)
)
exampleAlonzoNewEpochState
exampleTxAlonzo
Expand All @@ -87,11 +90,11 @@ ledgerExamples =
mkLedgerExamples ::
forall era.
AlonzoEraPParams era =>
ApplyTxError era ->
NonEmpty (PredicateFailure (EraRule "LEDGER" era)) ->
NewEpochState era ->
Tx TopTx era ->
TranslationContext era ->
LedgerExamples era
LedgerExamples "LEDGER" era
mkLedgerExamples
applyTxError
newEpochState
Expand Down
1 change: 1 addition & 0 deletions eras/babbage/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.13.0.0

* Add `BabbageApplyTxError` constructor for `ApplyTxError era`
* Add `babbageUtxoValidation`
* Add `babbageUtxoTests`
* Changed the type of the following fields to `CompactForm Coin` in `BabbagePParams`:
Expand Down
15 changes: 14 additions & 1 deletion eras/babbage/impl/src/Cardano/Ledger/Babbage.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}

Expand All @@ -10,6 +13,7 @@ module Cardano.Ledger.Babbage (
BabbageTxOut,
TxBody (BabbageTxBody),
Tx (..),
ApplyTxError (..),
AlonzoScript,
AlonzoTxAuxData,
) where
Expand All @@ -26,11 +30,20 @@ import Cardano.Ledger.Babbage.Tx (Tx (..))
import Cardano.Ledger.Babbage.TxBody (BabbageTxOut, TxBody (BabbageTxBody))
import Cardano.Ledger.Babbage.TxInfo ()
import Cardano.Ledger.Babbage.UTxO ()
import Cardano.Ledger.Binary (DecCBOR, EncCBOR)
import Cardano.Ledger.Shelley.API
import Cardano.Ledger.Shelley.Rules (ShelleyLedgerPredFailure)
import Data.Bifunctor (Bifunctor (first))
import Data.List.NonEmpty (NonEmpty)

-- =====================================================

instance ApplyTx BabbageEra where
applyTxValidation = ruleApplyTxValidation @"LEDGER"
newtype ApplyTxError BabbageEra = BabbageApplyTxError (NonEmpty (ShelleyLedgerPredFailure BabbageEra))
deriving (Eq, Show)
deriving newtype (EncCBOR, DecCBOR)
applyTxValidation validationPolicy globals env state tx =
first BabbageApplyTxError $
ruleApplyTxValidation @"LEDGER" validationPolicy globals env state tx

instance ApplyBlock BabbageEra
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,5 @@ instance Arbitrary (TxBody TopTx BabbageEra) where
deriving newtype instance Arbitrary (TransitionConfig BabbageEra)

deriving newtype instance Arbitrary (Tx TopTx BabbageEra)

deriving newtype instance Arbitrary (ApplyTxError BabbageEra)
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import Cardano.Ledger.Plutus.Data (
)
import Cardano.Ledger.Plutus.Language (Language (..))
import Cardano.Ledger.Shelley.API (
ApplyTxError (..),
Network (..),
NewEpochState (..),
ProposedPPUpdates (..),
Expand Down Expand Up @@ -59,13 +58,12 @@ import Test.Cardano.Ledger.Shelley.Examples (
mkKeyHash,
)

ledgerExamples :: LedgerExamples BabbageEra
ledgerExamples :: LedgerExamples "LEDGER" BabbageEra
ledgerExamples =
mkLedgerExamples
( ApplyTxError $
pure $
DelegsFailure $
DelegateeNotRegisteredDELEG @BabbageEra (mkKeyHash 1)
( pure $
DelegsFailure $
DelegateeNotRegisteredDELEG @BabbageEra (mkKeyHash 1)
)
exampleBabbageNewEpochState
exampleTxBabbage
Expand Down
1 change: 1 addition & 0 deletions eras/conway/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.21.0.0

* Add `ConwayApplyTxError` constructor for `ApplyTxError era`
* Re-export `UtxoEnv` from `Cardano.Ledger.Conway.Rules.Utxo`
* Changed the type of the following fields to `CompactForm Coin` in `ConwayPParams`:
- `cppMinFeeA`
Expand Down
1 change: 1 addition & 0 deletions eras/conway/impl/cardano-ledger-conway.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ library testlib
Test.Cardano.Ledger.Conway.Imp.GovSpec
Test.Cardano.Ledger.Conway.Imp.HardForkSpec
Test.Cardano.Ledger.Conway.Imp.LedgerSpec
Test.Cardano.Ledger.Conway.Imp.MempoolSpec
Test.Cardano.Ledger.Conway.Imp.RatifySpec
Test.Cardano.Ledger.Conway.Imp.UtxoSpec
Test.Cardano.Ledger.Conway.Imp.UtxosSpec
Expand Down
17 changes: 15 additions & 2 deletions eras/conway/impl/src/Cardano/Ledger/Conway.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}

Expand All @@ -12,9 +14,11 @@ module Cardano.Ledger.Conway (
hardforkConwayDELEGIncorrectDepositsAndRefunds,
hardforkConwayMoveWithdrawalsAndDRepChecksToLedgerRule,
Tx (..),
ApplyTxError (..),
) where

import Cardano.Ledger.Babbage.TxBody ()
import Cardano.Ledger.BaseTypes (Inject (..))
import Cardano.Ledger.Conway.BlockBody ()
import Cardano.Ledger.Conway.Era (
ConwayEra,
Expand All @@ -24,7 +28,7 @@ import Cardano.Ledger.Conway.Era (
hardforkConwayMoveWithdrawalsAndDRepChecksToLedgerRule,
)
import Cardano.Ledger.Conway.Governance (RunConwayRatify (..))
import Cardano.Ledger.Conway.Rules ()
import Cardano.Ledger.Conway.Rules (ConwayLedgerPredFailure)
import Cardano.Ledger.Conway.State ()
import Cardano.Ledger.Conway.Transition ()
import Cardano.Ledger.Conway.Translation ()
Expand All @@ -33,12 +37,21 @@ import Cardano.Ledger.Conway.TxInfo ()
import Cardano.Ledger.Conway.TxOut ()
import Cardano.Ledger.Conway.UTxO ()
import Cardano.Ledger.Shelley.API
import Data.Bifunctor (Bifunctor (first))
import Data.List.NonEmpty (NonEmpty)

-- =====================================================

instance ApplyTx ConwayEra where
applyTxValidation = ruleApplyTxValidation @"MEMPOOL"
newtype ApplyTxError ConwayEra = ConwayApplyTxError (NonEmpty (ConwayLedgerPredFailure ConwayEra))
deriving (Eq, Show)
applyTxValidation validationPolicy globals env state tx =
first ConwayApplyTxError $
ruleApplyTxValidation @"MEMPOOL" validationPolicy globals env state tx

instance ApplyBlock ConwayEra

instance RunConwayRatify ConwayEra

instance Inject (NonEmpty (ConwayLedgerPredFailure ConwayEra)) (ApplyTxError ConwayEra) where
inject = ConwayApplyTxError
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import Cardano.Ledger.Plutus.Data (
)
import Cardano.Ledger.Plutus.Language (Language (..))
import Cardano.Ledger.Shelley.API (
ApplyTxError (..),
RewardAccount (..),
TxId (..),
)
Expand Down Expand Up @@ -60,13 +59,12 @@ import Test.Cardano.Ledger.Shelley.Examples (
mkKeyHash,
)

ledgerExamples :: LedgerExamples ConwayEra
ledgerExamples :: LedgerExamples "LEDGER" ConwayEra
ledgerExamples =
mkLedgerExamples
( ApplyTxError $
pure $
wrapFailed @(ConwayDELEG ConwayEra) @(ConwayLEDGER ConwayEra) $
DelegateeStakePoolNotRegisteredDELEG @ConwayEra (mkKeyHash 1)
( pure $
wrapFailed @(ConwayDELEG ConwayEra) @(ConwayLEDGER ConwayEra) $
DelegateeStakePoolNotRegisteredDELEG @ConwayEra (mkKeyHash 1)
)
exampleBabbageNewEpochState
exampleTxConway
Expand Down
2 changes: 2 additions & 0 deletions eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import qualified Test.Cardano.Ledger.Conway.Imp.GovCertSpec as GovCert
import qualified Test.Cardano.Ledger.Conway.Imp.GovSpec as Gov
import qualified Test.Cardano.Ledger.Conway.Imp.HardForkSpec as HardFork
import qualified Test.Cardano.Ledger.Conway.Imp.LedgerSpec as Ledger
import qualified Test.Cardano.Ledger.Conway.Imp.MempoolSpec as Mempool
import qualified Test.Cardano.Ledger.Conway.Imp.RatifySpec as Ratify
import qualified Test.Cardano.Ledger.Conway.Imp.UtxoSpec as Utxo
import qualified Test.Cardano.Ledger.Conway.Imp.UtxosSpec as Utxos
Expand Down Expand Up @@ -75,6 +76,7 @@ conwayEraSpecificSpec :: SpecWith (ImpInit (LedgerSpec ConwayEra))
conwayEraSpecificSpec = do
describe "Conway era specific Imp spec" $ do
describe "UTXO" Utxo.conwayEraSpecificSpec
describe "MEMPOOL" Mempool.conwayEraSpecificSpec

instance EraSpecificSpec ConwayEra where
eraSpecificSpec =
Expand Down
Loading