Skip to content

Commit

Permalink
Merge pull request #4810 from IntersectMBO/lehins/deprecate-auxiliary…
Browse files Browse the repository at this point in the history
…datahash

Deprecate `AauxiliaryDataHash`
  • Loading branch information
lehins authored Dec 20, 2024
2 parents a5c4074 + e8f0bea commit ea1d436
Show file tree
Hide file tree
Showing 51 changed files with 151 additions and 188 deletions.
1 change: 1 addition & 0 deletions eras/allegra/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.7.0.0

* Remove deprecated `AuxiliaryData` type synonym
* Deprecate `Allegra` type synonym
* Remove crypto parametrization from `AllegraEra`

Expand Down
10 changes: 0 additions & 10 deletions eras/allegra/impl/src/Cardano/Ledger/Allegra/TxAuxData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,11 @@ module Cardano.Ledger.Allegra.TxAuxData (
metadataAllegraTxAuxDataL,
AllegraEraTxAuxData (..),
timelockScriptsAllegraTxAuxDataL,

-- * Deprecations
AuxiliaryData,
)
where

import Cardano.Ledger.Allegra.Era (AllegraEra)
import Cardano.Ledger.Allegra.Scripts (Timelock)
import Cardano.Ledger.AuxiliaryData (AuxiliaryDataHash (..))
import Cardano.Ledger.Binary (
Annotator (..),
DecCBOR (..),
Expand Down Expand Up @@ -100,8 +96,6 @@ instance EraTxAuxData AllegraEra where

validateTxAuxData _ (AllegraTxAuxData md as) = as `deepseq` all validMetadatum md

hashTxAuxData aux = AuxiliaryDataHash (hashAnnotated aux)

metadataAllegraTxAuxDataL :: Era era => Lens' (AllegraTxAuxData era) (Map Word64 Metadatum)
metadataAllegraTxAuxDataL =
lensMemoRawType atadrMetadata $ \txAuxDataRaw md -> txAuxDataRaw {atadrMetadata = md}
Expand Down Expand Up @@ -151,10 +145,6 @@ pattern AllegraTxAuxData blob sp <- (getMemoRawType -> AllegraTxAuxDataRaw blob

{-# COMPLETE AllegraTxAuxData #-}

type AuxiliaryData = AllegraTxAuxData

{-# DEPRECATED AuxiliaryData "Use `AllegraTxAuxData` instead" #-}

--------------------------------------------------------------------------------
-- Serialisation
--------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import Cardano.Ledger.Allegra.Era (AllegraEra)
import Cardano.Ledger.Allegra.Scripts (ValidityInterval (..))
import Cardano.Ledger.Allegra.TxCert ()
import Cardano.Ledger.Allegra.TxOut ()
import Cardano.Ledger.AuxiliaryData (AuxiliaryDataHash)
import Cardano.Ledger.BaseTypes (SlotNo, StrictMaybe (SJust, SNothing))
import Cardano.Ledger.Binary (Annotator, DecCBOR (..), EncCBOR (..), ToCBOR)
import Cardano.Ledger.Binary.Coders (
Expand Down Expand Up @@ -106,7 +105,7 @@ data AllegraTxBodyRaw ma era = AllegraTxBodyRaw
, atbrTxFee :: !Coin
, atbrValidityInterval :: !ValidityInterval
, atbrUpdate :: !(StrictMaybe (Update era))
, atbrAuxDataHash :: !(StrictMaybe AuxiliaryDataHash)
, atbrAuxDataHash :: !(StrictMaybe TxAuxDataHash)
, atbrMint :: !ma
}

Expand Down Expand Up @@ -261,7 +260,7 @@ pattern AllegraTxBody ::
Coin ->
ValidityInterval ->
StrictMaybe (Update era) ->
StrictMaybe AuxiliaryDataHash ->
StrictMaybe TxAuxDataHash ->
AllegraTxBody era
pattern AllegraTxBody
{ atbInputs
Expand Down
2 changes: 2 additions & 0 deletions eras/alonzo/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 1.13.0.0

* Deprecate `hashAlonzoTxAuxData`
* Stop re-exporting deprecated `AuxiliaryDataHash` from `Cardano.Ledger.Alonzo.TxAuxData`
* Deprecate `Alonzo` type synonym
* Remove crypto parametrization from `AlonzoEra`

Expand Down
9 changes: 3 additions & 6 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxAuxData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ module Cardano.Ledger.Alonzo.TxAuxData (
AlonzoEraTxAuxData (..),
AlonzoTxAuxDataRaw,
mkAlonzoTxAuxData,
AuxiliaryDataHash (..),
hashAlonzoTxAuxData,
validateAlonzoTxAuxData,
getAlonzoTxAuxDataScripts,
Expand All @@ -56,7 +55,6 @@ import Cardano.Ledger.Alonzo.Scripts (
plutusScriptLanguage,
validScript,
)
import Cardano.Ledger.AuxiliaryData (AuxiliaryDataHash (..))
import Cardano.Ledger.BaseTypes (ProtVer)
import Cardano.Ledger.Binary (
Annotator (..),
Expand Down Expand Up @@ -263,8 +261,6 @@ instance EraTxAuxData AlonzoEra where
, atadrPlutus = mempty
}

hashTxAuxData = hashAlonzoTxAuxData

validateTxAuxData = validateAlonzoTxAuxData

metadataAlonzoTxAuxDataL :: Era era => Lens' (AlonzoTxAuxData era) (Map Word64 Metadatum)
Expand All @@ -274,8 +270,9 @@ metadataAlonzoTxAuxDataL =
hashAlonzoTxAuxData ::
HashAnnotated x EraIndependentTxAuxData =>
x ->
AuxiliaryDataHash
hashAlonzoTxAuxData x = AuxiliaryDataHash (hashAnnotated x)
TxAuxDataHash
hashAlonzoTxAuxData x = TxAuxDataHash (hashAnnotated x)
{-# DEPRECATED hashAlonzoTxAuxData "In favor of `hashTxAuxData`" #-}

validateAlonzoTxAuxData ::
(AlonzoEraScript era, Script era ~ AlonzoScript era) =>
Expand Down
8 changes: 4 additions & 4 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ import Cardano.Ledger.Alonzo.Scripts (
AsIxItem (..),
PlutusPurpose,
)
import Cardano.Ledger.Alonzo.TxAuxData (AuxiliaryDataHash (..))
import Cardano.Ledger.Alonzo.TxAuxData ()
import Cardano.Ledger.Alonzo.TxCert ()
import Cardano.Ledger.Alonzo.TxOut
import Cardano.Ledger.BaseTypes (
Expand Down Expand Up @@ -194,7 +194,7 @@ data AlonzoTxBodyRaw era = AlonzoTxBodyRaw
, atbrReqSignerHashes :: Set (KeyHash 'Witness)
, atbrMint :: !MultiAsset
, atbrScriptIntegrityHash :: !(StrictMaybe ScriptIntegrityHash)
, atbrAuxDataHash :: !(StrictMaybe AuxiliaryDataHash)
, atbrAuxDataHash :: !(StrictMaybe TxAuxDataHash)
, atbrTxNetworkId :: !(StrictMaybe Network)
}
deriving (Generic, Typeable)
Expand Down Expand Up @@ -409,7 +409,7 @@ pattern AlonzoTxBody ::
Set (KeyHash 'Witness) ->
MultiAsset ->
StrictMaybe ScriptIntegrityHash ->
StrictMaybe AuxiliaryDataHash ->
StrictMaybe TxAuxDataHash ->
StrictMaybe Network ->
AlonzoTxBody era
pattern AlonzoTxBody
Expand Down Expand Up @@ -498,7 +498,7 @@ withdrawals' :: AlonzoTxBody era -> Withdrawals
vldt' :: AlonzoTxBody era -> ValidityInterval
update' :: AlonzoTxBody era -> StrictMaybe (Update era)
reqSignerHashes' :: AlonzoTxBody era -> Set (KeyHash 'Witness)
adHash' :: AlonzoTxBody era -> StrictMaybe AuxiliaryDataHash
adHash' :: AlonzoTxBody era -> StrictMaybe TxAuxDataHash
mint' :: AlonzoTxBody era -> MultiAsset
scriptIntegrityHash' :: AlonzoTxBody era -> StrictMaybe ScriptIntegrityHash
txnetworkid' :: AlonzoTxBody era -> StrictMaybe Network
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import Cardano.Ledger.Alonzo.TxWits (
nullRedeemers,
)
import Cardano.Ledger.Alonzo.UTxO (AlonzoScriptsNeeded (..))
import Cardano.Ledger.AuxiliaryData (AuxiliaryDataHash)
import Cardano.Ledger.BaseTypes
import Cardano.Ledger.Binary (EncCBOR)
import Cardano.Ledger.Coin (Coin (..))
Expand Down Expand Up @@ -263,7 +262,7 @@ genAlonzoTxBody ::
Withdrawals ->
Coin ->
StrictMaybe (Update AlonzoEra) ->
StrictMaybe AuxiliaryDataHash ->
StrictMaybe TxAuxDataHash ->
Gen (TxBody AlonzoEra, [Script AlonzoEra])
genAlonzoTxBody _genenv utxo pparams currentslot input txOuts certs withdrawals fee updates auxDHash = do
netid <- genM $ pure Testnet -- frequency [(2, pure Mainnet), (1, pure Testnet)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Cardano.Ledger.Alonzo.Scripts (
Prices (..),
)
import Cardano.Ledger.Alonzo.Tx (AlonzoTx (..), IsValid (..))
import Cardano.Ledger.Alonzo.TxAuxData (AuxiliaryDataHash (..), mkAlonzoTxAuxData)
import Cardano.Ledger.Alonzo.TxAuxData (mkAlonzoTxAuxData)
import Cardano.Ledger.Alonzo.TxBody (AlonzoTxBody (..), AlonzoTxOut (..))
import Cardano.Ledger.Alonzo.TxWits (AlonzoTxWits (..), Redeemers (..), TxDats (..))
import Cardano.Ledger.BaseTypes (NonNegativeInterval, StrictMaybe (..), boundRational)
Expand Down Expand Up @@ -124,7 +124,7 @@ exampleTxBodyAlonzo =
(Set.singleton $ SLE.mkKeyHash 212) -- reqSignerHashes
exampleMultiAsset -- mint
(SJust $ mkDummySafeHash 42) -- scriptIntegrityHash
(SJust . AuxiliaryDataHash $ mkDummySafeHash 42) -- adHash
(SJust . TxAuxDataHash $ mkDummySafeHash 42) -- adHash
(SJust Mainnet) -- txnetworkid
where
MaryValue _ exampleMultiAsset = SLE.exampleMultiAssetValue 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Cardano.Ledger.Alonzo (AlonzoEra)
import Cardano.Ledger.Alonzo.Core
import Cardano.Ledger.Alonzo.Scripts (AlonzoScript (..))
import Cardano.Ledger.Alonzo.Tx (AlonzoTxBody (..))
import Cardano.Ledger.Alonzo.TxAuxData (AuxiliaryDataHash)
import Cardano.Ledger.Alonzo.TxBody (AlonzoTxOut (..))
import Cardano.Ledger.BaseTypes
import Cardano.Ledger.Binary (EncCBOR (..))
Expand Down Expand Up @@ -46,7 +45,7 @@ instance Era era => Twiddle (ShelleyTxCert era) where
instance Twiddle Withdrawals where
twiddle v = twiddle v . toTerm v

instance Twiddle AuxiliaryDataHash where
instance Twiddle TxAuxDataHash where
twiddle v = twiddle v . toTerm v

instance Twiddle (Update AlonzoEra) where
Expand Down
3 changes: 0 additions & 3 deletions eras/babbage/impl/src/Cardano/Ledger/Babbage/TxAuxData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module Cardano.Ledger.Babbage.TxAuxData () where
import Cardano.Ledger.Alonzo.Core
import Cardano.Ledger.Alonzo.TxAuxData (
AlonzoTxAuxData (..),
hashAlonzoTxAuxData,
metadataAlonzoTxAuxDataL,
plutusScriptsAllegraTxAuxDataL,
timelockScriptsAlonzoTxAuxDataL,
Expand All @@ -25,8 +24,6 @@ instance EraTxAuxData BabbageEra where

upgradeTxAuxData = translateAlonzoTxAuxData

hashTxAuxData = hashAlonzoTxAuxData

validateTxAuxData = validateAlonzoTxAuxData

instance AllegraEraTxAuxData BabbageEra where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ module Cardano.Ledger.Babbage.TxBody.Internal (
import Cardano.Ledger.Alonzo (AlonzoEra)
import Cardano.Ledger.Alonzo.Core
import Cardano.Ledger.Alonzo.PParams (AlonzoPParams (appExtraEntropy), appD)
import Cardano.Ledger.Alonzo.TxAuxData (AuxiliaryDataHash (..))
import Cardano.Ledger.Alonzo.TxBody (alonzoRedeemerPointer, alonzoRedeemerPointerInverse)
import Cardano.Ledger.Babbage.Era (BabbageEra)
import Cardano.Ledger.Babbage.PParams (upgradeBabbagePParams)
Expand Down Expand Up @@ -177,7 +176,7 @@ data BabbageTxBodyRaw era = BabbageTxBodyRaw
-- Operations on the TxBody in the BabbageEra depend upon this.
-- We now store only the MultiAsset part of a Mary.Value.
btbrScriptIntegrityHash :: !(StrictMaybe ScriptIntegrityHash)
, btbrAuxDataHash :: !(StrictMaybe AuxiliaryDataHash)
, btbrAuxDataHash :: !(StrictMaybe TxAuxDataHash)
, btbrTxNetworkId :: !(StrictMaybe Network)
}
deriving (Generic, Typeable)
Expand Down Expand Up @@ -263,7 +262,7 @@ feeBabbageTxBodyL =
{-# INLINEABLE feeBabbageTxBodyL #-}

auxDataHashBabbageTxBodyL ::
BabbageEraTxBody era => Lens' (BabbageTxBody era) (StrictMaybe AuxiliaryDataHash)
BabbageEraTxBody era => Lens' (BabbageTxBody era) (StrictMaybe TxAuxDataHash)
auxDataHashBabbageTxBodyL =
lensMemoRawType btbrAuxDataHash $
\txBodyRaw auxDataHash -> txBodyRaw {btbrAuxDataHash = auxDataHash}
Expand Down Expand Up @@ -601,7 +600,7 @@ pattern BabbageTxBody ::
Set (KeyHash 'Witness) ->
MultiAsset ->
StrictMaybe ScriptIntegrityHash ->
StrictMaybe AuxiliaryDataHash ->
StrictMaybe TxAuxDataHash ->
StrictMaybe Network ->
BabbageTxBody era
pattern BabbageTxBody
Expand Down Expand Up @@ -703,7 +702,7 @@ withdrawals' :: BabbageTxBody era -> Withdrawals
vldt' :: BabbageTxBody era -> ValidityInterval
update' :: BabbageTxBody era -> StrictMaybe (Update era)
reqSignerHashes' :: BabbageTxBody era -> Set (KeyHash 'Witness)
adHash' :: BabbageTxBody era -> StrictMaybe AuxiliaryDataHash
adHash' :: BabbageTxBody era -> StrictMaybe TxAuxDataHash
mint' :: BabbageTxBody era -> MultiAsset
scriptIntegrityHash' :: BabbageTxBody era -> StrictMaybe ScriptIntegrityHash
spendInputs' = btbrSpendInputs . getMemoRawType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ module Test.Cardano.Ledger.Babbage.Examples.Consensus where
import Cardano.Ledger.Alonzo.Scripts (AlonzoPlutusPurpose (..), AlonzoScript (..), ExUnits (..))
import Cardano.Ledger.Alonzo.Translation ()
import Cardano.Ledger.Alonzo.Tx (AlonzoTx (..), IsValid (..))
import Cardano.Ledger.Alonzo.TxAuxData (
AuxiliaryDataHash (..),
mkAlonzoTxAuxData,
)
import Cardano.Ledger.Alonzo.TxAuxData (mkAlonzoTxAuxData)
import Cardano.Ledger.Alonzo.TxWits (AlonzoTxWits (..), Redeemers (..), TxDats (..))
import Cardano.Ledger.Babbage (BabbageEra)
import Cardano.Ledger.Babbage.Core
Expand Down Expand Up @@ -139,7 +136,7 @@ exampleTxBodyBabbage =
(Set.singleton $ SLE.mkKeyHash 212) -- reqSignerHashes
exampleMultiAsset -- mint
(SJust $ SLE.mkDummySafeHash 42) -- scriptIntegrityHash
(SJust . AuxiliaryDataHash $ SLE.mkDummySafeHash 42) -- adHash
(SJust . TxAuxDataHash $ SLE.mkDummySafeHash 42) -- adHash
(SJust Mainnet) -- txnetworkid
where
MaryValue _ exampleMultiAsset = MarySLE.exampleMultiAssetValue 3
Expand Down
7 changes: 3 additions & 4 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Utxow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import Cardano.Ledger.Alonzo.Rules (
)
import qualified Cardano.Ledger.Alonzo.Rules as Alonzo (AlonzoUtxowPredFailure (..))
import Cardano.Ledger.Alonzo.UTxO (AlonzoEraUTxO, AlonzoScriptsNeeded)
import Cardano.Ledger.AuxiliaryData (AuxiliaryDataHash)
import Cardano.Ledger.Babbage.Rules (
BabbageUtxoPredFailure,
BabbageUtxowPredFailure,
Expand Down Expand Up @@ -87,12 +86,12 @@ data ConwayUtxowPredFailure era
!(Set ScriptHash)
| -- | hash of the full metadata
MissingTxBodyMetadataHash
!AuxiliaryDataHash
!TxAuxDataHash
| -- | hash of the metadata included in the transaction body
MissingTxMetadata
!AuxiliaryDataHash
!TxAuxDataHash
| ConflictingMetadataHash
!(Mismatch 'RelEQ AuxiliaryDataHash)
!(Mismatch 'RelEQ TxAuxDataHash)
| -- | Contains out of range values (string`s too long)
InvalidMetadata
| -- | extraneous scripts
Expand Down
3 changes: 0 additions & 3 deletions eras/conway/impl/src/Cardano/Ledger/Conway/TxAuxData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module Cardano.Ledger.Conway.TxAuxData () where
import Cardano.Ledger.Alonzo.Core
import Cardano.Ledger.Alonzo.TxAuxData (
AlonzoTxAuxData (..),
hashAlonzoTxAuxData,
metadataAlonzoTxAuxDataL,
plutusScriptsAllegraTxAuxDataL,
timelockScriptsAlonzoTxAuxDataL,
Expand All @@ -25,8 +24,6 @@ instance EraTxAuxData ConwayEra where

upgradeTxAuxData = translateAlonzoTxAuxData

hashTxAuxData = hashAlonzoTxAuxData

validateTxAuxData = validateAlonzoTxAuxData

instance AllegraEraTxAuxData ConwayEra where
Expand Down
5 changes: 2 additions & 3 deletions eras/conway/impl/src/Cardano/Ledger/Conway/TxBody/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ module Cardano.Ledger.Conway.TxBody.Internal (
conwayProposalsDeposits,
) where

import Cardano.Ledger.Alonzo.TxAuxData (AuxiliaryDataHash (..))
import Cardano.Ledger.Alonzo.TxBody (Indexable (..))
import Cardano.Ledger.Babbage.Core
import Cardano.Ledger.Babbage.TxBody (
Expand Down Expand Up @@ -146,7 +145,7 @@ data ConwayTxBodyRaw era = ConwayTxBodyRaw
, ctbrReqSignerHashes :: !(Set (KeyHash 'Witness))
, ctbrMint :: !MultiAsset
, ctbrScriptIntegrityHash :: !(StrictMaybe ScriptIntegrityHash)
, ctbrAuxDataHash :: !(StrictMaybe AuxiliaryDataHash)
, ctbrAuxDataHash :: !(StrictMaybe TxAuxDataHash)
, ctbrTxNetworkId :: !(StrictMaybe Network)
, ctbrVotingProcedures :: !(VotingProcedures era)
, ctbrProposalProcedures :: !(OSet.OSet (ProposalProcedure era))
Expand Down Expand Up @@ -544,7 +543,7 @@ pattern ConwayTxBody ::
Set (KeyHash 'Witness) ->
MultiAsset ->
StrictMaybe ScriptIntegrityHash ->
StrictMaybe AuxiliaryDataHash ->
StrictMaybe TxAuxDataHash ->
StrictMaybe Network ->
VotingProcedures era ->
OSet.OSet (ProposalProcedure era) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ module Test.Cardano.Ledger.Conway.Examples.Consensus where

import Cardano.Ledger.Alonzo.Scripts (AlonzoScript (..), ExUnits (..))
import Cardano.Ledger.Alonzo.Tx (IsValid (..))
import Cardano.Ledger.Alonzo.TxAuxData (
AuxiliaryDataHash (..),
mkAlonzoTxAuxData,
)
import Cardano.Ledger.Alonzo.TxAuxData (mkAlonzoTxAuxData)
import Cardano.Ledger.Alonzo.TxWits (Redeemers (..), TxDats (..))
import Cardano.Ledger.Babbage.TxBody (BabbageTxOut (..))
import Cardano.Ledger.BaseTypes
Expand Down Expand Up @@ -152,7 +149,7 @@ exampleTxBodyConway =
(Set.singleton $ SLE.mkKeyHash 212) -- reqSignerHashes
exampleMultiAsset -- mint
(SJust $ mkDummySafeHash 42) -- scriptIntegrityHash
(SJust . AuxiliaryDataHash $ mkDummySafeHash 42) -- adHash
(SJust . TxAuxDataHash $ mkDummySafeHash 42) -- adHash
(SJust Mainnet) -- txnetworkid
(VotingProcedures mempty)
mempty
Expand Down
3 changes: 0 additions & 3 deletions eras/mary/impl/src/Cardano/Ledger/Mary/TxAuxData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import Cardano.Ledger.Allegra.TxAuxData (
metadataAllegraTxAuxDataL,
timelockScriptsAllegraTxAuxDataL,
)
import Cardano.Ledger.AuxiliaryData (AuxiliaryDataHash (..))
import Cardano.Ledger.Core
import Cardano.Ledger.Mary.Era (MaryEra)
import Cardano.Ledger.Mary.Scripts ()
Expand All @@ -38,7 +37,5 @@ instance EraTxAuxData MaryEra where

validateTxAuxData _ (AllegraTxAuxData md as) = as `deepseq` all validMetadatum md

hashTxAuxData aux = AuxiliaryDataHash (hashAnnotated aux)

instance AllegraEraTxAuxData MaryEra where
timelockScriptsTxAuxDataL = timelockScriptsAllegraTxAuxDataL
Loading

0 comments on commit ea1d436

Please sign in to comment.