Skip to content

Commit bf99a54

Browse files
committed
Deprecate witsFromTxWitnesses in favor of keyHashWitnessesTxWits
1 parent 3210223 commit bf99a54

File tree

7 files changed

+22
-16
lines changed

7 files changed

+22
-16
lines changed

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxow.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ import Cardano.Ledger.Shelley.Rules (
6767
validateNeededWitnesses,
6868
)
6969
import qualified Cardano.Ledger.Shelley.Rules as Shelley
70-
import Cardano.Ledger.Shelley.Tx (witsFromTxWitnesses)
7170
import Cardano.Ledger.Shelley.UTxO (ShelleyScriptsNeeded (..))
7271
import Cardano.Ledger.State (
7372
EraCertState (..),
@@ -341,7 +340,7 @@ alonzoStyleWitness = do
341340
{- witsKeyHashes := { hashKey vk | vk ∈ dom(txwitsVKey txw) } -}
342341
let utxo = utxosUtxo u
343342
txBody = tx ^. bodyTxL
344-
witsKeyHashes = witsFromTxWitnesses @era tx
343+
witsKeyHashes = keyHashWitnessesTxWits (tx ^. witsTxL)
345344
scriptsProvided = getScriptsProvided utxo tx
346345

347346
-- check scripts

eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxow.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ import Cardano.Ledger.Shelley.Rules (
6262
validateNeededWitnesses,
6363
)
6464
import qualified Cardano.Ledger.Shelley.Rules as Shelley
65-
import Cardano.Ledger.Shelley.Tx (witsFromTxWitnesses)
6665
import Cardano.Ledger.State (EraCertState (..), EraUTxO (..), ScriptsProvided (..))
6766
import Control.DeepSeq (NFData)
6867
import Control.Monad.Trans.Reader (asks)
@@ -301,7 +300,7 @@ babbageUtxowMirTransition = do
301300
{- genSig := { hashKey gkey | gkey ∈ dom(genDelegs)} ∩ witsKeyHashes -}
302301
{- { c ∈ txcerts txb ∩ TxCert_mir} ≠ ∅ ⇒ |genSig| ≥ Quorum -}
303302
let genDelegs = certState ^. certDStateL . dsGenDelegsL
304-
witsKeyHashes = witsFromTxWitnesses tx
303+
witsKeyHashes = keyHashWitnessesTxWits (tx ^. witsTxL)
305304
coreNodeQuorum <- liftSTS $ asks quorum
306305
runTest $
307306
Shelley.validateMIRInsufficientGenesisSigs genDelegs coreNodeQuorum witsKeyHashes tx
@@ -335,7 +334,7 @@ babbageUtxowTransition = do
335334
{- witsKeyHashes := { hashKey vk | vk ∈ dom(txwitsVKey txw) } -}
336335
let utxo = utxosUtxo u
337336
txBody = tx ^. bodyTxL
338-
witsKeyHashes = witsFromTxWitnesses tx
337+
witsKeyHashes = keyHashWitnessesTxWits (tx ^. witsTxL)
339338
inputs = (txBody ^. referenceInputsTxBodyL) `Set.union` (txBody ^. inputsTxBodyL)
340339

341340
-- check scripts

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+
* Deprecate `witsFromTxWitnesses`
56
* Expose access to `ShelleyTxRaw`, `ShelleyTxAuxDataRaw`, `ShelleyTxBodyRaw`, `ShelleyTxWitsRaw`, `MkMultiSig`
67
* Expose constructors `MkShelleyTx`, `MkShelleyTxAuxData`, `MkShelleyTxBody`, `MkShelleyTxWits`, `MultiSigRaw`
78
* Remove re-export of `WitVKey` from `Cardano.Ledger.Shelley.TxWits`

eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Utxow.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ import Cardano.Ledger.Shelley.Rules.Utxo (
6969
UtxoEvent,
7070
)
7171
import qualified Cardano.Ledger.Shelley.SoftForks as SoftForks
72-
import Cardano.Ledger.Shelley.Tx (witsFromTxWitnesses)
7372
import Cardano.Ledger.Shelley.TxCert (isInstantaneousRewards)
7473
import Cardano.Ledger.Shelley.UTxO (
7574
EraUTxO (..),
@@ -303,7 +302,7 @@ transitionRulesUTXOW = do
303302
{- (utxo,_,_,_ ) := utxoSt -}
304303
{- witsKeyHashes := { hashKey vk | vk ∈ dom(txwitsVKey txw) } -}
305304
let utxo = utxosUtxo u
306-
witsKeyHashes = witsFromTxWitnesses tx
305+
witsKeyHashes = keyHashWitnessesTxWits (tx ^. witsTxL)
307306
scriptsProvided = getScriptsProvided utxo tx
308307

309308
-- check scripts

eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx/Internal.hs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
{-# LANGUAGE FlexibleContexts #-}
55
{-# LANGUAGE FlexibleInstances #-}
66
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
7-
{-# LANGUAGE LambdaCase #-}
87
{-# LANGUAGE NamedFieldPuns #-}
98
{-# LANGUAGE PatternSynonyms #-}
109
{-# LANGUAGE ScopedTypeVariables #-}
@@ -63,8 +62,6 @@ import Cardano.Ledger.Binary.Coders
6362
import qualified Cardano.Ledger.Binary.Plain as Plain
6463
import Cardano.Ledger.Coin (Coin)
6564
import Cardano.Ledger.Core
66-
import Cardano.Ledger.Keys.Bootstrap (bootstrapWitKeyHash)
67-
import Cardano.Ledger.Keys.WitVKey (witVKeyHash)
6865
import Cardano.Ledger.MemoBytes (
6966
EqRaw (..),
7067
Mem,
@@ -91,7 +88,6 @@ import Data.Maybe.Strict (
9188
strictMaybeToMaybe,
9289
)
9390
import Data.Set (Set)
94-
import qualified Data.Set as Set
9591
import Data.Typeable (Typeable)
9692
import Data.Word (Word32)
9793
import GHC.Generics (Generic)
@@ -431,6 +427,5 @@ witsFromTxWitnesses ::
431427
EraTx era =>
432428
Tx era ->
433429
Set (KeyHash 'Witness)
434-
witsFromTxWitnesses tx =
435-
Set.map witVKeyHash (tx ^. witsTxL . addrTxWitsL)
436-
`Set.union` Set.map bootstrapWitKeyHash (tx ^. witsTxL . bootAddrTxWitsL)
430+
witsFromTxWitnesses tx = keyHashWitnessesTxWits (tx ^. witsTxL)
431+
{-# DEPRECATED witsFromTxWitnesses "In favor ot `keyHashWitnessesTxWits`" #-}

libs/cardano-ledger-core/CHANGELOG.md

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

33
## 1.18.0.0
44

5+
* Add `keyHashWitnessesTxWits`
56
* Remove export of `mkMemoBytes` from `Cardano.Ledger.MemoBytes` as unsafe
67
* Add `CanGetChainAccountState` and `CanSetChainAccountState`
78
* Add `treasuryL` and `reservesL`

libs/cardano-ledger-core/src/Cardano/Ledger/Core.hs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ module Cardano.Ledger.Core (
3838
hashScript,
3939
isNativeScript,
4040
hashScriptTxWitsL,
41+
keyHashWitnessesTxWits,
4142
Value,
4243
EraPParams (..),
4344
mkCoinTxOut,
@@ -92,8 +93,8 @@ import Cardano.Ledger.Core.Translation
9293
import Cardano.Ledger.Core.TxCert
9394
import Cardano.Ledger.Credential (Credential)
9495
import Cardano.Ledger.Hashes hiding (GenDelegPair (..), GenDelegs (..), unsafeMakeSafeHash)
95-
import Cardano.Ledger.Keys.Bootstrap (BootstrapWitness)
96-
import Cardano.Ledger.Keys.WitVKey (WitVKey)
96+
import Cardano.Ledger.Keys.Bootstrap (BootstrapWitness, bootstrapWitKeyHash)
97+
import Cardano.Ledger.Keys.WitVKey (WitVKey, witVKeyHash)
9798
import Cardano.Ledger.MemoBytes
9899
import Cardano.Ledger.Metadata
99100
import Cardano.Ledger.Rewards (Reward (..), RewardType (..))
@@ -110,6 +111,7 @@ import Data.Maybe.Strict (StrictMaybe, strictMaybe)
110111
import Data.MemPack
111112
import Data.Sequence.Strict (StrictSeq)
112113
import Data.Set (Set)
114+
import qualified Data.Set as Set
113115
import Data.Void (Void)
114116
import Data.Word (Word32, Word64)
115117
import GHC.Stack (HasCallStack)
@@ -512,6 +514,16 @@ hashScriptTxWitsL =
512514
(\wits ss -> wits & scriptTxWitsL .~ Map.fromList [(hashScript s, s) | s <- ss])
513515
{-# INLINEABLE hashScriptTxWitsL #-}
514516

517+
-- | Extract all of the `KeyHash` witnesses provided in the `TxWits`
518+
keyHashWitnessesTxWits ::
519+
EraTxWits era =>
520+
TxWits era ->
521+
Set (KeyHash 'Witness)
522+
keyHashWitnessesTxWits txWits =
523+
Set.map witVKeyHash (txWits ^. addrTxWitsL)
524+
`Set.union` Set.map bootstrapWitKeyHash (txWits ^. bootAddrTxWitsL)
525+
{-# INLINEABLE keyHashWitnessesTxWits #-}
526+
515527
-----------------------------------------------------------------------------
516528
-- Script Validation
517529
-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)