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

Ouroboros.Consensus.Protocol.PBFT.State

Description

PBFT chain state

Intended for qualified import.

Synopsis

Documentation

data PBftSigner c Source #

Slot and corresponding genesis key

Instances

Instances details
PBftCrypto c ⇒ Eq (PBftSigner c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Methods

(==)PBftSigner c → PBftSigner c → Bool Source #

(/=)PBftSigner c → PBftSigner c → Bool Source #

PBftCrypto c ⇒ Show (PBftSigner c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Generic (PBftSigner c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Associated Types

type Rep (PBftSigner c) ∷ TypeType Source #

Methods

fromPBftSigner c → Rep (PBftSigner c) x Source #

toRep (PBftSigner c) x → PBftSigner c Source #

Serialise (PBftVerKeyHash c) ⇒ Serialise (PBftSigner c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Methods

encodePBftSigner c → Encoding #

decode ∷ Decoder s (PBftSigner c) #

encodeList ∷ [PBftSigner c] → Encoding #

decodeList ∷ Decoder s [PBftSigner c] #

PBftCrypto c ⇒ NoThunks (PBftSigner c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Methods

noThunks ∷ Context → PBftSigner c → IO (Maybe ThunkInfo) #

wNoThunks ∷ Context → PBftSigner c → IO (Maybe ThunkInfo) #

showTypeOfProxy (PBftSigner c) → String #

type Rep (PBftSigner c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

type Rep (PBftSigner c) = D1 ('MetaData "PBftSigner" "Ouroboros.Consensus.Protocol.PBFT.State" "ouroboros-consensus-0.3.1.0-inplace" 'False) (C1 ('MetaCons "PBftSigner" 'PrefixI 'True) (S1 ('MetaSel ('Just "pbftSignerSlotNo") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo) :*: S1 ('MetaSel ('Just "pbftSignerGenesisKey") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PBftVerKeyHash c))))

data PBftState c Source #

PBFT state

For a window size of n, the PBFT chain state is a sequence of signatures over the last n slots

+-------------------------------------------+
|                signatures                 |
+-------------------------------------------+

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                 window of n

We need the last n signatures to verify that no single key has signed more than a certain threshold percentage of the slots.

When near genesis, we will have less than n signatures in the history.

The window size itself is pretty much arbitrary and will be fixed by a particular blockchain specification (e.g., Byron).

Constructors

PBftState 

Fields

  • inWindow ∷ !(StrictSeq (PBftSigner c))

    Signatures in the window

    We should have precisely n signatures in the window, unless we are near genesis.

    INVARIANT Empty if and only if we are exactly at genesis.

  • counts ∷ !(Map (PBftVerKeyHash c) Word64)

    Cached counts of the signatures in the window

Instances

Instances details
PBftCrypto c ⇒ Eq (PBftState c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Methods

(==)PBftState c → PBftState c → Bool Source #

(/=)PBftState c → PBftState c → Bool Source #

PBftCrypto c ⇒ Show (PBftState c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Generic (PBftState c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Associated Types

type Rep (PBftState c) ∷ TypeType Source #

Methods

fromPBftState c → Rep (PBftState c) x Source #

toRep (PBftState c) x → PBftState c Source #

PBftCrypto c ⇒ NoThunks (PBftState c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Methods

noThunks ∷ Context → PBftState c → IO (Maybe ThunkInfo) #

wNoThunks ∷ Context → PBftState c → IO (Maybe ThunkInfo) #

showTypeOfProxy (PBftState c) → String #

type Rep (PBftState c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

type Rep (PBftState c) = D1 ('MetaData "PBftState" "Ouroboros.Consensus.Protocol.PBFT.State" "ouroboros-consensus-0.3.1.0-inplace" 'False) (C1 ('MetaCons "PBftState" 'PrefixI 'True) (S1 ('MetaSel ('Just "inWindow") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (StrictSeq (PBftSigner c))) :*: S1 ('MetaSel ('Just "counts") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map (PBftVerKeyHash c) Word64))))
data Ticked (PBftState c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT

data family Ticked st ∷ Type Source #

" Ticked " piece of state (LedgerState, LedgerView, ChainIndepState)

Ticking refers to the passage of time (the ticking of the clock). When a piece of state is marked as ticked, it means that time-related changes have been applied to the state (or forecast).

Some examples of time related changes:

  • Scheduled delegations might have been applied in Byron
  • New leader schedule computed for Shelley
  • Transition from Byron to Shelley activated in the hard fork combinator.
  • Nonces switched out at the start of a new epoch.

Instances

Instances details
Show (Ticked ()) Source # 
Instance details

Defined in Ouroboros.Consensus.Ticked

Methods

showsPrecIntTicked () → ShowS Source #

showTicked () → String Source #

showList ∷ [Ticked ()] → ShowS Source #

Show (Ticked a) ⇒ Show (Ticked (K a x)) Source # 
Instance details

Defined in Ouroboros.Consensus.Ticked

Methods

showsPrecIntTicked (K a x) → ShowS Source #

showTicked (K a x) → String Source #

showList ∷ [Ticked (K a x)] → ShowS Source #

(SListI xs, Show (Ticked a)) ⇒ Show (Ticked (HardForkLedgerView_ (K a ∷ TypeType) xs)) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Protocol.LedgerView

Generic (Ticked (LedgerState (HardForkBlock xs))) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

Associated Types

type Rep (Ticked (LedgerState (HardForkBlock xs))) ∷ TypeType Source #

NoThunks (Ticked (LedgerState (DualBlock m a))) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

Methods

noThunks ∷ Context → Ticked (LedgerState (DualBlock m a)) → IO (Maybe ThunkInfo) #

wNoThunks ∷ Context → Ticked (LedgerState (DualBlock m a)) → IO (Maybe ThunkInfo) #

showTypeOfProxy (Ticked (LedgerState (DualBlock m a))) → String #

CanHardFork xs ⇒ NoThunks (Ticked (LedgerState (HardForkBlock xs))) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

Methods

noThunks ∷ Context → Ticked (LedgerState (HardForkBlock xs)) → IO (Maybe ThunkInfo) #

wNoThunks ∷ Context → Ticked (LedgerState (HardForkBlock xs)) → IO (Maybe ThunkInfo) #

showTypeOfProxy (Ticked (LedgerState (HardForkBlock xs))) → String #

Bridge m a ⇒ GetTip (Ticked (LedgerState (DualBlock m a))) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

CanHardFork xs ⇒ GetTip (Ticked (LedgerState (HardForkBlock xs))) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

IsLedger (LedgerState blk) ⇒ GetTip (Ticked (ExtLedgerState blk)) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Extended

Isomorphic (Ticked :.: LedgerState) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Embed.Unary

Show (Ticked (f a)) ⇒ Show ((Ticked :.: f) a) Source # 
Instance details

Defined in Ouroboros.Consensus.Ticked

Methods

showsPrecInt → (Ticked :.: f) a → ShowS Source #

show ∷ (Ticked :.: f) a → String Source #

showList ∷ [(Ticked :.: f) a] → ShowS Source #

NoThunks (Ticked (f a)) ⇒ NoThunks ((Ticked :.: f) a) Source # 
Instance details

Defined in Ouroboros.Consensus.Ticked

Methods

noThunks ∷ Context → (Ticked :.: f) a → IO (Maybe ThunkInfo) #

wNoThunks ∷ Context → (Ticked :.: f) a → IO (Maybe ThunkInfo) #

showTypeOfProxy ((Ticked :.: f) a) → String #

data Ticked () Source # 
Instance details

Defined in Ouroboros.Consensus.Ticked

type Rep (Ticked (LedgerState (HardForkBlock xs))) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

type Rep (Ticked (LedgerState (HardForkBlock xs))) = D1 ('MetaData "Ticked" "Ouroboros.Consensus.HardFork.Combinator.Ledger" "ouroboros-consensus-0.3.1.0-inplace" 'False) (C1 ('MetaCons "TickedHardForkLedgerState" 'PrefixI 'True) (S1 ('MetaSel ('Just "tickedHardForkLedgerStateTransition") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TransitionInfo) :*: S1 ('MetaSel ('Just "tickedHardForkLedgerStatePerEra") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (HardForkState (Ticked :.: LedgerState) xs))))
type HeaderHash (Ticked l) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Basics

data Ticked (LedgerState (DualBlock m a)) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

data Ticked (LedgerState (HardForkBlock xs)) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

data Ticked (HeaderState blk) Source # 
Instance details

Defined in Ouroboros.Consensus.HeaderValidation

newtype Ticked (WrapLedgerView blk) Source # 
Instance details

Defined in Ouroboros.Consensus.TypeFamilyWrappers

newtype Ticked (WrapChainDepState blk) Source # 
Instance details

Defined in Ouroboros.Consensus.TypeFamilyWrappers

data Ticked (ExtLedgerState blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Extended

data Ticked (HardForkChainDepState xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Protocol

data Ticked (PBftState c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT

newtype Ticked (PBftLedgerView c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT

data Ticked (HardForkLedgerView_ f xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Protocol.LedgerView

newtype Ticked (K a x) Source # 
Instance details

Defined in Ouroboros.Consensus.Ticked

newtype Ticked (K a x) = TickedK {}

newtype WindowSize Source #

Window size

See PBftState itself for a detailed discussion on the window size versus the number of signatures.

Constructors

WindowSize 

Fields

Instances

Instances details
Enum WindowSize Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Eq WindowSize Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Integral WindowSize Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Num WindowSize Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Ord WindowSize Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Real WindowSize Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Show WindowSize Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Construction

append ∷ ∀ c. PBftCrypto c ⇒ WindowSizePBftSigner c → PBftState c → PBftState c Source #

Append new signature

Drops the oldest signature, provided we have reached the required number.

emptyPBftState c Source #

Empty PBFT chain state

In other words, the PBFT chain state corresponding to genesis.

Queries

countSignaturesPBftState c → Word64 Source #

Number of signatures in the window

This will be equal to the specified window size, unless near genesis

countSignedByPBftCrypto c ⇒ PBftState c → PBftVerKeyHash c → Word64 Source #

The number of blocks signed by the specified genesis key

This only considers the signatures within the window, not in the pre-window; see PBftState for detailed discussion.

lastSignedSlotPBftState c → WithOrigin SlotNo Source #

The last (most recent) signed slot in the window

Returns Origin if there are no signatures in the window (this will happen exactly at genesis only).

Unaffected by EBBs, since they're not signed.

Conversion

fromListPBftCrypto c ⇒ [PBftSigner c] → PBftState c Source #

Note: we are not checking the invariants because we don't want to require the WindowSize to be in the context, see #2383. When assertions are enabled, we would notice the invariant violation as soon as we append.

PRECONDITION: the slots of the signers are in ascending order.

Serialization

decodePBftState ∷ ∀ c. (PBftCrypto c, Serialise (PBftVerKeyHash c)) ⇒ ∀ s. Decoder s (PBftState c) Source #