Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0f12697
api: add Point to LedgerPeerSnapshot
crocodile-dentist Sep 17, 2025
db879c8
o-n: remove dependence on cardano-slotting
crocodile-dentist Oct 28, 2025
fb4a961
o-n tests: remove dependence on cardano-slotting
crocodile-dentist Oct 28, 2025
a501ced
peer-selection: verify peer snapshot with hash
crocodile-dentist Sep 17, 2025
98992a3
Bump to NodeToClientV_23
crocodile-dentist Sep 18, 2025
b10bcab
dmq: integrate LedgerPeerSnapshot changes
crocodile-dentist Oct 30, 2025
5275f26
scriv
crocodile-dentist Oct 28, 2025
9f5e7f5
nix: fix static build
crocodile-dentist Nov 4, 2025
69b14c7
quickcheck-monoids: compatibility with QuickCheck-2.16
coot Aug 27, 2025
7abeb5a
Revert "Ensure that compared fragments always intersect"
crocodile-dentist Aug 25, 2025
0d76f9c
Revert "Support dynamic chain comparisons"
crocodile-dentist Aug 25, 2025
8e05c22
Revert "`BlockFetchConsensusInterface`: simplify `headerForgeUTCTime`"
crocodile-dentist Aug 25, 2025
268aa96
bootstrap consensus
crocodile-dentist Oct 30, 2025
ff55b63
diffusion: export withiomanager
crocodile-dentist Aug 25, 2025
0b9eee5
dmq: node kernel to hold pool ids
crocodile-dentist Aug 25, 2025
d812243
dmq: add cardano-node socket path to configuration & cli options
crocodile-dentist Sep 3, 2025
73ae20a
dmq: local state query client for cardano-node interop
crocodile-dentist Aug 26, 2025
0de3477
sig validation
crocodile-dentist Sep 12, 2025
0242634
mempool: adapt for generalized validation
crocodile-dentist Sep 11, 2025
026e486
localmsgsubmission: codec and server changes
crocodile-dentist Sep 14, 2025
3d4650f
app: integration
crocodile-dentist Sep 11, 2025
65cd903
make it build
crocodile-dentist Oct 15, 2025
04a982a
move some things to a private library
crocodile-dentist Oct 23, 2025
e7b69fb
Expose big ledger peers to dmq node and add ocert counter
crocodile-dentist Oct 27, 2025
0c49fd2
Validate ocert counter, change encoding of validation failures
crocodile-dentist Oct 16, 2025
289411c
tx-sub tests: integrate getMempoolWriter
crocodile-dentist Oct 27, 2025
7969b50
mempool: rename `MempoolAddFail` to `TxValidationFail`
crocodile-dentist Nov 4, 2025
345ad32
cleanup
crocodile-dentist Nov 4, 2025
86412d4
sig-submission test: integrate validateSig
crocodile-dentist Nov 5, 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: sha256-Kww2GEqi+GbjmKVIhMADazpUddOBuXqQCiR58WkMj10=
subdir: typed-protocols

-- 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: sha256-slF7zuBy2DKWKlQfhBPW5FDRhueWrFcJkrHW4jEEELs=
subdir:
kes-agent
kes-agent-crypto

source-repository-package
type: git
location: https://github.com/IntersectMBO/ouroboros-consensus
tag: 97137fb0484454f0cd208c55bfee278f7561e9ed
--sha256: sha256-T56Axhx/dk7D9s+LOi+NhY+Tb5n7H99OfUjUE5hPxtQ=
subdir:
ouroboros-consensus-cardano
ouroboros-consensus-diffusion
sop-extras
ouroboros-consensus-protocol
ouroboros-consensus
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ data NodeToClientVersion
-- ^ new codecs for @PParams@ and @CompactGenesis@
| NodeToClientV_22
-- ^ support SRV records in @GetBigLedgerPeerSnapshot@ query
-- TODO: remove CBOR instances from LedgerPeers.Type when V22 support
-- is removed, update {To,From}JSON LedgerPeerSnapshot instances
-- and update LedgerPeerSnapshot query encoding in consensus.
-- marked with TODO's.
| NodeToClientV_23
-- ^ added @QueryDRepsDelegations@,
-- LedgerPeerSnapshot CBOR encoding contains block hash and NetworkMagic
deriving (Eq, Ord, Enum, Bounded, Show, Generic, NFData)

-- | We set 16ths bit to distinguish `NodeToNodeVersion` and
Expand Down
7 changes: 6 additions & 1 deletion cardano-diffusion/cardano-diffusion.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ library
aeson,
base >=4.14 && <4.22,
bytestring,
cardano-crypto-class,
cardano-diffusion:{api, protocols},
containers,
contra-tracer,
Expand Down Expand Up @@ -430,10 +431,13 @@ test-suite protocols-bench

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

