ouroboros-consensus
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State

Description

What one LeiosNotify client remembers about its upstream peer, and how it judges that peer's replies against it.

Synopsis

Documentation

data ExnLeiosNotifyInvalidVotes Source #

Thrown when a peer's MsgLeiosVotes holds a vote an honest peer would not send; the ensuing thread death disconnects it.

Constructors

ExnLeiosVoteWithoutAnnouncement !RankingBlockHash

A vote for an announcing block this peer never sent us. This also rules out a vote in an empty slot.

ExnLeiosRepeatedVote

A second vote from one seat in one slot.

Fields

ExnLeiosVoteTooEarly

A vote too young to have been cast. Votes are cast 3 L_hdr after the slot began, the time equivocations take to come to light, widened by the node's maximum clock skew so that an honest peer is never disconnected.

Fields

ExnLeiosVoteTooLate

A vote too old to still be relayed. Votes stop being relayed when their diffusion period ends, 3 L_hdr + L_vote + L_diff after the slot began, widened by voteLateGrace so that an honest peer is never disconnected. A vote for a slot behind the immutable tip is among these, long past its diffusion period.

Fields

ExnLeiosVoteOutsideHorizon

A vote whose election slot the immutable tip cannot forecast to. Its announcement was validated by such a forecast, from an older immutable tip, so this should never happen.

Fields

ExnLeiosInvalidVote !AcceptedVote !InvalidVoteReason

An accepted vote turned out to be invalid.

data InvalidVoteReason Source #

Why a vote is invalid.

Constructors

SeatNotResolvable

Its seat is not in the election's committee.

SeatHasNoKey

Its seat is in the election's committee, but holds no key.

BadSignature !Text

Its signature does not verify under its seat's key.

data AcceptedVote Source #

A vote a client accepted from its peer, with what the node's VoteState needs to judge and relay it.

Constructors

MkAcceptedVote 

Fields

Instances

Instances details
Show AcceptedVote Source # 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State

checkLeiosVotes Source #

Arguments

∷ (LedgerSupportsProtocol blk, HasHardForkHistory blk) 
⇒ TopLevelConfig blk 
→ ClockSkew

the most that an honest peer's clock may differ from ours

→ ExtLedgerState blk EmptyMK

the immutable tip's ledger state

→ RelativeTime

now

→ NonEmpty LeiosVote 
→ LeiosNotifyPeerState blk 
→ Except ExnLeiosNotifyInvalidVotes (LeiosNotifyPeerState blk, [AcceptedVote]) 

Accept a peer's MsgLeiosVotes, or say why the peer must go; see ExnLeiosNotifyInvalidVotes.

This does not check a vote's seat or signature. The node's VoteState will, once per vote, unless copies arrive simultaneously, so a badly signed copy of a vote the node already has costs it only the bytes; see ExnLeiosInvalidVote.

data VoteWindow Source #

When a vote should be cast and relayed.

Constructors

MkVoteWindow 

Fields

  • voteFrom ∷ !RelativeTime

    Before this, a downstream peer whose clock is behind ours could reject the vote.

  • voteUntil ∷ !RelativeTime

    The vote's deadline: the earliest block that can certify its announcement is in the first slot at or after it, and the node uses no vote it has only after it.

Instances

Instances details
Eq VoteWindow Source # 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State

Methods

(==) ∷ VoteWindow → VoteWindow → Bool #

(/=) ∷ VoteWindow → VoteWindow → Bool #

Generic VoteWindow Source # 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State

Associated Types

type Rep VoteWindow 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State

