| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
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
- data ExnLeiosNotifyInvalidAnnouncement blk
- data ExnLeiosNotifyInvalidVotes
- checkLeiosVotes ∷ (LedgerSupportsProtocol blk, HasHardForkHistory blk, LeiosProtocol (BlockProtocol blk)) ⇒ TopLevelConfig blk → ClockSkew → ExtLedgerState blk EmptyMK → RelativeTime → NonEmpty LeiosVote → LeiosNotifyPeerState blk → Except ExnLeiosNotifyInvalidVotes (LeiosNotifyPeerState blk)
- voteLateGrace ∷ NominalDiffTime
- data ExnLeiosNotifyInvalidOffer
- = ExnLeiosBlockOfferWithoutAnnouncement !LeiosPoint !BytesSize
- | ExnLeiosBlockOfferBadSize !LeiosPoint !BytesSize !BytesSize
- | ExnLeiosRepeatedBlockOffer !LeiosPoint
- | ExnLeiosClosureOfferWithoutAnnouncement !LeiosPoint
- | ExnLeiosRepeatedClosureOffer !LeiosPoint
- | ExnLeiosOfferTooOld !LeiosPoint !SlotNo
- | ExnLeiosBlockOfferOutsideHorizon !LeiosPoint !OutsideForecastRange
- checkLeiosBlockOffer ∷ (LedgerSupportsProtocol blk, LeiosProtocol (BlockProtocol blk)) ⇒ TopLevelConfig blk → ExtLedgerState blk EmptyMK → LeiosPoint → BytesSize → LeiosNotifyPeerState blk → Except ExnLeiosNotifyInvalidOffer (LeiosNotifyPeerState blk)
- checkLeiosClosureOffer ∷ LeiosPoint → LeiosNotifyPeerState blk → Except ExnLeiosNotifyInvalidOffer (LeiosNotifyPeerState blk)
- data LeiosNotifyPeerState blk = MkLeiosNotifyPeerState {
- lnpsPruneSlot ∷ !SlotNo
- lnpsAnnouncements ∷ !(State (AnnouncingHeader blk))
- lnpsBodyOffers ∷ !(Set LeiosPoint)
- lnpsClosureOffers ∷ !(Set LeiosPoint)
- lnpsAnnouncedRbHashes ∷ !(Map RbHash SlotNo)
- lnpsVotes ∷ !(Set (SlotNo, LeiosSeatId))
- emptyLeiosNotifyPeerState ∷ LeiosNotifyPeerState blk
- onLeiosNotifyAnnouncement ∷ ∀ (m ∷ Type → Type) blk. (IOLike m, LedgerSupportsProtocol blk, ConvertRawHash blk, LeiosProtocol (BlockProtocol blk)) ⇒ SystemTime m → SomeHeaderInFutureCheck m blk → TopLevelConfig blk → ExtLedgerState blk EmptyMK → LeiosNotifyPeerState blk → Header blk → ExceptT (ExnLeiosNotifyInvalidAnnouncement blk) m (LeiosNotifyPeerState blk)
- pruneLeiosNotifyPeerState ∷ (ConvertRawHash blk, GetHeader blk) ⇒ SlotNo → LeiosNotifyPeerState blk → LeiosNotifyPeerState blk
Documentation
data ExnLeiosNotifyInvalidAnnouncement blk Source #
Thrown when a peer's MsgLeiosBlockAnnouncement is one an honest peer
would not send; the ensuing thread death disconnects it.
Constructors
| ExnLeiosNotifyAnnouncementMissing | The header carries no announcement, so it should not have been relayed as one. |
| ExnLeiosNotifyInvalidAnnouncement !(Error (AnnouncementInvalidity blk)) |
Instances
| (Typeable blk, Show (ValidationErr (BlockProtocol blk)), Show (OtherHeaderEnvelopeError blk)) ⇒ Exception (ExnLeiosNotifyInvalidAnnouncement blk) Source # | |
| (Show (ValidationErr (BlockProtocol blk)), Show (OtherHeaderEnvelopeError blk)) ⇒ Show (ExnLeiosNotifyInvalidAnnouncement blk) Source # | |
Defined in Ouroboros.Consensus.MiniProtocol.LeiosNotify.Client.State Methods showsPrec ∷ Int → ExnLeiosNotifyInvalidAnnouncement blk → ShowS # show ∷ ExnLeiosNotifyInvalidAnnouncement blk → String # showList ∷ [ExnLeiosNotifyInvalidAnnouncement blk] → ShowS # | |
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 |
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. |
Instances
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. |
Instances
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
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.