Skip to content

Commit

Permalink
[ADP-3339] Prepare UI server support (#4711)
Browse files Browse the repository at this point in the history
This PR is almost a pure refactoring to prepare the main application to
run multiple http services. I added a sub one that will be replaced with
the UI service later

- [x] Add cli options to control the presence of the UI server on a
different port than API server
- [x] Move non-api http server code from api package to exe package
(including tls module)
- [x] Add support for a do-nothing service running along the main api
service

ADP-3339
  • Loading branch information
paolino authored Aug 4, 2024
2 parents bffb2d7 + 9d2d9b9 commit af45e29
Show file tree
Hide file tree
Showing 18 changed files with 624 additions and 394 deletions.
33 changes: 24 additions & 9 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,16 @@ steps:
concurrency: 1
concurrency_group: 'linux-e2e-tests'

- label: Private Network Full Sync
- label: Build .#cardano-wallet (linux)
key: cardano-wallet
depends_on: linux-nix
timeout: 20
command: 'nix build .#cardano-wallet'
agents:
system: ${linux}

- label: Private Network Full Sync
depends_on: cardano-wallet
timeout: 10
command: |
rm -rf run/private/nix/logs
mkdir -p run/private/nix/logs
Expand All @@ -158,10 +165,12 @@ steps:
env:
NODE_LOGS_FILE: ./logs/node.log
WALLET_LOGS_FILE: ./logs/wallet.log
CLEANUP_DB: true
NETWORK: testnet

- label: Mainnet Boot Sync
depends_on: linux-nix
timeout: 30
depends_on: cardano-wallet
timeout: 2
command: |
cd run/mainnet/nix
rm -rf logs
Expand All @@ -176,17 +185,19 @@ steps:
SUCCESS_STATUS: syncing
NODE_LOGS_FILE: ./logs/node.log
WALLET_LOGS_FILE: ./logs/wallet.log
CLEANUP_DB: true
NETWORK: mainnet

- block: Sanchonet Full Sync
if: build.env("RELEASE_CANDIDATE") == null
depends_on: linux-nix
depends_on: cardano-wallet
key: linux-sanchonet-full-sync-block

- label: Sanchonet Full Sync
depends_on:
- linux-nix
- cardano-wallet
- linux-sanchonet-full-sync-block
timeout_in_minutes: 240
timeout_in_minutes: 30
command: |
rm -rf run/sanchonet/nix/logs
mkdir -p run/sanchonet/nix/logs
Expand All @@ -199,6 +210,8 @@ steps:
env:
NODE_LOGS_FILE: ./logs/node.log
WALLET_LOGS_FILE: ./logs/wallet.log
CLEANUP_DB: true
NETWORK: testnet

- block: Preprod Full Sync
if: build.env("RELEASE_CANDIDATE") == null
Expand All @@ -207,9 +220,9 @@ steps:

- label: Preprod Full Sync
depends_on:
- linux-nix
- cardano-wallet
- linux-preprod-full-sync-block
timeout_in_minutes: 240
timeout_in_minutes: 30
command: |
cd run/preprod/nix
rm -rf logs
Expand All @@ -224,6 +237,8 @@ steps:
env:
NODE_LOGS_FILE: ./logs/node.log
WALLET_LOGS_FILE: ./logs/wallet.log
CLEANUP_DB: true
NETWORK: testnet


- group: Code Quality Checks
Expand Down
11 changes: 0 additions & 11 deletions lib/api/cardano-wallet-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ library
, containers
, contra-tracer
, crypto-primitives
, data-default
, deepseq
, either
, errors
Expand All @@ -73,7 +72,6 @@ library
, iohk-monitoring
, memory
, mtl
, network
, network-uri
, OddWord
, quiet
Expand All @@ -82,20 +80,12 @@ library
, servant
, servant-client
, servant-server
, streaming-commons
, text
, text-class
, time
, tls
, transformers
, unliftio
, wai
, wai-middleware-logging
, warp
, warp-tls
, x509
, x509-store
, x509-validation

exposed-modules:
Cardano.Wallet.Api
Expand All @@ -116,7 +106,6 @@ library
Cardano.Wallet.Api.Http.Server.Error.IsServerError
Cardano.Wallet.Api.Http.Server.Handlers.MintBurn
Cardano.Wallet.Api.Http.Server.Handlers.TxCBOR
Cardano.Wallet.Api.Http.Server.Tls
Cardano.Wallet.Api.Http.Shelley.Server
Cardano.Wallet.Api.Lib.ApiAsArray
Cardano.Wallet.Api.Lib.ApiT
Expand Down
31 changes: 5 additions & 26 deletions lib/api/src/Cardano/Wallet/Api/Http/Logging.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
-- Logging functionality for the Shelley wallet
--
module Cardano.Wallet.Api.Http.Logging
( ApplicationLog(..)
( ApiApplicationLog(..)
) where

import Prelude
Expand All @@ -26,9 +26,6 @@ import Cardano.BM.Tracing
import Cardano.Launcher.Node
( CardanoNodeConn
)
import Cardano.Wallet.Api.Http.Shelley.Server
( ListenError (..)
)
import Data.Text
( Text
)
Expand All @@ -46,46 +43,28 @@ import Network.URI
import qualified Data.Text as T

-- | Log messages related to application startup and shutdown.
data ApplicationLog
data ApiApplicationLog
= MsgStartingNode CardanoNodeConn
| MsgNetworkName Text
| MsgServerStartupError ListenError
| MsgFailedConnectSMASH URI
deriving (Generic, Show, Eq)

instance ToText ApplicationLog where
instance ToText ApiApplicationLog where
toText = \case
MsgStartingNode conn ->
"Wallet backend server starting. Using " <> toText conn <> "."
MsgNetworkName network ->
"Node is Haskell Node on " <> network <> "."
MsgServerStartupError startupErr -> case startupErr of
ListenErrorHostDoesNotExist host -> mempty
<> "Can't listen on "
<> T.pack (show host)
<> ". It does not exist."
ListenErrorInvalidAddress host -> mempty
<> "Can't listen on "
<> T.pack (show host)
<> ". Invalid address."
ListenErrorAddressAlreadyInUse mPort -> mempty
<> "The API server listen port "
<> maybe "(unknown)" (T.pack . show) mPort
<> " is already in use."
ListenErrorOperationNotPermitted -> mempty
<> "Cannot listen on the given port. "
<> "The operation is not permitted."
MsgFailedConnectSMASH uri -> T.unwords
[ "Failed connect to the given smash server\
\ or validate a healthy status."
, "SMASH uri was: "
, T.pack $ uriToString id uri ""
]

instance HasPrivacyAnnotation ApplicationLog
instance HasSeverityAnnotation ApplicationLog where
instance HasPrivacyAnnotation ApiApplicationLog
instance HasSeverityAnnotation ApiApplicationLog where
getSeverityAnnotation = \case
MsgStartingNode _ -> Info
MsgNetworkName _ -> Info
MsgServerStartupError _ -> Alert
MsgFailedConnectSMASH _ -> Warning
Loading

0 comments on commit af45e29

Please sign in to comment.