type Rep VoteWindow = D1 ('MetaData "VoteWindow" "Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State" "ouroboros-consensus-5.0.0.0-inplace" 'False) (C1 ('MetaCons "MkVoteWindow" 'PrefixI 'True) (S1 ('MetaSel ('Just "voteFrom") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RelativeTime) :*: S1 ('MetaSel ('Just "voteUntil") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RelativeTime)))
Show VoteWindow Source # 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State

NoThunks VoteWindow Source # 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State

type Rep VoteWindow Source # 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State

type Rep VoteWindow = D1 ('MetaData "VoteWindow" "Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State" "ouroboros-consensus-5.0.0.0-inplace" 'False) (C1 ('MetaCons "MkVoteWindow" 'PrefixI 'True) (S1 ('MetaSel ('Just "voteFrom") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RelativeTime) :*: S1 ('MetaSel ('Just "voteUntil") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RelativeTime)))

leiosVoteWindow ∷ LeiosLedgerView → RelativeTime → VoteWindow Source #

When a vote is worth relaying, given its election's ledger view and when its election slot began: from 3 L_hdr after until 3 L_hdr + L_vote + L_diff after, or until its announcement is no longer relayed, if sooner.

voteLateGrace ∷ NominalDiffTime Source #

How much later than its deadline a vote may arrive without the node disconnecting the peer: enough for transmission, clock skew, and votes queued behind other traffic. Such a vote is too late to use, and the node's VoteState traces it.

TODO magic number; measure buffer bloat on a loaded network.

data ExnLeiosNotifyInvalidOffer Source #

Thrown when a peer's offer over LeiosNotify is one an honest peer would not send; the ensuing thread death disconnects it.

Without these checks, peers could send bogus offers, and there are infinitely many of those.

Constructors

ExnLeiosBlockOfferWithoutAnnouncement

A body offer of an endorser block this peer never announced.

Fields

ExnLeiosBlockOfferBadSize

A body offer claiming no bytes, or more bytes than the ledger lets an endorser block in that slot have.

Fields

ExnLeiosRepeatedBlockOffer !LeiosPoint

A second body offer of an endorser block.

ExnLeiosClosureOfferWithoutAnnouncement !LeiosPoint

A closure offer of an endorser block this peer never announced.

ExnLeiosRepeatedClosureOffer !LeiosPoint

A second closure offer of an endorser block.

ExnLeiosOfferTooOld

An offer below the slot this peer's state has been pruned to, which is therefore unanswerable on its own terms.

TODO When the honest server offers endorser blocks, explain why it never trips this, eg because it offers one only while it is at least a minimum lead younger than its own immutable tip.

Fields

ExnLeiosBlockOfferOutsideHorizon !LeiosPoint !OutsideForecastRange

A body offer whose slot the immutable tip cannot forecast to. Its announcement was validated by such a forecast, from an older immutable tip, so this should never happen.

checkLeiosBlockOffer Source #

Arguments

∷ LedgerSupportsProtocol blk 
⇒ TopLevelConfig blk 
→ ExtLedgerState blk EmptyMK

the immutable tip's ledger state

→ LeiosPoint 
→ BytesSize 
→ LeiosNotifyPeerState blk 
→ Except ExnLeiosNotifyInvalidOffer (LeiosNotifyPeerState blk) 

Accept a peer's MsgLeiosBlockOffer, or say why the peer must go.

A peer may offer only an endorser block it has itself announced. That is what stops an offer from being an independent way to make us track an endorser block, outside the two-per-election cap on announcements.

Only the point is held to the announcements; the size is free, within the ledger's bound. An offer claims to hold a body, and whoever holds a body knows its size, so a peer may well state a size that no announcement we received claimed.

checkLeiosClosureOffer ∷ LeiosPoint → LeiosNotifyPeerState blk → Except ExnLeiosNotifyInvalidOffer (LeiosNotifyPeerState blk) Source #

Accept a peer's MsgLeiosBlockTxsOffer, or say why the peer must go.

Held to the same announcement as the body offer and otherwise independent of it: either may arrive first, or alone. So a LeiosNotify server never has to track what it has already offered a peer in order to synthesise a body offer ahead of a closure offer.

data LeiosNotifyPeerState blk Source #

What one LeiosNotify client remembers about its upstream peer.

Only an announcement adds to it, and every entry is for an election at or after lnpsPruneSlot; the node prunes it as its immutable tip advances.

Constructors

MkLeiosNotifyPeerState 

Fields

Instances

Instances details
Generic (LeiosNotifyPeerState blk) Source # 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State

Associated Types

type Rep (LeiosNotifyPeerState blk) 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State

type Rep (LeiosNotifyPeerState blk) = D1 ('MetaData "LeiosNotifyPeerState" "Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State" "ouroboros-consensus-5.0.0.0-inplace" 'False) (C1 ('MetaCons "MkLeiosNotifyPeerState" 'PrefixI 'True) ((S1 ('MetaSel ('Just "lnpsPruneSlot") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo) :*: (S1 ('MetaSel ('Just "lnpsAnnouncements") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (State (AnnouncingHeader blk))) :*: S1 ('MetaSel ('Just "lnpsBodyOffers") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set LeiosPoint)))) :*: (S1 ('MetaSel ('Just "lnpsClosureOffers") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set LeiosPoint)) :*: (S1 ('MetaSel ('Just "lnpsAnnouncedRbHashes") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map RankingBlockHash SlotNo)) :*: S1 ('MetaSel ('Just "lnpsVotes") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set (SlotNo, LeiosSeatId)))))))
NoThunks (Header blk) ⇒ NoThunks (LeiosNotifyPeerState blk) Source # 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State

type Rep (LeiosNotifyPeerState blk) Source # 
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State

type Rep (LeiosNotifyPeerState blk) = D1 ('MetaData "LeiosNotifyPeerState" "Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State" "ouroboros-consensus-5.0.0.0-inplace" 'False) (C1 ('MetaCons "MkLeiosNotifyPeerState" 'PrefixI 'True) ((S1 ('MetaSel ('Just "lnpsPruneSlot") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo) :*: (S1 ('MetaSel ('Just "lnpsAnnouncements") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (State (AnnouncingHeader blk))) :*: S1 ('MetaSel ('Just "lnpsBodyOffers") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set LeiosPoint)))) :*: (S1 ('MetaSel ('Just "lnpsClosureOffers") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set LeiosPoint)) :*: (S1 ('MetaSel ('Just "lnpsAnnouncedRbHashes") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map RankingBlockHash SlotNo)) :*: S1 ('MetaSel ('Just "lnpsVotes") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set (SlotNo, LeiosSeatId)))))))

onLeiosNotifyAnnouncement Source #

Arguments

∷ ∀ (m ∷ Type → Type) blk. (IOLike m, LedgerSupportsProtocol blk, ConvertRawHash blk) 
⇒ SystemTime m 
→ SomeHeaderInFutureCheck m blk 
→ TopLevelConfig blk 
→ AnnounceState m blk 
→ ExtLedgerState blk EmptyMK

the immutable tip's ledger state

→ LeiosNotifyPeerState blk 
→ Header blk 
→ ExceptT (ExnLeiosNotifyInvalidAnnouncement blk) m (LeiosNotifyPeerState blk) 

Accept a peer's MsgLeiosBlockAnnouncement, or say why the peer must go.

An accepted announcement goes on to the node's AnnounceState.

pruneLeiosNotifyPeerState ∷ (ConvertRawHash blk, GetHeader blk) ⇒ SlotNo → LeiosNotifyPeerState blk → LeiosNotifyPeerState blk Source #

Forget everything about elections before the given slot, which is the immutable tip's.