visibility: public
hs-source-dirs: tests/lib
build-depends:
QuickCheck >=2.16,
QuickCheck,
aeson,
base >=4.14 && <4.22,
bytestring,
Expand All @@ -453,6 +457,7 @@ library cardano-diffusion-tests-lib
pipes,
pretty-simple,
psqueues,
quickcheck-monoids,
random,
serialise,
tasty,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!--
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

cardano-diffusion:
- added `lpGetBlockInfo` to `LedgerPeersConsensusInterface`

### Non-Breaking

cardano-diffusion:
- moved `jobVerifyPeerSnapshot` from o-n
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
@@ -1,3 +1,5 @@
{-# LANGUAGE RankNTypes #-}

module Cardano.Network.LedgerPeerConsensusInterface
( LedgerPeersConsensusInterface (..)
-- * Re-exports
Expand All @@ -8,11 +10,14 @@ module Cardano.Network.LedgerPeerConsensusInterface

import Control.Concurrent.Class.MonadSTM (MonadSTM (..))

import Ouroboros.Network.BlockFetch.ConsensusInterface (FetchMode (..))

import Cardano.Crypto.Hash (Blake2b_256, Hash)
import Cardano.Network.LedgerStateJudgement
import Cardano.Network.PeerSelection.LocalRootPeers
(OutboundConnectionsState (..))
import Ouroboros.Network.Block (SlotNo)
import Ouroboros.Network.BlockFetch.ConsensusInterface (FetchMode (..))
import Ouroboros.Network.Point (Block)


-- | Cardano Node specific consensus interface actions.
--
Expand All @@ -31,4 +36,6 @@ data LedgerPeersConsensusInterface m =
-- it only has local peers.
--
, updateOutboundConnectionsState :: OutboundConnectionsState -> STM m ()

, getBlockHash :: forall a. SlotNo -> STM m (Block SlotNo (Hash Blake2b_256 a))
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}

-- | This module contains governor decisions for monitoring tasks:
--
Expand All @@ -18,14 +22,18 @@ module Cardano.Network.PeerSelection.Governor.Monitor
, ExtraTrace (..)
) where

import Data.Set qualified as Set

import Control.Concurrent.JobPool (Job (..))
import Control.Exception (assert)
import Control.Monad.Class.MonadSTM
import Control.Monad.Class.MonadTime.SI
import Control.Monad.Class.MonadTimer.SI
import Data.Map.Strict (Map)
import Data.Map.Strict qualified as Map
import Data.Set (Set)
import Data.Set qualified as Set

import Cardano.Crypto.Hash as Crypto (castHash)
import Cardano.Network.ConsensusMode
import Cardano.Network.Diffusion.Configuration qualified as Cardano (srvPrefix)
import Cardano.Network.LedgerPeerConsensusInterface qualified as Cardano
import Cardano.Network.LedgerStateJudgement
import Cardano.Network.PeerSelection.Bootstrap (UseBootstrapPeers (..),
Expand All @@ -37,23 +45,22 @@ import Cardano.Network.PeerSelection.Governor.PeerSelectionState qualified as Ca
import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable (..))
import Cardano.Network.PeerSelection.PublicRootPeers qualified as Cardano.PublicRootPeers
import Cardano.Network.PeerSelection.State.LocalRootPeers qualified as LocalRootPeers
import Control.Exception (assert)
import Data.Map.Strict (Map)
import Data.Map.Strict qualified as Map
import Data.Set (Set)
import Ouroboros.Network.Block (HeaderHash, SlotNo, atSlot, pattern BlockPoint,
withHash)
import Ouroboros.Network.PeerSelection.Governor.ActivePeers
(jobDemoteActivePeer)
import Ouroboros.Network.PeerSelection.Governor.Monitor (jobVerifyPeerSnapshot)
import Ouroboros.Network.PeerSelection.Governor.Types hiding
(PeerSelectionCounters)
import Ouroboros.Network.PeerSelection.LedgerPeers.Type
(LedgerPeersConsensusInterface (..))
(LedgerPeerSnapshot (..), LedgerPeersConsensusInterface (..),
LedgerPeersKind (..))
import Ouroboros.Network.PeerSelection.PublicRootPeers qualified as PublicRootPeers
import Ouroboros.Network.PeerSelection.State.EstablishedPeers qualified as EstablishedPeers
import Ouroboros.Network.PeerSelection.State.KnownPeers qualified as KnownPeers
import Ouroboros.Network.PeerSelection.State.LocalRootPeers
(LocalRootConfig (..))
import Ouroboros.Network.PeerSelection.Types
import Ouroboros.Network.Point (Block (..))


