Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/IntersectMBO/ouroboros-network
-- from coot/dmq-related-changes
tag: 625296c92363b8c5e77cddee40de4525421d2660
--sha256: sha256-WRbKqNimAsYtgj/r3SJ0IT6z7+Q3XZf3p89BM9w6bF8=
-- from fmaste/cardano-logging that is on top of coot/dmq-related-changes
tag: 2d1984996cdad1565fbaa29ae3f10e1fd3f84240
--sha256: sha256-alRm44wPMwVxJTlEBiKfThdEIvmN1EOA2eLlacv4Fw0=
subdir:
acts-generic
cardano-diffusion
Expand Down
49 changes: 15 additions & 34 deletions dmq-node/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
Expand All @@ -11,13 +12,11 @@
module Main where

import Control.Concurrent.Class.MonadSTM.Strict
import Control.Concurrent.Class.MonadMVar
import Control.Monad (void, when)
import Control.Monad.Class.MonadThrow
import Control.Tracer (Tracer (..), nullTracer, traceWith)
import "contra-tracer" Control.Tracer (traceWith)

import Data.Act
import Data.Aeson (ToJSON)
import Data.ByteString.Lazy qualified as BSL
import Data.Functor.Contravariant ((>$<))
import Data.Foldable (traverse_)
Expand Down Expand Up @@ -47,7 +46,9 @@ import DMQ.NodeToNode (NodeToNodeVersion, dmqCodecs, dmqLimitsAndTimeouts,
ntnApps)
import DMQ.Protocol.SigSubmission.Type (Sig (..))
import DMQ.Tracer

( mkCardanoTracer
, WithEventType (WithEventType), EventType (DMQ)
)
import DMQ.Diffusion.PeerSelection (policy)
import DMQ.NodeToClient.LocalStateQueryClient
import DMQ.Protocol.SigSubmission.Validate
Expand Down Expand Up @@ -81,24 +82,14 @@ runDMQ commandLineConfig = do
-- combine default configuration, configuration file and command line
-- options
let dmqConfig@Configuration {
dmqcPrettyLog = I prettyLog,
dmqcTopologyFile = I topologyFile,
dmqcHandshakeTracer = I handshakeTracer,
dmqcValidationTracer = I validationTracer,
dmqcLocalHandshakeTracer = I localHandshakeTracer,
dmqcCardanoNodeSocket = I snocketPath,
dmqcVersion = I version,
dmqcLocalStateQueryTracer = I localStateQueryTracer
dmqcVersion = I version
} = config' <> commandLineConfig
`act`
defaultConfiguration

lock <- newMVar ()
let tracer', tracer :: ToJSON ev => Tracer IO (WithEventType ev)
tracer' = dmqTracer prettyLog
-- use a lock to prevent writing two lines at the same time
-- TODO: this won't be needed with `cardano-tracer` integration
tracer = Tracer $ \a -> withMVar lock $ \_ -> traceWith tracer' a
(tracer, dmqDiffusionTracers) <- mkCardanoTracer configFilePath

when version $ do
let gitrev = $(gitRev)
Expand All @@ -117,9 +108,9 @@ runDMQ commandLineConfig = do
]
exitSuccess

traceWith tracer (WithEventType "Configuration" dmqConfig)
traceWith tracer (WithEventType (DMQ "Configuration") dmqConfig)
nt <- readTopologyFileOrError topologyFile
traceWith tracer (WithEventType "NetworkTopology" nt)
traceWith tracer (WithEventType (DMQ "NetworkTopology") nt)

stdGen <- newStdGen
let (psRng, policyRng) = split stdGen
Expand All @@ -129,9 +120,7 @@ runDMQ commandLineConfig = do
withIOManager \iocp -> do
let localSnocket' = localSnocket iocp
mkStakePoolMonitor = connectToCardanoNode
(if localStateQueryTracer
then WithEventType "LocalStateQuery" >$< tracer
else nullTracer)
(WithEventType (DMQ "LocalStateQuery") >$< tracer)
localSnocket'
snocketPath

