Safe Haskell | None |
---|---|
Language | Haskell2010 |
PBFT chain state
Intended for qualified import.
Synopsis
-
data
PBftSigner
c =
PBftSigner
{
- pbftSignerSlotNo :: ! SlotNo
- pbftSignerGenesisKey :: !( PBftVerKeyHash c)
-
data
PBftState
c =
PBftState
{
- inWindow :: !( StrictSeq ( PBftSigner c))
- counts :: !( Map ( PBftVerKeyHash c) Word64 )
- data family Ticked st :: Type
- newtype WindowSize = WindowSize { }
- append :: forall c. 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 :: forall c. ( PBftCrypto c, Serialise ( PBftVerKeyHash c)) => forall s. Decoder s ( PBftState c)
- encodePBftState :: ( PBftCrypto c, Serialise ( PBftVerKeyHash c)) => PBftState c -> Encoding
Documentation
data PBftSigner c Source #
Slot and corresponding genesis key
PBftSigner | |
|
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).
PBftState | |
|
Instances
PBftCrypto c => Eq ( PBftState c) Source # | |
PBftCrypto c => Show ( PBftState c) Source # | |
Generic ( PBftState c) Source # | |
PBftCrypto c => NoThunks ( PBftState c) Source # | |
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.1.0.1-DT4Cvwf63DZKctsEvaJqCU" '
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 # | |
Defined in Ouroboros.Consensus.Protocol.PBFT
data
Ticked
(
PBftState
c) =
TickedPBftState
{
|
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
newtype WindowSize Source #
Window size
See
PBftState
itself for a detailed discussion on the window size
versus the number of signatures.
Instances
Construction
append :: forall c. 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 :: forall c. ( PBftCrypto c, Serialise ( PBftVerKeyHash c)) => forall s. Decoder s ( PBftState c) Source #
encodePBftState :: ( PBftCrypto c, Serialise ( PBftVerKeyHash c)) => PBftState c -> Encoding Source #