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

conformance: Add budgeting for haskell steppable #6791

Merged
merged 1 commit into from
Jan 28, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions plutus-conformance/haskell-steppable/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
module Main (main) where

import PlutusConformance.Common
import PlutusCore.Evaluation.Machine.ExBudgetingDefaults (defaultCekParametersForTesting)
import PlutusCore.Evaluation.Machine.MachineParameters.Default
import PlutusPrelude
import UntypedPlutusCore as UPLC
import UntypedPlutusCore.Evaluation.Machine.SteppableCek qualified as SCek

import Control.Lens
import UntypedPlutusCore.Evaluation.Machine.SteppableCek as SCek

failingEvaluationTests :: [FilePath]
failingEvaluationTests = []
Expand All @@ -17,15 +16,18 @@ failingBudgetTests = []

-- | The `evaluator` for the steppable-version of the CEK machine.
evalSteppableUplcProg :: UplcEvaluator
evalSteppableUplcProg = UplcEvaluatorWithoutCosting $ traverseOf UPLC.progTerm $ \t -> do
evalSteppableUplcProg = UplcEvaluatorWithCosting $ \modelParams (UPLC.Program a v t) -> do
params <- case mkMachineParametersFor [def] modelParams of
Left _ -> Nothing
Right machParamsList -> lookup def machParamsList
-- runCek-like functions (e.g. evaluateCekNoEmit) are partial on term's with free variables,
-- that is why we manually check first for any free vars
case UPLC.deBruijnTerm t of
Left (_ :: UPLC.FreeVariableError) -> Nothing
Right _ -> Just ()
case SCek.evaluateCekNoEmit defaultCekParametersForTesting t of
Left _ -> Nothing
Right prog -> Just prog
case SCek.runCekNoEmit params counting t of
(Left _,_) -> Nothing
(Right t', CountingSt cost) -> Just (UPLC.Program a v t', cost)

main :: IO ()
main =
Expand Down
1 change: 0 additions & 1 deletion plutus-conformance/plutus-conformance.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ test-suite haskell-steppable-conformance
other-modules:
build-depends:
, base >=4.9 && <5
, lens
, plutus-conformance
, plutus-core ^>=1.39

Expand Down
Loading