| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Leios.VoteState
Contents
Description
The votes the node has accepted, from whichever peer.
Each LeiosNotify client already holds its own upstream peer to one vote per seat in an election. But the node relays what it accepts from all its peers, and a downstream peer holds the node to the same, and to having relayed the announcement a vote is for. So the node decides once, here, whether a vote is new and valid, and only then relays it.
A vote is relayed only to be aggregated into a certificate, which the
earliest block that can carry it needs in the first slot at or after the
vote's deadline, the end of its diffusion period (voteUntil). The node
neither keeps nor relays a vote it has only after its deadline. Such a vote
could still complete a certificate for a later block, but a quorum that late
is no evidence that the endorser block's data diffused in time, so the node
deliberately gives up that throughput rather than endanger safety.
Synopsis
- data VoteState (m ∷ Type → Type) blk
- newVoteState ∷ IOLike m ⇒ Tracer m TraceLeiosVoteState → AnnounceState m blk → NotifyLog m blk → m (VoteState m blk)
- data TraceLeiosVoteState
- data AddVoteResult
- addVote ∷ (IOLike m, ConvertRawHash blk, GetHeader blk) ⇒ VoteState m blk → SystemTime m → AcceptedVote → m AddVoteResult
- votePruner ∷ IOLike m ⇒ VoteState m blk → SystemTime m → m Void
- currentVotes ∷ ∀ (m ∷ Type → Type) blk. IOLike m ⇒ VoteState m blk → STM m (Map SlotNo (Map LeiosSeatId LeiosVote))
- recordVote ∷ ∀ (m ∷ Type → Type) blk. IOLike m ⇒ VoteState m blk → AcceptedVote → STM m (Either AddVoteResult ())
- pruneVotes ∷ ∀ (m ∷ Type → Type) blk. IOLike m ⇒ VoteState m blk → RelativeTime → STM m ()
Documentation
data VoteState (m ∷ Type → Type) blk Source #
The node's votes, and where it learns which announcements it relays and relays the votes.
newVoteState ∷ IOLike m ⇒ Tracer m TraceLeiosVoteState → AnnounceState m blk → NotifyLog m blk → m (VoteState m blk) Source #
data TraceLeiosVoteState Source #
What the node's VoteState traces, for each vote it adds or does not, so
these are frequent. What addVote did with a vote is up to its caller to
trace.
Constructors
| TraceLeiosVoteAdding !LeiosVote | The node starts to add a vote, and to check whether it should. |
| TraceLeiosVoteAwaitingWindow !LeiosVote !NominalDiffTime | The vote arrived before its window opened, so the node waits this long before adding it. |
| TraceLeiosVoteValidated !LeiosVote | The node validated a vote, its seat and signature, and has yet to add it. |
Instances
| Show TraceLeiosVoteState Source # | |
Defined in Ouroboros.Consensus.Leios.VoteState Methods showsPrec ∷ Int → TraceLeiosVoteState → ShowS # show ∷ TraceLeiosVoteState → String # showList ∷ [TraceLeiosVoteState] → ShowS # | |
data AddVoteResult Source #
What addVote did with a vote.
Constructors
| ArrivedTooLate | The node had it only after its deadline, or after it forgot its election. |
| AlreadyKnown | We already saw a vote of its seat in its election. |
| NotAnnounced | We did not relay the announcement it is for. |
| VoteInvalid !InvalidVoteReason | Its seat has no key in the committee, or its signature does not verify under it. |
| Added | The node keeps the vote and relays it. |
Instances
| Eq AddVoteResult Source # | |
Defined in Ouroboros.Consensus.Leios.VoteState | |
| Show AddVoteResult Source # | |
Defined in Ouroboros.Consensus.Leios.VoteState Methods showsPrec ∷ Int → AddVoteResult → ShowS # show ∷ AddVoteResult → String # showList ∷ [AddVoteResult] → ShowS # | |
addVote ∷ (IOLike m, ConvertRawHash blk, GetHeader blk) ⇒ VoteState m blk → SystemTime m → AcceptedVote → m AddVoteResult Source #
Add a vote, if it is the first valid vote of its seat in its election, for an announcement the node relays, and the node has it by its deadline.
NOTE: This will wait until the vote's window is open.
The signature is verified between two transactions, so that a retry does
not repeat a BLS verification. As verifying takes time, recordVote checks
again whether the node has seen or forgotten the vote. The relay log stops
relaying it after its deadline.
votePruner ∷ IOLike m ⇒ VoteState m blk → SystemTime m → m Void Source #
Prune the votes every second; see pruneVotes.
The votes kept
currentVotes ∷ ∀ (m ∷ Type → Type) blk. IOLike m ⇒ VoteState m blk → STM m (Map SlotNo (Map LeiosSeatId LeiosVote)) Source #
The votes the node keeps, by election slot and seat.
recordVote ∷ ∀ (m ∷ Type → Type) blk. IOLike m ⇒ VoteState m blk → AcceptedVote → STM m (Either AddVoteResult ()) Source #
Keep a vote the node has neither seen nor forgotten, as it was pruned past the vote's deadline already.
pruneVotes ∷ ∀ (m ∷ Type → Type) blk. IOLike m ⇒ VoteState m blk → RelativeTime → STM m () Source #
Forget the votes of every election slot whose deadline has passed at the given time.
recordVote then finds any later copy of their votes ArrivedTooLate.