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 !RbHash

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 3 L_hdr + L_vote 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 any window.

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

checkLeiosVotes Source #

Arguments

∷ (LedgerSupportsProtocol blk, HasHardForkHistory blk, LeiosProtocol (BlockProtocol 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) 

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 central vote processing will, once per vote, caching the result, so a badly signed copy of a vote the node already has costs it only the bytes.

voteLateGrace ∷ NominalDiffTime Source #

How much later than 3 L_hdr + L_vote after its election slot began a vote may arrive: enough for transmission, clock skew, and votes queued behind other traffic.

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, LeiosProtocol (BlockProtocol 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 RbHash 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 RbHash 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, LeiosProtocol (BlockProtocol blk)) 
⇒ SystemTime m 
→ SomeHeaderInFutureCheck m blk 
→ TopLevelConfig 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.

Nothing else in the node processes the announcement yet.

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.