Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data PBft c
- data PBftCanBeLeader c = PBftCanBeLeader {}
- data PBftFields c toSign = PBftFields {
- pbftIssuer ∷ VerKeyDSIGN (PBftDSIGN c)
- pbftGenKey ∷ VerKeyDSIGN (PBftDSIGN c)
- pbftSignature ∷ SignedDSIGN (PBftDSIGN c) toSign
- data PBftIsLeader c = PBftIsLeader {}
- newtype PBftLedgerView c = PBftLedgerView {
- pbftDelegates ∷ Bimap (PBftVerKeyHash c) (PBftVerKeyHash c)
- data PBftParams = PBftParams {}
- data PBftSelectView = PBftSelectView {}
- newtype PBftSignatureThreshold = PBftSignatureThreshold {}
- mkPBftSelectView ∷ GetHeader blk ⇒ Header blk → PBftSelectView
- pbftWindowExceedsThreshold ∷ PBftCrypto c ⇒ PBftWindowParams → PBftState c → PBftVerKeyHash c → Either Word64 ()
- pbftWindowSize ∷ SecurityParam → WindowSize
- forgePBftFields ∷ ∀ c toSign. (PBftCrypto c, Signable (PBftDSIGN c) toSign) ⇒ (VerKeyDSIGN (PBftDSIGN c) → ContextDSIGN (PBftDSIGN c)) → IsLeader (PBft c) → toSign → PBftFields c toSign
- class (Typeable c, DSIGNAlgorithm (PBftDSIGN c), Condense (SigDSIGN (PBftDSIGN c)), Show (PBftVerKeyHash c), Ord (PBftVerKeyHash c), Eq (PBftVerKeyHash c), Show (PBftVerKeyHash c), NoThunks (PBftVerKeyHash c), NoThunks (PBftDelegationCert c)) ⇒ PBftCrypto c where
- type PBftDSIGN c ∷ Type
- type PBftDelegationCert c = (d ∷ Type) | d → c
- type PBftVerKeyHash c = (d ∷ Type) | d → c
- dlgCertGenVerKey ∷ PBftDelegationCert c → VerKeyDSIGN (PBftDSIGN c)
- dlgCertDlgVerKey ∷ PBftDelegationCert c → VerKeyDSIGN (PBftDSIGN c)
- hashVerKey ∷ VerKeyDSIGN (PBftDSIGN c) → PBftVerKeyHash c
- data PBftMockCrypto
- newtype PBftMockVerKeyHash = PBftMockVerKeyHash {}
- data PBftValidateView c
- = ∀ signed.Signable (PBftDSIGN c) signed ⇒ PBftValidateRegular (PBftFields c signed) signed (ContextDSIGN (PBftDSIGN c))
- | PBftValidateBoundary
- pbftValidateBoundary ∷ hdr → PBftValidateView c
- pbftValidateRegular ∷ (SignedHeader hdr, Signable (PBftDSIGN c) (Signed hdr)) ⇒ ContextDSIGN (PBftDSIGN c) → (hdr → PBftFields c (Signed hdr)) → hdr → PBftValidateView c
- data PBftCannotForge c
- pbftCheckCanForge ∷ ∀ c. PBftCrypto c ⇒ ConsensusConfig (PBft c) → PBftCanBeLeader c → SlotNo → Ticked (PBftState c) → Either (PBftCannotForge c) ()
- data family ConsensusConfig p ∷ Type
- data family Ticked st ∷ Type
- data PBftValidationErr c
Documentation
Permissive BFT
As defined in https://hydra.iohk.io/job/Cardano/cardano-ledger-specs/byronChainSpec/latest/download-by-type/doc-pdf/blockchain-spec
Instances
data PBftCanBeLeader c Source #
If we are a core node (i.e. a block producing node) we know which core node we are, and we have the operational key pair and delegation certificate.
Instances
data PBftFields c toSign Source #
PBftFields | |
|
Instances
data PBftIsLeader c Source #
Information required to produce a block.
PBftIsLeader | |
|
Instances
Generic (PBftIsLeader c) Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT type Rep (PBftIsLeader c) ∷ Type → Type # from ∷ PBftIsLeader c → Rep (PBftIsLeader c) x # to ∷ Rep (PBftIsLeader c) x → PBftIsLeader c # | |
PBftCrypto c ⇒ NoThunks (PBftIsLeader c) Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT | |
type Rep (PBftIsLeader c) Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT type Rep (PBftIsLeader c) = D1 ('MetaData "PBftIsLeader" "Ouroboros.Consensus.Protocol.PBFT" "ouroboros-consensus-0.21.0.0-inplace" 'False) (C1 ('MetaCons "PBftIsLeader" 'PrefixI 'True) (S1 ('MetaSel ('Just "pbftIsLeaderSignKey") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (SignKeyDSIGN (PBftDSIGN c))) :*: S1 ('MetaSel ('Just "pbftIsLeaderDlgCert") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PBftDelegationCert c)))) |
newtype PBftLedgerView c Source #
PBftLedgerView | |
|
Instances
data PBftParams Source #
Protocol parameters
PBftParams | |
|
Instances
Generic PBftParams Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT type Rep PBftParams ∷ Type → Type # from ∷ PBftParams → Rep PBftParams x # to ∷ Rep PBftParams x → PBftParams # | |
Show PBftParams Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT | |
NoThunks PBftParams Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT | |
type Rep PBftParams Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT type Rep PBftParams = D1 ('MetaData "PBftParams" "Ouroboros.Consensus.Protocol.PBFT" "ouroboros-consensus-0.21.0.0-inplace" 'False) (C1 ('MetaCons "PBftParams" 'PrefixI 'True) (S1 ('MetaSel ('Just "pbftSecurityParam") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SecurityParam) :*: (S1 ('MetaSel ('Just "pbftNumNodes") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NumCoreNodes) :*: S1 ('MetaSel ('Just "pbftSignatureThreshold") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PBftSignatureThreshold)))) |
data PBftSelectView Source #
Part of the header required for chain selection
EBBs share a block number with regular blocks, and so for chain selection we need to know if a block is an EBB or not (because a chain ending on an EBB with a particular block number is longer than a chain on a regular block with that same block number).
Instances
newtype PBftSignatureThreshold Source #
Signature threshold. This represents the proportion of blocks in a
pbftSignatureWindow
-sized window which may be signed by any single key.
Instances
Generic PBftSignatureThreshold Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT type Rep PBftSignatureThreshold ∷ Type → Type # | |
Show PBftSignatureThreshold Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT | |
Eq PBftSignatureThreshold Source # | |
NoThunks PBftSignatureThreshold Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT | |
type Rep PBftSignatureThreshold Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT type Rep PBftSignatureThreshold = D1 ('MetaData "PBftSignatureThreshold" "Ouroboros.Consensus.Protocol.PBFT" "ouroboros-consensus-0.21.0.0-inplace" 'True) (C1 ('MetaCons "PBftSignatureThreshold" 'PrefixI 'True) (S1 ('MetaSel ('Just "getPBftSignatureThreshold") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double))) |
mkPBftSelectView ∷ GetHeader blk ⇒ Header blk → PBftSelectView Source #
pbftWindowExceedsThreshold ∷ PBftCrypto c ⇒ PBftWindowParams → PBftState c → PBftVerKeyHash c → Either Word64 () Source #
Does the number of blocks signed by this key exceed the threshold?
Returns Just
the number of blocks signed if exceeded.
pbftWindowSize ∷ SecurityParam → WindowSize Source #
Window size used by PBFT
We set the window size to be equal to k.
Forging
∷ ∀ c toSign. (PBftCrypto c, Signable (PBftDSIGN c) toSign) | |
⇒ (VerKeyDSIGN (PBftDSIGN c) → ContextDSIGN (PBftDSIGN c)) | Construct DSIGN context given |
→ IsLeader (PBft c) | |
→ toSign | |
→ PBftFields c toSign |
Classes
class (Typeable c, DSIGNAlgorithm (PBftDSIGN c), Condense (SigDSIGN (PBftDSIGN c)), Show (PBftVerKeyHash c), Ord (PBftVerKeyHash c), Eq (PBftVerKeyHash c), Show (PBftVerKeyHash c), NoThunks (PBftVerKeyHash c), NoThunks (PBftDelegationCert c)) ⇒ PBftCrypto c where Source #
Crypto primitives required by BFT
Cardano stores a map of stakeholder IDs rather than the verification key directly. We make this family injective for convenience - whilst it's _possible_ that there could be non-injective instances, the chances of there being more than the two instances here are basically non-existent.
type PBftDSIGN c ∷ Type Source #
type PBftDelegationCert c = (d ∷ Type) | d → c Source #
type PBftVerKeyHash c = (d ∷ Type) | d → c Source #
dlgCertGenVerKey ∷ PBftDelegationCert c → VerKeyDSIGN (PBftDSIGN c) Source #
dlgCertDlgVerKey ∷ PBftDelegationCert c → VerKeyDSIGN (PBftDSIGN c) Source #
hashVerKey ∷ VerKeyDSIGN (PBftDSIGN c) → PBftVerKeyHash c Source #
Instances
PBftCrypto PBftMockCrypto Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT.Crypto type PBftDSIGN PBftMockCrypto Source # type PBftDelegationCert PBftMockCrypto = (d ∷ Type) Source # type PBftVerKeyHash PBftMockCrypto = (d ∷ Type) Source # |
data PBftMockCrypto Source #
Instances
PBftCrypto PBftMockCrypto Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT.Crypto type PBftDSIGN PBftMockCrypto Source # type PBftDelegationCert PBftMockCrypto = (d ∷ Type) Source # type PBftVerKeyHash PBftMockCrypto = (d ∷ Type) Source # | |
type PBftDSIGN PBftMockCrypto Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT.Crypto | |
type PBftDelegationCert PBftMockCrypto Source # | |
type PBftVerKeyHash PBftMockCrypto Source # | |
newtype PBftMockVerKeyHash Source #
We don't hash and just use the underlying Word64
.
Instances
data PBftValidateView c Source #
Part of the header that we validate
∀ signed.Signable (PBftDSIGN c) signed ⇒ PBftValidateRegular (PBftFields c signed) signed (ContextDSIGN (PBftDSIGN c)) | Regular block Regular blocks are signed, and so we need to validate them. We also need to know the slot number of the block |
PBftValidateBoundary | Boundary block (EBB) EBBs are not signed and they do not affect the consensus state. |
pbftValidateBoundary ∷ hdr → PBftValidateView c Source #
Convenience constructor for PBftValidateView
for boundary blocks
pbftValidateRegular ∷ (SignedHeader hdr, Signable (PBftDSIGN c) (Signed hdr)) ⇒ ContextDSIGN (PBftDSIGN c) → (hdr → PBftFields c (Signed hdr)) → hdr → PBftValidateView c Source #
Convenience constructor for PBftValidateView
for regular blocks
CannotForge
data PBftCannotForge c Source #
Expresses that, whilst we believe ourselves to be a leader for this slot, we are nonetheless unable to forge a block.
PBftCannotForgeInvalidDelegation !(PBftVerKeyHash c) | We cannot forge a block because we are not the current delegate of the genesis key we have a delegation certificate from. |
PBftCannotForgeThresholdExceeded !Word64 | We cannot lead because delegates of the genesis key we have a delegation from have already forged the maximum number of blocks in this signing window. |
Instances
pbftCheckCanForge ∷ ∀ c. PBftCrypto c ⇒ ConsensusConfig (PBft c) → PBftCanBeLeader c → SlotNo → Ticked (PBftState c) → Either (PBftCannotForge c) () Source #
Type instances
data family ConsensusConfig p ∷ Type Source #
Static configuration required to run the consensus protocol
Every method in the ConsensusProtocol
class takes the consensus
configuration as a parameter, so having this as a data family rather than a
type family resolves most ambiguity.
Defined out of the class so that protocols can define this type without having to define the entire protocol at the same time (or indeed in the same module).
Instances
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
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
Exported for tracing errors
data PBftValidationErr c Source #
NOTE: this type is stored in the state, so it must be in normal form to avoid space leaks.
PBftInvalidSignature !Text | |
PBftNotGenesisDelegate !(PBftVerKeyHash c) !(PBftLedgerView c) | |
PBftExceededSignThreshold !(PBftVerKeyHash c) !Word64 | We record how many slots this key signed |
PBftInvalidSlot |