ouroboros-consensus-0.21.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellSafe-Inferred
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
Generic (PBftSigner c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Associated Types

type Rep (PBftSigner c) ∷ TypeType #

Methods

fromPBftSigner c → Rep (PBftSigner c) x #

toRep (PBftSigner c) x → PBftSigner c #

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

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Methods

showsPrecIntPBftSigner c → ShowS #

showPBftSigner c → String #

showList ∷ [PBftSigner c] → ShowS #

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

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Methods

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

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

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

Defined in Ouroboros.Consensus.Protocol.PBFT.State

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

Defined in Ouroboros.Consensus.Protocol.PBFT.State

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.21.0.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
Generic (PBftState c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Associated Types

type Rep (PBftState c) ∷ TypeType #

Methods

fromPBftState c → Rep (PBftState c) x #

toRep (PBftState c) x → PBftState c #

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

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Methods

showsPrecIntPBftState c → ShowS #

showPBftState c → String #

showList ∷ [PBftState c] → ShowS #

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

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Methods

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

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

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

Defined in Ouroboros.Consensus.Protocol.PBFT.State

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.21.0.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, either LedgerState or ChainDepState

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. There are exactly two methods in the interface that do that: tickChainDepState and applyChainTickLedgerResult.

Also note that a successful forecast forecastFor (ledgerViewForecastAt cfg st) slot must equal protocolLedgerView cfg (applyChainTick cfg slot st). Thus a LedgerView can only be projected from a Ticked state, but cannot itself be ticked.

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
Generic (Ticked (LedgerState (HardForkBlock xs))) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

Associated Types

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

Show (Ticked ()) Source # 
Instance details

Defined in Ouroboros.Consensus.Ticked

Methods

showsPrecIntTicked () → ShowS #

showTicked () → String #

showList ∷ [Ticked ()] → ShowS #

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

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

NoThunks (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

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

Defined in Ouroboros.Consensus.Ledger.Dual

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 #

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

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

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

Defined in Ouroboros.Consensus.Ticked

data Ticked () Source # 
Instance details

Defined in Ouroboros.Consensus.Ticked

type HeaderHash (Ticked l ∷ Type) Source # 
Instance details

Defined in Ouroboros.Consensus.Ticked

type HeaderHash (Ticked l ∷ Type) = HeaderHash l
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.21.0.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))))
data Ticked (HardForkChainDepState xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Protocol

data Ticked (HeaderState blk) Source # 
Instance details

Defined in Ouroboros.Consensus.HeaderValidation

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

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

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

Defined in Ouroboros.Consensus.Ledger.Dual

data Ticked (ExtLedgerState blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Extended

data Ticked (PBftState c) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT

newtype Ticked (WrapChainDepState blk) Source # 
Instance details

Defined in Ouroboros.Consensus.TypeFamilyWrappers

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

Num WindowSize Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Integral 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

Eq WindowSize Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT.State

Methods

(==)WindowSizeWindowSizeBool #

(/=)WindowSizeWindowSizeBool #

Ord 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