11{-# LANGUAGE BangPatterns #-}
22{-# LANGUAGE FlexibleContexts #-}
3+ {-# LANGUAGE LambdaCase #-}
34{-# LANGUAGE NamedFieldPuns #-}
45{-# LANGUAGE OverloadedStrings #-}
56{-# LANGUAGE TypeApplications #-}
@@ -11,6 +12,10 @@ import Cardano.Ledger.Api.Era
1112import Cardano.Ledger.Api.State.Query (queryStakePoolDelegsAndRewards )
1213import Cardano.Ledger.BaseTypes
1314import Cardano.Ledger.Binary
15+ import Cardano.Ledger.Conway.Rules (
16+ ConwayLedgerPredFailure (ConwayUtxowFailure ),
17+ ConwayUtxowPredFailure (InvalidWitnessesUTXOW ),
18+ )
1419import Cardano.Ledger.Core
1520import Cardano.Ledger.Shelley.API.Mempool
1621import Cardano.Ledger.Shelley.API.Wallet (getFilteredUTxO , getUTxO )
@@ -30,10 +35,11 @@ import Control.DeepSeq
3035import Control.Monad (when )
3136import Criterion.Main
3237import Data.Aeson
33- import Data.Bifunctor (first )
38+ import Data.Bifunctor (bimap , first )
3439import Data.ByteString.Base16.Lazy as BSL16
3540import Data.ByteString.Lazy (ByteString )
3641import Data.Foldable as F
42+ import Data.List.NonEmpty (NonEmpty ((:|) ))
3743import Data.Map.Strict (Map )
3844import qualified Data.Map.Strict as Map
3945import Data.MapExtras (extractKeys , extractKeysSmallSet )
@@ -75,8 +81,12 @@ main = do
7581 toMempoolState NewEpochState {nesEs = EpochState {esLState}} = esLState
7682 ! globals = mkGlobals genesis
7783 ! slotNo = SlotNo 55733343
84+ restrictError = \ case
85+ ApplyTxError (ConwayUtxowFailure (InvalidWitnessesUTXOW [_]) :| [] ) -> ()
86+ otherErr -> error . show $ otherErr
7887 applyTx' mempoolEnv mempoolState =
79- either (error . show ) seqTuple
88+ -- TODO: revert this to `either (error . show) seqTuple` after tx's are fixed
89+ bimap restrictError seqTuple
8090 . applyTx globals mempoolEnv mempoolState
8191 reapplyTx' mempoolEnv mempoolState =
8292 either (error . show ) id
@@ -112,7 +122,9 @@ main = do
112122 bench " Tx3" . whnf (applyTx' mempoolEnv mempoolState)
113123 , env
114124 (pure [validatedTx1, validatedTx2, validatedTx3])
115- $ bench " Tx1+Tx2+Tx3" . whnf (F. foldl' (\ ms -> fst . applyTx' mempoolEnv ms . extractTx) mempoolState)
125+ $ bench " Tx1+Tx2+Tx3"
126+ -- TODO: revert this to `foldl'` without `fmap` after tx's are fixed
127+ . whnf (F. foldlM (\ ms -> fmap fst . applyTx' mempoolEnv ms . extractTx) mempoolState)
116128 ]
117129 , env (pure utxo) $ \ utxo' ->
118130 bgroup
0 commit comments