Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
21952e9
quickcheck-monoids: compatibility with QuickCheck-2.16
coot Aug 27, 2025
3a843ef
Revert "Ensure that compared fragments always intersect"
crocodile-dentist Aug 25, 2025
ea7c94e
Revert "Support dynamic chain comparisons"
crocodile-dentist Aug 25, 2025
f877b45
Revert "`BlockFetchConsensusInterface`: simplify `headerForgeUTCTime`"
crocodile-dentist Aug 25, 2025
6c9d826
bootstrap consensus
crocodile-dentist Oct 14, 2025
ca21322
mempool: compute set of txids in the mempool incrementally
coot Aug 13, 2025
aaa80b4
tx-submission: adjusted renderRanges in tests
coot Sep 5, 2025
479b18f
dmq: Sig validation
coot Sep 5, 2025
a1b08e3
dmq: genesis file & KES EvolutionConfig
coot Sep 5, 2025
c1aa86d
ouroboros-network-api: RemoteAddress encoding
coot Oct 13, 2025
0a96cbc
dmq-node: disable StandardCrypto tests on Windows
coot Oct 15, 2025
c263cab
demo-ping-pong: added client-flood
coot Oct 15, 2025
edb1b95
added changelogs
coot Oct 16, 2025
2532ec3
diffusion: export withiomanager
crocodile-dentist Aug 25, 2025
01eb191
dmq: node kernel to hold pool ids
crocodile-dentist Aug 25, 2025
4d248ea
dmq: add cardano-node socket path to configuration & cli options
crocodile-dentist Sep 3, 2025
874cde5
dmq: local state query client for cardano-node interop
crocodile-dentist Aug 26, 2025
b100abf
sig validation
crocodile-dentist Sep 12, 2025
a6f50ef
mempool: adapt for generalized validation
crocodile-dentist Sep 11, 2025
dba12c1
localmsgsubmission: codec and server changes
crocodile-dentist Sep 14, 2025
92e3118
app: integration
crocodile-dentist Sep 11, 2025
a5dd816
make it build
crocodile-dentist Oct 15, 2025
b5b7815
wip
crocodile-dentist Oct 16, 2025
bd12083
move some things to a private library
crocodile-dentist Oct 23, 2025
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
35 changes: 30 additions & 5 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ index-state:
, hackage.haskell.org 2025-08-05T15:28:56Z

-- Bump this if you need newer packages from CHaP
, cardano-haskell-packages 2025-03-18T17:41:11Z
, cardano-haskell-packages 2025-09-10T02:05:10Z

packages: ./cardano-ping
./monoidal-synchronisation
Expand Down Expand Up @@ -55,10 +55,35 @@ package acts

allow-newer: quickcheck-instances:QuickCheck

constraints:
QuickCheck <2.16

-- temp
source-repository-package
type: git
location: https://github.com/input-output-hk/typed-protocols
tag: e29a21541c4af44a3d586ef0b2a61f8d87cc6bdd
--sha256:
subdir: typed-protocols

source-repository-package
type: git
location: https://github.com/IntersectMBO/ouroboros-consensus
tag: 30d4260783f1ae20d4e8a4163d68a8d54cf6f33a
--sha256:
subdir:
ouroboros-consensus-cardano
ouroboros-consensus-diffusion
sop-extras
ouroboros-consensus-protocol
ouroboros-consensus

-- kes-agent is not yet in CHaP, so we pull it from its GitHub repo
source-repository-package
type: git
location: https://github.com/input-output-hk/kes-agent
tag: 6d0f51fba415d3c641a8a8da37130e7adfc3ea01
--sha256: sha256-qM8RgmKOGBMlizPtXw2YOboYIzM6T3kvG9/Rp1F+bYQ=
subdir: kes-agent-crypto
location: https://github.com/crocodile-dentist/kes-agent
tag: c0ef04dde5582a28415ff7c8c1bb197adeec6fc8
--sha256:
subdir:
kes-agent
kes-agent-crypto
5 changes: 4 additions & 1 deletion cardano-diffusion/cardano-diffusion.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,14 @@ test-suite protocols-bench
ghc-options: -fproc-alignment=64

