Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove missingScriptsSymmetricDifference #4208

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ alonzoStyleWitness = do
let scriptsNeeded = getScriptsNeeded utxo txBody
scriptsHashesNeeded = getScriptsHashesNeeded scriptsNeeded
shelleyScriptsNeeded = ShelleyScriptsNeeded scriptsHashesNeeded
runTest $ Shelley.validateMissingScripts pp shelleyScriptsNeeded scriptsProvided
runTest $ Shelley.validateMissingScripts shelleyScriptsNeeded scriptsProvided

{- inputHashes := { h | (_ → (a,_,h)) ∈ txins tx ◁ utxo, isTwoPhaseScriptAddress tx a} -}
{- inputHashes ⊆ dom(txdats txw) -}
Expand Down
2 changes: 2 additions & 0 deletions eras/shelley/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 1.10.0.0

* Remove the `PParams` param from `validateMissingScripts`
* Remove the `missingScriptsSymmetricDifference` function
* Add `NFData` instance for `AdaPots`, `ShelleyDelegEvent`
* Add `Generic`, `Eq` and `NFData` instances for:
* `ShelleyDelegsEvent`
Expand Down
8 changes: 0 additions & 8 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/HardForks.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module Cardano.Ledger.Shelley.HardForks (
aggregatedRewards,
allowMIRTransfer,
validatePoolRewardAccountNetID,
missingScriptsSymmetricDifference,
forgoRewardPrefilter,
translateUpperBoundForPlutusScripts,
forgoPointerAddressResolution,
Expand Down Expand Up @@ -39,13 +38,6 @@ validatePoolRewardAccountNetID ::
Bool
validatePoolRewardAccountNetID pv = pvMajor pv > natVersion @4

-- | Starting with protocol version 7, the UTXO rule predicate failure
-- MissingScriptWitnessesUTXOW will not be used for extraneous scripts
missingScriptsSymmetricDifference ::
ProtVer ->
Bool
missingScriptsSymmetricDifference pv = pvMajor pv > natVersion @6

-- | Starting with protocol version 7, the reward calculation no longer
-- filters out unregistered stake addresses at the moment the calculation begins.
-- See the Shelley Ledger Errata 17.2.
Expand Down
22 changes: 7 additions & 15 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Utxow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ import Cardano.Ledger.Rules.ValidationMode (
import Cardano.Ledger.SafeHash (extractHash, hashAnnotated)
import Cardano.Ledger.Shelley.Core
import Cardano.Ledger.Shelley.Era (ShelleyEra, ShelleyUTXOW)
import qualified Cardano.Ledger.Shelley.HardForks as HardForks
import Cardano.Ledger.Shelley.LedgerState.Types (UTxOState (..))
import Cardano.Ledger.Shelley.PParams (ProposedPPUpdates (ProposedPPUpdates), Update (..))
import Cardano.Ledger.Shelley.Rules.Ppup (ShelleyPpupPredFailure)
Expand Down Expand Up @@ -330,7 +329,7 @@ transitionRulesUTXOW = do

{- { s | (_,s) ∈ scriptsNeeded utxo tx} = dom(txscripts txw) -}
let scriptsNeeded = getScriptsNeeded utxo (tx ^. bodyTxL)
runTest $ validateMissingScripts pp scriptsNeeded scriptsProvided
runTest $ validateMissingScripts scriptsNeeded scriptsProvided

-- check VKey witnesses
{- ∀ (vk ↦ σ) ∈ (txwitsVKey txw), V_vk⟦ txbodyHash ⟧_σ -}
Expand Down Expand Up @@ -406,23 +405,16 @@ validateFailedNativeScripts (ScriptsProvided scriptsProvided) tx = do
{- sNeeded := scriptsNeeded utxo tx -}
{- sProvided := Map.keysSet (tx ^. witsTxL . scriptTxWitsL) -}
validateMissingScripts ::
EraPParams era =>
PParams era ->
ShelleyScriptsNeeded era ->
ScriptsProvided era ->
Test (ShelleyUtxowPredFailure era)
validateMissingScripts pp (ShelleyScriptsNeeded sNeeded) scriptsprovided =
if HardForks.missingScriptsSymmetricDifference (pp ^. ppProtocolVersionL)
neilmayhew marked this conversation as resolved.
Show resolved Hide resolved
then
sequenceA_
[ failureUnless (sNeeded `Set.isSubsetOf` sProvided) $
MissingScriptWitnessesUTXOW (sNeeded `Set.difference` sProvided)
, failureUnless (sProvided `Set.isSubsetOf` sNeeded) $
ExtraneousScriptWitnessesUTXOW (sProvided `Set.difference` sNeeded)
]
else
failureUnless (sNeeded == sProvided) $
validateMissingScripts (ShelleyScriptsNeeded sNeeded) scriptsprovided =
sequenceA_
[ failureUnless (sNeeded `Set.isSubsetOf` sProvided) $
MissingScriptWitnessesUTXOW (sNeeded `Set.difference` sProvided)
, failureUnless (sProvided `Set.isSubsetOf` sNeeded) $
ExtraneousScriptWitnessesUTXOW (sProvided `Set.difference` sNeeded)
]
where
sProvided = Map.keysSet $ unScriptsProvided scriptsprovided

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ testEverybodySigns =

testWrongScript :: Assertion
testWrongScript =
utxoSt' @?= (Left . pure . MissingScriptWitnessesUTXOW) wits
utxoSt' @?= Left (pure extraneous <> pure missing)
where
utxoSt' =
applyTxWithScript
Expand All @@ -178,7 +178,9 @@ testWrongScript =
(Withdrawals Map.empty)
(Coin 0)
[asWitness Cast.alicePay, asWitness Cast.bobPay]
wits = Set.singleton $ hashScript @C aliceOnly
asHashes = Set.singleton . hashScript @C
extraneous = ExtraneousScriptWitnessesUTXOW $ asHashes aliceOrBob
missing = MissingScriptWitnessesUTXOW $ asHashes aliceOnly

testAliceOrBob :: Assertion
testAliceOrBob =
Expand Down