-- | Used to set 'bootstrapPeersTimeout' for crashing the node in a critical
Expand Down Expand Up @@ -495,8 +502,8 @@ monitorLedgerStateJudgement
(TimedDecision m Cardano.ExtraState extraDebugState extraFlags
(Cardano.ExtraPeers peeraddr) ExtraTrace peeraddr peerconn)
monitorLedgerStateJudgement PeerSelectionActions{
getLedgerStateCtx = ledgerCtx@LedgerPeersConsensusInterface {
lpExtraAPI = Cardano.LedgerPeersConsensusInterface {
getLedgerStateCtx = LedgerPeersConsensusInterface {
lpExtraAPI = lpExtraAPI@Cardano.LedgerPeersConsensusInterface {
Cardano.getLedgerStateJudgement = readLedgerStateJudgement
}
}
Expand All @@ -523,8 +530,9 @@ monitorLedgerStateJudgement PeerSelectionActions{
Decision {
decisionTrace = [ExtraTrace (TraceLedgerStateJudgementChanged lsj)],
decisionJobs = case (lsj, ledgerPeerSnapshot) of
(TooOld, Just ledgerPeerSnapshot') ->
[jobVerifyPeerSnapshot Cardano.srvPrefix ledgerPeerSnapshot' ledgerCtx]
(TooOld, Just (LedgerBigPeerSnapshotV23 point _magic _pools))
| BlockPoint { atSlot, withHash } <- point ->
[jobVerifyPeerSnapshot (atSlot, withHash) lpExtraAPI]
_otherwise -> [],
decisionState = st {
extraState = cpst {
Expand Down Expand Up @@ -675,6 +683,35 @@ waitForSystemToQuiesce st@PeerSelectionState{
| otherwise = GuardedSkip Nothing


-- |This job, which is initiated by monitorLedgerStateJudgement job,
-- verifies whether the provided big ledger pools match up with the
-- ledger state once the node catches up to the slot at which the
-- snapshot was ostensibly taken
--
jobVerifyPeerSnapshot :: (MonadSTM m)
=> (SlotNo, HeaderHash (LedgerPeerSnapshot BigLedgerPeers))
-> Cardano.LedgerPeersConsensusInterface m
-> Job () m (Completion m extraState extraDebugState extraFlags extraPeers extraTrace peeraddr peerconn)
jobVerifyPeerSnapshot (slotNo, theHash)
Cardano.LedgerPeersConsensusInterface { getBlockHash }
= Job job (const (completion False)) () "jobVerifyPeerSnapshot"
where
completion result = return . Completion $ \st _now ->
Decision {
decisionTrace = [TraceVerifyPeerSnapshot result],
decisionState = st,
decisionJobs = [] }

job = do
Block { blockPointHash } <- atomically $ getBlockHash slotNo
let result = theHash == Crypto.castHash blockPointHash
return . Completion $ \st _now ->
Decision {
decisionTrace = [TraceVerifyPeerSnapshot result],
decisionState = st,
decisionJobs = [] }


-- | Extra trace points for `TracePeerSelection`.
--
-- TODO: it ought to be moved to `Types`, but that introduces a circular
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ versionTable = { * versionNumber => nodeToClientVersionData }


; as of version 2 (which is no longer supported) we set 16th bit to 1
; 16 / 17 / 18 / 19 / 20 / 21 / 22 / 23
; 16 / 17 / 18 / 19 / 20 / 21 / 22 / 23
versionNumber = 32784 / 32785 / 32786 / 32787 / 32788 / 32789 / 32790 / 32791

; As of version 15 and higher
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 @@ -106,6 +107,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 @@ -1245,6 +1245,7 @@ diffusionSimulationM
Cardano.LedgerPeersConsensusInterface {
Cardano.readFetchMode = pure (PraosFetchMode FetchModeDeadline)
, Cardano.getLedgerStateJudgement = pure TooOld
, Cardano.getBlockHash = const retry
, Cardano.updateOutboundConnectionsState =
\a -> do
a' <- readTVar onlyOutboundConnectionsStateVar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import Ouroboros.Network.PeerSelection.State.KnownPeers qualified as KnownPeers
import Ouroboros.Network.PeerSelection.State.LocalRootPeers
(LocalRootPeers (..))
import Ouroboros.Network.Point
import Ouroboros.Network.Socket ()

import Test.Cardano.Network.PeerSelection.MockEnvironment hiding (tests)
import Test.Cardano.Network.PeerSelection.Utils
Expand All @@ -93,6 +94,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 Expand Up @@ -4382,6 +4384,7 @@ _governorFindingPublicRoots targetNumberOfRootPeers readDomains readUseBootstrap
lpExtraAPI = Cardano.LedgerPeersConsensusInterface {
readFetchMode = pure (PraosFetchMode FetchModeDeadline),
getLedgerStateJudgement = readLedgerStateJudgement,
getBlockHash = const retry,
updateOutboundConnectionsState = \a -> do
a' <- readTVar olocVar
when (a /= a') $
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ mockPeerSelectionActions' tracer
lpExtraAPI = Cardano.LedgerPeersConsensusInterface {
readFetchMode = pure (PraosFetchMode FetchModeDeadline),
getLedgerStateJudgement = readLedgerStateJudgement,
getBlockHash = const retry,
updateOutboundConnectionsState = \a -> do
a' <- readTVar outboundConnectionsStateVar
when (a /= a') $
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!--
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

- Added `NodeToClientVersionV23`
Loading
Loading