Skip to content

Commit

Permalink
Extract hashTxAuxData from EraTxAuxData into a standalone function.
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Dec 20, 2024
1 parent e164ebf commit 2182bc3
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 22 deletions.
2 changes: 0 additions & 2 deletions eras/allegra/impl/src/Cardano/Ledger/Allegra/TxAuxData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ instance EraTxAuxData AllegraEra where

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

hashTxAuxData aux = TxAuxDataHash (hashAnnotated aux)

metadataAllegraTxAuxDataL :: Era era => Lens' (AllegraTxAuxData era) (Map Word64 Metadatum)
metadataAllegraTxAuxDataL =
lensMemoRawType atadrMetadata $ \txAuxDataRaw md -> txAuxDataRaw {atadrMetadata = md}
Expand Down
1 change: 1 addition & 0 deletions eras/alonzo/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 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
3 changes: 1 addition & 2 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxAuxData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -261,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,6 +272,7 @@ hashAlonzoTxAuxData ::
x ->
TxAuxDataHash
hashAlonzoTxAuxData x = TxAuxDataHash (hashAnnotated x)
{-# DEPRECATED hashAlonzoTxAuxData "In favor of `hashTxAuxData`" #-}

validateAlonzoTxAuxData ::
(AlonzoEraScript era, Script era ~ AlonzoScript era) =>
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
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
2 changes: 0 additions & 2 deletions eras/mary/impl/src/Cardano/Ledger/Mary/TxAuxData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,5 @@ instance EraTxAuxData MaryEra where

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

hashTxAuxData aux = TxAuxDataHash (hashAnnotated aux)

instance AllegraEraTxAuxData MaryEra where
timelockScriptsTxAuxDataL = timelockScriptsAllegraTxAuxDataL
1 change: 1 addition & 0 deletions eras/shelley/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.16.0.0

* Deprecate `hashShelleyTxAuxData`
* Stop re-exporting `ScriptHash` from `Cardano.Ledger.Shelley.Scripts`. Import it instead from `Cardano.Ledger.Hashes`.
* Deprecate `Shelley` type synonym
* Deprecate `PPUpdateEnv`
Expand Down
7 changes: 1 addition & 6 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/TxAuxData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import Cardano.Ledger.Metadata (Metadatum (..), validMetadatum)
import Cardano.Ledger.Shelley.Era (ShelleyEra)
import Control.DeepSeq (NFData)
import Data.Map.Strict (Map)
import Data.Typeable (Proxy (..))
import Data.Word (Word64)
import GHC.Generics (Generic)
import NoThunks.Class (InspectHeapNamed (..), NoThunks (..))
Expand Down Expand Up @@ -102,11 +101,6 @@ instance EraTxAuxData ShelleyEra where

validateTxAuxData _ (ShelleyTxAuxData m) = all validMetadatum m

hashTxAuxData txAuxData =
TxAuxDataHash (makeHashWithExplicitProxys index txAuxData)
where
index = Proxy @EraIndependentTxAuxData

instance EqRaw (ShelleyTxAuxData era)

instance HashAnnotated (ShelleyTxAuxData era) EraIndependentTxAuxData where
Expand All @@ -116,6 +110,7 @@ hashShelleyTxAuxData ::
ShelleyTxAuxData era ->
SafeHash EraIndependentTxAuxData
hashShelleyTxAuxData = hashAnnotated
{-# DEPRECATED hashShelleyTxAuxData "In favor of `hashAnnotated`" #-}

pattern ShelleyTxAuxData :: forall era. Era era => Map Word64 Metadatum -> ShelleyTxAuxData era
pattern ShelleyTxAuxData m <-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ import Cardano.Ledger.Alonzo.TxAuxData (
mkAlonzoTxAuxData,
)
import Cardano.Ledger.Api.Era ()
import Cardano.Ledger.Core (EraTxAuxData (..))
import Cardano.Ledger.Core (EraTxAuxData (..), hashTxAuxData)
import Cardano.Ledger.Shelley.TxAuxData (Metadatum (..), ShelleyTxAuxData (..))
1 change: 1 addition & 0 deletions libs/cardano-ledger-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.17.0.0

* Extract `hashTxAuxData` from `EraTxAuxData` into a standalone function.
* Add `TxAuxDataHash` and deprecate `AuxiliaryDayaHash` in its favor.
* Deprecate `Cardano.Ledger.Crypto` module in favor of `cardano-protocol-tpraos:Cardano.Protocol.Crypto`
* Deprecate `KESignable`, `SignedKES`, `SignKeyKES`, `VerKeyKES`, `VRFSignable`,
Expand Down
7 changes: 5 additions & 2 deletions libs/cardano-ledger-core/src/Cardano/Ledger/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module Cardano.Ledger.Core (
EraTxBody (..),
txIdTxBody,
EraTxAuxData (..),
hashTxAuxData,
EraTxWits (..),
EraScript (..),
hashScript,
Expand Down Expand Up @@ -455,10 +456,12 @@ class
-- preserved. If you need to retain underlying bytes you can use `translateEraThroughCBOR`
upgradeTxAuxData :: EraTxAuxData (PreviousEra era) => TxAuxData (PreviousEra era) -> TxAuxData era

hashTxAuxData :: TxAuxData era -> TxAuxDataHash

validateTxAuxData :: ProtVer -> TxAuxData era -> Bool

-- | Compute a hash of `TxAuxData`
hashTxAuxData :: EraTxAuxData era => TxAuxData era -> TxAuxDataHash
hashTxAuxData = TxAuxDataHash . hashAnnotated

-- | A collection of witnesses in a Tx
class
( EraScript era
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module Test.Cardano.Ledger.EraClass (
EraTxWits (TxWits, mkBasicTxWits, addrTxWitsL, bootAddrTxWitsL, scriptTxWitsL),
AlonzoEraTxWits (datsTxWitsL, rdmrsTxWitsL),
-- TxAuxData
EraTxAuxData (TxAuxData, hashTxAuxData, validateTxAuxData),
EraTxAuxData (TxAuxData, validateTxAuxData),
-- TxCerts
EraTxCert (
TxCert,
Expand Down

0 comments on commit 2182bc3

Please sign in to comment.