Expand All @@ -146,9 +135,7 @@ runDMQ commandLineConfig = do
let sigSize :: Sig StandardCrypto -> SizeInBytes
sigSize = fromIntegral . BSL.length . sigRawBytes
mempoolReader = Mempool.getReader sigId sigSize (mempool nodeKernel)
ntnValidationTracer = if validationTracer
then WithEventType "NtN Validation" >$< tracer
else nullTracer
ntnValidationTracer = (WithEventType (DMQ "NtC Validation") >$< tracer)
dmqNtNApps =
let ntnMempoolWriter =
Mempool.getWriter SigDuplicate
Expand Down Expand Up @@ -180,9 +167,7 @@ runDMQ commandLineConfig = do
(decodeRemoteAddress (maxBound @NodeToNodeVersion)))
dmqLimitsAndTimeouts
defaultSigDecisionPolicy
ntcValidationTracer = if validationTracer
then WithEventType "NtC Validation" >$< tracer
else nullTracer
ntcValidationTracer = (WithEventType (DMQ "NtC Validation") >$< tracer)
dmqNtCApps =
let ntcMempoolWriter =
Mempool.getWriter SigDuplicate
Expand All @@ -198,12 +183,8 @@ runDMQ commandLineConfig = do
mempoolReader ntcMempoolWriter
NtC.dmqCodecs
dmqDiffusionArguments =
diffusionArguments (if handshakeTracer
then WithEventType "Handshake" >$< tracer
else nullTracer)
(if localHandshakeTracer
then WithEventType "Handshake" >$< tracer
else nullTracer)
diffusionArguments (WithEventType (DMQ "Handshake") >$< tracer)
(WithEventType (DMQ "LocalHandshake") >$< tracer)
$ maybe [] out <$> tryReadTMVar nodeKernel.stakePools.ledgerPeersVar
where
out :: LedgerPeerSnapshot AllLedgerPeers
Expand All @@ -220,6 +201,6 @@ runDMQ commandLineConfig = do
(policy policyRngVar)

Diffusion.run dmqDiffusionArguments
(dmqDiffusionTracers dmqConfig tracer)
dmqDiffusionTracers
dmqDiffusionConfiguration
dmqDiffusionApplications
44 changes: 44 additions & 0 deletions dmq-node/config.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,46 @@
{ "NetworkMagic": 12
, "TraceOptions": {
"": {
"backends": [
"Stdout MachineFormat"
],
"severity": "Info"
}
, "Handshake": {
"severity": "Debug"
}
, "LocalMux": {
"severity": "Debug"
}
, "LocalHandshake": {
"severity": "Debug"
}
, "Diffusion": {
"severity": "Debug"
}
, "PeerSelection": {
"severity": "Debug"
}
, "PeerSelectionCounters": {
"severity": "Debug"
}
, "ConnectionManager": {
"severity": "Debug"
}
, "Server": {
"severity": "Debug"
}
, "InboundGovernor": {
"severity": "Debug"
}
, "LocalMsgSubmission.Protocol.Server": {
"severity": "Debug"
}
, "LocalMsgNotification.Protocol.Server": {
"severity": "Debug"
}
, "SigSubmission.Inbound": {
"severity": "Debug"
}
}
}
5 changes: 4 additions & 1 deletion dmq-node/dmq-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,19 @@ library
mtl,
network ^>=3.2.7,
network-mux ^>=0.9.1,
network-mux:cardano-logging,
optparse-applicative >=0.18 && <0.20,
ouroboros-consensus,
ouroboros-consensus-cardano,
ouroboros-consensus-diffusion,
ouroboros-network:{ouroboros-network, api, framework, orphan-instances, protocols} ^>=0.23,
ouroboros-network:cardano-logging,
ouroboros-network:framework-cardano-logging,
random ^>=1.2,
singletons,
text >=1.2.4 && <2.2,
time >=1.12 && <1.15,
trace-dispatcher ^>= 2.11.0,
transformers,
typed-protocols:{typed-protocols, cborg} ^>=1.1,

Expand All @@ -144,7 +148,6 @@ executable dmq-node
build-depends:
Win32-network,
acts,
aeson,
base,
bytestring,
cardano-git-rev,
Expand Down
Loading
Loading