ouroboros-consensus-0.1.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.MiniProtocol.ChainSync.Client

Contents

Synopsis

Documentation

data ChainDbView m blk Source #

Abstract over the ChainDB

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

∀ blk.(BlockSupportsProtocol blk, ValidateEnvelope blk) ⇒ HeaderError

Header validation threw an error.

Fields

∀ 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

∀ 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

∀ blk.LedgerSupportsProtocol blk ⇒ InvalidBlock

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

Fields

  • (Point blk)

    Block that triggered the validity check.

  • (HeaderHash blk)

    Invalid block. If pipelining was negotiated, this can be different from the previous argument.

  • (InvalidBlockReason blk)
     

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

∀ blk.BlockSupportsProtocol blk ⇒ ForkTooDeep

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

Fields

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

∀ 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

type Consensus (client ∷ TypeTypeType → (TypeType) → TypeType) blk m = client (Header blk) (Point blk) (Tip blk) m ChainSyncClientResult Source #

newtype Our a Source #

Constructors

Our 

Fields

Instances

Instances details
Eq a ⇒ Eq (Our a) Source # 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.ChainSync.Client

Methods

(==)Our a → Our a → Bool Source #

(/=)Our a → Our a → Bool Source #

Show a ⇒ Show (Our a) Source # 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.ChainSync.Client

Methods

showsPrecIntOur a → ShowS Source #

showOur a → String Source #

showList ∷ [Our a] → ShowS Source #

NoThunks a ⇒ NoThunks (Our a) Source # 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.ChainSync.Client

Methods

noThunks ∷ Context → Our a → IO (Maybe ThunkInfo) #

wNoThunks ∷ Context → Our a → IO (Maybe ThunkInfo) #

showTypeOfProxy (Our a) → String #

newtype Their a Source #

Constructors

Their 

Fields

Instances

Instances details
Eq a ⇒ Eq (Their a) Source # 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.ChainSync.Client

Methods

(==)Their a → Their a → Bool Source #

(/=)Their a → Their a → Bool Source #

Show a ⇒ Show (Their a) Source # 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.ChainSync.Client

Methods

showsPrecIntTheir a → ShowS Source #

showTheir a → String Source #

showList ∷ [Their a] → ShowS Source #

NoThunks a ⇒ NoThunks (Their a) Source # 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.ChainSync.Client

Methods

noThunks ∷ Context → Their a → IO (Maybe ThunkInfo) #

wNoThunks ∷ Context → Their a → IO (Maybe ThunkInfo) #

showTypeOfProxy (Their a) → String #

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 ∷ ∀ m blk. (IOLike m, LedgerSupportsProtocol blk) ⇒ MkPipelineDecision → Tracer m (TraceChainSyncClientEvent blk) → TopLevelConfig blk → ChainDbView m blk → NodeToNodeVersionControlMessageSTM 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

Associated Types

type Rep (InvalidBlockReason blk) ∷ TypeType Source #

LedgerSupportsProtocol blk ⇒ NoThunks (InvalidBlockReason blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.ChainDB.API

Methods

noThunks ∷ Context → InvalidBlockReason blk → IO (Maybe ThunkInfo) #

wNoThunks ∷ Context → InvalidBlockReason blk → IO (Maybe ThunkInfo) #

showTypeOfProxy (InvalidBlockReason blk) → String #

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.0-inplace" 'False) (C1 ('MetaCons "ValidationError" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (ExtValidationError blk))) :+: C1 ('MetaCons "InFutureExceedsClockSkew" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe 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.