From fcd659dc135862faa1c20f3bf17e24b8b4a085cd Mon Sep 17 00:00:00 2001 From: Sebastian Nagel Date: Thu, 23 May 2024 12:40:23 +0200 Subject: [PATCH] Plutus: Re-enable simplification on inline, but conservatively According to https://github.com/IntersectMBO/plutus/issues/5460 this should be enough to ensure traces are not simplified away, but still allow for some simplifications and potential smaller / faster code. --- CHANGELOG.md | 4 ++++ hydra-plutus/hydra-plutus.cabal | 2 +- hydra-plutus/src/Hydra/Contract/Commit.hs | 4 ++-- hydra-plutus/src/Hydra/Contract/Head.hs | 4 ++-- hydra-plutus/src/Hydra/Contract/HeadTokens.hs | 4 ++-- hydra-plutus/src/Hydra/Contract/Initial.hs | 6 +++--- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eba76dff580..a79b5605fd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 As a minor extension, we also keep a semantic version for the `UNRELEASED` changes. +## [0.18.0] - UNRELEASED + +- **BREAKING** Change `plutus-tx` flags when building `hydra-plutus` scripts, resulting in a script hash change. + ## [0.17.0] - 2024-05-20 - **BREAKING** Change `hydra-node` API `/commit` endpoint for committing from scripts [#1380](https://github.com/input-output-hk/hydra/pull/1380): diff --git a/hydra-plutus/hydra-plutus.cabal b/hydra-plutus/hydra-plutus.cabal index 3a11478cf5a..ebf043241a7 100644 --- a/hydra-plutus/hydra-plutus.cabal +++ b/hydra-plutus/hydra-plutus.cabal @@ -1,6 +1,6 @@ cabal-version: 2.2 name: hydra-plutus -version: 0.17.0 +version: 0.18.0 synopsis: Hydra Plutus Contracts author: IOG copyright: 2022 IOG diff --git a/hydra-plutus/src/Hydra/Contract/Commit.hs b/hydra-plutus/src/Hydra/Contract/Commit.hs index 069934c917b..fcead9e931f 100644 --- a/hydra-plutus/src/Hydra/Contract/Commit.hs +++ b/hydra-plutus/src/Hydra/Contract/Commit.hs @@ -1,8 +1,8 @@ {-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -fno-specialize #-} {-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:defer-errors #-} --- Avoid trace calls to be optimized away when inlining functions. -{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:no-simplifier-inline #-} +-- Avoid trace calls to be optimized away. +{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:conservative-optimisation #-} -- Plutus core version to compile to. In babbage era, that is Cardano protocol -- version 7 and 8, only plutus-core version 1.0.0 is available. {-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:target-version=1.0.0 #-} diff --git a/hydra-plutus/src/Hydra/Contract/Head.hs b/hydra-plutus/src/Hydra/Contract/Head.hs index 7380284d83c..28c1a99b735 100644 --- a/hydra-plutus/src/Hydra/Contract/Head.hs +++ b/hydra-plutus/src/Hydra/Contract/Head.hs @@ -2,8 +2,8 @@ {-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -fno-specialize #-} {-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:defer-errors #-} --- Avoid trace calls to be optimized away when inlining functions. -{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:no-simplifier-inline #-} +-- Avoid trace calls to be optimized away. +{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:conservative-optimisation #-} -- Plutus core version to compile to. In babbage era, that is Cardano protocol -- version 7 and 8, only plutus-core version 1.0.0 is available. {-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:target-version=1.0.0 #-} diff --git a/hydra-plutus/src/Hydra/Contract/HeadTokens.hs b/hydra-plutus/src/Hydra/Contract/HeadTokens.hs index abcf91be160..728676355a5 100644 --- a/hydra-plutus/src/Hydra/Contract/HeadTokens.hs +++ b/hydra-plutus/src/Hydra/Contract/HeadTokens.hs @@ -1,8 +1,8 @@ {-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -fno-specialize #-} {-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:defer-errors #-} --- Avoid trace calls to be optimized away when inlining functions. -{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:no-simplifier-inline #-} +-- Avoid trace calls to be optimized away. +{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:conservative-optimisation #-} -- Plutus core version to compile to. In babbage era, that is Cardano protocol -- version 7 and 8, only plutus-core version 1.0.0 is available. {-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:target-version=1.0.0 #-} diff --git a/hydra-plutus/src/Hydra/Contract/Initial.hs b/hydra-plutus/src/Hydra/Contract/Initial.hs index c83bf27b2b0..96ec623f899 100644 --- a/hydra-plutus/src/Hydra/Contract/Initial.hs +++ b/hydra-plutus/src/Hydra/Contract/Initial.hs @@ -1,8 +1,8 @@ {-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -fno-specialize #-} +-- Avoid trace calls to be optimized away. +{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:conservative-optimisation #-} {-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:defer-errors #-} --- Avoid trace calls to be optimized away when inlining functions. -{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:no-simplifier-inline #-} -- Plutus core version to compile to. In babbage era, that is Cardano protocol -- version 7 and 8, only plutus-core version 1.0.0 is available. {-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:target-version=1.0.0 #-} @@ -173,7 +173,7 @@ checkCommit commitValidator headId committedRefs context = Nothing -> traceError $(errorCode ExpectedCommitDatumTypeGotSomethingElse) Just (_party, commits, hid) -> (commits, hid) - _ -> traceError $(errorCode ExpectedSingleCommitOutput) + _ -> traceIfFalse $(errorCode ExpectedSingleCommitOutput) False ScriptContext{scriptContextTxInfo = txInfo} = context