Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
-
data
ChainDbView
m blk =
ChainDbView
{
- getCurrentChain :: STM m ( AnchoredFragment ( Header blk))
- getHeaderStateHistory :: STM m ( HeaderStateHistory blk)
- getPastLedger :: Point blk -> STM m ( Maybe ( ExtLedgerState blk))
- getIsInvalidBlock :: STM m ( WithFingerprint ( HeaderHash blk -> Maybe ( InvalidBlockReason blk)))
-
data
ChainSyncClientException
- = forall blk.( BlockSupportsProtocol blk, ValidateEnvelope blk) => HeaderError ( Point blk) ( HeaderError blk) ( Our ( Tip blk)) ( Their ( Tip blk))
- | forall blk. BlockSupportsProtocol blk => InvalidIntersection ( Point blk) ( Our ( Tip blk)) ( Their ( Tip blk))
- | forall blk. BlockSupportsProtocol blk => DoesntFit ( ChainHash blk) ( ChainHash blk) ( Our ( Tip blk)) ( Their ( Tip blk))
- | forall blk. LedgerSupportsProtocol blk => InvalidBlock ( Point blk) ( HeaderHash blk) ( InvalidBlockReason blk)
-
data
ChainSyncClientResult
- = forall blk. BlockSupportsProtocol blk => ForkTooDeep ( Point blk) ( Our ( Tip blk)) ( Their ( Tip blk))
- | forall blk. BlockSupportsProtocol blk => NoMoreIntersection ( Our ( Tip blk)) ( Their ( Tip blk))
- | forall blk. BlockSupportsProtocol blk => RolledBackPastIntersection ( Point blk) ( Our ( Tip blk)) ( Their ( Tip blk))
- | AskedToTerminate
- type Consensus (client :: Type -> Type -> Type -> ( Type -> Type ) -> Type -> Type ) blk m = client ( Header blk) ( Point blk) ( Tip blk) m ChainSyncClientResult
-
newtype
Our
a =
Our
{
- unOur :: a
-
newtype
Their
a =
Their
{
- unTheir :: a
- bracketChainSyncClient :: ( IOLike m, Ord peer, BlockSupportsProtocol blk, LedgerSupportsProtocol blk) => Tracer m ( TraceChainSyncClientEvent blk) -> ChainDbView m blk -> StrictTVar m ( Map peer ( StrictTVar m ( AnchoredFragment ( Header blk)))) -> peer -> NodeToNodeVersion -> ( StrictTVar m ( AnchoredFragment ( Header blk)) -> m a) -> m a
- chainSyncClient :: forall m blk. ( IOLike m, LedgerSupportsProtocol blk) => MkPipelineDecision -> Tracer m ( TraceChainSyncClientEvent blk) -> TopLevelConfig blk -> ChainDbView m blk -> NodeToNodeVersion -> ControlMessageSTM m -> HeaderMetricsTracer m -> StrictTVar m ( AnchoredFragment ( Header blk)) -> Consensus ChainSyncClientPipelined blk m
- defaultChainDbView :: ( IOLike m, LedgerSupportsProtocol blk) => ChainDB m blk -> ChainDbView m blk
- data InvalidBlockReason blk
-
data
TraceChainSyncClientEvent
blk
- = TraceDownloadedHeader ( Header blk)
- | TraceRolledBack ( Point blk)
- | TraceFoundIntersection ( Point blk) ( Our ( Tip blk)) ( Their ( Tip blk))
- | TraceException ChainSyncClientException
- | TraceTermination ChainSyncClientResult
Documentation
data ChainDbView m blk Source #
Abstract over the ChainDB
ChainDbView | |
|
data ChainSyncClientException Source #
When the upstream node violates the protocol or exhibits malicious behaviour, e.g., serving an invalid header or a header corresponding to a known invalid block, we throw an exception to disconnect. This will bring down all miniprotocols in both directions with that node.
forall blk.( BlockSupportsProtocol blk, ValidateEnvelope blk) => HeaderError |
Header validation threw an error. |
forall blk. BlockSupportsProtocol blk => InvalidIntersection |
We send the upstream node a bunch of points from a chain fragment and the upstream node responded with an intersection point that is not on our chain fragment, and thus not among the points we sent. We store the intersection point the upstream node sent us. |
forall blk. BlockSupportsProtocol blk => DoesntFit |
The received header to roll forward doesn't fit onto the previous one.
The first
|
forall blk. LedgerSupportsProtocol blk => InvalidBlock |
The upstream node's chain contained a block that we know is invalid. |
|
data ChainSyncClientResult Source #
The Chain sync client only _gracefully_ terminates when the upstream node's chain is not interesting (e.g., forked off too far in the past). By gracefully terminating, the network layer can keep the other mini-protocols connect to the same upstream node running.
For example, a relay node will often receive connections from nodes syncing from scratch or an old chain. Since these nodes have a chain that is shorter than the relay node's chain, it's useless for the relay node to run the client-side of the chain sync protocol. However, the other direction of the protocol, and, e.g., the transaction submission protocol, should keep running.
forall blk. BlockSupportsProtocol blk => ForkTooDeep |
The server we're connecting to forked more than
|
forall blk. BlockSupportsProtocol blk => NoMoreIntersection ( Our ( Tip blk)) ( Their ( Tip blk)) |
Our chain changed such that it no longer intersects with the candidate's fragment, and asking for a new intersection did not yield one. |
forall blk. BlockSupportsProtocol blk => RolledBackPastIntersection |
We were asked to roll back past the anchor point of the candidate's
fragment. This means the candidate chain no longer forks off within
|
AskedToTerminate |
We were asked to terminate via the
|
Instances
type Consensus (client :: Type -> Type -> Type -> ( Type -> Type ) -> Type -> Type ) blk m = client ( Header blk) ( Point blk) ( Tip blk) m ChainSyncClientResult Source #
bracketChainSyncClient Source #
:: ( IOLike m, Ord peer, BlockSupportsProtocol blk, LedgerSupportsProtocol blk) | |
=> Tracer m ( TraceChainSyncClientEvent blk) | |
-> ChainDbView m blk | |
-> StrictTVar m ( Map peer ( StrictTVar m ( AnchoredFragment ( Header blk)))) |
The candidate chains, we need the whole map because we
(de)register nodes (
|
-> peer | |
-> NodeToNodeVersion | |
-> ( StrictTVar m ( AnchoredFragment ( Header blk)) -> m a) | |
-> m a |
chainSyncClient :: forall m blk. ( IOLike m, LedgerSupportsProtocol blk) => MkPipelineDecision -> Tracer m ( TraceChainSyncClientEvent blk) -> TopLevelConfig blk -> ChainDbView m blk -> NodeToNodeVersion -> ControlMessageSTM m -> HeaderMetricsTracer m -> StrictTVar m ( AnchoredFragment ( Header blk)) -> Consensus ChainSyncClientPipelined blk m Source #
Chain sync client
This never terminates. In case of a failure, a
ChainSyncClientException
is thrown. The network layer classifies exception such that the
corresponding peer will never be chosen again.
defaultChainDbView :: ( IOLike m, LedgerSupportsProtocol blk) => ChainDB m blk -> ChainDbView m blk Source #
Trace events
data InvalidBlockReason blk Source #
The reason why a block is invalid.
Instances
data TraceChainSyncClientEvent blk Source #
Events traced by the Chain Sync Client.
TraceDownloadedHeader ( Header blk) |
While following a candidate chain, we rolled forward by downloading a header. |
TraceRolledBack ( Point blk) |
While following a candidate chain, we rolled back to the given point. |
TraceFoundIntersection ( Point blk) ( Our ( Tip blk)) ( Their ( Tip blk)) |
We found an intersection between our chain fragment and the candidate's chain. |
TraceException ChainSyncClientException |
An exception was thrown by the Chain Sync Client. |
TraceTermination ChainSyncClientResult |
The client has terminated. |
Instances
( BlockSupportsProtocol blk, Eq ( ValidationErr ( BlockProtocol blk)), Eq ( Header blk)) => Eq ( TraceChainSyncClientEvent blk) Source # | |
Defined in Ouroboros.Consensus.MiniProtocol.ChainSync.Client (==) :: TraceChainSyncClientEvent blk -> TraceChainSyncClientEvent blk -> Bool Source # (/=) :: TraceChainSyncClientEvent blk -> TraceChainSyncClientEvent blk -> Bool Source # |
|
( BlockSupportsProtocol blk, Show ( Header blk)) => Show ( TraceChainSyncClientEvent blk) Source # | |