library cardano-diffusion-tests-lib
mixins:
QuickCheck hiding (Test.QuickCheck.Monoids)

import: ghc-options-tests
visibility: public
hs-source-dirs: tests/lib
build-depends:
QuickCheck >=2.16,
QuickCheck,
aeson,
base >=4.14 && <4.22,
bytestring,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Non-Breaking

- Addapted tests to changes in the `Ouroboros.Network.TxSubmission.Mempool.Simple` API

14 changes: 6 additions & 8 deletions cardano-diffusion/demo/chain-sync.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ import Ouroboros.Network.Protocol.BlockFetch.Type qualified as BlockFetch
import Ouroboros.Network.BlockFetch
import Ouroboros.Network.BlockFetch.Client
import Ouroboros.Network.BlockFetch.ClientRegistry (FetchClientRegistry (..))
import Ouroboros.Network.BlockFetch.ConsensusInterface (ChainSelStarvation (..),
initialWithFingerprint)
import Ouroboros.Network.BlockFetch.ConsensusInterface (ChainSelStarvation (..))
import Ouroboros.Network.DeltaQ (defaultGSV)

import Ouroboros.Network.Server.Simple qualified as Server.Simple
Expand Down Expand Up @@ -436,10 +435,8 @@ clientBlockFetch sockAddrs maxSlotNo = withIOManager $ \iocp -> do
pure $ \p b ->
addTestFetchedBlock blockHeap (castPoint p) (blockHeader b),

readChainComparison = pure $ initialWithFingerprint ChainComparison {
plausibleCandidateChain,
compareCandidateChains
},
plausibleCandidateChain,
compareCandidateChains,

blockFetchSize = \_ -> 1000,
blockMatchesHeader = \_ _ -> True,
Expand All @@ -453,8 +450,9 @@ clientBlockFetch sockAddrs maxSlotNo = withIOManager $ \iocp -> do
plausibleCandidateChain cur candidate =
AF.headBlockNo candidate > AF.headBlockNo cur

headerForgeUTCTime =
convertSlotToTimeForTestsAssumingNoHardFork . headerSlot
headerForgeUTCTime (FromConsensus hdr) =
pure $
convertSlotToTimeForTestsAssumingNoHardFork (headerSlot hdr)

compareCandidateChains c1 c2 =
AF.headBlockNo c1 `compare` AF.headBlockNo c2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
Expand Down Expand Up @@ -104,6 +105,9 @@ import Test.Ouroboros.Network.TxSubmission.Types (Tx (..), TxId)
import Test.Ouroboros.Network.Utils hiding (SmallDelay, debugTracer)

import Test.QuickCheck
#if !MIN_VERSION_QuickCheck(2,16,0)
import "quickcheck-monoids" Test.QuickCheck.Monoids
#endif
import Test.Tasty
import Test.Tasty.QuickCheck (testProperty)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ applications debugTracer txSubmissionInboundTracer txSubmissionInboundDebug node

txSubmissionInitiator
:: TxDecisionPolicy
-> Mempool m (Tx TxId)
-> Mempool m TxId (Tx TxId)
-> MiniProtocolCb (ExpandedInitiatorContext NtNAddr m) ByteString m ()
txSubmissionInitiator txDecisionPolicy mempool =
MiniProtocolCb $
Expand All @@ -709,7 +709,7 @@ applications debugTracer txSubmissionInboundTracer txSubmissionInboundDebug node
(txSubmissionClientPeer client)

txSubmissionResponder
:: Mempool m (Tx TxId)
:: Mempool m TxId (Tx TxId)
-> TxChannelsVar m NtNAddr Int (Tx Int)
-> TxMempoolSem m
-> SharedTxStateVar m NtNAddr Int (Tx Int)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import Cardano.Network.PeerSelection.Governor.Types qualified as Cardano.ExtraSi
import Cardano.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers
import Ouroboros.Network.BlockFetch (FetchMode (..), PraosFetchMode (..))
import Test.QuickCheck
import Test.QuickCheck.Monoids
import Test.Tasty
import Test.Tasty.QuickCheck
import Text.Pretty.Simple
Expand Down
141 changes: 90 additions & 51 deletions dmq-node/app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}

