Skip to content

Commit

Permalink
conformance: Add budgeting for haskell steppable
Browse files Browse the repository at this point in the history
  • Loading branch information
bezirg committed Jan 14, 2025
1 parent cea546c commit cfd4168
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
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

0 comments on commit cfd4168

Please sign in to comment.