Skip to content

Commit

Permalink
Separate repl into separate project
Browse files Browse the repository at this point in the history
- Fix builtin gas charging for repl builtins
- Move tracing flags to repl sublibrary
  • Loading branch information
jmcardon committed Nov 4, 2024
1 parent adccfca commit 5ef5609
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 55 deletions.
14 changes: 12 additions & 2 deletions gasmodel/Pact/Core/GasModel/ContractBench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import Pact.Core.Gas
import Pact.Core.Namespace
import Pact.Core.Serialise
import Pact.Core.Persistence.MockPersistence
import qualified Pact.Core.IR.Eval.Direct.Evaluator as Direct
import qualified Pact.Core.IR.Eval.Direct.CoreBuiltin as Direct

import Pact.Core.Errors
import Pact.Core.Interpreter
Expand All @@ -59,7 +61,15 @@ interpretBigStep :: Interpreter ExecRuntime CoreBuiltin Info
interpretBigStep = evalInterpreter

interpretDirect :: Interpreter ExecRuntime CoreBuiltin Info
interpretDirect = evalDirectInterpreter
interpretDirect =
Interpreter runGuard runTerm resume evalWithCap
where
runTerm purity term = Direct.eval purity benv term
runGuard info g = Direct.interpretGuard info benv g
resume info defPact = Direct.evalResumePact info benv defPact
evalWithCap info purity ct term =
Direct.evalWithinCap info purity benv ct term
benv = Direct.coreBuiltinEnv


data CoinBenchSenders
Expand Down Expand Up @@ -179,7 +189,7 @@ setupCoinTxs pdb = do
putStrLn "Setting up the coin contract and the default funds"
source <- T.readFile (contractsPath </> "coin-v5-create.pact")
ee <- setupBenchEvalEnv pdb coinInitSigners coinInitData
() <$ runPactTxFromSource ee source evalDirectInterpreter
() <$ runPactTxFromSource ee source interpretDirect


_run :: IO ()
Expand Down
52 changes: 15 additions & 37 deletions pact-tng.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,6 @@ library
import: pact-common
hs-source-dirs: pact

if (flag(with-funcall-tracing))
cpp-options: -DWITH_FUNCALL_TRACING

if (flag(with-native-tracing))
cpp-options: -DWITH_NATIVE_TRACING

if (flag(with-native-tracing) || flag(with-funcall-tracing))
cpp-options: -DWITH_TRACING

if (flag(with-crypto))
build-depends: pact-tng:pact-crypto
else
Expand Down Expand Up @@ -280,15 +271,6 @@ library
Pact.Core.Trans.MPFR
Pact.Core.Version

-- Repl
-- Pact.Core.Repl
-- Pact.Core.Repl.Utils
-- Pact.Core.Repl.Runtime.ReplBuiltin
-- Pact.Core.Repl.Compile
-- Pact.Core.Repl.BuiltinDocs
-- Pact.Core.Repl.BuiltinDocs.Internal
-- Pact.Core.Repl.UserDocs

-- Serialization
Pact.Core.Serialise
Pact.Core.Serialise.LegacyPact
Expand All @@ -310,6 +292,20 @@ library pact-repl
import: pact-common
hs-source-dirs: pact-repl

if (flag(with-crypto))
build-depends: pact-tng:pact-crypto
else
cpp-options: -DWITHOUT_CRYPTO

if (flag(with-funcall-tracing))
cpp-options: -DWITH_FUNCALL_TRACING

if (flag(with-native-tracing))
cpp-options: -DWITH_NATIVE_TRACING

if (flag(with-native-tracing) || flag(with-funcall-tracing))
cpp-options: -DWITH_TRACING

exposed-modules:
Pact.Core.Repl
Pact.Core.Repl.Utils
Expand Down Expand Up @@ -354,6 +350,7 @@ executable gasmodel

build-depends:
, pact-tng
, pact-tng:pact-repl
, criterion
, terminal-progress-bar
, neat-interpolation
Expand Down Expand Up @@ -590,22 +587,3 @@ test-suite core-tests
, Pact.Core.Test.ServerUtils
if (flag(with-crypto))
build-depends: pact-tng:pact-crypto


-- -- tools
-- executable pact-server
-- import: pact-common
-- hs-source-dirs: pact-server

-- main-is: Pact/Server.hs

-- build-depends:
-- , pact-tng
-- , async
-- , fast-logger
-- , filepath
-- , servant
-- , servant-server
-- ghc-options: -Wall -threaded -rtsopts -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints
-- ghc-prof-options: -fprof-auto -fprof-auto-calls
-- default-language: Haskell2010
14 changes: 0 additions & 14 deletions pact/Pact/Core/Evaluate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ module Pact.Core.Evaluate
, Eval
, EvalBuiltinEnv
, allModuleExports
-- , evalDirectInterpreter
, evalInterpreter
, EvalInput
, EnableGasLogs(..)
Expand Down Expand Up @@ -64,8 +63,6 @@ import Pact.Core.Info
import Pact.Core.Signer
import Pact.Core.IR.Eval.CEK.CoreBuiltin
import qualified Pact.Core.IR.Eval.CEK.Evaluator as CEK
-- import qualified Pact.Core.IR.Eval.Direct.Evaluator as Direct
-- import qualified Pact.Core.IR.Eval.Direct.CoreBuiltin as Direct
import qualified Pact.Core.Syntax.Lexer as Lisp
import qualified Pact.Core.Syntax.Parser as Lisp
import qualified Pact.Core.Syntax.ParseTree as Lisp
Expand Down Expand Up @@ -118,17 +115,6 @@ evalInterpreter =
cekEnv :: CEK.BuiltinEnv ExecRuntime CoreBuiltin Info
cekEnv = coreBuiltinEnv @ExecRuntime

-- evalDirectInterpreter :: Interpreter ExecRuntime CoreBuiltin Info
-- evalDirectInterpreter =
-- Interpreter runGuard runTerm resume evalWithCap
-- where
-- runTerm purity term = Direct.eval purity env term
-- runGuard info g = Direct.interpretGuard info env g
-- resume info defPact = Direct.evalResumePact info env defPact
-- evalWithCap info purity ct term =
-- Direct.evalWithinCap info purity env ct term
-- env = Direct.coreBuiltinEnv

-- | Transaction-payload related environment data.
data MsgData = MsgData
{ mdData :: !PactValue
Expand Down
4 changes: 2 additions & 2 deletions profile-tx/ProfileTx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ setupCoinTxs pdb = do
putStrLn "Setting up the coin contract and the default funds"
source <- T.readFile (contractsPath </> "coin-v5-create.pact")
ee <- setupBenchEvalEnv pdb coinInitSigners coinInitData
() <$ runPactTxFromSource ee source evalDirectInterpreter
() <$ runPactTxFromSource ee source evalInterpreter


_run :: IO ()
Expand Down Expand Up @@ -242,7 +242,7 @@ _testCoinTransfer = withSqlitePactDb serialisePact_lineinfo (T.pack benchmarkSql
t <- liftEither $ compileOnlyTermLineInfo (RawCode termText)
_dsOut <$> runDesugarTerm t
term <- getRightIO eterm
(out, _) <- runEvalM (ExecEnv ee) es (eval evalDirectInterpreter PImpure term)
(out, _) <- runEvalM (ExecEnv ee) es (eval evalInterpreter PImpure term)
print out

unsafeModuleHash :: Text -> Hash
Expand Down

0 comments on commit 5ef5609

Please sign in to comment.