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

Clearer Plutip sub-service failure messages #1539

Merged
merged 3 commits into from
Sep 27, 2023
Merged
Changes from 1 commit
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
52 changes: 36 additions & 16 deletions src/Internal/Plutip/Server.purs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Contract.Address (NetworkId(MainnetId))
import Contract.Chain (waitNSlots)
import Contract.Config (defaultSynchronizationParams, defaultTimeParams)
import Contract.Monad (Contract, ContractEnv, liftContractM, runContractInEnv)
import Control.Monad.Error.Class (liftEither)
import Control.Monad.Error.Class (liftEither, throwError)
import Control.Monad.State (State, execState, modify_)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Writer (censor, execWriterT, tell)
Expand Down Expand Up @@ -78,7 +78,7 @@ import Ctl.Internal.Wallet.Key (PrivatePaymentKey(PrivatePaymentKey))
import Data.Array as Array
import Data.Bifunctor (lmap)
import Data.BigInt as BigInt
import Data.Either (Either(Left), either, isLeft)
import Data.Either (Either(Left, Right), either, isLeft)
import Data.Foldable (sum)
import Data.HTTP.Method as Method
import Data.Log.Level (LogLevel)
Expand All @@ -103,7 +103,7 @@ import Effect.Aff.Retry
, recovering
)
import Effect.Class (liftEffect)
import Effect.Exception (error, throw)
import Effect.Exception (error, message, throw)
import Effect.Ref (Ref)
import Effect.Ref as Ref
import Mote (bracket) as Mote
Expand Down Expand Up @@ -270,19 +270,39 @@ startPlutipContractEnv
, clearLogs :: Aff Unit
}
startPlutipContractEnv plutipCfg distr cleanupRef = do
configCheck plutipCfg
startPlutipServer'
ourKey /\ response <- startPlutipCluster'
startOgmios' response
startKupo' response
{ env, printLogs, clearLogs } <- mkContractEnv'
wallets <- mkWallets' env ourKey response
pure
{ env
, wallets
, printLogs
, clearLogs
}
configChecked <- try (configCheck plutipCfg)
case configChecked of
Left err -> throwError $ error $ "Config check failed: " <> message err
kozross marked this conversation as resolved.
Show resolved Hide resolved
Right _ -> do
serverStarted <- try startPlutipServer'
case serverStarted of
Left err -> throwError $ error $ "Could not start Plutip server: " <>
message err
Right _ -> do
clusterStarted <- try startPlutipCluster'
case clusterStarted of
Left err -> throwError $ error $ "Could not start Plutip cluster: "
<> message err
Right (ourKey /\ response) -> do
ogmiosStarted <- try (startOgmios' response)
case ogmiosStarted of
Left err -> throwError $ error $ "Could not start Ogmios: " <>
message err
Right _ -> do
kupoStarted <- try (startKupo' response)
case kupoStarted of
Left err -> throwError $ error $ "Could not start Kupo: " <>
message err
Right _ -> do
{ env, printLogs, clearLogs } <-
mkContractEnv'
wallets <- mkWallets' env ourKey response
pure
kozross marked this conversation as resolved.
Show resolved Hide resolved
{ env
, wallets
, printLogs
, clearLogs
}
where
-- Similar to `Aff.bracket`, except cleanup is pushed onto a stack to be run
-- later.
Expand Down