Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.Protocol.PBFT.State
Description
PBFT chain state
Intended for qualified import.
Synopsis
- data PBftSigner c = PBftSigner {}
- data PBftState c = PBftState {
- inWindow ∷ !(StrictSeq (PBftSigner c))
- counts ∷ !(Map (PBftVerKeyHash c) Word64)
- data family Ticked (st ∷ k) ∷ k
- newtype WindowSize = WindowSize {}
- append ∷ PBftCrypto c ⇒ WindowSize → PBftSigner c → PBftState c → PBftState c
- empty ∷ PBftState c
- countSignatures ∷ PBftState c → Word64
- countSignedBy ∷ PBftCrypto c ⇒ PBftState c → PBftVerKeyHash c → Word64
- lastSignedSlot ∷ PBftState c → WithOrigin SlotNo
- fromList ∷ PBftCrypto c ⇒ [PBftSigner c] → PBftState c
- toList ∷ PBftState c → [PBftSigner c]
- decodePBftState ∷ PBftCrypto c ⇒ ∀ s. Decoder s (PBftState c)
- encodePBftState ∷ PBftCrypto c ⇒ PBftState c → Encoding
Documentation
data PBftSigner c Source #
Slot and corresponding genesis key
Constructors
PBftSigner | |
Fields |
Instances
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
|
Instances
Generic (PBftState c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PBFT.State Associated Types
| |||||
PBftCrypto c ⇒ Show (PBftState c) Source # | |||||
PBftCrypto c ⇒ Eq (PBftState c) Source # | |||||
PBftCrypto c ⇒ NoThunks (PBftState c) Source # | |||||
data Ticked (PBftState c ∷ Type) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PBFT | |||||
type Rep (PBftState c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PBFT.State type Rep (PBftState c) = D1 ('MetaData "PBftState" "Ouroboros.Consensus.Protocol.PBFT.State" "ouroboros-consensus-0.26.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 family Ticked (st ∷ k) ∷ k 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
must equal
forecastFor
(ledgerViewForecastAt
cfg st)
slot
. Thus a
protocolLedgerView
cfg
(applyChainTick
cfg slot st)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
Show (Ticked ()) Source # | |
CanHardFork xs ⇒ GetTip (Ticked (LedgerState (HardForkBlock xs))) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger Methods getTip ∷ ∀ (mk ∷ MapKind). Ticked (LedgerState (HardForkBlock xs)) mk → Point (Ticked (LedgerState (HardForkBlock xs))) Source # | |
Bridge m a ⇒ GetTip (Ticked (LedgerState (DualBlock m a))) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual | |
IsLedger (LedgerState blk) ⇒ GetTip (Ticked (ExtLedgerState blk)) Source # | |
Defined in Ouroboros.Consensus.Ledger.Extended Methods getTip ∷ ∀ (mk ∷ MapKind). Ticked (ExtLedgerState blk) mk → Point (Ticked (ExtLedgerState blk)) Source # | |
(CanHardFork xs, HasCanonicalTxIn xs, HasHardForkTxOut xs) ⇒ HasLedgerTables (Ticked (LedgerState (HardForkBlock xs))) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger Methods projectLedgerTables ∷ ∀ (mk ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked (LedgerState (HardForkBlock xs)) mk → LedgerTables (Ticked (LedgerState (HardForkBlock xs))) mk Source # withLedgerTables ∷ ∀ (mk ∷ MapKind) (any ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked (LedgerState (HardForkBlock xs)) any → LedgerTables (Ticked (LedgerState (HardForkBlock xs))) mk → Ticked (LedgerState (HardForkBlock xs)) mk Source # | |
(Bridge m a, NoThunks (TxOut (LedgerState m)), NoThunks (TxIn (LedgerState m)), Show (TxOut (LedgerState m)), Show (TxIn (LedgerState m)), Eq (TxOut (LedgerState m)), Ord (TxIn (LedgerState m)), MemPack (TxIn (LedgerState m))) ⇒ HasLedgerTables (Ticked (LedgerState (DualBlock m a))) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual Methods projectLedgerTables ∷ ∀ (mk ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked (LedgerState (DualBlock m a)) mk → LedgerTables (Ticked (LedgerState (DualBlock m a))) mk Source # withLedgerTables ∷ ∀ (mk ∷ MapKind) (any ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked (LedgerState (DualBlock m a)) any → LedgerTables (Ticked (LedgerState (DualBlock m a))) mk → Ticked (LedgerState (DualBlock m a)) mk Source # | |
(HasLedgerTables (Ticked (LedgerState blk)), NoThunks (TxOut (LedgerState blk)), NoThunks (TxIn (LedgerState blk)), Show (TxOut (LedgerState blk)), Show (TxIn (LedgerState blk)), Eq (TxOut (LedgerState blk)), Ord (TxIn (LedgerState blk)), MemPack (TxIn (LedgerState blk))) ⇒ HasLedgerTables (Ticked (ExtLedgerState blk)) Source # | |
Defined in Ouroboros.Consensus.Ledger.Extended Methods projectLedgerTables ∷ ∀ (mk ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked (ExtLedgerState blk) mk → LedgerTables (Ticked (ExtLedgerState blk)) mk Source # withLedgerTables ∷ ∀ (mk ∷ MapKind) (any ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked (ExtLedgerState blk) any → LedgerTables (Ticked (ExtLedgerState blk)) mk → Ticked (ExtLedgerState blk) mk Source # | |
LedgerTablesAreTrivial (Ticked (LedgerState blk)) ⇒ LedgerTablesAreTrivial (Ticked (ExtLedgerState blk)) Source # | |
Defined in Ouroboros.Consensus.Ledger.Extended Methods convertMapKind ∷ ∀ (mk ∷ MapKind) (mk' ∷ MapKind). Ticked (ExtLedgerState blk) mk → Ticked (ExtLedgerState blk) mk' Source # | |
NoThunks (Ticked (LedgerState (DualBlock m a)) mk) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual | |
Show (Ticked (f a)) ⇒ Show (((Ticked ∷ Type → Type) :.: f) a) Source # | |
NoThunks (Ticked (f a)) ⇒ NoThunks (((Ticked ∷ Type → Type) :.: f) a) Source # | |
data Ticked () Source # | |
Defined in Ouroboros.Consensus.Ticked | |
data Ticked (HardForkChainDepState xs ∷ Type) Source # | |
data Ticked (HeaderState blk ∷ Type) Source # | |
Defined in Ouroboros.Consensus.HeaderValidation | |
data Ticked (PBftState c ∷ Type) Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT | |
newtype Ticked (WrapChainDepState blk ∷ Type) Source # | |
Defined in Ouroboros.Consensus.TypeFamilyWrappers | |
type HeaderHash (Ticked l ∷ k) Source # | |
Defined in Ouroboros.Consensus.Ticked | |
type TxIn (Ticked l) Source # | |
Defined in Ouroboros.Consensus.Ledger.Tables.Basics | |
type TxOut (Ticked l) Source # | |
Defined in Ouroboros.Consensus.Ledger.Tables.Basics | |
data Ticked (LedgerState (HardForkBlock xs) ∷ MapKind → Type) (mk ∷ MapKind) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger data Ticked (LedgerState (HardForkBlock xs) ∷ MapKind → Type) (mk ∷ MapKind) = TickedHardForkLedgerState {} | |
data Ticked (LedgerState (DualBlock m a) ∷ MapKind → Type) (mk ∷ MapKind) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual data Ticked (LedgerState (DualBlock m a) ∷ MapKind → Type) (mk ∷ MapKind) = TickedDualLedgerState {} | |
data Ticked (ExtLedgerState blk ∷ MapKind → Type) (mk ∷ MapKind) Source # | |
Defined in Ouroboros.Consensus.Ledger.Extended data Ticked (ExtLedgerState blk ∷ MapKind → Type) (mk ∷ MapKind) = TickedExtLedgerState {
|
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
Enum WindowSize Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT.State Methods succ ∷ WindowSize → WindowSize # pred ∷ WindowSize → WindowSize # toEnum ∷ Int → WindowSize # fromEnum ∷ WindowSize → Int # enumFrom ∷ WindowSize → [WindowSize] # enumFromThen ∷ WindowSize → WindowSize → [WindowSize] # enumFromTo ∷ WindowSize → WindowSize → [WindowSize] # enumFromThenTo ∷ WindowSize → WindowSize → WindowSize → [WindowSize] # | |
Num WindowSize Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT.State Methods (+) ∷ WindowSize → WindowSize → WindowSize # (-) ∷ WindowSize → WindowSize → WindowSize # (*) ∷ WindowSize → WindowSize → WindowSize # negate ∷ WindowSize → WindowSize # abs ∷ WindowSize → WindowSize # signum ∷ WindowSize → WindowSize # | |
Integral WindowSize Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT.State Methods quot ∷ WindowSize → WindowSize → WindowSize # rem ∷ WindowSize → WindowSize → WindowSize # div ∷ WindowSize → WindowSize → WindowSize # mod ∷ WindowSize → WindowSize → WindowSize # quotRem ∷ WindowSize → WindowSize → (WindowSize, WindowSize) # divMod ∷ WindowSize → WindowSize → (WindowSize, WindowSize) # toInteger ∷ WindowSize → Integer # | |
Real WindowSize Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT.State Methods | |
Show WindowSize Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT.State Methods showsPrec ∷ Int → WindowSize → ShowS # show ∷ WindowSize → String # showList ∷ [WindowSize] → ShowS # | |
Eq WindowSize Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT.State | |
Ord WindowSize Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT.State Methods compare ∷ WindowSize → WindowSize → Ordering # (<) ∷ WindowSize → WindowSize → Bool # (<=) ∷ WindowSize → WindowSize → Bool # (>) ∷ WindowSize → WindowSize → Bool # (>=) ∷ WindowSize → WindowSize → Bool # max ∷ WindowSize → WindowSize → WindowSize # min ∷ WindowSize → WindowSize → WindowSize # |
Construction
append ∷ PBftCrypto c ⇒ WindowSize → PBftSigner c → PBftState c → PBftState c Source #
Append new signature
Drops the oldest signature, provided we have reached the required number.
Empty PBFT chain state
In other words, the PBFT chain state corresponding to genesis.
Queries
countSignatures ∷ PBftState c → Word64 Source #
Number of signatures in the window
This will be equal to the specified window size, unless near genesis
countSignedBy ∷ PBftCrypto 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.
lastSignedSlot ∷ PBftState 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
fromList ∷ PBftCrypto 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.
toList ∷ PBftState c → [PBftSigner c] Source #
Serialization
decodePBftState ∷ PBftCrypto c ⇒ ∀ s. Decoder s (PBftState c) Source #
encodePBftState ∷ PBftCrypto c ⇒ PBftState c → Encoding Source #