diff --git a/app/Commands/Dev/Nockma/Options.hs b/app/Commands/Dev/Nockma/Options.hs index 4b4f87431d..9937351e45 100644 --- a/app/Commands/Dev/Nockma/Options.hs +++ b/app/Commands/Dev/Nockma/Options.hs @@ -30,7 +30,7 @@ parseNockmaCommand = runInfo = info (NockmaRun <$> parseNockmaRunOptions) - (progDesc "Run an Anoma program. It should be used with artefacts obtained from compilation with the anoma target.") + (progDesc ("Run an Anoma program. It should be used with artefacts obtained from compilation with the anoma target. If the --" <> anomaDirOptLongStr <> " is given, then it runs the code in an anoma node")) commandFromAsm :: Mod CommandFields NockmaCommand commandFromAsm = command "eval" fromAsmInfo diff --git a/app/Commands/Dev/Nockma/Run/Options.hs b/app/Commands/Dev/Nockma/Run/Options.hs index cf2fd7e2cc..f3236e11e8 100644 --- a/app/Commands/Dev/Nockma/Run/Options.hs +++ b/app/Commands/Dev/Nockma/Run/Options.hs @@ -6,7 +6,6 @@ data NockmaRunOptions = NockmaRunOptions { _nockmaRunFile :: AppPath File, _nockmaRunAnomaDir :: Maybe (AppPath Dir), _nockmaRunProfile :: Bool, - _nockmaRunAnoma :: Bool, _nockmaRunArgs :: Maybe (AppPath File) } deriving stock (Data) @@ -26,11 +25,6 @@ parseNockmaRunOptions = do <> action "file" ) pure AppPath {_pathIsInput = True, ..} - _nockmaRunAnoma <- - switch - ( long "anoma" - <> help ("Run in Anoma node (makes --" <> anomaDirOptLongStr <> " mandatory)") - ) _nockmaRunAnomaDir <- optional anomaDirOpt _nockmaRunProfile <- switch diff --git a/src/Anoma/Effect/Base.hs b/src/Anoma/Effect/Base.hs index 01a6cc6e7b..e0af2ea3ad 100644 --- a/src/Anoma/Effect/Base.hs +++ b/src/Anoma/Effect/Base.hs @@ -84,7 +84,7 @@ withSapwnAnomaNode :: Sem r a withSapwnAnomaNode body = withSystemTempFile "start.exs" $ \fp tmpHandle -> do liftIO (B.hPutStr tmpHandle anomaStartExs) - hFlush tmpHandle + hClose tmpHandle curDir <- getCurrentDir asks (^. anomaPath) >>= setCurrentDir withCreateProcess (cprocess (toFilePath fp)) $ \_stdin mstdout _stderr procHandle -> do @@ -108,7 +108,7 @@ anomaRpc' msg = do stdoutH = fromJust mstdout inputbs = B.toStrict (encode msg) liftIO (B.hPutStr stdinH inputbs) - hFlush stdinH + hClose stdinH res <- eitherDecodeStrict <$> liftIO (B.hGetContents stdoutH) case res of Right r -> return r @@ -116,15 +116,17 @@ anomaRpc' msg = do grpcCliProcess :: (Members '[Reader AnomaPath] r) => Sem r CreateProcess grpcCliProcess = do - protoFile <- relativeToAnomaDir relProtoFile + paths <- relativeToAnomaDir relProtoDir return ( proc "grpc_cli" [ "call", "--json_input", "--json_output", + "--proto_path", + toFilePath paths, "--protofiles", - toFilePath protoFile, + toFilePath relProtoFile, "localhost:" <> show listenPort, "Anoma.Protobuf.Intents.Prove" ] @@ -133,8 +135,11 @@ grpcCliProcess = do std_out = CreatePipe } where + relProtoDir :: Path Rel Dir + relProtoDir = $(mkRelDir "apps/anoma_protobuf/priv/protobuf") + relProtoFile :: Path Rel File - relProtoFile = $(mkRelFile "apps/anoma_protobuf/priv/protobuf/anoma.proto") + relProtoFile = $(mkRelFile "anoma.proto") runAnoma :: forall r a. (Members '[Logger, EmbedIO] r) => AnomaPath -> Sem (Anoma ': r) a -> Sem r a runAnoma anomapath body = runReader anomapath . runConcurrent . runProcess $ diff --git a/src/Anoma/Effect/RunNockma.hs b/src/Anoma/Effect/RunNockma.hs index 040664eccb..8219b00513 100644 --- a/src/Anoma/Effect/RunNockma.hs +++ b/src/Anoma/Effect/RunNockma.hs @@ -56,5 +56,6 @@ runNockma prog inputs = do _runNockPrivateInputs = args, _runNockPublicInputs = [] } - res :: Rpc.Response <- anomaRpc (Aeson.toJSON msg) >>= fromJSON + let json = Aeson.toJSON msg + res :: Rpc.Response <- anomaRpc json >>= fromJSON decodeJam64 (res ^. Rpc.proof) diff --git a/src/Juvix/Prelude/Trace.hs b/src/Juvix/Prelude/Trace.hs index c926ba1aa0..5643a45ed4 100644 --- a/src/Juvix/Prelude/Trace.hs +++ b/src/Juvix/Prelude/Trace.hs @@ -46,6 +46,6 @@ traceToFile fpath t a = return a {-# WARNING traceToFile "Using traceToFile" #-} -traceToFileM :: (Applicative m) => Path Abs File -> Text -> a -> m () -traceToFileM fpath t a = pure (traceToFile fpath t a) $> () +traceToFileM :: (Applicative m) => Path Abs File -> Text -> m () +traceToFileM fpath t = pure (traceToFile fpath t ()) $> () {-# WARNING traceToFileM "Using traceFileM" #-}