1
1
{-# LANGUAGE BangPatterns #-}
2
2
{-# LANGUAGE FlexibleContexts #-}
3
+ {-# LANGUAGE LambdaCase #-}
3
4
{-# LANGUAGE NamedFieldPuns #-}
4
5
{-# LANGUAGE OverloadedStrings #-}
5
6
{-# LANGUAGE TypeApplications #-}
@@ -11,6 +12,10 @@ import Cardano.Ledger.Api.Era
11
12
import Cardano.Ledger.Api.State.Query (queryStakePoolDelegsAndRewards )
12
13
import Cardano.Ledger.BaseTypes
13
14
import Cardano.Ledger.Binary
15
+ import Cardano.Ledger.Conway.Rules (
16
+ ConwayLedgerPredFailure (ConwayUtxowFailure ),
17
+ ConwayUtxowPredFailure (InvalidWitnessesUTXOW ),
18
+ )
14
19
import Cardano.Ledger.Core
15
20
import Cardano.Ledger.Shelley.API.Mempool
16
21
import Cardano.Ledger.Shelley.API.Wallet (getFilteredUTxO , getUTxO )
@@ -30,10 +35,11 @@ import Control.DeepSeq
30
35
import Control.Monad (when )
31
36
import Criterion.Main
32
37
import Data.Aeson
33
- import Data.Bifunctor (first )
38
+ import Data.Bifunctor (bimap , first )
34
39
import Data.ByteString.Base16.Lazy as BSL16
35
40
import Data.ByteString.Lazy (ByteString )
36
41
import Data.Foldable as F
42
+ import Data.List.NonEmpty (NonEmpty ((:|) ))
37
43
import Data.Map.Strict (Map )
38
44
import qualified Data.Map.Strict as Map
39
45
import Data.MapExtras (extractKeys , extractKeysSmallSet )
@@ -75,8 +81,12 @@ main = do
75
81
toMempoolState NewEpochState {nesEs = EpochState {esLState}} = esLState
76
82
! globals = mkGlobals genesis
77
83
! slotNo = SlotNo 55733343
84
+ restrictError = \ case
85
+ ApplyTxError (ConwayUtxowFailure (InvalidWitnessesUTXOW [_]) :| [] ) -> ()
86
+ otherErr -> error . show $ otherErr
78
87
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
80
90
. applyTx globals mempoolEnv mempoolState
81
91
reapplyTx' mempoolEnv mempoolState =
82
92
either (error . show ) id
@@ -112,7 +122,9 @@ main = do
112
122
bench " Tx3" . whnf (applyTx' mempoolEnv mempoolState)
113
123
, env
114
124
(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)
116
128
]
117
129
, env (pure utxo) $ \ utxo' ->
118
130
bgroup
0 commit comments