Skip to content

Commit

Permalink
proto_path
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed Oct 28, 2024
1 parent b21c7fe commit a4399b1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/Commands/Dev/Nockma/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions app/Commands/Dev/Nockma/Run/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
15 changes: 10 additions & 5 deletions src/Anoma/Effect/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -108,23 +108,25 @@ 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
Left err -> error (pack err)

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"
]
Expand All @@ -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 $
Expand Down
3 changes: 2 additions & 1 deletion src/Anoma/Effect/RunNockma.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions src/Juvix/Prelude/Trace.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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" #-}

0 comments on commit a4399b1

Please sign in to comment.