Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.Protocol.PBFT
Synopsis
- data PBft c
-
data
PBftCanBeLeader
c =
PBftCanBeLeader
{
- pbftCanBeLeaderCoreNodeId :: ! CoreNodeId
- pbftCanBeLeaderSignKey :: !( SignKeyDSIGN ( PBftDSIGN c))
- pbftCanBeLeaderDlgCert :: !( PBftDelegationCert c)
-
data
PBftFields
c toSign =
PBftFields
{
- pbftIssuer :: VerKeyDSIGN ( PBftDSIGN c)
- pbftGenKey :: VerKeyDSIGN ( PBftDSIGN c)
- pbftSignature :: SignedDSIGN ( PBftDSIGN c) toSign
-
data
PBftIsLeader
c =
PBftIsLeader
{
- pbftIsLeaderSignKey :: !( SignKeyDSIGN ( PBftDSIGN c))
- pbftIsLeaderDlgCert :: !( PBftDelegationCert c)
-
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 :: 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
- newtype PBftMockVerKeyHash = PBftMockVerKeyHash { }
-
data
PBftValidateView
c
- = forall 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 :: 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
- = PBftInvalidSignature ! Text
- | PBftNotGenesisDelegate !( PBftVerKeyHash c) !( PBftLedgerView c)
- | PBftExceededSignThreshold !( PBftVerKeyHash c) ! Word64
- | PBftInvalidSlot
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.
Constructors
PBftCanBeLeader | |
Fields
|
Instances
data PBftFields c toSign Source #
Constructors
PBftFields | |
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 Methods from :: PBftIsLeader c -> Rep ( PBftIsLeader c) x Source # to :: Rep ( PBftIsLeader c) x -> PBftIsLeader c Source # |
|
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.1-DT4Cvwf63DZKctsEvaJqCU" '
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 #
Constructors
PBftLedgerView | |
Fields
|
Instances
data PBftParams Source #
Protocol parameters
Constructors
PBftParams | |
Fields
|
Instances
Show PBftParams Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT |
|
Generic PBftParams Source # | |
Defined in Ouroboros.Consensus.Protocol.PBFT Methods from :: PBftParams -> Rep PBftParams x Source # to :: Rep PBftParams x -> PBftParams Source # |
|
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.1.0.1-DT4Cvwf63DZKctsEvaJqCU" '
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).
Constructors
PBftSelectView | |
Fields |
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
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
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 # | |
Defined in Ouroboros.Consensus.Protocol.PBFT.Crypto |
|
type PBftVerKeyHash PBftMockCrypto Source # | |
newtype PBftMockVerKeyHash Source #
We don't hash and just use the underlying
Word64
.
Constructors
PBftMockVerKeyHash | |
Fields |
Instances
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. |
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.
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 |