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
8 changes: 8 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ index-state:
-- Bump this if you need newer packages from CHaP
, cardano-haskell-packages 2025-03-18T17:41:11Z

-- `trace-dispatcher` from repo "cardano-node" branch "fmaste/dmq-node".
source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-node.git
subdir: trace-dispatcher
tag: c33672805ce56fdbbb29fcab5e64d30c88277857
--sha256: 04gsn3r1znqydmjlbipwlrvwk2yq91hg6rv92b3dzphiqrrlfgsr

packages: ./cardano-ping
./monoidal-synchronisation
./network-mux
Expand Down
34 changes: 15 additions & 19 deletions dmq-node/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE PackageImports #-}

module Main where

import Control.Exception (throwIO)
import Control.Monad (void, when)
import Control.Tracer (Tracer (..), nullTracer, traceWith)
import "contra-tracer" Control.Tracer (traceWith)

import Data.Act
import Data.Aeson (ToJSON)
import Data.Functor.Contravariant ((>$<))
import Data.Maybe (maybeToList)
import Data.Text qualified as Text
Expand All @@ -38,8 +38,10 @@ import DMQ.NodeToNode (NodeToNodeVersion, dmqCodecs, dmqLimitsAndTimeouts,
ntnApps)
import DMQ.Protocol.LocalMsgSubmission.Codec
import DMQ.Protocol.SigSubmission.Type (Sig (..))
import DMQ.Tracer

import DMQ.Tracer (
mkCardanoTracer
, WithEventType (WithEventType), EventType (DMQ)
)
import DMQ.Diffusion.PeerSelection (policy)
import Ouroboros.Network.Diffusion qualified as Diffusion
import Ouroboros.Network.PeerSelection.PeerSharing.Codec (decodeRemoteAddress,
Expand Down Expand Up @@ -68,17 +70,14 @@ runDMQ commandLineConfig = do
-- combine default configuration, configuration file and command line
-- options
let dmqConfig@Configuration {
dmqcPrettyLog = I prettyLog,
dmqcTopologyFile = I topologyFile,
dmqcShelleyGenesisFile = I genesisFile,
dmqcHandshakeTracer = I handshakeTracer,
dmqcLocalHandshakeTracer = I localHandshakeTracer,
dmqcVersion = I version
} = config' <> commandLineConfig
`act`
defaultConfiguration
let tracer :: ToJSON ev => Tracer IO (WithEventType ev)
tracer = dmqTracer prettyLog

(tracer, dmqDiffusionTracers) <- mkCardanoTracer configFilePath

when version $ do
let gitrev = $(gitRev)
Expand All @@ -100,13 +99,14 @@ runDMQ commandLineConfig = do

res <- KES.evolutionConfigFromGenesisFile genesisFile
evolutionConfig <- case res of
Left err -> traceWith tracer (WithEventType "ShelleyGenesisFile" err)
Left err -> traceWith tracer (WithEventType (DMQ "ShelleyGenesisFile") err)
>> throwIO (userError $ err)
Right ev -> return ev

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 Down Expand Up @@ -139,12 +139,8 @@ runDMQ commandLineConfig = do
mempoolReader mempoolWriter maxMsgs
(NtC.dmqCodecs encodeReject decodeReject)
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)
dmqDiffusionApplications =
diffusionApplications nodeKernel
dmqConfig
Expand All @@ -155,6 +151,6 @@ runDMQ commandLineConfig = do
(policy policyRng)

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"
}
}
}
9 changes: 7 additions & 2 deletions dmq-node/dmq-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ library
base16-bytestring,
bytestring >=0.10 && <0.13,
cardano-binary,
-- TODO
--cardano-diffusion:logging,
cardano-crypto-class,
cborg >=0.2.1 && <0.3,
containers >=0.5 && <0.8,
Expand All @@ -107,12 +109,16 @@ library
kes-agent-crypto ^>=0.1,
network ^>=3.2.7,
network-mux ^>=0.9.1,
network-mux:cardano-logging,
optparse-applicative ^>=0.18,
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,
trace-dispatcher ^>= 2.10.0,
typed-protocols:{typed-protocols, cborg} ^>=1.1,

hs-source-dirs: src
Expand All @@ -132,7 +138,6 @@ executable dmq-node

build-depends:
acts,
aeson,
base,
cardano-git-rev,
contra-tracer >=0.1 && <0.3,
Expand All @@ -141,7 +146,7 @@ executable dmq-node
optparse-applicative,
ouroboros-network:{ouroboros-network, api},
random,
text,
text

hs-source-dirs: app
default-language: Haskell2010
Expand Down
Loading
Loading