@@ -94,6 +94,7 @@ import Cardano.Ledger.Alonzo.TxWits (
9494 unRedeemersL ,
9595 unTxDatsL ,
9696 )
97+ import Cardano.Ledger.BaseTypes (integralToBounded )
9798import Cardano.Ledger.Binary (
9899 Annotator ,
99100 DecCBOR (.. ),
@@ -118,8 +119,10 @@ import Cardano.Ledger.State (EraUTxO, ScriptsProvided (..))
118119import qualified Cardano.Ledger.State as Shelley
119120import Cardano.Ledger.Val (Val ((<+>) , (<×>) ))
120121import Control.DeepSeq (NFData (.. ))
122+ import Control.Monad.Trans.Fail.String (errorFail )
121123import Data.Aeson (ToJSON (.. ))
122124import qualified Data.ByteString.Lazy as LBS
125+ import Data.Int (Int64 )
123126import qualified Data.Map.Strict as Map
124127import Data.Maybe (mapMaybe )
125128import Data.Maybe.Strict (
@@ -130,6 +133,7 @@ import Data.Maybe.Strict (
130133import Data.Set (Set )
131134import qualified Data.Set as Set
132135import Data.Typeable (Typeable )
136+ import Data.Word (Word32 )
133137import GHC.Generics (Generic )
134138import Lens.Micro hiding (set )
135139import NoThunks.Class (NoThunks )
@@ -217,10 +221,11 @@ auxDataAlonzoTxL = lens atAuxData (\tx txTxAuxData -> tx {atAuxData = txTxAuxDat
217221{-# INLINEABLE auxDataAlonzoTxL #-}
218222
219223-- | txsize computes the length of the serialised bytes (for estimations)
220- sizeAlonzoTxF :: forall era . EraTx era => SimpleGetter (AlonzoTx era ) Integer
224+ sizeAlonzoTxF :: forall era . EraTx era => SimpleGetter (AlonzoTx era ) Word32
221225sizeAlonzoTxF =
222226 to $
223- fromIntegral
227+ errorFail
228+ . integralToBounded @ Int64 @ Word32
224229 . LBS. length
225230 . serialize (eraProtVerLow @ era )
226231 . toCBORForSizeComputation
0 commit comments