ouroboros-consensus-0.1.0.1: Consensus layer for the Ouroboros blockchain protocol
Safe Haskell None
Language Haskell2010

Ouroboros.Consensus.MiniProtocol.ChainSync.Client

Synopsis

Documentation

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.

Constructors

forall blk.( BlockSupportsProtocol blk, ValidateEnvelope blk) => HeaderError

Header validation threw an error.

Fields

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.

Fields

forall blk. BlockSupportsProtocol blk => DoesntFit

The received header to roll forward doesn't fit onto the previous one.

The first ChainHash is the previous hash of the received header and the second ChainHash is that of the previous one.

Fields

forall blk. LedgerSupportsProtocol blk => InvalidBlock

The upstream node's chain contained a block that we know is invalid.

Fields

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.

Constructors

forall blk. BlockSupportsProtocol blk => ForkTooDeep

The server we're connecting to forked more than k blocks ago.

Fields

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 k , making it impossible to switch to.

Fields

AskedToTerminate

We were asked to terminate via the ControlMessageSTM

bracketChainSyncClient Source #

Arguments

:: ( 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 ).

-> 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.

Trace events

data InvalidBlockReason blk Source #

The reason why a block is invalid.

Instances

Instances details
LedgerSupportsProtocol blk => Eq ( InvalidBlockReason blk) Source #
Instance details

Defined in Ouroboros.Consensus.Storage.ChainDB.API

LedgerSupportsProtocol blk => Show ( InvalidBlockReason blk) Source #
Instance details

Defined in Ouroboros.Consensus.Storage.ChainDB.API

Generic ( InvalidBlockReason blk) Source #
Instance details

Defined in Ouroboros.Consensus.Storage.ChainDB.API

LedgerSupportsProtocol blk => NoThunks ( InvalidBlockReason blk) Source #
Instance details

Defined in Ouroboros.Consensus.Storage.ChainDB.API

type Rep ( InvalidBlockReason blk) Source #
Instance details

Defined in Ouroboros.Consensus.Storage.ChainDB.API

type Rep ( InvalidBlockReason blk) = D1 (' MetaData "InvalidBlockReason" "Ouroboros.Consensus.Storage.ChainDB.API" "ouroboros-consensus-0.1.0.1-DT4Cvwf63DZKctsEvaJqCU" ' False ) ( C1 (' MetaCons "ValidationError" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( ExtValidationError blk))) :+: C1 (' MetaCons "InFutureExceedsClockSkew" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( RealPoint blk))))

data TraceChainSyncClientEvent blk Source #

Events traced by the Chain Sync Client.

Constructors

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.