@@ -38,7 +38,7 @@ module Ouroboros.Consensus.Shelley.Ledger.Mempool (
38
38
39
39
import qualified Cardano.Crypto.Hash as Hash
40
40
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 ,
42
42
fromTxSeq , ppMaxBBSizeL , ppMaxBlockExUnitsL , sizeTxF )
43
43
import qualified Cardano.Ledger.Alonzo.Rules as AlonzoEra
44
44
import Cardano.Ledger.Alonzo.Scripts (ExUnits , ExUnits' ,
@@ -49,7 +49,7 @@ import qualified Cardano.Ledger.Babbage.Rules as BabbageEra
49
49
import qualified Cardano.Ledger.BaseTypes as L
50
50
import Cardano.Ledger.Binary (Annotator (.. ), DecCBOR (.. ),
51
51
EncCBOR (.. ), FromCBOR (.. ), FullByteString (.. ),
52
- ToCBOR (.. ), toPlainDecoder )
52
+ ToCBOR (.. ))
53
53
import qualified Cardano.Ledger.Conway.Rules as ConwayEra
54
54
import qualified Cardano.Ledger.Conway.Rules as SL
55
55
import qualified Cardano.Ledger.Conway.UTxO as SL
@@ -199,7 +199,7 @@ instance ShelleyCompatible proto era => ToCBOR (GenTx (ShelleyBlock proto era))
199
199
200
200
instance ShelleyCompatible proto era => FromCBOR (GenTx (ShelleyBlock proto era )) where
201
201
fromCBOR = fmap mkShelleyTx $ unwrapCBORinCBOR
202
- $ toPlainDecoder (eraProtVerLow @ era ) $ (. Full ) . runAnnotator <$> decCBOR
202
+ $ eraDecoder @ era $ (. Full ) . runAnnotator <$> decCBOR
203
203
204
204
{- ------------------------------------------------------------------------------
205
205
Pretty-printing
@@ -353,41 +353,51 @@ instance MaxTxSizeUTxO (ShelleyEra c) where
353
353
, mismatchExpected = txSizeLimit }
354
354
355
355
instance MaxTxSizeUTxO (AllegraEra c ) where
356
- maxTxSizeUTxO x y =
356
+ maxTxSizeUTxO txSize txSizeLimit =
357
357
SL. ApplyTxError . pure
358
358
$ ShelleyEra. UtxowFailure
359
359
$ ShelleyEra. UtxoFailure
360
- $ AllegraEra. MaxTxSizeUTxO x y
360
+ $ AllegraEra. MaxTxSizeUTxO
361
+ $ L. Mismatch { mismatchSupplied = txSize
362
+ , mismatchExpected = txSizeLimit }
361
363
362
364
instance MaxTxSizeUTxO (MaryEra c ) where
363
- maxTxSizeUTxO x y =
365
+ maxTxSizeUTxO txSize txSizeLimit =
364
366
SL. ApplyTxError . pure
365
367
$ ShelleyEra. UtxowFailure
366
368
$ ShelleyEra. UtxoFailure
367
- $ AllegraEra. MaxTxSizeUTxO x y
369
+ $ AllegraEra. MaxTxSizeUTxO
370
+ $ L. Mismatch { mismatchSupplied = txSize
371
+ , mismatchExpected = txSizeLimit }
368
372
369
373
instance MaxTxSizeUTxO (AlonzoEra c ) where
370
- maxTxSizeUTxO x y =
374
+ maxTxSizeUTxO txSize txSizeLimit =
371
375
SL. ApplyTxError . pure
372
376
$ ShelleyEra. UtxowFailure
373
377
$ AlonzoEra. ShelleyInAlonzoUtxowPredFailure
374
378
$ ShelleyEra. UtxoFailure
375
- $ AlonzoEra. MaxTxSizeUTxO x y
379
+ $ AlonzoEra. MaxTxSizeUTxO
380
+ $ L. Mismatch { mismatchSupplied = txSize
381
+ , mismatchExpected = txSizeLimit }
376
382
377
383
instance MaxTxSizeUTxO (BabbageEra c ) where
378
- maxTxSizeUTxO x y =
384
+ maxTxSizeUTxO txSize txSizeLimit =
379
385
SL. ApplyTxError . pure
380
386
$ ShelleyEra. UtxowFailure
381
387
$ BabbageEra. UtxoFailure
382
388
$ BabbageEra. AlonzoInBabbageUtxoPredFailure
383
- $ AlonzoEra. MaxTxSizeUTxO x y
389
+ $ AlonzoEra. MaxTxSizeUTxO
390
+ $ L. Mismatch { mismatchSupplied = txSize
391
+ , mismatchExpected = txSizeLimit }
384
392
385
393
instance MaxTxSizeUTxO (ConwayEra c ) where
386
- maxTxSizeUTxO x y =
394
+ maxTxSizeUTxO txSize txSizeLimit =
387
395
SL. ApplyTxError . pure
388
396
$ ConwayEra. ConwayUtxowFailure
389
397
$ ConwayEra. UtxoFailure
390
- $ ConwayEra. MaxTxSizeUTxO x y
398
+ $ ConwayEra. MaxTxSizeUTxO
399
+ $ L. Mismatch { mismatchSupplied = txSize
400
+ , mismatchExpected = txSizeLimit }
391
401
392
402
-----
393
403
@@ -455,37 +465,43 @@ txMeasureAlonzo st tx@(ShelleyTx _txid tx') =
455
465
limit = pparams ^. L. ppMaxTxExUnitsL
456
466
457
467
exunits =
458
- validateMaybe (exUnitsTooBigUTxO limit txsz) $ do
468
+ validateMaybe (exUnitsTooBigUTxO txsz limit ) $ do
459
469
guard $ pointWiseExUnits (<=) txsz limit
460
470
Just $ fromExUnits txsz
461
471
462
472
class ExUnitsTooBigUTxO era where
463
473
exUnitsTooBigUTxO :: ExUnits -> ExUnits -> SL. ApplyTxError era
464
474
465
475
instance Crypto c => ExUnitsTooBigUTxO (AlonzoEra c ) where
466
- exUnitsTooBigUTxO x y =
476
+ exUnitsTooBigUTxO txsz limit =
467
477
SL. ApplyTxError . pure
468
478
$ ShelleyEra. UtxowFailure
469
479
$ AlonzoEra. ShelleyInAlonzoUtxowPredFailure
470
480
$ ShelleyEra. UtxoFailure
471
- $ AlonzoEra. ExUnitsTooBigUTxO x y
481
+ $ AlonzoEra. ExUnitsTooBigUTxO
482
+ $ L. Mismatch { mismatchSupplied = txsz
483
+ , mismatchExpected = limit }
472
484
473
485
instance Crypto c => ExUnitsTooBigUTxO (BabbageEra c ) where
474
- exUnitsTooBigUTxO x y =
486
+ exUnitsTooBigUTxO txsz limit =
475
487
SL. ApplyTxError . pure
476
488
$ ShelleyEra. UtxowFailure
477
489
$ BabbageEra. AlonzoInBabbageUtxowPredFailure
478
490
$ AlonzoEra. ShelleyInAlonzoUtxowPredFailure
479
491
$ ShelleyEra. UtxoFailure
480
492
$ BabbageEra. AlonzoInBabbageUtxoPredFailure
481
- $ AlonzoEra. ExUnitsTooBigUTxO x y
493
+ $ AlonzoEra. ExUnitsTooBigUTxO
494
+ $ L. Mismatch { mismatchSupplied = txsz
495
+ , mismatchExpected = limit }
482
496
483
497
instance Crypto c => ExUnitsTooBigUTxO (ConwayEra c ) where
484
- exUnitsTooBigUTxO x y =
498
+ exUnitsTooBigUTxO txsz limit =
485
499
SL. ApplyTxError . pure
486
500
$ ConwayEra. ConwayUtxowFailure
487
501
$ ConwayEra. UtxoFailure
488
- $ ConwayEra. ExUnitsTooBigUTxO x y
502
+ $ ConwayEra. ExUnitsTooBigUTxO
503
+ $ L. Mismatch { mismatchSupplied = txsz
504
+ , mismatchExpected = limit }
489
505
490
506
-----
491
507
@@ -546,17 +562,19 @@ txMeasureConway st tx@(ShelleyTx _txid tx') =
546
562
limit = SL. maxRefScriptSizePerTx
547
563
548
564
refScriptBytes =
549
- validateMaybe (txRefScriptsSizeTooBig limit txsz) $ do
565
+ validateMaybe (txRefScriptsSizeTooBig txsz limit ) $ do
550
566
guard $ txsz <= limit
551
567
Just $ IgnoringOverflow $ ByteSize32 $ fromIntegral txsz
552
568
553
569
class TxRefScriptsSizeTooBig era where
554
570
txRefScriptsSizeTooBig :: Int -> Int -> SL. ApplyTxError era
555
571
556
572
instance Crypto c => TxRefScriptsSizeTooBig (ConwayEra c ) where
557
- txRefScriptsSizeTooBig x y =
573
+ txRefScriptsSizeTooBig txsz limit =
558
574
SL. ApplyTxError . pure
559
- $ ConwayEra. ConwayTxRefScriptsSizeTooBig x y
575
+ $ ConwayEra. ConwayTxRefScriptsSizeTooBig
576
+ $ L. Mismatch { mismatchSupplied = txsz
577
+ , mismatchExpected = limit }
560
578
561
579
-----
562
580
0 commit comments