Skip to content

Commit a020b7b

Browse files
authored
Integrate cardano-ledger releases (#1345)
Integrate the changes in new versions that `cardano-ledger` recently added to CHaP
2 parents 592e11c + 0d65a19 commit a020b7b

File tree

27 files changed

+113
-85
lines changed

27 files changed

+113
-85
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ cabal run db-analyser
115115
To test all the packages in this repository run:
116116

117117
```sh
118-
cabal build all
118+
cabal test all
119119
```
120120

121121
in the command line, either inside `nix-shell` if you use `nix`, or in a

cabal.project

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ repository cardano-haskell-packages
1414
-- update either of these.
1515
index-state:
1616
-- Bump this if you need newer packages from Hackage
17-
, hackage.haskell.org 2024-10-22T14:26:27Z
17+
, hackage.haskell.org 2024-12-10T16:20:07Z
1818
-- Bump this if you need newer packages from CHaP
19-
, cardano-haskell-packages 2024-10-30T11:23:17Z
19+
, cardano-haskell-packages 2024-12-18T14:29:04Z
2020

2121
packages:
2222
ouroboros-consensus

flake.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Breaking
2+
3+
- Change the type of the `mkKeyHashVrf` function to use the new `VRFVerKeyHash` ledger type.

ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal

+9-9
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,17 @@ library
135135
cardano-crypto-class,
136136
cardano-crypto-wrapper,
137137
cardano-ledger-allegra ^>=1.6,
138-
cardano-ledger-alonzo ^>=1.11,
139-
cardano-ledger-api ^>=1.9.3,
138+
cardano-ledger-alonzo ^>=1.12,
139+
cardano-ledger-api ^>=1.10,
140140
cardano-ledger-babbage ^>=1.10,
141-
cardano-ledger-binary ^>=1.4,
141+
cardano-ledger-binary ^>=1.5,
142142
cardano-ledger-byron ^>=1.0.1,
143-
cardano-ledger-conway ^>=1.17.2,
144-
cardano-ledger-core ^>=1.15,
143+
cardano-ledger-conway ^>=1.18,
144+
cardano-ledger-core ^>=1.16,
145145
cardano-ledger-mary ^>=1.7,
146-
cardano-ledger-shelley ^>=1.14,
146+
cardano-ledger-shelley ^>=1.15,
147147
cardano-prelude,
148-
cardano-protocol-tpraos ^>=1.2,
148+
cardano-protocol-tpraos ^>=1.3,
149149
cardano-slotting,
150150
cardano-strict-containers,
151151
cborg ^>=0.2.2,
@@ -390,7 +390,7 @@ library unstable-cardano-testlib
390390
cardano-ledger-api,
391391
cardano-ledger-byron,
392392
cardano-ledger-conway:testlib,
393-
cardano-ledger-conway-test >=1.2.1,
393+
cardano-ledger-conway-test ^>=1.3,
394394
cardano-ledger-core:{cardano-ledger-core, testlib},
395395
cardano-ledger-shelley,
396396
cardano-protocol-tpraos,
@@ -535,7 +535,7 @@ library unstable-cardano-tools
535535
cardano-ledger-mary,
536536
cardano-ledger-shelley,
537537
cardano-prelude,
538-
cardano-protocol-tpraos ^>=1.2,
538+
cardano-protocol-tpraos ^>=1.3,
539539
cardano-slotting,
540540
cardano-strict-containers,
541541
cborg ^>=0.2.2,

ouroboros-consensus-cardano/src/byron/Ouroboros/Consensus/Byron/Ledger/Serialisation.hs

+6-6
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ encodeByronBlock blk = mconcat [
178178
-- | Inverse of 'encodeByronBlock'
179179
decodeByronBlock :: CC.EpochSlots -> Decoder s (Lazy.ByteString -> ByronBlock)
180180
decodeByronBlock epochSlots =
181-
toPlainDecoder byronProtVer $
181+
toPlainDecoder Nothing byronProtVer $
182182
flip (\bs -> mkByronBlock epochSlots
183183
. annotationBytes bs)
184184
<$> CC.decCBORABlockOrBoundary epochSlots
@@ -195,7 +195,7 @@ decodeByronBlock epochSlots =
195195
decodeByronRegularBlock :: CC.EpochSlots
196196
-> Decoder s (Lazy.ByteString -> ByronBlock)
197197
decodeByronRegularBlock epochSlots =
198-
toPlainDecoder byronProtVer $
198+
toPlainDecoder Nothing byronProtVer $
199199
flip (\bs -> mkByronBlock epochSlots
200200
. annotationBytes bs
201201
. CC.ABOBBlock)
@@ -213,7 +213,7 @@ decodeByronRegularBlock epochSlots =
213213
decodeByronBoundaryBlock :: CC.EpochSlots
214214
-> Decoder s (Lazy.ByteString -> ByronBlock)
215215
decodeByronBoundaryBlock epochSlots =
216-
toPlainDecoder byronProtVer $
216+
toPlainDecoder Nothing byronProtVer $
217217
flip (\bs -> mkByronBlock epochSlots
218218
. annotationBytes bs
219219
. CC.ABOBBoundary)
@@ -231,7 +231,7 @@ decodeByronRegularHeader ::
231231
CC.EpochSlots
232232
-> Decoder s (Lazy.ByteString -> RawHeader)
233233
decodeByronRegularHeader epochSlots =
234-
toPlainDecoder byronProtVer $
234+
toPlainDecoder Nothing byronProtVer $
235235
flip annotationBytes <$> CC.decCBORAHeader epochSlots
236236

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

250250
-- | The 'BinaryBlockInfo' of the given 'ByronBlock'.
@@ -325,7 +325,7 @@ encodeUnsizedHeader (UnsizedHeader raw _ _) = toByronCBOR $ CC.encCBORABlockOrBo
325325
decodeUnsizedHeader :: CC.EpochSlots
326326
-> Decoder s (Lazy.ByteString -> UnsizedHeader)
327327
decodeUnsizedHeader epochSlots =
328-
toPlainDecoder byronProtVer $
328+
toPlainDecoder Nothing byronProtVer $
329329
fillInByteString <$> CC.decCBORABlockOrBoundaryHdr epochSlots
330330
where
331331
fillInByteString :: CC.ABlockOrBoundaryHdr ByteSpan

ouroboros-consensus-cardano/src/ouroboros-consensus-cardano/Ouroboros/Consensus/Cardano/CanHardFork.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ import qualified Cardano.Chain.Genesis as CC.Genesis
3333
import qualified Cardano.Chain.Update as CC.Update
3434
import Cardano.Crypto.DSIGN (Ed25519DSIGN)
3535
import Cardano.Crypto.Hash.Blake2b (Blake2b_224, Blake2b_256)
36+
import qualified Cardano.Ledger.Core as SL
3637
import Cardano.Ledger.Crypto (ADDRHASH, Crypto, DSIGN, HASH)
37-
import qualified Cardano.Ledger.Era as SL
3838
import qualified Cardano.Ledger.Genesis as SL
3939
import Cardano.Ledger.Hashes (EraIndependentTxBody)
4040
import Cardano.Ledger.Keys (DSignable, Hash)

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Block.hs

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ module Ouroboros.Consensus.Shelley.Ledger.Block (
4040

4141
import qualified Cardano.Crypto.Hash as Crypto
4242
import Cardano.Ledger.Binary (Annotator (..), DecCBOR (..),
43-
EncCBOR (..), FullByteString (..), serialize,
44-
toPlainDecoder)
43+
EncCBOR (..), FullByteString (..), serialize)
4544
import qualified Cardano.Ledger.Binary.Plain as Plain
46-
import Cardano.Ledger.Core as SL (eraProtVerLow, toEraCBOR)
45+
import Cardano.Ledger.Core as SL (eraDecoder, eraProtVerLow,
46+
toEraCBOR)
47+
import qualified Cardano.Ledger.Core as SL (hashTxSeq)
4748
import Cardano.Ledger.Crypto (HASH)
48-
import qualified Cardano.Ledger.Era as SL (hashTxSeq)
4949
import qualified Cardano.Ledger.Shelley.API as SL
5050
import qualified Cardano.Protocol.TPraos.BHeader as SL
5151
import qualified Data.ByteString.Lazy as Lazy
@@ -274,7 +274,7 @@ encodeShelleyBlock = toEraCBOR @era
274274
decodeShelleyBlock ::
275275
forall proto era. ShelleyCompatible proto era
276276
=> forall s. Plain.Decoder s (Lazy.ByteString -> ShelleyBlock proto era)
277-
decodeShelleyBlock = toPlainDecoder (eraProtVerLow @era) $ (. Full) . runAnnotator <$> decCBOR
277+
decodeShelleyBlock = eraDecoder @era $ (. Full) . runAnnotator <$> decCBOR
278278

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

298298
{-------------------------------------------------------------------------------
299299
Condense

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Forge.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
module Ouroboros.Consensus.Shelley.Ledger.Forge (forgeShelleyBlock) where
88

99
import qualified Cardano.Ledger.Core as Core (Tx)
10-
import qualified Cardano.Ledger.Era as SL (hashTxSeq, toTxSeq)
10+
import qualified Cardano.Ledger.Core as SL (hashTxSeq, toTxSeq)
1111
import qualified Cardano.Ledger.Shelley.API as SL (Block (..), extractTx)
1212
import qualified Cardano.Ledger.Shelley.BlockChain as SL (bBodySize)
1313
import qualified Cardano.Protocol.TPraos.BHeader as SL

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs

+41-23
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module Ouroboros.Consensus.Shelley.Ledger.Mempool (
3838

3939
import qualified Cardano.Crypto.Hash as Hash
4040
import qualified Cardano.Ledger.Allegra.Rules as AllegraEra
41-
import Cardano.Ledger.Alonzo.Core (Tx, TxSeq, bodyTxL, eraProtVerLow,
41+
import Cardano.Ledger.Alonzo.Core (Tx, TxSeq, bodyTxL, eraDecoder,
4242
fromTxSeq, ppMaxBBSizeL, ppMaxBlockExUnitsL, sizeTxF)
4343
import qualified Cardano.Ledger.Alonzo.Rules as AlonzoEra
4444
import Cardano.Ledger.Alonzo.Scripts (ExUnits, ExUnits',
@@ -49,7 +49,7 @@ import qualified Cardano.Ledger.Babbage.Rules as BabbageEra
4949
import qualified Cardano.Ledger.BaseTypes as L
5050
import Cardano.Ledger.Binary (Annotator (..), DecCBOR (..),
5151
EncCBOR (..), FromCBOR (..), FullByteString (..),
52-
ToCBOR (..), toPlainDecoder)
52+
ToCBOR (..))
5353
import qualified Cardano.Ledger.Conway.Rules as ConwayEra
5454
import qualified Cardano.Ledger.Conway.Rules as SL
5555
import qualified Cardano.Ledger.Conway.UTxO as SL
@@ -199,7 +199,7 @@ instance ShelleyCompatible proto era => ToCBOR (GenTx (ShelleyBlock proto era))
199199

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

204204
{-------------------------------------------------------------------------------
205205
Pretty-printing
@@ -353,41 +353,51 @@ instance MaxTxSizeUTxO (ShelleyEra c) where
353353
, mismatchExpected = txSizeLimit }
354354

355355
instance MaxTxSizeUTxO (AllegraEra c) where
356-
maxTxSizeUTxO x y =
356+
maxTxSizeUTxO txSize txSizeLimit =
357357
SL.ApplyTxError . pure
358358
$ ShelleyEra.UtxowFailure
359359
$ ShelleyEra.UtxoFailure
360-
$ AllegraEra.MaxTxSizeUTxO x y
360+
$ AllegraEra.MaxTxSizeUTxO
361+
$ L.Mismatch { mismatchSupplied = txSize
362+
, mismatchExpected = txSizeLimit }
361363

362364
instance MaxTxSizeUTxO (MaryEra c) where
363-
maxTxSizeUTxO x y =
365+
maxTxSizeUTxO txSize txSizeLimit =
364366
SL.ApplyTxError . pure
365367
$ ShelleyEra.UtxowFailure
366368
$ ShelleyEra.UtxoFailure
367-
$ AllegraEra.MaxTxSizeUTxO x y
369+
$ AllegraEra.MaxTxSizeUTxO
370+
$ L.Mismatch { mismatchSupplied = txSize
371+
, mismatchExpected = txSizeLimit }
368372

369373
instance MaxTxSizeUTxO (AlonzoEra c) where
370-
maxTxSizeUTxO x y =
374+
maxTxSizeUTxO txSize txSizeLimit =
371375
SL.ApplyTxError . pure
372376
$ ShelleyEra.UtxowFailure
373377
$ AlonzoEra.ShelleyInAlonzoUtxowPredFailure
374378
$ ShelleyEra.UtxoFailure
375-
$ AlonzoEra.MaxTxSizeUTxO x y
379+
$ AlonzoEra.MaxTxSizeUTxO
380+
$ L.Mismatch { mismatchSupplied = txSize
381+
, mismatchExpected = txSizeLimit }
376382

377383
instance MaxTxSizeUTxO (BabbageEra c) where
378-
maxTxSizeUTxO x y =
384+
maxTxSizeUTxO txSize txSizeLimit =
379385
SL.ApplyTxError . pure
380386
$ ShelleyEra.UtxowFailure
381387
$ BabbageEra.UtxoFailure
382388
$ BabbageEra.AlonzoInBabbageUtxoPredFailure
383-
$ AlonzoEra.MaxTxSizeUTxO x y
389+
$ AlonzoEra.MaxTxSizeUTxO
390+
$ L.Mismatch { mismatchSupplied = txSize
391+
, mismatchExpected = txSizeLimit }
384392

385393
instance MaxTxSizeUTxO (ConwayEra c) where
386-
maxTxSizeUTxO x y =
394+
maxTxSizeUTxO txSize txSizeLimit =
387395
SL.ApplyTxError . pure
388396
$ ConwayEra.ConwayUtxowFailure
389397
$ ConwayEra.UtxoFailure
390-
$ ConwayEra.MaxTxSizeUTxO x y
398+
$ ConwayEra.MaxTxSizeUTxO
399+
$ L.Mismatch { mismatchSupplied = txSize
400+
, mismatchExpected = txSizeLimit }
391401

392402
-----
393403

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

457467
exunits =
458-
validateMaybe (exUnitsTooBigUTxO limit txsz) $ do
468+
validateMaybe (exUnitsTooBigUTxO txsz limit) $ do
459469
guard $ pointWiseExUnits (<=) txsz limit
460470
Just $ fromExUnits txsz
461471

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

465475
instance Crypto c => ExUnitsTooBigUTxO (AlonzoEra c) where
466-
exUnitsTooBigUTxO x y =
476+
exUnitsTooBigUTxO txsz limit =
467477
SL.ApplyTxError . pure
468478
$ ShelleyEra.UtxowFailure
469479
$ AlonzoEra.ShelleyInAlonzoUtxowPredFailure
470480
$ ShelleyEra.UtxoFailure
471-
$ AlonzoEra.ExUnitsTooBigUTxO x y
481+
$ AlonzoEra.ExUnitsTooBigUTxO
482+
$ L.Mismatch { mismatchSupplied = txsz
483+
, mismatchExpected = limit }
472484

473485
instance Crypto c => ExUnitsTooBigUTxO (BabbageEra c) where
474-
exUnitsTooBigUTxO x y =
486+
exUnitsTooBigUTxO txsz limit =
475487
SL.ApplyTxError . pure
476488
$ ShelleyEra.UtxowFailure
477489
$ BabbageEra.AlonzoInBabbageUtxowPredFailure
478490
$ AlonzoEra.ShelleyInAlonzoUtxowPredFailure
479491
$ ShelleyEra.UtxoFailure
480492
$ BabbageEra.AlonzoInBabbageUtxoPredFailure
481-
$ AlonzoEra.ExUnitsTooBigUTxO x y
493+
$ AlonzoEra.ExUnitsTooBigUTxO
494+
$ L.Mismatch { mismatchSupplied = txsz
495+
, mismatchExpected = limit }
482496

483497
instance Crypto c => ExUnitsTooBigUTxO (ConwayEra c) where
484-
exUnitsTooBigUTxO x y =
498+
exUnitsTooBigUTxO txsz limit =
485499
SL.ApplyTxError . pure
486500
$ ConwayEra.ConwayUtxowFailure
487501
$ ConwayEra.UtxoFailure
488-
$ ConwayEra.ExUnitsTooBigUTxO x y
502+
$ ConwayEra.ExUnitsTooBigUTxO
503+
$ L.Mismatch { mismatchSupplied = txsz
504+
, mismatchExpected = limit }
489505

490506
-----
491507

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

548564
refScriptBytes =
549-
validateMaybe (txRefScriptsSizeTooBig limit txsz) $ do
565+
validateMaybe (txRefScriptsSizeTooBig txsz limit) $ do
550566
guard $ txsz <= limit
551567
Just $ IgnoringOverflow $ ByteSize32 $ fromIntegral txsz
552568

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

556572
instance Crypto c => TxRefScriptsSizeTooBig (ConwayEra c) where
557-
txRefScriptsSizeTooBig x y =
573+
txRefScriptsSizeTooBig txsz limit =
558574
SL.ApplyTxError . pure
559-
$ ConwayEra.ConwayTxRefScriptsSizeTooBig x y
575+
$ ConwayEra.ConwayTxRefScriptsSizeTooBig
576+
$ L.Mismatch { mismatchSupplied = txsz
577+
, mismatchExpected = limit }
560578

561579
-----
562580

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query/PParamsLegacyEncoder.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ instance Crypto c => ToCBOR (LegacyPParams (AlonzoEra c)) where
103103

104104
instance Crypto c => FromCBOR (LegacyPParams (AlonzoEra c)) where
105105
fromCBOR =
106-
toPlainDecoder (eraProtVerLow @(AlonzoEra c)) $
106+
eraDecoder @(AlonzoEra c) $
107107
decode $
108108
RecD mkLegacyAlonzoPParams
109109
<! From -- appMinFeeA
@@ -173,7 +173,7 @@ instance Crypto c => ToCBOR (LegacyPParams (BabbageEra c)) where
173173

174174
instance Crypto c => FromCBOR (LegacyPParams (BabbageEra c)) where
175175
fromCBOR =
176-
toPlainDecoder (eraProtVerLow @(BabbageEra c)) $
176+
eraDecoder @(BabbageEra c) $
177177
decode $
178178
RecD mkLegacyBabbagePParams
179179
<! From -- bppMinFeeA

0 commit comments

Comments
 (0)