Skip to content

Commit

Permalink
Drop 'FromCBOR' for ValidatedTx.
Browse files Browse the repository at this point in the history
The ValidatedTx type now exists only inside of blocks, and as such is
serialised only as part of a TxSeq. So we can drop the `FromCBOR`
instance entirely - it will never be used.

We _do_ still use the stored bytes, in order to compute the transaction
size. So for the moment we do still use the `ToCBOR` instances.
  • Loading branch information
nc6 committed Apr 8, 2021
1 parent 9b8742d commit 03ac217
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 51 deletions.
49 changes: 1 addition & 48 deletions alonzo/impl/src/Cardano/Ledger/Alonzo/Tx.hs
Expand Up @@ -124,7 +124,7 @@ import Cardano.Ledger.SafeHash
hashAnnotated,
)
import Cardano.Ledger.Shelley.Constraints
import Cardano.Ledger.Val (DecodeMint, DecodeNonNegative, Val (coin, (<+>), (<×>)))
import Cardano.Ledger.Val (Val (coin, (<+>), (<×>)))
import Control.DeepSeq (NFData (..))
import qualified Data.ByteString.Lazy as LBS (toStrict)
import qualified Data.ByteString.Short as SBS (length, toShort)
Expand Down Expand Up @@ -606,53 +606,6 @@ encodeTxRaw ValidatedTxRaw {_body, _wits, _isValidating, _auxiliaryData} =
!> To _isValidating
!> E (encodeNullMaybe toCBOR . strictMaybeToMaybe) _auxiliaryData

instance
( Era era,
FromCBOR (Annotator (Core.Script era)),
FromCBOR (Annotator (Core.TxBody era)),
FromCBOR (Annotator (Core.AuxiliaryData era)),
FromCBOR (PParamsDelta era),
ToCBOR (Core.Script era),
Typeable (Core.Script era),
Typeable (Core.AuxiliaryData era),
Compactible (Core.Value era),
DecodeNonNegative (Core.Value era),
DecodeMint (Core.Value era),
Show (Core.Value era),
Val (Core.Value era)
) =>
FromCBOR (Annotator (ValidatedTxRaw era))
where
fromCBOR =
decode $
Ann (RecD ValidatedTxRaw)
<*! From
<*! From
<*! Ann From
<*! D
( sequence . maybeToStrictMaybe
<$> decodeNullMaybe fromCBOR
)

deriving via
Mem (ValidatedTxRaw era)
instance
( Era era,
FromCBOR (Annotator (Core.Script era)),
FromCBOR (Annotator (Core.TxBody era)),
FromCBOR (Annotator (Core.AuxiliaryData era)),
FromCBOR (PParamsDelta era),
ToCBOR (Core.Script era),
Typeable (Core.Script era),
Typeable (Core.AuxiliaryData era),
Compactible (Core.Value era),
DecodeNonNegative (Core.Value era),
DecodeMint (Core.Value era),
Show (Core.Value era),
Val (Core.Value era)
) =>
FromCBOR (Annotator (ValidatedTx era))

segwitTx ::
( Era era,
ToCBOR (Core.TxBody era),
Expand Down
Expand Up @@ -13,7 +13,7 @@ import Cardano.Ledger.Alonzo.Rules.Utxos (UtxosPredicateFailure)
-- TODO resolve the problem with the Utxow predicate failure type, so we will need this import
-- import Cardano.Ledger.Alonzo.Rules.Utxow (AlonzoPredFail)
import Cardano.Ledger.Alonzo.Scripts (Script)
import Cardano.Ledger.Alonzo.Tx (CostModel, Tx, WitnessPPData)
import Cardano.Ledger.Alonzo.Tx (CostModel, WitnessPPData)
import Cardano.Ledger.Alonzo.TxBody (TxBody)
import Cardano.Ledger.Alonzo.TxWitness
import qualified Data.ByteString.Base16.Lazy as Base16
Expand Down Expand Up @@ -75,8 +75,6 @@ tests =
trippingAnn @(TxWitness (AlonzoEra C_Crypto)),
testProperty "alonzo/TxBody" $
trippingAnn @(TxBody (AlonzoEra C_Crypto)),
testProperty "alonzo/Tx" $
trippingAnn @(Tx (AlonzoEra C_Crypto)),
testProperty "alonzo/CostModel" $
tripping @CostModel,
testProperty "alonzo/PParams" $
Expand Down

0 comments on commit 03ac217

Please sign in to comment.