| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Protocol.PBFT
Synopsis
- data PBft c
- newtype PBftSignatureThreshold = PBftSignatureThreshold {}
- data PBftLedgerView c = PBftLedgerView {
- pbftDelegates :: !(Bimap (PBftVerKeyHash c) (PBftVerKeyHash c))
- data PBftFields c toSign = PBftFields {
- pbftIssuer :: VerKeyDSIGN (PBftDSIGN c)
- pbftGenKey :: VerKeyDSIGN (PBftDSIGN c)
- pbftSignature :: SignedDSIGN (PBftDSIGN c) toSign
- data PBftParams = PBftParams {}
- data PBftCanBeLeader c = PBftCanBeLeader {}
- data PBftIsLeader c = PBftIsLeader {
- pbftIsLeaderSignKey :: !(SignKeyDSIGN (PBftDSIGN c))
- pbftIsLeaderDlgCert :: !(PBftDelegationCert c)
- pbftWindowSize :: SecurityParam -> WindowSize
- pbftWindowExceedsThreshold :: PBftCrypto c => PBftWindowParams -> PBftState c -> PBftVerKeyHash c -> Either Word64 ()
- forgePBftFields :: forall 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
- data PBftValidateView c
- = forall signed.Signable (PBftDSIGN c) signed => PBftValidateRegular (PBftFields c signed) signed (ContextDSIGN (PBftDSIGN c))
- | PBftValidateBoundary
- pbftValidateRegular :: (SignedHeader hdr, Signable (PBftDSIGN c) (Signed hdr)) => ContextDSIGN (PBftDSIGN c) -> (hdr -> PBftFields c (Signed hdr)) -> hdr -> PBftValidateView c
- pbftValidateBoundary :: hdr -> PBftValidateView c
- data PBftCannotForge c
- pbftCheckCanForge :: forall 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
newtype PBftSignatureThreshold Source #
Signature threshold. This represents the proportion of blocks in a
pbftSignatureWindow-sized window which may be signed by any single key.
Constructors
| PBftSignatureThreshold | |
Fields | |
Instances
data PBftLedgerView c Source #
Constructors
| PBftLedgerView | |
Fields
| |
Instances
data PBftFields c toSign Source #
Constructors
| PBftFields | |
Fields
| |
Instances
data PBftParams Source #
Protocol parameters
Constructors
| PBftParams | |
Fields
| |
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.
Constructors
| PBftCanBeLeader | |
Fields | |
Instances
data PBftIsLeader c Source #
Information required to produce a block.
Constructors
| PBftIsLeader | |
Fields
| |
Instances
| Generic (PBftIsLeader c) Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT Associated Types type Rep (PBftIsLeader c) :: Type -> Type # Methods 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.1.0.0-GfJNvFcM6lj2s5utKAUPEp" '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)))) | |
pbftWindowSize :: SecurityParam -> WindowSize Source #
Window size used by PBFT
We set the window size to be equal to k.
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.
Forging
Arguments
| :: forall 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.
Associated Types
type PBftDSIGN c :: Type Source #
type PBftDelegationCert c = (d :: Type) | d -> c Source #
type PBftVerKeyHash c = (d :: Type) | d -> c Source #
Methods
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 Associated Types type PBftDSIGN PBftMockCrypto Source # type PBftDelegationCert PBftMockCrypto = (d :: Type) Source # type PBftVerKeyHash PBftMockCrypto = (d :: Type) Source # Methods dlgCertGenVerKey :: PBftDelegationCert PBftMockCrypto -> VerKeyDSIGN (PBftDSIGN PBftMockCrypto) Source # dlgCertDlgVerKey :: PBftDelegationCert PBftMockCrypto -> VerKeyDSIGN (PBftDSIGN PBftMockCrypto) Source # hashVerKey :: VerKeyDSIGN (PBftDSIGN PBftMockCrypto) -> PBftVerKeyHash PBftMockCrypto Source # | |
data PBftMockCrypto Source #
Instances
| PBftCrypto PBftMockCrypto Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT.Crypto Associated Types type PBftDSIGN PBftMockCrypto Source # type PBftDelegationCert PBftMockCrypto = (d :: Type) Source # type PBftVerKeyHash PBftMockCrypto = (d :: Type) Source # Methods dlgCertGenVerKey :: PBftDelegationCert PBftMockCrypto -> VerKeyDSIGN (PBftDSIGN PBftMockCrypto) Source # dlgCertDlgVerKey :: PBftDelegationCert PBftMockCrypto -> VerKeyDSIGN (PBftDSIGN PBftMockCrypto) Source # hashVerKey :: VerKeyDSIGN (PBftDSIGN PBftMockCrypto) -> PBftVerKeyHash PBftMockCrypto Source # | |
| type PBftDSIGN PBftMockCrypto Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT.Crypto | |
| type PBftDelegationCert PBftMockCrypto Source # | |
| type PBftVerKeyHash PBftMockCrypto Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT.Crypto | |
data PBftValidateView c Source #
Part of the header that we validate
Constructors
| forall 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. |
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
pbftValidateBoundary :: hdr -> PBftValidateView c Source #
Convenience constructor for PBftValidateView for boundary 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.
Constructors
| 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 :: forall 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 (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
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.
Constructors
| PBftInvalidSignature !Text | |
| PBftNotGenesisDelegate !(PBftVerKeyHash c) !(PBftLedgerView c) | |
| PBftExceededSignThreshold !(PBftVerKeyHash c) !Word64 | We record how many slots this key signed |
| PBftInvalidSlot |