module Main where

import Control.Exception (throwIO)
import Control.Monad (void, when)
import Control.Tracer (Tracer (..), nullTracer, traceWith)

Expand All @@ -22,14 +25,17 @@ import System.Exit (exitSuccess)
import System.Random (newStdGen, split)

import Cardano.Git.Rev (gitRev)
import Cardano.KESAgent.KES.Evolution qualified as KES
import Cardano.KESAgent.Protocols.StandardCrypto (StandardCrypto)
import Cardano.Ledger.Keys (VKey (..))
import Cardano.Ledger.Hashes (hashKey)

import DMQ.Configuration
import DMQ.Configuration.CLIOptions (parseCLIOptions)
import DMQ.Configuration.Topology (readTopologyFileOrError)
import DMQ.Diffusion.Applications (diffusionApplications)
import DMQ.Diffusion.Arguments
import DMQ.Diffusion.NodeKernel (mempool, withNodeKernel)
import DMQ.Diffusion.NodeKernel
import DMQ.Handlers.TopLevel (toplevelExceptionHandler)
import DMQ.NodeToClient qualified as NtC
import DMQ.NodeToNode (NodeToNodeVersion, dmqCodecs, dmqLimitsAndTimeouts,
Expand All @@ -39,9 +45,13 @@ import DMQ.Protocol.SigSubmission.Type (Sig (..))
import DMQ.Tracer

import DMQ.Diffusion.PeerSelection (policy)
import DMQ.NodeToClient.LocalStateQueryClient
import DMQ.Protocol.SigSubmission.Validate
import Ouroboros.Network.Diffusion qualified as Diffusion
import Ouroboros.Network.PeerSelection.PeerSharing.Codec (decodeRemoteAddress,
encodeRemoteAddress)
import Ouroboros.Network.SizeInBytes
import Ouroboros.Network.Snocket
import Ouroboros.Network.TxSubmission.Mempool.Simple qualified as Mempool

import Paths_dmq_node qualified as Meta
Expand All @@ -68,8 +78,10 @@ runDMQ commandLineConfig = do
let dmqConfig@Configuration {
dmqcPrettyLog = I prettyLog,
dmqcTopologyFile = I topologyFile,
dmqcShelleyGenesisFile = I genesisFile,
dmqcHandshakeTracer = I handshakeTracer,
dmqcLocalHandshakeTracer = I localHandshakeTracer,
dmqcCardanoNodeSocket = I snocketPath,
dmqcVersion = I version
} = config' <> commandLineConfig
`act`
Expand All @@ -95,55 +107,82 @@ runDMQ commandLineConfig = do
]
exitSuccess

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

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

stdGen <- newStdGen
let (psRng, policyRng) = split stdGen

withNodeKernel @StandardCrypto tracer dmqConfig psRng $ \nodeKernel -> do
dmqDiffusionConfiguration <- mkDiffusionConfiguration dmqConfig nt

let dmqNtNApps =
ntnApps tracer
dmqConfig
nodeKernel
(dmqCodecs
-- TODO: `maxBound :: Cardano.Network.NodeToNode.NodeToNodeVersion`
-- is unsafe here!
(encodeRemoteAddress (maxBound :: NodeToNodeVersion))
(decodeRemoteAddress (maxBound :: NodeToNodeVersion)))
dmqLimitsAndTimeouts
defaultSigDecisionPolicy
dmqNtCApps =
let sigSize _ = 0 -- TODO
maxMsgs = 1000 -- TODO: make this dynamic?
mempoolReader = Mempool.getReader sigId sigSize (mempool nodeKernel)
mempoolWriter = Mempool.getWriter sigId (pure ())
(\_ _ -> Right () :: Either Void ())
(\_ -> True)
(mempool nodeKernel)
in NtC.ntcApps tracer dmqConfig
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)
dmqDiffusionApplications =
diffusionApplications nodeKernel
dmqConfig
dmqDiffusionConfiguration
dmqLimitsAndTimeouts
dmqNtNApps
dmqNtCApps
(policy policyRng)

