Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit 353f13b

Browse files
authored
Merge branch 'master' into ksaric/GH-208
2 parents c12e0b0 + f1157f0 commit 353f13b

29 files changed

+1465
-300
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
dist/*
55
dist-newstyle/*
66
.ghc.environment.*
7+
stack.yaml.lock
78

89
# From daedalus-bridge
910
node_modules/*

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ stylish-haskell: ## Apply stylish-haskell on all *.hs files
77
@find . -type f -name "*.hs" -not -path '.git' -not -path '*.stack-work*' -print0 | xargs -0 stylish-haskell -i
88

99
ghci: ## Run repl
10-
@stack ghci $(PROJECT_NAME):lib --haddock-deps --ghci-options=-fobject-code
10+
@stack ghci $(PROJECT_NAME):lib --haddock-deps --ghci-options=-fobject-code --nix
1111

1212
ghcid: ## Run ghcid
1313
@ghcid --command "stack ghci $(PROJECT_NAME):lib --nix -j12 --ghci-options=-fobject-code"
1414

1515
run-test: ## Build & run test
16-
@stack build --fast && \
17-
stack test --fast
16+
@stack build --fast --nix && \
17+
stack test --fast --nix
1818

1919
test-ghci: ## Run repl on test suites
20-
@stack ghci $(PROJECT_NAME):lib $(PROJECT_NAME):test:$(PROJECT_NAME)-test --ghci-options=-fobject-code
20+
@stack ghci $(PROJECT_NAME):lib $(PROJECT_NAME):test:$(PROJECT_NAME)-test --ghci-options=-fobject-code --nix
2121

2222
test-ghcid: ## Run ghcid on test suites
23-
@ghcid --command "stack ghci $(PROJECT_NAME):lib $(PROJECT_NAME):test:$(PROJECT_NAME)-test --ghci-options=-fobject-code"
23+
@ghcid --command "stack ghci --nix $(PROJECT_NAME):lib $(PROJECT_NAME):test:$(PROJECT_NAME)-test --ghci-options=-fobject-code"
2424

2525
test-ghcid-nix: ## Run ghcid on test suites with Nix
2626
#NUM_PROC = $(nproc --all) # Either try to fetch the real num of cores or default to 4

app/Cardano/Shell/Features/Logging.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import Control.Exception.Safe (MonadCatch)
2424
import qualified Control.Monad.STM as STM
2525
import Options.Applicative
2626

27+
import Cardano.BM.Data.Backend (Backend)
28+
import qualified Cardano.BM.Backend.Switchboard as Switchboard
2729
import Cardano.BM.Configuration (Configuration)
2830
import qualified Cardano.BM.Configuration as Config
2931
import Cardano.BM.Data.LogItem (LOContent (..), LOMeta (..),
@@ -71,12 +73,14 @@ data LoggingLayer = LoggingLayer
7173
, llLogNotice :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
7274
, llLogWarning :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
7375
, llLogError :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
74-
, llAppendName :: forall m a. (MonadIO m, Show a) => LoggerName -> Trace m a -> m (Trace m a)
76+
, llAppendName :: forall m a. (Show a) => LoggerName -> Trace m a -> Trace m a
7577
, llBracketMonadIO :: forall a t. (Show a) => Trace IO a -> Severity -> Text -> IO t -> IO t
7678
, llBracketMonadM :: forall m a t. (MonadCatch m, MonadIO m, Show a) => Trace m a -> Severity -> Text -> m t -> m t
7779
, llBracketMonadX :: forall m a t. (MonadIO m, Show a) => Trace m a -> Severity -> Text -> m t -> m t
7880
, llBracketStmIO :: forall a t. (Show a) => Trace IO a -> Severity -> Text -> STM.STM t -> IO t
7981
, llBracketStmLogIO :: forall a t. (Show a) => Trace IO a -> Severity -> Text -> STM.STM (t,[(LOMeta, LOContent a)]) -> IO t
82+
, llConfiguration :: Configuration
83+
, llAddBackend :: Backend Text -> Text -> IO ()
8084
}
8185

8286
--------------------------------
@@ -96,7 +100,6 @@ loggingParser = LoggingCLIArguments
96100
<$> strOption
97101
( long "log-config"
98102
<> metavar "LOGCONFIG"
99-
<> value ""
100103
<> help "Configuration file for logging"
101104
)
102105

@@ -152,6 +155,8 @@ loggingCardanoFeatureInit loggingConfiguration = do
152155
, llBracketMonadX = Monadic.bracketObserveX logConfig
153156
, llBracketStmIO = Stm.bracketObserveIO logConfig
154157
, llBracketStmLogIO = Stm.bracketObserveLogIO logConfig
158+
, llConfiguration = logConfig
159+
, llAddBackend = Switchboard.addExternalBackend switchBoard
155160
}
156161

157162
-- Cleanup function which shuts down the switchboard.

app/Cardano/Shell/Features/Networking.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import Cardano.Shell.Features.Logging (LoggingLayer (..))
1212
import Cardano.Shell.Types (CardanoEnvironment, CardanoFeature (..),
1313
CardanoFeatureInit (..))
1414

15-
import Cardano.Shell.Constants.Types (CardanoConfiguration)
15+
import Cardano.Shell.Constants.Types (CardanoConfiguration (..),
16+
Core (..), Wallet (..))
1617
--------------------------------------------------------------------------------
1718
-- Networking feature
1819
--------------------------------------------------------------------------------
@@ -75,6 +76,9 @@ createNetworkingFeature loggingLayer cardanoEnvironment cardanoConfiguration = d
7576
-- the filesystem, so we give him the most flexible/powerful context, @IO@.
7677
networkingConfiguration <- pure "THIS IS AN EXAMPLE OF A CONFIGURATION!"
7778

79+
putTextLn $ "The DB version - " <> (show $ coDBSerializeVersion $ ccCore cardanoConfiguration)
80+
putTextLn $ "The Wallet Throttle - " <> (show $ thRate $ ccWallet cardanoConfiguration)
81+
7882
-- we construct the layer
7983
networkingLayer <- (featureInit networkingCardanoFeatureInit) cardanoEnvironment loggingLayer cardanoConfiguration networkingConfiguration
8084

@@ -97,21 +101,18 @@ networkingCardanoFeatureInit = CardanoFeatureInit
97101
where
98102
actualNetworkFeature :: CardanoEnvironment -> LoggingLayer -> CardanoConfiguration -> Text -> IO NetworkLayer
99103
actualNetworkFeature _ loggingLayer _ _ = do
100-
--putTextLn "Starting up networking!"
101104
pure $ testNetworkLayer loggingLayer
102105

103106
featureCleanup' :: NetworkLayer -> IO ()
104-
featureCleanup' _ = pure () --putTextLn "Shutting down networking feature!" -- close all connections, for example
107+
featureCleanup' _ = pure () -- close all connections, for example
105108

106109

107110
networkingCardanoFeature :: NetworkingCardanoFeature -> NetworkLayer -> CardanoFeature
108111
networkingCardanoFeature networkingCardanoFeature' networkingLayer = CardanoFeature
109112
{ featureName = featureType networkingCardanoFeature'
110113
, featureStart = liftIO $ do
111-
--putTextLn "Starting up networkingCardanoFeature!"
112114
void $ pure networkingLayer -- or whatever it means for YOU (a specific team)
113115
, featureShutdown = liftIO $ do
114-
--putTextLn "Shutting down networkingCardanoFeature!"
115116
(featureCleanup networkingCardanoFeature') networkingLayer
116117
}
117118

app/Launcher/Main.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import Formatting.Buildable (Buildable (..))
1818

1919
import Control.Exception.Safe (throwM)
2020

21+
-- import Cardano.Shell.Update.Lib (runUpdater, updaterData)
2122
import Cardano.Shell.Configuration.Types (LauncherConfig (..),
2223
WalletArguments (..),
2324
WalletPath (..))
@@ -37,7 +38,7 @@ import Data.X509.Extra (failIfReasons, genRSA256KeyPair,
3738

3839
main :: IO ()
3940
main = do
40-
41+
4142
let launcherConfig :: LauncherConfig
4243
launcherConfig = LauncherConfig
4344
{ lcfgFilePath = "./configuration/cert-configuration.yaml"

app/Main.hs

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{-# LANGUAGE RecordWildCards #-}
2+
13
module Main (main) where
24

35
import Cardano.Prelude
@@ -8,13 +10,20 @@ import Cardano.Shell.Features.Logging (LoggingCLIArguments,
810
loggingParser)
911
import Cardano.Shell.Features.Networking (createNetworkingFeature)
1012

11-
import Cardano.Shell.Constants.Types (CardanoConfiguration (..))
13+
import Cardano.Shell.Configuration.Lib (finaliseCardanoConfiguration)
14+
import Cardano.Shell.Constants.CLI (configCardanoConfigurationCLIParser)
15+
import Cardano.Shell.Constants.PartialTypes (PartialCardanoConfiguration (..))
1216
import Cardano.Shell.Lib
1317
import Cardano.Shell.Presets (mainnetConfiguration)
1418
import Cardano.Shell.Types
1519

1620
import Options.Applicative
1721

22+
23+
-- | The product type of all command line arguments.
24+
-- All here being - from all the features.
25+
data CLIArguments = CLIArguments !LoggingCLIArguments !PartialCardanoConfiguration
26+
1827
main :: IO ()
1928
main = do
2029

@@ -34,7 +43,7 @@ main = do
3443
let appendName = llAppendName loggingLayer
3544

3645
logNotice logTrace "Hello from logging layer ..."
37-
logTrace' <- appendName "cardano-shell" logTrace
46+
let logTrace' = appendName "cardano-shell" logTrace
3847
logNotice logTrace' "Hello #2 from logging layer ..."
3948

4049
_ <- replicateM 5 (threadDelay 1000000 >> putTextLn "Running node/wallet/whatever!")
@@ -73,16 +82,32 @@ main = do
7382
-- anytime.
7483
-- Another interesting thing is that we stack the effects ONLY when we use a function from
7584
-- another layer, and we don't get all the effects, just the ones the function contains.
76-
initializeAllFeatures :: CardanoConfiguration -> CardanoEnvironment -> IO ([CardanoFeature], LoggingLayer)
77-
initializeAllFeatures cardanoConfiguration cardanoEnvironment = do
85+
initializeAllFeatures :: PartialCardanoConfiguration -> CardanoEnvironment -> IO ([CardanoFeature], LoggingLayer)
86+
initializeAllFeatures partialConfig cardanoEnvironment = do
7887

7988
-- Here we parse the __CLI__ arguments for the actual application.
80-
loggingCLIArguments <- execParser parserWithInfo
89+
CLIArguments loggingCLIArguments cardanoConfigurationCLI <- execParser parserWithInfo
90+
91+
let cardanoConfiguration' = partialConfig <> cardanoConfigurationCLI
92+
93+
putTextLn "************************************************"
94+
putTextLn "Cardano configurationn"
95+
putTextLn "************************************************"
96+
putTextLn $ show partialConfig
97+
putTextLn "------------------------------------------------"
98+
putTextLn $ show cardanoConfigurationCLI
99+
putTextLn "------------------------------------------------"
100+
putTextLn $ show cardanoConfiguration'
101+
putTextLn "------------------------------------------------"
102+
103+
-- Finalize the configuration and if something is missing, just throw error.
104+
finalConfig <- either (throwIO . ConfigurationError) pure $
105+
finaliseCardanoConfiguration cardanoConfiguration'
81106

82107
-- Here we initialize all the features
83-
(loggingLayer, loggingFeature) <- createLoggingFeature cardanoEnvironment cardanoConfiguration loggingCLIArguments
108+
(loggingLayer, loggingFeature) <- createLoggingFeature cardanoEnvironment finalConfig loggingCLIArguments
84109

85-
(_ , networkFeature) <- createNetworkingFeature loggingLayer cardanoEnvironment cardanoConfiguration
110+
(_ , networkFeature) <- createNetworkingFeature loggingLayer cardanoEnvironment finalConfig
86111

87112
-- Here we return all the features.
88113
let allCardanoFeatures :: [CardanoFeature]
@@ -94,9 +119,16 @@ initializeAllFeatures cardanoConfiguration cardanoEnvironment = do
94119
pure (allCardanoFeatures, loggingLayer)
95120
where
96121
-- | Top level parser with info.
97-
parserWithInfo :: ParserInfo LoggingCLIArguments
98-
parserWithInfo = info (loggingParser <**> helper)
122+
parserWithInfo :: ParserInfo CLIArguments
123+
parserWithInfo = info (commandLineParser <**> helper)
99124
( fullDesc
100125
<> progDesc "Logging Feature"
101126
<> header "cardano-shell: logging feature"
102127
)
128+
129+
-- | The product parser for all the CLI arguments.
130+
commandLineParser :: Parser CLIArguments
131+
commandLineParser = CLIArguments
132+
<$> loggingParser
133+
<*> configCardanoConfigurationCLIParser
134+

cabal.project

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ packages:
44
source-repository-package
55
type: git
66
location: https://github.com/input-output-hk/iohk-monitoring-framework
7-
tag: e2dc8b2160bb2ccd1ef9817a6498cda06ad36580
7+
tag: b2022cf7f5925e486f9e0a31f6f6d02145d5ebda
88
subdir: contra-tracer
99

1010
source-repository-package
1111
type: git
1212
location: https://github.com/input-output-hk/iohk-monitoring-framework
13-
tag: e2dc8b2160bb2ccd1ef9817a6498cda06ad36580
13+
tag: b2022cf7f5925e486f9e0a31f6f6d02145d5ebda
1414
subdir: iohk-monitoring
1515

1616
source-repository-package
@@ -21,7 +21,7 @@ source-repository-package
2121
source-repository-package
2222
type: git
2323
location: https://github.com/input-output-hk/cardano-prelude
24-
tag: fda38e60007a019c0c8569e8a0fc08f2102c92cc
24+
tag: d673b92f2a2d9354d102514d0a0fa74f8248b14a
2525

2626
source-repository-package
2727
type: git

cardano-shell.cabal

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,18 @@ library
3333
-- Update system
3434
, CardanoShellSpec
3535
, Cardano.Shell.Update.Types
36+
, Cardano.Shell.Update.Lib
3637
-- Constants
38+
, Cardano.Shell.Constants.PartialTypes
3739
, Cardano.Shell.Constants.Types
40+
, Cardano.Shell.Constants.CLI
3841
, Cardano.Shell.Presets
3942
-- Features
4043
, Cardano.Shell.Features.Logging
4144
other-modules:
4245
Cardano.Shell.NodeIPC.Lib
4346
, Cardano.Shell.NodeIPC.Message
4447
, Cardano.Shell.NodeIPC.ServerExample
45-
4648
hs-source-dirs:
4749
app
4850
, src
@@ -69,6 +71,9 @@ library
6971
, async
7072
, text
7173
, transformers
74+
, generic-monoid
75+
if os(windows)
76+
build-depends: Win32
7277

7378
default-language: Haskell2010
7479
default-extensions: NoImplicitPrelude
@@ -203,6 +208,7 @@ test-suite cardano-shell-test
203208
other-modules:
204209
Paths_cardano_shell
205210
DhallConfigSpec
211+
UpdaterSpec
206212
if !os(windows)
207213
other-modules:
208214
NodeIPCSpec

configuration/log-configuration.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,17 @@ options:
4141
# mapBackends:
4242
# demo-playground.simple-node.CoreId 0.validation:
4343
# - AggregationBK
44+
mapSubtrace:
45+
'#messagecounters.aggregation':
46+
subtrace: NoTrace
47+
'#messagecounters.ekgview':
48+
subtrace: NoTrace
49+
'#messagecounters.switchboard':
50+
subtrace: NoTrace
51+
'#messagecounters.katip':
52+
subtrace: NoTrace
53+
'#messagecounters.monitoring':
54+
subtrace: NoTrace
55+
'#messagecounters.graylog':
56+
subtrace: NoTrace
57+

default.nix

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,15 @@ in defaultNix // {
6060
# env will provide the dependencies of cardano-shell
6161
packages = ps: with ps; [ cardano-shell ];
6262
# This adds git to the shell, which is used by stack.
63-
buildInputs = with pkgs; [ git stack commonLib.stack-hpc-coveralls pkgconfig systemd ];
63+
buildInputs = with pkgs; [
64+
defaultNix.nix-tools._raw.cabal-install.components.exes.cabal
65+
defaultNix.nix-tools._raw.ghcid.components.exes.ghcid
66+
git
67+
pkgconfig
68+
stack
69+
commonLib.stack-hpc-coveralls
70+
systemd
71+
];
6472
};
6573

6674
runCoveralls = pkgs.stdenv.mkDerivation {

nix/.stack.nix/cardano-prelude-test.nix

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/.stack.nix/cardano-prelude.nix

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/.stack.nix/cardano-shell.nix

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/.stack.nix/contra-tracer.nix

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/.stack.nix/default.nix

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)