Skip to content

Commit a36a72f

Browse files
neilmayhewlehins
authored andcommitted
cardano-ledger upgrade: use new predicate failure API with Mismatch
1 parent ea81b54 commit a36a72f

File tree

1 file changed

+38
-20
lines changed
  • ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger

1 file changed

+38
-20
lines changed

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

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)