Diffusion.run dmqDiffusionArguments
(dmqDiffusionTracers dmqConfig tracer)
dmqDiffusionConfiguration
dmqDiffusionApplications
Diffusion.withIOManager \iocp -> do
let localSnocket' = localSnocket iocp
mkStakePoolMonitor = connectToCardanoNode tracer localSnocket' snocketPath

withNodeKernel @StandardCrypto
tracer
dmqConfig
evolutionConfig
psRng
mkStakePoolMonitor $ \nodeKernel -> do
dmqDiffusionConfiguration <- mkDiffusionConfiguration dmqConfig nt

let sigSize :: Sig StandardCrypto -> SizeInBytes
sigSize _ = 0 -- TODO
mempoolReader = Mempool.getReader sigId sigSize (mempool nodeKernel)
dmqNtNApps =
let ntnMempoolWriter = Mempool.writerAdapter $
Mempool.getWriter sigId
(poolValidationCtx $ stakePools nodeKernel)
(validateSig FailDefault (hashKey . VKey))
SigDuplicate
(mempool nodeKernel)
in ntnApps tracer
dmqConfig
mempoolReader
ntnMempoolWriter
sigSize
nodeKernel
(dmqCodecs
-- TODO: `maxBound :: Cardano.Network.NodeToNode.NodeToNodeVersion`
-- is unsafe here!
(encodeRemoteAddress (maxBound @NodeToNodeVersion))
(decodeRemoteAddress (maxBound @NodeToNodeVersion)))
dmqLimitsAndTimeouts
defaultSigDecisionPolicy
dmqNtCApps =
let maxMsgs = 1000 -- TODO: make this negotiated in the handshake?
ntcMempoolWriter =
Mempool.getWriter sigId
(poolValidationCtx $ stakePools nodeKernel)
(validateSig FailSoft (hashKey . VKey))
SigDuplicate
(mempool nodeKernel)
in NtC.ntcApps tracer dmqConfig
mempoolReader ntcMempoolWriter maxMsgs
(NtC.dmqCodecs encodeReject decodeReject)
dmqDiffusionArguments =
diffusionArguments (if handshakeTracer
then WithEventType "Handshake" >$< tracer
else nullTracer)
(if localHandshakeTracer
then WithEventType "Handshake" >$< tracer
else nullTracer)
dmqDiffusionApplications =
diffusionApplications nodeKernel
dmqConfig
dmqDiffusionConfiguration
dmqLimitsAndTimeouts
dmqNtNApps
dmqNtCApps
(policy policyRng)

Diffusion.run dmqDiffusionArguments
(dmqDiffusionTracers dmqConfig tracer)
dmqDiffusionConfiguration
dmqDiffusionApplications
2 changes: 1 addition & 1 deletion dmq-node/cddl/specs/sig.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ messagePayload = [

messageId = bstr
messageBody = bstr
kesSignature = bstr
kesSignature = bstr .size 448
kesPeriod = word64
operationalCertificate = [ bstr .size 32, word64, word64, bstr .size 64 ]
coldVerificationKey = bstr .size 32
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
For top level release notes, leave all the headers commented out.
-->

### Breaking

- Using `KESPeriod` from `Cardano.Crypto.KES` instead of `SigKESPeriod`
newtype. `KESPeriod` is used by `SigRaw` data type.
- `SigKESSignature` holds `SigKES (KES crypto)` instead of a `ByteString`.
- `SigColdKey` holds `VerKeyDSIGN` instead of a `ByteString`.
- `ntnApps` constraints changed in order to use `sigValidate` function.

### Non-Breaking

- `Sig` codec decodes KES signatures, and the cold key.
- Added `DMQ.SigSubmission.Type.validateSig` and `SigValidationError`.

Loading
Loading