diff --git a/plutus-benchmark/script-contexts/src/PlutusBenchmark/ScriptContexts.hs b/plutus-benchmark/script-contexts/src/PlutusBenchmark/ScriptContexts.hs index e281a11ff60..479b75e3689 100644 --- a/plutus-benchmark/script-contexts/src/PlutusBenchmark/ScriptContexts.hs +++ b/plutus-benchmark/script-contexts/src/PlutusBenchmark/ScriptContexts.hs @@ -134,24 +134,6 @@ mkScriptContextEqualityDataCode sc = `PlutusTx.unsafeApplyCode` PlutusTx.liftCodeDef sc `PlutusTx.unsafeApplyCode` PlutusTx.liftCodeDef d --- This example checks the script context for equality (with itself) when encoded --- as a normal (i.e. Scott-encoded) term, using the normal (i.e. typeclass-based) equality --- functions. This can be quite expensive for a large structure! -{-# INLINABLE scriptContextEqualityTerm #-} -scriptContextEqualityTerm :: ScriptContext -> PlutusTx.BuiltinData -> () --- See Note [Redundant arguments to equality benchmarks] -scriptContextEqualityTerm sc _ = - if sc PlutusTx.== sc - then () - else PlutusTx.traceError "The argument is not equal to itself" - -mkScriptContextEqualityTermCode :: ScriptContext -> PlutusTx.CompiledCode () -mkScriptContextEqualityTermCode sc = - let d = PlutusTx.toBuiltinData sc - in $$(PlutusTx.compile [|| scriptContextEqualityTerm ||]) - `PlutusTx.unsafeApplyCode` PlutusTx.liftCodeDef sc - `PlutusTx.unsafeApplyCode` PlutusTx.liftCodeDef d - -- This example is just the overhead from the previous two -- See Note [Redundant arguments to equality benchmarks] {-# INLINABLE scriptContextEqualityOverhead #-} diff --git a/plutus-benchmark/script-contexts/test/9.6/checkScriptContextEqualityTerm-20.budget.golden b/plutus-benchmark/script-contexts/test/9.6/checkScriptContextEqualityTerm-20.budget.golden deleted file mode 100644 index 2e284ed406f..00000000000 --- a/plutus-benchmark/script-contexts/test/9.6/checkScriptContextEqualityTerm-20.budget.golden +++ /dev/null @@ -1,2 +0,0 @@ -({cpu: 201713366 -| mem: 1195470}) \ No newline at end of file diff --git a/plutus-benchmark/script-contexts/test/9.6/checkScriptContextEqualityTerm-20.eval.golden b/plutus-benchmark/script-contexts/test/9.6/checkScriptContextEqualityTerm-20.eval.golden deleted file mode 100644 index 1dd2b8ed5d3..00000000000 --- a/plutus-benchmark/script-contexts/test/9.6/checkScriptContextEqualityTerm-20.eval.golden +++ /dev/null @@ -1 +0,0 @@ -(constr 0) \ No newline at end of file diff --git a/plutus-benchmark/script-contexts/test/Spec.hs b/plutus-benchmark/script-contexts/test/Spec.hs index 62557c4ccb5..7cd5cb5c0d7 100644 --- a/plutus-benchmark/script-contexts/test/Spec.hs +++ b/plutus-benchmark/script-contexts/test/Spec.hs @@ -85,10 +85,6 @@ testCheckScEquality = testGroup "checkScriptContextEquality" mkScriptContextEqualityDataCode (mkScriptContext 20) , Tx.goldenEvalCekCatch "checkScriptContextEqualityData-20" $ [mkScriptContextEqualityDataCode (mkScriptContext 20)] - , Tx.goldenBudget "checkScriptContextEqualityTerm-20" $ - mkScriptContextEqualityTermCode (mkScriptContext 20) - , Tx.goldenEvalCekCatch "checkScriptContextEqualityTerm-20" $ - [mkScriptContextEqualityTermCode (mkScriptContext 20)] , Tx.goldenBudget "checkScriptContextEqualityOverhead-20" $ mkScriptContextEqualityOverheadCode (mkScriptContext 20) , Tx.goldenEvalCekCatch "checkScriptContextEqualityOverhead-20" $ diff --git a/plutus-ledger-api/src/PlutusLedgerApi/V2/Contexts.hs b/plutus-ledger-api/src/PlutusLedgerApi/V2/Contexts.hs index 1314c6cfaff..d32fd7e10b6 100644 --- a/plutus-ledger-api/src/PlutusLedgerApi/V2/Contexts.hs +++ b/plutus-ledger-api/src/PlutusLedgerApi/V2/Contexts.hs @@ -84,12 +84,7 @@ data TxInfo = TxInfo , txInfoData :: Map DatumHash Datum -- ^ The lookup table of datums attached to the transaction -- /V1->V2/: changed from assoc list to a 'PlutusTx.AssocMap' , txInfoId :: TxId -- ^ Hash of the pending transaction body (i.e. transaction excluding witnesses) - } deriving stock (Generic, Haskell.Show, Haskell.Eq) - -instance Eq TxInfo where - {-# INLINABLE (==) #-} - TxInfo i ri o f m c w r s rs d tid == TxInfo i' ri' o' f' m' c' w' r' s' rs' d' tid' = - i == i' && ri == ri' && o == o' && f == f' && m == m' && c == c' && w == w' && r == r' && s == s' && rs == rs' && d == d' && tid == tid' + } deriving stock (Generic, Haskell.Show) instance Pretty TxInfo where pretty TxInfo{txInfoInputs, txInfoReferenceInputs, txInfoOutputs, txInfoFee, txInfoMint, txInfoDCert, txInfoWdrl, txInfoValidRange, txInfoSignatories, txInfoRedeemers, txInfoData, txInfoId} = @@ -113,11 +108,7 @@ data ScriptContext = ScriptContext { scriptContextTxInfo :: TxInfo -- ^ information about the transaction the currently-executing script is included in , scriptContextPurpose :: ScriptPurpose -- ^ the purpose of the currently-executing script } - deriving stock (Generic, Haskell.Eq, Haskell.Show) - -instance Eq ScriptContext where - {-# INLINABLE (==) #-} - ScriptContext info purpose == ScriptContext info' purpose' = info == info' && purpose == purpose' + deriving stock (Generic, Haskell.Show) instance Pretty ScriptContext where pretty ScriptContext{scriptContextTxInfo, scriptContextPurpose} = diff --git a/plutus-ledger-api/src/PlutusLedgerApi/V3/Contexts.hs b/plutus-ledger-api/src/PlutusLedgerApi/V3/Contexts.hs index 3d26a2f05dd..0fac2e88685 100644 --- a/plutus-ledger-api/src/PlutusLedgerApi/V3/Contexts.hs +++ b/plutus-ledger-api/src/PlutusLedgerApi/V3/Contexts.hs @@ -237,7 +237,7 @@ data Committee = Committee , committeeQuorum :: PlutusTx.Rational -- ^ Quorum of the committee that is necessary for a successful vote } - deriving stock (Generic, Haskell.Show, Haskell.Eq) + deriving stock (Generic, Haskell.Show) instance Pretty Committee where pretty Committee{..} = @@ -246,11 +246,6 @@ instance Pretty Committee where , "committeeQuorum:" <+> pretty committeeQuorum ] -instance PlutusTx.Eq Committee where - {-# INLINEABLE (==) #-} - Committee a b == Committee a' b' = - a PlutusTx.== a' PlutusTx.&& b PlutusTx.== b' - -- | A constitution. The optional anchor is omitted. newtype Constitution = Constitution { constitutionScript :: Haskell.Maybe V2.ScriptHash @@ -322,35 +317,16 @@ data GovernanceAction Rational -- ^ New quorum | NewConstitution (Haskell.Maybe GovernanceActionId) Constitution | InfoAction - deriving stock (Generic, Haskell.Show, Haskell.Eq) + deriving stock (Generic, Haskell.Show) deriving (Pretty) via (PrettyShow GovernanceAction) -instance PlutusTx.Eq GovernanceAction where - {-# INLINEABLE (==) #-} - ParameterChange a b c == ParameterChange a' b' c' = - a PlutusTx.== a' PlutusTx.&& b PlutusTx.== b' PlutusTx.&& c PlutusTx.== c' - HardForkInitiation a b == HardForkInitiation a' b' = - a PlutusTx.== a' PlutusTx.&& b PlutusTx.== b' - TreasuryWithdrawals a b == TreasuryWithdrawals a' b' = - a PlutusTx.== a' PlutusTx.&& b PlutusTx.== b' - NoConfidence a == NoConfidence a' = a PlutusTx.== a' - UpdateCommittee a b c d == UpdateCommittee a' b' c' d' = - a PlutusTx.== a' - PlutusTx.&& b PlutusTx.== b' - PlutusTx.&& c PlutusTx.== c' - PlutusTx.&& d PlutusTx.== d' - NewConstitution a b == NewConstitution a' b' = - a PlutusTx.== a' PlutusTx.&& b PlutusTx.== b' - InfoAction == InfoAction = Haskell.True - _ == _ = Haskell.False - -- | A proposal procedure. The optional anchor is omitted. data ProposalProcedure = ProposalProcedure { ppDeposit :: V2.Lovelace , ppReturnAddr :: V2.Credential , ppGovernanceAction :: GovernanceAction } - deriving stock (Generic, Haskell.Show, Haskell.Eq) + deriving stock (Generic, Haskell.Show) instance Pretty ProposalProcedure where pretty ProposalProcedure{..} = @@ -360,13 +336,6 @@ instance Pretty ProposalProcedure where , "ppGovernanceAction:" <+> pretty ppGovernanceAction ] -instance PlutusTx.Eq ProposalProcedure where - {-# INLINEABLE (==) #-} - ProposalProcedure a b c == ProposalProcedure a' b' c' = - a PlutusTx.== a' - PlutusTx.&& b PlutusTx.== b' - PlutusTx.&& c PlutusTx.== c' - -- | A `ScriptPurpose` uniquely identifies a Plutus script within a transaction. data ScriptPurpose = Minting V2.CurrencySymbol @@ -381,25 +350,9 @@ data ScriptPurpose Haskell.Integer -- ^ 0-based index of the given `ProposalProcedure` in `txInfoProposalProcedures` ProposalProcedure - deriving stock (Generic, Haskell.Show, Haskell.Eq) + deriving stock (Generic, Haskell.Show) deriving (Pretty) via (PrettyShow ScriptPurpose) -instance PlutusTx.Eq ScriptPurpose where - {-# INLINEABLE (==) #-} - Minting a == Minting a' = - a PlutusTx.== a' - Spending a == Spending a' = - a PlutusTx.== a' - Rewarding a == Rewarding a' = - a PlutusTx.== a' - Certifying a b == Certifying a' b' = - a PlutusTx.== a' PlutusTx.&& b PlutusTx.== b' - Voting a == Voting a' = - a PlutusTx.== a' - Proposing a b == Proposing a' b' = - a PlutusTx.== a' PlutusTx.&& b PlutusTx.== b' - _ == _ = Haskell.False - -- | Like `ScriptPurpose` but with an optional datum for spending scripts. data ScriptInfo = MintingScript V2.CurrencySymbol @@ -414,25 +367,9 @@ data ScriptInfo Haskell.Integer -- ^ 0-based index of the given `ProposalProcedure` in `txInfoProposalProcedures` ProposalProcedure - deriving stock (Generic, Haskell.Show, Haskell.Eq) + deriving stock (Generic, Haskell.Show) deriving (Pretty) via (PrettyShow ScriptInfo) -instance PlutusTx.Eq ScriptInfo where - {-# INLINEABLE (==) #-} - MintingScript a == MintingScript a' = - a PlutusTx.== a' - SpendingScript a b== SpendingScript a' b' = - a PlutusTx.== a' PlutusTx.&& b PlutusTx.== b' - RewardingScript a == RewardingScript a' = - a PlutusTx.== a' - CertifyingScript a b == CertifyingScript a' b' = - a PlutusTx.== a' PlutusTx.&& b PlutusTx.== b' - VotingScript a == VotingScript a' = - a PlutusTx.== a' - ProposingScript a b == ProposingScript a' b' = - a PlutusTx.== a' PlutusTx.&& b PlutusTx.== b' - _ == _ = Haskell.False - -- | An input of a pending transaction. data TxInInfo = TxInInfo { txInInfoOutRef :: V3.TxOutRef @@ -471,7 +408,7 @@ data TxInfo = TxInfo , txInfoCurrentTreasuryAmount :: Haskell.Maybe V2.Lovelace , txInfoTreasuryDonation :: Haskell.Maybe V2.Lovelace } - deriving stock (Generic, Haskell.Show, Haskell.Eq) + deriving stock (Generic, Haskell.Show) instance Pretty TxInfo where pretty TxInfo{..} = @@ -494,27 +431,6 @@ instance Pretty TxInfo where , "Treasury Donation:" <+> pretty txInfoTreasuryDonation ] -instance PlutusTx.Eq TxInfo where - {-# INLINEABLE (==) #-} - TxInfo a b c d e f g h i j k l m n o p - == TxInfo a' b' c' d' e' f' g' h' i' j' k' l' m' n' o' p' = - a PlutusTx.== a' - PlutusTx.&& b PlutusTx.== b' - PlutusTx.&& c PlutusTx.== c' - PlutusTx.&& d PlutusTx.== d' - PlutusTx.&& e PlutusTx.== e' - PlutusTx.&& f PlutusTx.== f' - PlutusTx.&& g PlutusTx.== g' - PlutusTx.&& h PlutusTx.== h' - PlutusTx.&& i PlutusTx.== i' - PlutusTx.&& j PlutusTx.== j' - PlutusTx.&& k PlutusTx.== k' - PlutusTx.&& l PlutusTx.== l' - PlutusTx.&& m PlutusTx.== m' - PlutusTx.&& n PlutusTx.== n' - PlutusTx.&& o PlutusTx.== o' - PlutusTx.&& p PlutusTx.== p' - -- | The context that the currently-executing script can access. data ScriptContext = ScriptContext { scriptContextTxInfo :: TxInfo @@ -525,7 +441,7 @@ data ScriptContext = ScriptContext -- ^ the purpose of the currently-executing script, along with information associated -- with the purpose } - deriving stock (Generic, Haskell.Eq, Haskell.Show) + deriving stock (Generic, Haskell.Show) instance Pretty ScriptContext where pretty ScriptContext{..} = @@ -535,11 +451,6 @@ instance Pretty ScriptContext where , nest 2 (vsep ["Redeemer:", pretty scriptContextRedeemer]) ] -instance PlutusTx.Eq ScriptContext where - {-# INLINEABLE (==) #-} - ScriptContext a b c == ScriptContext a' b' c' = - a PlutusTx.== a' PlutusTx.&& b PlutusTx.== b' PlutusTx.&& c PlutusTx.== c' - {-# INLINEABLE findOwnInput #-} -- | Find the input currently being validated. diff --git a/plutus-tx/changelog.d/20240607_155832_ana.pantilie95_fix_assocmap_instances.md b/plutus-tx/changelog.d/20240607_155832_ana.pantilie95_fix_assocmap_instances.md new file mode 100644 index 00000000000..50b2c381d5f --- /dev/null +++ b/plutus-tx/changelog.d/20240607_155832_ana.pantilie95_fix_assocmap_instances.md @@ -0,0 +1,3 @@ +### Removed + +- Removed incorrect Ord and Eq instances from AssocMap and Data.AssocMap. diff --git a/plutus-tx/src/PlutusTx/AssocMap.hs b/plutus-tx/src/PlutusTx/AssocMap.hs index d5c6c800150..2e7c32c7163 100644 --- a/plutus-tx/src/PlutusTx/AssocMap.hs +++ b/plutus-tx/src/PlutusTx/AssocMap.hs @@ -70,8 +70,8 @@ import Prettyprinter (Pretty (..)) -- Take care when using 'fromBuiltinData' and 'unsafeFromBuiltinData', as neither function performs -- deduplication of the input collection and may create invalid 'Map's! newtype Map k v = Map {unMap :: [(k, v)]} - deriving stock (Generic, Haskell.Eq, Haskell.Show, Data, TH.Lift) - deriving newtype (Eq, Ord, NFData) + deriving stock (Generic, Haskell.Show, Data, TH.Lift) + deriving newtype (NFData) -- | Hand-written instances to use the underlying 'Map' type in 'Data', and -- to be reasonably efficient. diff --git a/plutus-tx/src/PlutusTx/Data/AssocMap.hs b/plutus-tx/src/PlutusTx/Data/AssocMap.hs index 59b426915b2..5fded4753d9 100644 --- a/plutus-tx/src/PlutusTx/Data/AssocMap.hs +++ b/plutus-tx/src/PlutusTx/Data/AssocMap.hs @@ -63,7 +63,7 @@ this implementation provides slow lookup and update operations because it is bas on a list representation. -} newtype Map k a = Map (BI.BuiltinList (BI.BuiltinPair BuiltinData BuiltinData)) - deriving stock (Haskell.Eq, Haskell.Show) + deriving stock (Haskell.Show) instance P.ToData (Map k a) where {-# INLINEABLE toBuiltinData #-}