Skip to content
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

Integrate cardano-ledger releases #1345

Merged
merged 8 commits into from
Dec 21, 2024
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ cabal run db-analyser
To test all the packages in this repository run:

```sh
cabal build all
cabal test all
```

in the command line, either inside `nix-shell` if you use `nix`, or in a
Expand Down
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ repository cardano-haskell-packages
-- update either of these.
index-state:
-- Bump this if you need newer packages from Hackage
, hackage.haskell.org 2024-10-22T14:26:27Z
, hackage.haskell.org 2024-12-10T16:20:07Z
-- Bump this if you need newer packages from CHaP
, cardano-haskell-packages 2024-10-30T11:23:17Z
, cardano-haskell-packages 2024-12-18T14:29:04Z

packages:
ouroboros-consensus
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Breaking

- Change the type of the `mkKeyHashVrf` function to use the new `VRFVerKeyHash` ledger type.
18 changes: 9 additions & 9 deletions ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,17 @@ library
cardano-crypto-class,
cardano-crypto-wrapper,
cardano-ledger-allegra ^>=1.6,
cardano-ledger-alonzo ^>=1.11,
cardano-ledger-api ^>=1.9.3,
cardano-ledger-alonzo ^>=1.12,
cardano-ledger-api ^>=1.10,
cardano-ledger-babbage ^>=1.10,
cardano-ledger-binary ^>=1.4,
cardano-ledger-binary ^>=1.5,
cardano-ledger-byron ^>=1.0.1,
cardano-ledger-conway ^>=1.17.2,
cardano-ledger-core ^>=1.15,
cardano-ledger-conway ^>=1.18,
cardano-ledger-core ^>=1.16,
cardano-ledger-mary ^>=1.7,
cardano-ledger-shelley ^>=1.14,
cardano-ledger-shelley ^>=1.15,
cardano-prelude,
cardano-protocol-tpraos ^>=1.2,
cardano-protocol-tpraos ^>=1.3,
cardano-slotting,
cardano-strict-containers,
cborg ^>=0.2.2,
Expand Down Expand Up @@ -390,7 +390,7 @@ library unstable-cardano-testlib
cardano-ledger-api,
cardano-ledger-byron,
cardano-ledger-conway:testlib,
cardano-ledger-conway-test >=1.2.1,
cardano-ledger-conway-test ^>=1.3,
cardano-ledger-core:{cardano-ledger-core, testlib},
cardano-ledger-shelley,
cardano-protocol-tpraos,
Expand Down Expand Up @@ -535,7 +535,7 @@ library unstable-cardano-tools
cardano-ledger-mary,
cardano-ledger-shelley,
cardano-prelude,
cardano-protocol-tpraos ^>=1.2,
cardano-protocol-tpraos ^>=1.3,
cardano-slotting,
cardano-strict-containers,
cborg ^>=0.2.2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ encodeByronBlock blk = mconcat [
-- | Inverse of 'encodeByronBlock'
decodeByronBlock :: CC.EpochSlots -> Decoder s (Lazy.ByteString -> ByronBlock)
decodeByronBlock epochSlots =
toPlainDecoder byronProtVer $
toPlainDecoder Nothing byronProtVer $
flip (\bs -> mkByronBlock epochSlots
. annotationBytes bs)
<$> CC.decCBORABlockOrBoundary epochSlots
Expand All @@ -195,7 +195,7 @@ decodeByronBlock epochSlots =
decodeByronRegularBlock :: CC.EpochSlots
-> Decoder s (Lazy.ByteString -> ByronBlock)
decodeByronRegularBlock epochSlots =
toPlainDecoder byronProtVer $
toPlainDecoder Nothing byronProtVer $
flip (\bs -> mkByronBlock epochSlots
. annotationBytes bs
. CC.ABOBBlock)
Expand All @@ -213,7 +213,7 @@ decodeByronRegularBlock epochSlots =
decodeByronBoundaryBlock :: CC.EpochSlots
-> Decoder s (Lazy.ByteString -> ByronBlock)
decodeByronBoundaryBlock epochSlots =
toPlainDecoder byronProtVer $
toPlainDecoder Nothing byronProtVer $
flip (\bs -> mkByronBlock epochSlots
. annotationBytes bs
. CC.ABOBBoundary)
Expand All @@ -231,7 +231,7 @@ decodeByronRegularHeader ::
CC.EpochSlots
-> Decoder s (Lazy.ByteString -> RawHeader)
decodeByronRegularHeader epochSlots =
toPlainDecoder byronProtVer $
toPlainDecoder Nothing byronProtVer $
flip annotationBytes <$> CC.decCBORAHeader epochSlots

-- | Encodes a raw Byron EBB header /without/ a tag indicating whether it's a
Expand All @@ -244,7 +244,7 @@ encodeByronBoundaryHeader = toByronCBOR . CBOR.encodePreEncoded . CC.boundaryHea
-- | Inverse of 'encodeByronBoundaryHeader'
decodeByronBoundaryHeader :: Decoder s (Lazy.ByteString -> RawBoundaryHeader)
decodeByronBoundaryHeader =
toPlainDecoder byronProtVer $
toPlainDecoder Nothing byronProtVer $
flip annotationBytes <$> CC.decCBORABoundaryHeader

-- | The 'BinaryBlockInfo' of the given 'ByronBlock'.
Expand Down Expand Up @@ -325,7 +325,7 @@ encodeUnsizedHeader (UnsizedHeader raw _ _) = toByronCBOR $ CC.encCBORABlockOrBo
decodeUnsizedHeader :: CC.EpochSlots
-> Decoder s (Lazy.ByteString -> UnsizedHeader)
decodeUnsizedHeader epochSlots =
toPlainDecoder byronProtVer $
toPlainDecoder Nothing byronProtVer $
fillInByteString <$> CC.decCBORABlockOrBoundaryHdr epochSlots
where
fillInByteString :: CC.ABlockOrBoundaryHdr ByteSpan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import qualified Cardano.Chain.Genesis as CC.Genesis
import qualified Cardano.Chain.Update as CC.Update
import Cardano.Crypto.DSIGN (Ed25519DSIGN)
import Cardano.Crypto.Hash.Blake2b (Blake2b_224, Blake2b_256)
import qualified Cardano.Ledger.Core as SL
import Cardano.Ledger.Crypto (ADDRHASH, Crypto, DSIGN, HASH)
import qualified Cardano.Ledger.Era as SL
import qualified Cardano.Ledger.Genesis as SL
import Cardano.Ledger.Hashes (EraIndependentTxBody)
import Cardano.Ledger.Keys (DSignable, Hash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ module Ouroboros.Consensus.Shelley.Ledger.Block (

import qualified Cardano.Crypto.Hash as Crypto
import Cardano.Ledger.Binary (Annotator (..), DecCBOR (..),
EncCBOR (..), FullByteString (..), serialize,
toPlainDecoder)
EncCBOR (..), FullByteString (..), serialize)
import qualified Cardano.Ledger.Binary.Plain as Plain
import Cardano.Ledger.Core as SL (eraProtVerLow, toEraCBOR)
import Cardano.Ledger.Core as SL (eraDecoder, eraProtVerLow,
toEraCBOR)
import qualified Cardano.Ledger.Core as SL (hashTxSeq)
import Cardano.Ledger.Crypto (HASH)
import qualified Cardano.Ledger.Era as SL (hashTxSeq)
import qualified Cardano.Ledger.Shelley.API as SL
import qualified Cardano.Protocol.TPraos.BHeader as SL
import qualified Data.ByteString.Lazy as Lazy
Expand Down Expand Up @@ -274,7 +274,7 @@ encodeShelleyBlock = toEraCBOR @era
decodeShelleyBlock ::
forall proto era. ShelleyCompatible proto era
=> forall s. Plain.Decoder s (Lazy.ByteString -> ShelleyBlock proto era)
decodeShelleyBlock = toPlainDecoder (eraProtVerLow @era) $ (. Full) . runAnnotator <$> decCBOR
decodeShelleyBlock = eraDecoder @era $ (. Full) . runAnnotator <$> decCBOR

shelleyBinaryBlockInfo :: forall proto era. ShelleyCompatible proto era => ShelleyBlock proto era -> BinaryBlockInfo
shelleyBinaryBlockInfo blk = BinaryBlockInfo {
Expand All @@ -293,7 +293,7 @@ encodeShelleyHeader = toEraCBOR @era
decodeShelleyHeader ::
forall proto era. ShelleyCompatible proto era
=> forall s. Plain.Decoder s (Lazy.ByteString -> Header (ShelleyBlock proto era))
decodeShelleyHeader = toPlainDecoder (eraProtVerLow @era) $ (. Full) . runAnnotator <$> decCBOR
decodeShelleyHeader = eraDecoder @era $ (. Full) . runAnnotator <$> decCBOR

{-------------------------------------------------------------------------------
Condense
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module Ouroboros.Consensus.Shelley.Ledger.Forge (forgeShelleyBlock) where

import qualified Cardano.Ledger.Core as Core (Tx)
import qualified Cardano.Ledger.Era as SL (hashTxSeq, toTxSeq)
import qualified Cardano.Ledger.Core as SL (hashTxSeq, toTxSeq)
import qualified Cardano.Ledger.Shelley.API as SL (Block (..), extractTx)
import qualified Cardano.Ledger.Shelley.BlockChain as SL (bBodySize)
import qualified Cardano.Protocol.TPraos.BHeader as SL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module Ouroboros.Consensus.Shelley.Ledger.Mempool (

import qualified Cardano.Crypto.Hash as Hash
import qualified Cardano.Ledger.Allegra.Rules as AllegraEra
import Cardano.Ledger.Alonzo.Core (Tx, TxSeq, bodyTxL, eraProtVerLow,
import Cardano.Ledger.Alonzo.Core (Tx, TxSeq, bodyTxL, eraDecoder,
fromTxSeq, ppMaxBBSizeL, ppMaxBlockExUnitsL, sizeTxF)
import qualified Cardano.Ledger.Alonzo.Rules as AlonzoEra
import Cardano.Ledger.Alonzo.Scripts (ExUnits, ExUnits',
Expand All @@ -49,7 +49,7 @@ import qualified Cardano.Ledger.Babbage.Rules as BabbageEra
import qualified Cardano.Ledger.BaseTypes as L
import Cardano.Ledger.Binary (Annotator (..), DecCBOR (..),
EncCBOR (..), FromCBOR (..), FullByteString (..),
ToCBOR (..), toPlainDecoder)
ToCBOR (..))
import qualified Cardano.Ledger.Conway.Rules as ConwayEra
import qualified Cardano.Ledger.Conway.Rules as SL
import qualified Cardano.Ledger.Conway.UTxO as SL
Expand Down Expand Up @@ -199,7 +199,7 @@ instance ShelleyCompatible proto era => ToCBOR (GenTx (ShelleyBlock proto era))

instance ShelleyCompatible proto era => FromCBOR (GenTx (ShelleyBlock proto era)) where
fromCBOR = fmap mkShelleyTx $ unwrapCBORinCBOR
$ toPlainDecoder (eraProtVerLow @era) $ (. Full) . runAnnotator <$> decCBOR
$ eraDecoder @era $ (. Full) . runAnnotator <$> decCBOR

{-------------------------------------------------------------------------------
Pretty-printing
Expand Down Expand Up @@ -353,41 +353,51 @@ instance MaxTxSizeUTxO (ShelleyEra c) where
, mismatchExpected = txSizeLimit }

instance MaxTxSizeUTxO (AllegraEra c) where
maxTxSizeUTxO x y =
maxTxSizeUTxO txSize txSizeLimit =
SL.ApplyTxError . pure
$ ShelleyEra.UtxowFailure
$ ShelleyEra.UtxoFailure
$ AllegraEra.MaxTxSizeUTxO x y
$ AllegraEra.MaxTxSizeUTxO
$ L.Mismatch { mismatchSupplied = txSize
, mismatchExpected = txSizeLimit }

instance MaxTxSizeUTxO (MaryEra c) where
maxTxSizeUTxO x y =
maxTxSizeUTxO txSize txSizeLimit =
SL.ApplyTxError . pure
$ ShelleyEra.UtxowFailure
$ ShelleyEra.UtxoFailure
$ AllegraEra.MaxTxSizeUTxO x y
$ AllegraEra.MaxTxSizeUTxO
$ L.Mismatch { mismatchSupplied = txSize
, mismatchExpected = txSizeLimit }

instance MaxTxSizeUTxO (AlonzoEra c) where
maxTxSizeUTxO x y =
maxTxSizeUTxO txSize txSizeLimit =
SL.ApplyTxError . pure
$ ShelleyEra.UtxowFailure
$ AlonzoEra.ShelleyInAlonzoUtxowPredFailure
$ ShelleyEra.UtxoFailure
$ AlonzoEra.MaxTxSizeUTxO x y
$ AlonzoEra.MaxTxSizeUTxO
$ L.Mismatch { mismatchSupplied = txSize
, mismatchExpected = txSizeLimit }

instance MaxTxSizeUTxO (BabbageEra c) where
maxTxSizeUTxO x y =
maxTxSizeUTxO txSize txSizeLimit =
SL.ApplyTxError . pure
$ ShelleyEra.UtxowFailure
$ BabbageEra.UtxoFailure
$ BabbageEra.AlonzoInBabbageUtxoPredFailure
$ AlonzoEra.MaxTxSizeUTxO x y
$ AlonzoEra.MaxTxSizeUTxO
$ L.Mismatch { mismatchSupplied = txSize
, mismatchExpected = txSizeLimit }

instance MaxTxSizeUTxO (ConwayEra c) where
maxTxSizeUTxO x y =
maxTxSizeUTxO txSize txSizeLimit =
SL.ApplyTxError . pure
$ ConwayEra.ConwayUtxowFailure
$ ConwayEra.UtxoFailure
$ ConwayEra.MaxTxSizeUTxO x y
$ ConwayEra.MaxTxSizeUTxO
$ L.Mismatch { mismatchSupplied = txSize
, mismatchExpected = txSizeLimit }

-----

Expand Down Expand Up @@ -455,37 +465,43 @@ txMeasureAlonzo st tx@(ShelleyTx _txid tx') =
limit = pparams ^. L.ppMaxTxExUnitsL

exunits =
validateMaybe (exUnitsTooBigUTxO limit txsz) $ do
validateMaybe (exUnitsTooBigUTxO txsz limit) $ do
guard $ pointWiseExUnits (<=) txsz limit
Just $ fromExUnits txsz

class ExUnitsTooBigUTxO era where
exUnitsTooBigUTxO :: ExUnits -> ExUnits -> SL.ApplyTxError era

instance Crypto c => ExUnitsTooBigUTxO (AlonzoEra c) where
exUnitsTooBigUTxO x y =
exUnitsTooBigUTxO txsz limit =
SL.ApplyTxError . pure
$ ShelleyEra.UtxowFailure
$ AlonzoEra.ShelleyInAlonzoUtxowPredFailure
$ ShelleyEra.UtxoFailure
$ AlonzoEra.ExUnitsTooBigUTxO x y
$ AlonzoEra.ExUnitsTooBigUTxO
$ L.Mismatch { mismatchSupplied = txsz
, mismatchExpected = limit }

instance Crypto c => ExUnitsTooBigUTxO (BabbageEra c) where
exUnitsTooBigUTxO x y =
exUnitsTooBigUTxO txsz limit =
SL.ApplyTxError . pure
$ ShelleyEra.UtxowFailure
$ BabbageEra.AlonzoInBabbageUtxowPredFailure
$ AlonzoEra.ShelleyInAlonzoUtxowPredFailure
$ ShelleyEra.UtxoFailure
$ BabbageEra.AlonzoInBabbageUtxoPredFailure
$ AlonzoEra.ExUnitsTooBigUTxO x y
$ AlonzoEra.ExUnitsTooBigUTxO
$ L.Mismatch { mismatchSupplied = txsz
, mismatchExpected = limit }

instance Crypto c => ExUnitsTooBigUTxO (ConwayEra c) where
exUnitsTooBigUTxO x y =
exUnitsTooBigUTxO txsz limit =
SL.ApplyTxError . pure
$ ConwayEra.ConwayUtxowFailure
$ ConwayEra.UtxoFailure
$ ConwayEra.ExUnitsTooBigUTxO x y
$ ConwayEra.ExUnitsTooBigUTxO
$ L.Mismatch { mismatchSupplied = txsz
, mismatchExpected = limit }

-----

Expand Down Expand Up @@ -546,17 +562,19 @@ txMeasureConway st tx@(ShelleyTx _txid tx') =
limit = SL.maxRefScriptSizePerTx

refScriptBytes =
validateMaybe (txRefScriptsSizeTooBig limit txsz) $ do
validateMaybe (txRefScriptsSizeTooBig txsz limit) $ do
guard $ txsz <= limit
Just $ IgnoringOverflow $ ByteSize32 $ fromIntegral txsz

class TxRefScriptsSizeTooBig era where
txRefScriptsSizeTooBig :: Int -> Int -> SL.ApplyTxError era

instance Crypto c => TxRefScriptsSizeTooBig (ConwayEra c) where
txRefScriptsSizeTooBig x y =
txRefScriptsSizeTooBig txsz limit =
SL.ApplyTxError . pure
$ ConwayEra.ConwayTxRefScriptsSizeTooBig x y
$ ConwayEra.ConwayTxRefScriptsSizeTooBig
$ L.Mismatch { mismatchSupplied = txsz
, mismatchExpected = limit }

-----

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ instance Crypto c => ToCBOR (LegacyPParams (AlonzoEra c)) where

instance Crypto c => FromCBOR (LegacyPParams (AlonzoEra c)) where
fromCBOR =
toPlainDecoder (eraProtVerLow @(AlonzoEra c)) $
eraDecoder @(AlonzoEra c) $
decode $
RecD mkLegacyAlonzoPParams
<! From -- appMinFeeA
Expand Down Expand Up @@ -173,7 +173,7 @@ instance Crypto c => ToCBOR (LegacyPParams (BabbageEra c)) where

instance Crypto c => FromCBOR (LegacyPParams (BabbageEra c)) where
fromCBOR =
toPlainDecoder (eraProtVerLow @(BabbageEra c)) $
eraDecoder @(BabbageEra c) $
decode $
RecD mkLegacyBabbagePParams
<! From -- bppMinFeeA
Expand Down
Loading
Loading