@@ -94,6 +94,7 @@ import Cardano.Ledger.Alonzo.TxWits (
94
94
unRedeemersL ,
95
95
unTxDatsL ,
96
96
)
97
+ import Cardano.Ledger.BaseTypes (integralToBounded )
97
98
import Cardano.Ledger.Binary (
98
99
Annotator ,
99
100
DecCBOR (.. ),
@@ -118,8 +119,10 @@ import Cardano.Ledger.State (EraUTxO, ScriptsProvided (..))
118
119
import qualified Cardano.Ledger.State as Shelley
119
120
import Cardano.Ledger.Val (Val ((<+>) , (<×>) ))
120
121
import Control.DeepSeq (NFData (.. ))
122
+ import Control.Monad.Trans.Fail.String (errorFail )
121
123
import Data.Aeson (ToJSON (.. ))
122
124
import qualified Data.ByteString.Lazy as LBS
125
+ import Data.Int (Int64 )
123
126
import qualified Data.Map.Strict as Map
124
127
import Data.Maybe (mapMaybe )
125
128
import Data.Maybe.Strict (
@@ -130,7 +133,9 @@ import Data.Maybe.Strict (
130
133
import Data.Set (Set )
131
134
import qualified Data.Set as Set
132
135
import Data.Typeable (Typeable )
136
+ import Data.Word (Word32 )
133
137
import GHC.Generics (Generic )
138
+ import GHC.Stack (HasCallStack )
134
139
import Lens.Micro hiding (set )
135
140
import NoThunks.Class (NoThunks )
136
141
@@ -217,10 +222,11 @@ auxDataAlonzoTxL = lens atAuxData (\tx txTxAuxData -> tx {atAuxData = txTxAuxDat
217
222
{-# INLINEABLE auxDataAlonzoTxL #-}
218
223
219
224
-- | txsize computes the length of the serialised bytes (for estimations)
220
- sizeAlonzoTxF :: forall era . EraTx era => SimpleGetter (AlonzoTx era ) Integer
225
+ sizeAlonzoTxF :: forall era . ( HasCallStack , EraTx era ) => SimpleGetter (AlonzoTx era ) Word32
221
226
sizeAlonzoTxF =
222
227
to $
223
- fromIntegral
228
+ errorFail
229
+ . integralToBounded @ Int64 @ Word32
224
230
. LBS. length
225
231
. serialize (eraProtVerLow @ era )
226
232
. toCBORForSizeComputation
0 commit comments