Skip to content

Commit 5478ff9

Browse files
Soupstrawlehinsteodanciu
committed
Remove MemoBytes from ShelleyTx
Co-authored-by: Alexey Kuleshevich <[email protected]> Co-authored-by: teodanciu <[email protected]>
1 parent 0a9a0bc commit 5478ff9

File tree

17 files changed

+311
-539
lines changed

17 files changed

+311
-539
lines changed

eras/allegra/impl/src/Cardano/Ledger/Allegra/Tx.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import Cardano.Ledger.Shelley.Tx (
3131
mkBasicShelleyTx,
3232
shelleyMinFeeTx,
3333
sizeShelleyTxF,
34-
wireSizeShelleyTxF,
3534
witsShelleyTxL,
3635
)
3736
import qualified Data.Set as Set (map)
@@ -56,9 +55,6 @@ instance EraTx AllegraEra where
5655
sizeTxF = sizeShelleyTxF
5756
{-# INLINE sizeTxF #-}
5857

59-
wireSizeTxF = wireSizeShelleyTxF
60-
{-# INLINE wireSizeTxF #-}
61-
6258
validateNativeScript = validateTimelock
6359
{-# INLINE validateNativeScript #-}
6460

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Tx.hs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ module Cardano.Ledger.Alonzo.Tx (
4848
witsAlonzoTxL,
4949
auxDataAlonzoTxL,
5050
sizeAlonzoTxF,
51-
wireSizeAlonzoTxF,
5251
isValidAlonzoTxL,
5352
txdats',
5453
txscripts',
@@ -127,7 +126,6 @@ import Data.Maybe.Strict (
127126
)
128127
import Data.Set (Set)
129128
import Data.Typeable (Typeable)
130-
import Data.Word (Word32)
131129
import GHC.Generics (Generic)
132130
import Lens.Micro hiding (set)
133131
import NoThunks.Class (NoThunks)
@@ -169,9 +167,6 @@ instance EraTx AlonzoEra where
169167
sizeTxF = sizeAlonzoTxF
170168
{-# INLINE sizeTxF #-}
171169

172-
wireSizeTxF = wireSizeAlonzoTxF
173-
{-# INLINE wireSizeTxF #-}
174-
175170
validateNativeScript = validateTimelock
176171
{-# INLINE validateNativeScript #-}
177172

@@ -226,21 +221,6 @@ sizeAlonzoTxF =
226221
. toCBORForSizeComputation
227222
{-# INLINEABLE sizeAlonzoTxF #-}
228223

229-
-- | txsize computes the length of the serialised bytes (actual size)
230-
wireSizeAlonzoTxF :: forall era. EraTx era => SimpleGetter (AlonzoTx era) Word32
231-
wireSizeAlonzoTxF =
232-
to $
233-
checkedFromIntegral
234-
. LBS.length
235-
. serialize (eraProtVerLow @era)
236-
. encCBOR
237-
where
238-
checkedFromIntegral n =
239-
if n <= fromIntegral (maxBound :: Word32)
240-
then fromIntegral n
241-
else error $ "Impossible: Size of the transaction is too big: " ++ show n
242-
{-# INLINEABLE wireSizeAlonzoTxF #-}
243-
244224
isValidAlonzoTxL :: Lens' (AlonzoTx era) IsValid
245225
isValidAlonzoTxL = lens isValid (\tx valid -> tx {isValid = valid})
246226
{-# INLINEABLE isValidAlonzoTxL #-}

eras/babbage/impl/src/Cardano/Ledger/Babbage/Tx.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ instance EraTx BabbageEra where
4646
sizeTxF = sizeAlonzoTxF
4747
{-# INLINE sizeTxF #-}
4848

49-
wireSizeTxF = wireSizeAlonzoTxF
50-
{-# INLINE wireSizeTxF #-}
51-
5249
validateNativeScript = validateTimelock
5350
{-# INLINE validateNativeScript #-}
5451

eras/conway/impl/src/Cardano/Ledger/Conway/Tx.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import Cardano.Ledger.Alonzo.Tx (
2121
isValidAlonzoTxL,
2222
mkBasicAlonzoTx,
2323
sizeAlonzoTxF,
24-
wireSizeAlonzoTxF,
2524
witsAlonzoTxL,
2625
)
2726
import Cardano.Ledger.Alonzo.TxSeq (
@@ -62,9 +61,6 @@ instance EraTx ConwayEra where
6261
sizeTxF = sizeAlonzoTxF
6362
{-# INLINE sizeTxF #-}
6463

65-
wireSizeTxF = wireSizeAlonzoTxF
66-
{-# INLINE wireSizeTxF #-}
67-
6864
validateNativeScript = validateTimelock
6965
{-# INLINE validateNativeScript #-}
7066

eras/mary/impl/src/Cardano/Ledger/Mary/Tx.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import Cardano.Ledger.Shelley.Tx (
2121
mkBasicShelleyTx,
2222
shelleyMinFeeTx,
2323
sizeShelleyTxF,
24-
wireSizeShelleyTxF,
2524
witsShelleyTxL,
2625
)
2726

@@ -44,9 +43,6 @@ instance EraTx MaryEra where
4443
sizeTxF = sizeShelleyTxF
4544
{-# INLINE sizeTxF #-}
4645

47-
wireSizeTxF = wireSizeShelleyTxF
48-
{-# INLINE wireSizeTxF #-}
49-
5046
validateNativeScript = validateTimelock
5147
{-# INLINE validateNativeScript #-}
5248

eras/shelley/impl/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 1.17.0.0
44

5+
* Remove `ShelleyTxRaw`, `MkShelleyTx`, `segWitTx`, `unsafeConstructTxWithBytes`
56
* Added `Generic` instances for:
67
* `ShelleyBbodyState`
78
* `ShelleyScriptsNeeded`

eras/shelley/impl/cardano-ledger-shelley.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ library
5353
Cardano.Ledger.Shelley.Transition
5454
Cardano.Ledger.Shelley.Translation
5555
Cardano.Ledger.Shelley.Tx
56-
Cardano.Ledger.Shelley.Tx.Internal
5756
Cardano.Ledger.Shelley.TxAuxData
5857
Cardano.Ledger.Shelley.TxBody
5958
Cardano.Ledger.Shelley.TxCert

eras/shelley/impl/src/Cardano/Ledger/Shelley/BlockChain.hs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ import Cardano.Ledger.BaseTypes (
3333
BlocksMade (..),
3434
Nonce (..),
3535
StrictMaybe (..),
36+
maybeToStrictMaybe,
3637
mkNonceFromNumber,
3738
strictMaybeToMaybe,
3839
)
3940
import Cardano.Ledger.Binary (
40-
Annotator,
41+
Annotator (..),
4142
DecCBOR (decCBOR),
4243
Decoder,
4344
EncCBOR (..),
@@ -50,7 +51,7 @@ import Cardano.Ledger.Binary (
5051
)
5152
import Cardano.Ledger.Core
5253
import Cardano.Ledger.Shelley.Era (ShelleyEra)
53-
import Cardano.Ledger.Shelley.Tx (ShelleyTx, segWitAnnTx)
54+
import Cardano.Ledger.Shelley.Tx (ShelleyTx (..))
5455
import Cardano.Ledger.Slot (SlotNo (..))
5556
import Control.Monad (unless)
5657
import Data.ByteString (ByteString)
@@ -232,10 +233,19 @@ instance
232233
<> ")"
233234
)
234235

235-
let txns =
236-
sequenceA $
237-
StrictSeq.forceToStrict $
238-
Seq.zipWith3 segWitAnnTx bodies wits metadata
236+
let
237+
segWitAnnTx bodyAnn witsAnn' metaAnn = Annotator $ \bytes ->
238+
let body' = runAnnotator bodyAnn bytes
239+
witnessSet = runAnnotator witsAnn' bytes
240+
metadata' = flip runAnnotator bytes <$> metaAnn
241+
in ShelleyTx
242+
body'
243+
witnessSet
244+
(maybeToStrictMaybe metadata')
245+
txns =
246+
sequenceA $
247+
StrictSeq.forceToStrict $
248+
Seq.zipWith3 segWitAnnTx bodies wits metadata
239249
pure $ TxSeq' <$> txns <*> bodiesAnn <*> witsAnn <*> metadataAnn
240250

241251
slotToNonce :: SlotNo -> Nonce

0 commit comments

Comments
 (0)