ouroboros-network
Ouroboros-Network Repository Hackage Documentation
This site contains Haskell documentation of
- Ouroboros-Network - networking component of the Haskell implementation of Ouroboros protocols
- Ouroboros-Consensus - Ouroboros Consensus family of protocols which integrate with `Ouroboros-Network`
Network
- ouroboros-network-framework - our instantiations and implementation of servers, clients, abstractions for working with named pipes and unix sockets. These are higher level components, which don't dependent on ouroboros protocols, but build a solid foundation for the networking library
ouroboros-network - networking library which supports /Ouroboros family of protocols/. It includes:
Implementations, type level specifications, and APIs of all the protocols:
/Block chain related data structures that the networking code needs to be aware of:/
Network applications:
- Block Fetch Application
Tx Submission Applications:
- Peer Selection
- Data Diffusion which combines all the pieces for supporting a node
- NodeToNode API
- NodeToClient API
Ouroboros Consensus
This graph depicts the relationship between the various `xxx-consensus-yyy` packages:
ouroboros-consensus : Main package for Cardano consensus implementation, aka. Ouroboros.
- The Ouroboros Consensus Modules Map represents the dependencies between various Consensus modules and is a map to navigate the (large) codebase. Clicking on a module should bring you to the corresponding haddock page from which you can later navigate to the source code. Note: The image needs to be enlarged to be useful hence why it's an external link.
ouroboros-consensus-test : Property and model-based tests for consensus, using io-sim
- ThreadNet Simulator: Simulates a network of nodes
- ouroboros-consensus-byron : Byron-era consensus logic
ouroboros-consensus-byron-test : Byron specific tests
ouroboros-consensus-shelley-test : Shelley specific tests
ouroboros-consensus-mock : Integration of consensus with a mock ledger, for testing and experimentation purpose
ouroboros-consensus-mock-test : Tests for consensus with mock ledger
- Generators provides various orphan
Arbitrary
instances
- Generators provides various orphan
- db-analyser: A command-line tool for offline analysis of the consensus database
Consensus implementation
The comments in modules listed below provide important information on the implementation of consensus.
- Ouroboros.Consensus.Util.ResourceRegistry
- Ouroboros.Consensus.HeaderValidation
- Ouroboros.Consensus.Mempool.API
- Ouroboros.Consensus.Forecast
- Ouroboros.Consensus.HardFork.History.EraParams
- Ouroboros.Consensus.HardFork.History.Qry
- Ouroboros.Consensus.HardFork.History.Summary
- Ouroboros.Consensus.Protocol.Abstract
- Ouroboros.Consensus.Storage.ChainDB.API
- Ouroboros.Consensus.Storage.ChainDB.Impl.ChainSel
- Ouroboros.Consensus.Storage.ChainDB.Impl.Iterator
- Ouroboros.Network.AnchoredFragment
- Ouroboros.Consensus.MiniProtocol.ChainSync.Client
- Ouroboros.Network.BlockFetch.Decision
Consensus Components
The following C4 Component Diagram provides a high-level overview of the main components involved in Consensus. Note that clicking on a box should link to the corresponding documentation:
Testing in the consensus layer
The vast majority of the tests in the consensus layer are QuickCheck property tests, and many of these are model based. There are only a handful of unit tests. The consensus layer is an intricate piece of software with lots of components, which we set at virtually every level of granularity. Below we give an overview of the tests that we do per component. For the detailed listing, please refer to the various test suites within the repository.
- test-infra/Main.hs provides tests for the infrastructure used for running consensus-related tests.
test-storage/Main.hs provides tests for the storage layer used by Consensus.
- The file system abstraction tests can be found in Test.Ouroboros.Storage.FS.StateMachine.
The immutable DB tests can be found in Test.Ouroboros.Storage.ImmutableDB.
- The primary index test can be found in Test.Ouroboros.Storage.ImmutableDB.Primary.
- The model-based tests for the immutable DB can be found in Test.Ouroboros.Storage.ImmutableDB.StateMachine.
- The tests for the volatile DB can be found in Test.Ouroboros.Storage.VolatileDB.StateMachine.
The ledger DB tests can be found in Test.Ouroboros.Storage.LedgerDB:
- The in-memory ledger DB tests can be found in Test.Ouroboros.Storage.LedgerDB.InMemory.
- The on-disk ledger DB tests can be found in Test.Ouroboros.Storage.LedgerDB.OnDisk.
The tests for the chain DB can be found in Test.Ouroboros.Storage.ChainDB. The tests include:
- The tests for the garbage collection schedule can be found in Test.Ouroboros.Storage.ChainDB.GcSchedule.
- The tests for the chain DB iterator can be found in Test.Ouroboros.Storage.ChainDB.Iterator.
- The tests of properties of the chain DB model can be found in Test.Ouroboros.Storage.ChainDB.Model.Test.
- The main tests for the chain DB can be found in Test.Ouroboros.Storage.ChainDB.StateMachine.
Golden tests: our golden tests infrastructure lives in Test.Util.Serialisation.Golden. Golden tests are specific to each era:
Miscellanous tests (
test-consensus
test suite)- The tests for the resource registry can be found in Test.Consensus.ResourceRegistry.
- The tests for the RAW lock mechanism we use can be found in Test.Consensus.Util.MonadSTM.RAWLock.
- The tests for the computation of blockchain time can be found in Test.Consensus.BlockchainTime.Simple.
- The tests for the mempool can be found in Test.Consensus.Mempool.
- The tests for the chain sync client can be found in Test.Consensus.MiniProtocol.ChainSync.Client.
- The tests for the local state query server can be found in Test.Consensus.MiniProtocol.LocalStateQuery.Server.
- The tests for versioned serialisation can be found in Test.Consensus.Util.Versioned.
- The tests for the DB marker and DB lock can be found in Test.Consensus.Node.
The hard fork combinator, time infrastructure: One of the responsibilities of the HFC is to offer time conversions (slot to epoch, wall clock to slot, etc.) across era transitions (which might change parameters such as the slot length and the epoch size). It does this by constructing a "summary" of the current state of the chain, basically recording what the various slot lengths and epoch sizes have been so far, and how far ahead we can look (the so-called "safe zone": if the transition to the next era is not yet known, there must exist a limited period after the ledger tip in which we can still time conversions).
- The tests for the hard fork summary can be found in Test.Consensus.HardFork.Summary.
- The tests for the hard fork history can be found in Test.Consensus.HardFork.History.
Consensus tests
The main consensus tests are the consensus layer's sophisticated tests. They are "system level" tests, in which we set up a mock network of nodes, where we can simulate things like nodes joining late, network message delay, etc. We then have these nodes run the full protocol, exchanging blocks, doing chain selection, etc. Finally we verify that the nodes can reach consensus. We have some generic infrastructure for doing all of this, and then have specific tests for each of the protocols/ledgers we support.
In a way, these are the most important tests we have, as they are testing properties of the system as a whole. Of course, that also means that if something goes wrong, debugging these tests can be difficult, and it would be better to have such problems caught by the other, more fine-grained, tests.
We run these tests for
- A mock ledger (containing bare bones UTxO style transactions) using a variety of consensus protocols: BFT, PBFT, Praos, and a version of Praos where we override the leader schedule. See this directory.
- Byron/PBFT. See Test.ThreadNet.Byron.
- DualByron. See Test.ThreadNet.DualByron.
- Shelley/TPraos. See Test.ThreadNet.Shelley.
- The hard fork combinator transitioning from a mock ledger
A
to a mock ledgerB
; these mock ledgers are absolutely minimal ledgers: the only transaction supported on theA
ledger is "initiate transition toB
", and theB
ledger can only contain blocks with a header only, no body at all. HardForkBlock '[Byron, Shelley]
: the hard fork combinator instantiated with the Byron and Shelley ledgers, runningPBFT
before the transition andTPraos
after.
Modules
- Cardano
- Api
- Client
- Network
- Node
- Tools
- DBAnalyser
- DBSynthesizer
- DBAnalyser
- Control
- Concurrent
- Data
- Network
- Ouroboros
- Consensus
- Ouroboros.Consensus.Block
- Ouroboros.Consensus.BlockchainTime
- Byron
- Crypto
- Ouroboros.Consensus.Byron.EBBs
- Ouroboros.Consensus.Byron.Ledger
- Ouroboros.Consensus.Byron.Ledger.Block
- Ouroboros.Consensus.Byron.Ledger.Config
- Ouroboros.Consensus.Byron.Ledger.Conversions
- Ouroboros.Consensus.Byron.Ledger.Forge
- Ouroboros.Consensus.Byron.Ledger.HeaderValidation
- Ouroboros.Consensus.Byron.Ledger.Inspect
- Ouroboros.Consensus.Byron.Ledger.Integrity
- Ouroboros.Consensus.Byron.Ledger.Ledger
- Ouroboros.Consensus.Byron.Ledger.Mempool
- Ouroboros.Consensus.Byron.Ledger.NetworkProtocolVersion
- Ouroboros.Consensus.Byron.Ledger.Orphans
- Ouroboros.Consensus.Byron.Ledger.PBFT
- Ouroboros.Consensus.Byron.Ledger.Serialisation
- Ouroboros.Consensus.Byron.Node
- Ouroboros.Consensus.Byron.Protocol
- ByronDual
- ByronSpec
- Ouroboros.Consensus.ByronSpec.Ledger
- Ouroboros.Consensus.ByronSpec.Ledger.Accessors
- Ouroboros.Consensus.ByronSpec.Ledger.Block
- Ouroboros.Consensus.ByronSpec.Ledger.Conversions
- Ouroboros.Consensus.ByronSpec.Ledger.Forge
- Ouroboros.Consensus.ByronSpec.Ledger.GenTx
- Ouroboros.Consensus.ByronSpec.Ledger.Genesis
- Ouroboros.Consensus.ByronSpec.Ledger.Ledger
- Ouroboros.Consensus.ByronSpec.Ledger.Mempool
- Ouroboros.Consensus.ByronSpec.Ledger.Orphans
- Ouroboros.Consensus.ByronSpec.Ledger.Rules
- Ouroboros.Consensus.ByronSpec.Ledger
- Ouroboros.Consensus.Cardano
- Ouroboros.Consensus.Config
- Ouroboros.Consensus.Forecast
- Fragment
- HardFork
- Ouroboros.Consensus.HardFork.Abstract
- Ouroboros.Consensus.HardFork.Combinator
- Ouroboros.Consensus.HardFork.Combinator.Abstract
- Ouroboros.Consensus.HardFork.Combinator.AcrossEras
- Ouroboros.Consensus.HardFork.Combinator.Basics
- Ouroboros.Consensus.HardFork.Combinator.Block
- Ouroboros.Consensus.HardFork.Combinator.Compat
- Ouroboros.Consensus.HardFork.Combinator.Condense
- Ouroboros.Consensus.HardFork.Combinator.Degenerate
- Embed
- Ouroboros.Consensus.HardFork.Combinator.Forging
- Ouroboros.Consensus.HardFork.Combinator.Info
- Ouroboros.Consensus.HardFork.Combinator.InjectTxs
- Ouroboros.Consensus.HardFork.Combinator.Ledger
- Ouroboros.Consensus.HardFork.Combinator.Mempool
- Ouroboros.Consensus.HardFork.Combinator.Node
- Ouroboros.Consensus.HardFork.Combinator.PartialConfig
- Ouroboros.Consensus.HardFork.Combinator.Protocol
- Ouroboros.Consensus.HardFork.Combinator.Serialisation
- Ouroboros.Consensus.HardFork.Combinator.State
- Ouroboros.Consensus.HardFork.Combinator.Translation
- Util
- Ouroboros.Consensus.HardFork.Combinator.Util.DerivingVia
- Ouroboros.Consensus.HardFork.Combinator.Util.Functors
- Ouroboros.Consensus.HardFork.Combinator.Util.InPairs
- Ouroboros.Consensus.HardFork.Combinator.Util.Match
- Ouroboros.Consensus.HardFork.Combinator.Util.Tails
- Ouroboros.Consensus.HardFork.Combinator.Util.Telescope
- Ouroboros.Consensus.HardFork.History
- Ouroboros.Consensus.HardFork.Simple
- Ouroboros.Consensus.HeaderStateHistory
- Ouroboros.Consensus.HeaderValidation
- Ledger
- Ouroboros.Consensus.Ledger.Abstract
- Ouroboros.Consensus.Ledger.Basics
- Ouroboros.Consensus.Ledger.CommonProtocolParams
- Ouroboros.Consensus.Ledger.Dual
- Ouroboros.Consensus.Ledger.Extended
- Ouroboros.Consensus.Ledger.Inspect
- Ouroboros.Consensus.Ledger.Query
- Ouroboros.Consensus.Ledger.SupportsMempool
- Ouroboros.Consensus.Ledger.SupportsPeerSelection
- Ouroboros.Consensus.Ledger.SupportsProtocol
- Ouroboros.Consensus.Mempool
- MiniProtocol
- BlockFetch
- ChainSync
- LocalStateQuery
- LocalTxMonitor
- LocalTxSubmission
- Mock
- Network
- Ouroboros.Consensus.Node
- Ouroboros.Consensus.Node.DbLock
- Ouroboros.Consensus.Node.DbMarker
- Ouroboros.Consensus.Node.ErrorPolicy
- Ouroboros.Consensus.Node.Exit
- Ouroboros.Consensus.Node.ExitPolicy
- Ouroboros.Consensus.Node.InitStorage
- Ouroboros.Consensus.Node.NetworkProtocolVersion
- Ouroboros.Consensus.Node.ProtocolInfo
- Ouroboros.Consensus.Node.Recovery
- Ouroboros.Consensus.Node.RethrowPolicy
- Ouroboros.Consensus.Node.Run
- Ouroboros.Consensus.Node.Serialisation
- Ouroboros.Consensus.Node.Tracers
- Ouroboros.Consensus.NodeId
- Ouroboros.Consensus.NodeKernel
- Protocol
- Ouroboros.Consensus.Protocol.Abstract
- Ouroboros.Consensus.Protocol.BFT
- Ouroboros.Consensus.Protocol.LeaderSchedule
- Ledger
- Ouroboros.Consensus.Protocol.MockChainSel
- Ouroboros.Consensus.Protocol.ModChainSel
- Ouroboros.Consensus.Protocol.PBFT
- Ouroboros.Consensus.Protocol.Praos
- Ouroboros.Consensus.Protocol.Signed
- Ouroboros.Consensus.Protocol.TPraos
- Ouroboros.Consensus.Protocol.Translate
- Shelley
- Ouroboros.Consensus.Shelley.Crypto
- Ouroboros.Consensus.Shelley.Eras
- Ouroboros.Consensus.Shelley.HFEras
- Ouroboros.Consensus.Shelley.Ledger
- Ouroboros.Consensus.Shelley.Ledger.Block
- Ouroboros.Consensus.Shelley.Ledger.Config
- Ouroboros.Consensus.Shelley.Ledger.Forge
- Ouroboros.Consensus.Shelley.Ledger.Inspect
- Ouroboros.Consensus.Shelley.Ledger.Integrity
- Ouroboros.Consensus.Shelley.Ledger.Ledger
- Ouroboros.Consensus.Shelley.Ledger.Mempool
- Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion
- Ouroboros.Consensus.Shelley.Ledger.PeerSelection
- Ouroboros.Consensus.Shelley.Ledger.Protocol
- Ouroboros.Consensus.Shelley.Ledger.Query
- Ouroboros.Consensus.Shelley.Ledger.SupportsProtocol
- Ouroboros.Consensus.Shelley.Node
- Protocol
- Ouroboros.Consensus.Shelley.ShelleyHFC
- Storage
- Ouroboros.Consensus.Storage.ChainDB
- Ouroboros.Consensus.Storage.ChainDB.API
- Ouroboros.Consensus.Storage.ChainDB.Impl
- Ouroboros.Consensus.Storage.ChainDB.Impl.Args
- Ouroboros.Consensus.Storage.ChainDB.Impl.Background
- Ouroboros.Consensus.Storage.ChainDB.Impl.BlockCache
- Ouroboros.Consensus.Storage.ChainDB.Impl.ChainSel
- Ouroboros.Consensus.Storage.ChainDB.Impl.Follower
- Ouroboros.Consensus.Storage.ChainDB.Impl.Iterator
- Ouroboros.Consensus.Storage.ChainDB.Impl.LgrDB
- Ouroboros.Consensus.Storage.ChainDB.Impl.Paths
- Ouroboros.Consensus.Storage.ChainDB.Impl.Query
- Ouroboros.Consensus.Storage.ChainDB.Impl.Types
- Ouroboros.Consensus.Storage.ChainDB.Init
- Ouroboros.Consensus.Storage.Common
- FS
- Ouroboros.Consensus.Storage.IO
- Ouroboros.Consensus.Storage.ImmutableDB
- Ouroboros.Consensus.Storage.ImmutableDB.API
- Ouroboros.Consensus.Storage.ImmutableDB.Chunks
- Ouroboros.Consensus.Storage.ImmutableDB.Impl
- Ouroboros.Consensus.Storage.ImmutableDB.Impl.Index
- Ouroboros.Consensus.Storage.ImmutableDB.Impl.Iterator
- Ouroboros.Consensus.Storage.ImmutableDB.Impl.Parser
- Ouroboros.Consensus.Storage.ImmutableDB.Impl.State
- Ouroboros.Consensus.Storage.ImmutableDB.Impl.Types
- Ouroboros.Consensus.Storage.ImmutableDB.Impl.Util
- Ouroboros.Consensus.Storage.ImmutableDB.Impl.Validation
- Ouroboros.Consensus.Storage.LedgerDB
- Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy
- Ouroboros.Consensus.Storage.LedgerDB.InMemory
- Ouroboros.Consensus.Storage.LedgerDB.Init
- Ouroboros.Consensus.Storage.LedgerDB.LedgerDB
- Ouroboros.Consensus.Storage.LedgerDB.OnDisk
- Ouroboros.Consensus.Storage.LedgerDB.Query
- Ouroboros.Consensus.Storage.LedgerDB.Snapshots
- Ouroboros.Consensus.Storage.LedgerDB.Stream
- Ouroboros.Consensus.Storage.LedgerDB.Types
- Ouroboros.Consensus.Storage.LedgerDB.Update
- Ouroboros.Consensus.Storage.Serialisation
- Ouroboros.Consensus.Storage.VolatileDB
- Ouroboros.Consensus.Storage.ChainDB
- Ouroboros.Consensus.Ticked
- Tutorial
- Ouroboros.Consensus.TypeFamilyWrappers
- Ouroboros.Consensus.Util
- Ouroboros.Consensus.Util.AnchoredFragment
- Ouroboros.Consensus.Util.Args
- Ouroboros.Consensus.Util.Assert
- Ouroboros.Consensus.Util.CBOR
- Ouroboros.Consensus.Util.CallStack
- Ouroboros.Consensus.Util.Condense
- Ouroboros.Consensus.Util.Counting
- Ouroboros.Consensus.Util.DepPair
- Ouroboros.Consensus.Util.EarlyExit
- Ouroboros.Consensus.Util.Enclose
- Ouroboros.Consensus.Util.FileLock
- Ouroboros.Consensus.Util.HList
- Ouroboros.Consensus.Util.IOLike
- MonadSTM
- Ouroboros.Consensus.Util.OptNP
- Ouroboros.Consensus.Util.Orphans
- Ouroboros.Consensus.Util.RedundantConstraints
- Ouroboros.Consensus.Util.ResourceRegistry
- Ouroboros.Consensus.Util.SOP
- Ouroboros.Consensus.Util.STM
- Ouroboros.Consensus.Util.Singletons
- Ouroboros.Consensus.Util.TentativeState
- Ouroboros.Consensus.Util.Time
- Ouroboros.Consensus.Util.TraceSize
- Ouroboros.Consensus.Util.Versioned
- Network
- Ouroboros.Network.AnchoredFragment
- Ouroboros.Network.AnchoredSeq
- Ouroboros.Network.Block
- Ouroboros.Network.BlockFetch
- Ouroboros.Network.Channel
- Ouroboros.Network.CodecCBORTerm
- Ouroboros.Network.ConnectionHandler
- Ouroboros.Network.ConnectionId
- ConnectionManager
- Ouroboros.Network.ControlMessage
- Ouroboros.Network.DeltaQ
- Ouroboros.Network.Diffusion
- Ouroboros.Network.Driver
- Ouroboros.Network.ErrorPolicy
- Ouroboros.Network.ExitPolicy
- Handshake
- Ouroboros.Network.IOManager
- Ouroboros.Network.InboundGovernor
- Ouroboros.Network.KeepAlive
- Ouroboros.Network.Magic
- Mock
- Ouroboros.Network.Mux
- Ouroboros.Network.MuxMode
- Ouroboros.Network.NodeToClient
- Ouroboros.Network.NodeToNode
- PeerSelection
- Ouroboros.Network.PeerSelection.EstablishedPeers
- Ouroboros.Network.PeerSelection.Governor
- Ouroboros.Network.PeerSelection.Governor.ActivePeers
- Ouroboros.Network.PeerSelection.Governor.EstablishedPeers
- Ouroboros.Network.PeerSelection.Governor.KnownPeers
- Ouroboros.Network.PeerSelection.Governor.Monitor
- Ouroboros.Network.PeerSelection.Governor.RootPeers
- Ouroboros.Network.PeerSelection.Governor.Types
- Ouroboros.Network.PeerSelection.KnownPeers
- Ouroboros.Network.PeerSelection.LedgerPeers
- Ouroboros.Network.PeerSelection.LocalRootPeers
- Ouroboros.Network.PeerSelection.PeerMetric
- Ouroboros.Network.PeerSelection.PeerStateActions
- Ouroboros.Network.PeerSelection.RelayAccessPoint
- Ouroboros.Network.PeerSelection.RootPeersDNS
- Ouroboros.Network.PeerSelection.Simple
- Ouroboros.Network.PeerSelection.Types
- Ouroboros.Network.Point
- Protocol
- BlockFetch
- ChainSync
- Ouroboros.Network.Protocol.Handshake
- KeepAlive
- Ouroboros.Network.Protocol.Limits
- LocalStateQuery
- LocalTxMonitor
- LocalTxSubmission
- TxSubmission2
- Ouroboros.Network.RethrowPolicy
- Server
- Ouroboros.Network.Server2
- Ouroboros.Network.SizeInBytes
- Ouroboros.Network.Snocket
- Ouroboros.Network.Socket
- Ouroboros.Network.Subscription
- Testing
- Ouroboros.Network.Tracers
- TxSubmission
- Util
- Consensus
- Simulation
- Network
- Test
- Consensus
- Byron
- Cardano
- Ledger
- Shelley
- ThreadNet
- Util
- Test.Util.Blob
- Test.Util.BoolProps
- Test.Util.ChainDB
- Test.Util.ChainUpdates
- Test.Util.ChunkInfo
- Test.Util.Classify
- Test.Util.Corruption
- FS
- Test.Util.FileLock
- HardFork
- Test.Util.InvertedMap
- Test.Util.LogicalClock
- Test.Util.MockChain
- Orphans
- Test.Util.Paths
- Test.Util.QSM
- Test.Util.QuickCheck
- Test.Util.Range
- Test.Util.RefEnv
- Test.Util.SOP
- Test.Util.Schedule
- Serialisation
- Test.Util.Shrink
- Test.Util.Slots
- Test.Util.Split
- Test.Util.Stream
- Test.Util.TestBlock
- Test.Util.TestEnv
- Test.Util.Time
- Test.Util.Tracer
- Test.Util.WithEq
- Consensus