| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Protocol.PolyPraos
Contents
Description
Praos, and the pieces every protocol built on Praos shares.
Each such protocol is its own proto type with its own instances, so that
none of Praos's rules are reused by accident. The data types, however, are
shared: they carry a proto parameter, so that there is one definition of
each Praos concept regardless of which extensions the protocol enables. The
functions suffixed PolyPraos are the method implementations every such
protocol delegates to.
Poly means "many": a PolyPraos type or function handles multiple
extensions of/overlays on Praos, the ones used for Cardano. And the
PolyPraos functions are indeed polymorphic in the proto tyvar.
This is not a fully modular design: subsequent additional extensions will also need to add to these same definitions (eg adding fields for Ouroboros Phalanx). That is intentional. This code does not need to be classically extensible, since there is, unfortunately, no such thing as an extensible security proof. Our protocol changes are well studied before implemented, and have never happened concurrently.
In other words: it's a very important benefit that there is one definition
to look at in order to see everything all of the Praos extensions
cumulatively do. The type-level DSL used to isolate extension components is
simple and legible; see the LeiosOnly data family, for example.
Synopsis
- class (Crypto c, Signable DSIGN (OCertSignable c), Signable (VRF c) InputVRF, Signable (KES c) (Signed (ShelleyProtocolHeader proto))) ⇒ PolyPraosCrypto proto c
- data PolyPraosState proto = PraosState {
- praosStateLastSlot ∷ !(WithOrigin SlotNo)
- praosStateOCertCounters ∷ !(Map (KeyHash 'BlockIssuer) Word64)
- praosStateEvolvingNonce ∷ !Nonce
- praosStateCandidateNonce ∷ !Nonce
- praosStateEpochNonce ∷ !Nonce
- praosStatePreviousEpochNonce ∷ !Nonce
- praosStateLabNonce ∷ !Nonce
- praosStateLastEpochBlockNonce ∷ !Nonce
- praosStateLeiosAnnouncement ∷ !(WhenLeios proto (Either WhyNotCertifiable LeiosAnnouncement))
- data PolyPraosValidationErr proto c
- = VRFKeyUnknown !(KeyHash 'StakePool)
- | VRFKeyWrongVRFKey !(KeyHash 'StakePool) !(Hash HASH (VerKeyVRF (VRF c))) !(Hash HASH (VerKeyVRF (VRF c)))
- | VRFKeyBadProof !SlotNo !Nonce !(CertifiedVRF (VRF c) InputVRF)
- | VRFLeaderValueTooBig Natural Rational ActiveSlotCoeff
- | KESBeforeStartOCERT !KESPeriod !KESPeriod
- | KESAfterEndOCERT !KESPeriod !KESPeriod !Word64
- | CounterTooSmallOCERT !Word64 !Word64
- | CounterOverIncrementedOCERT !Word64 !Word64
- | InvalidSignatureOCERT !Word64 !KESPeriod !String
- | InvalidKesSignatureOCERT !Word !Word !Word !Word64 !String
- | NoCounterForKeyHashOCERT !(KeyHash 'BlockIssuer)
- | LeiosCertWithoutAnnouncement !(VoidUnlessLeios proto ()) !WhyNotCertifiable !(WithOrigin SlotNo) !SlotNo
- | LeiosCertTooYoung !(VoidUnlessLeios proto ()) !SlotNo !SlotNo !SlotNo
- | LeiosEbTooBig !(VoidUnlessLeios proto ()) !Word32 !Word32
- data PraosCannotForge c = PraosCannotForgeKeyNotUsableYet !KESPeriod !KESPeriod
- data PraosFields c toSign = PraosFields {
- praosSignature ∷ SignedKES (KES c) toSign
- praosToSign ∷ toSign
- newtype PraosIsLeader c = PraosIsLeader {}
- data PraosParams = PraosParams {}
- data PraosToSign c = PraosToSign {}
- type SerialisePraosState proto = (Typeable proto, Applicative (WhenLeios proto), Traversable (WhenLeios proto))
- data family Ticked (st ∷ k) ∷ k
- checkIsLeaderPolyPraos ∷ PolyPraosCrypto proto c ⇒ PraosParams → PraosCanBeLeader c → SlotNo → Ticked (PolyPraosState proto) → Maybe (PraosIsLeader c)
- forgePraosFields ∷ (Crypto c, Signable (KES c) toSign, Monad m) ⇒ HotKey c m → PraosCanBeLeader c → PraosIsLeader c → (PraosToSign c → toSign) → m (PraosFields c toSign)
- getOpCertCountersPolyPraos ∷ PolyPraosState proto → Map (KeyHash 'BlockIssuer) Word64
- getPraosNoncesPolyPraos ∷ PolyPraosState proto → PraosNonces
- leiosContextFreeHeaderChecks ∷ (Applicative (WhenLeios proto), Foldable (WhenLeios proto), TypeSwitch (LeiosOnly proto)) ⇒ PolyPraosLedgerView proto → PolyPraosValidateView proto c → Except (PolyPraosValidationErr proto c) ()
- markUncertifiable ∷ WhyNotCertifiable → Either WhyNotCertifiable LeiosAnnouncement → Either WhyNotCertifiable LeiosAnnouncement
- praosCheckCanForge ∷ PraosParams → SlotNo → KESInfo → Either (PraosCannotForge c) ()
- reupdateChainDepStatePolyPraos ∷ Functor (WhenLeios proto) ⇒ PraosParams → EpochInfo (Except PastHorizonException) → PolyPraosValidateView proto c → SlotNo → Ticked (PolyPraosState proto) → PolyPraosState proto
- updateChainDepStatePolyPraos ∷ (PolyPraosCrypto proto c, Applicative (WhenLeios proto), Foldable (WhenLeios proto), TypeSwitch (LeiosOnly proto)) ⇒ PraosParams → EpochInfo (Except PastHorizonException) → PolyPraosValidateView proto c → SlotNo → Ticked (PolyPraosState proto) → Except (PolyPraosValidationErr proto c) (PolyPraosState proto)
- tickChainDepStatePolyPraos ∷ Functor (WhenLeios proto) ⇒ EpochInfo (Except PastHorizonException) → PolyPraosLedgerView proto → SlotNo → PolyPraosState proto → Ticked (PolyPraosState proto)
- validateKESSignature ∷ PolyPraosCrypto proto c ⇒ PraosParams → PolyPraosLedgerView proto → Map (KeyHash 'BlockIssuer) Word64 → PolyPraosValidateView proto c → Except (PolyPraosValidationErr proto c) ()
- validateVRFSignature ∷ PolyPraosCrypto proto c ⇒ Nonce → PolyPraosLedgerView proto → ActiveSlotCoeff → PolyPraosValidateView proto c → Except (PolyPraosValidationErr proto c) ()
- doValidateKESSignature ∷ PolyPraosCrypto proto c ⇒ Word64 → Word64 → Map (KeyHash 'StakePool) IndividualPoolStake → Map (KeyHash 'BlockIssuer) Word64 → PolyPraosValidateView proto c → Except (PolyPraosValidationErr proto c) ()
- doValidateKESSignature' ∷ PolyPraosCrypto proto c ⇒ WhetherToUpperBoundOCERT → Word64 → Word64 → Map (KeyHash 'StakePool) IndividualPoolStake → Map (KeyHash 'BlockIssuer) Word64 → PolyPraosValidateView proto c → Except (PolyPraosValidationErr proto c) ()
- getLeiosAnnouncementPolyPraos ∷ Foldable (WhenLeios proto) ⇒ PolyPraosValidateView proto c → Maybe LeiosAnnouncement
- getLeiosLedgerViewPolyPraos ∷ Foldable (WhenLeios proto) ⇒ PolyPraosLedgerView proto → Maybe LeiosLedgerView
- validateLeiosAnnouncementPolyPraos ∷ (PolyPraosCrypto proto c, Applicative (WhenLeios proto), Foldable (WhenLeios proto), TypeSwitch (LeiosOnly proto)) ⇒ PraosParams → PolyPraosValidateView proto c → Ticked (PolyPraosState proto) → Except (PolyPraosValidationErr proto c) OCINStaleness
- data WhetherToUpperBoundOCERT
- data WhyNotCertifiable
- doValidateVRFSignature ∷ PolyPraosCrypto proto c ⇒ Nonce → Map (KeyHash 'StakePool) IndividualPoolStake → ActiveSlotCoeff → PolyPraosValidateView proto c → Except (PolyPraosValidationErr proto c) ()
Documentation
class (Crypto c, Signable DSIGN (OCertSignable c), Signable (VRF c) InputVRF, Signable (KES c) (Signed (ShelleyProtocolHeader proto))) ⇒ PolyPraosCrypto proto c Source #
What a protocol needs of its crypto: the Praos essentials, plus signing whichever header body it is the protocol for.
Instances
data PolyPraosState proto Source #
Praos consensus state.
We track the last slot and the counters for operational certificates, as well as a series of nonces which get updated in different ways over the course of an epoch.
Constructors
| PraosState | |
Fields
| |
Instances
data PolyPraosValidationErr proto c Source #
Errors which we might encounter
Constructors
| VRFKeyUnknown !(KeyHash 'StakePool) | |
| VRFKeyWrongVRFKey !(KeyHash 'StakePool) !(Hash HASH (VerKeyVRF (VRF c))) !(Hash HASH (VerKeyVRF (VRF c))) | |
| VRFKeyBadProof !SlotNo !Nonce !(CertifiedVRF (VRF c) InputVRF) | |
| VRFLeaderValueTooBig Natural Rational ActiveSlotCoeff | |
| KESBeforeStartOCERT !KESPeriod !KESPeriod | |
| KESAfterEndOCERT !KESPeriod !KESPeriod !Word64 | |
| CounterTooSmallOCERT !Word64 !Word64 | |
| CounterOverIncrementedOCERT !Word64 !Word64 | The KES counter has been incremented by more than 1 |
| InvalidSignatureOCERT !Word64 !KESPeriod !String | |
| InvalidKesSignatureOCERT !Word !Word !Word !Word64 !String | |
| NoCounterForKeyHashOCERT !(KeyHash 'BlockIssuer) | |
| LeiosCertWithoutAnnouncement !(VoidUnlessLeios proto ()) !WhyNotCertifiable !(WithOrigin SlotNo) !SlotNo | The header sets its cert bit, but there is no announcement for the certificate to certify. |
| LeiosCertTooYoung !(VoidUnlessLeios proto ()) !SlotNo !SlotNo !SlotNo | The header sets its cert bit too soon after its predecessor's announcement: the announcement, voting and diffusion periods have not all elapsed. |
| LeiosEbTooBig !(VoidUnlessLeios proto ()) !Word32 !Word32 | The header announces an endorser block larger than the protocol parameters allow. |
Instances
| (Crypto c, Eq (VoidUnlessLeios proto ())) ⇒ Eq (PolyPraosValidationErr proto c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos Methods (==) ∷ PolyPraosValidationErr proto c → PolyPraosValidationErr proto c → Bool # (/=) ∷ PolyPraosValidationErr proto c → PolyPraosValidationErr proto c → Bool # | |||||
| Generic (PolyPraosValidationErr proto c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos Associated Types
Methods from ∷ PolyPraosValidationErr proto c → Rep (PolyPraosValidationErr proto c) x # to ∷ Rep (PolyPraosValidationErr proto c) x → PolyPraosValidationErr proto c # | |||||
| (Crypto c, Show (VoidUnlessLeios proto ())) ⇒ Show (PolyPraosValidationErr proto c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos Methods showsPrec ∷ Int → PolyPraosValidationErr proto c → ShowS # show ∷ PolyPraosValidationErr proto c → String # showList ∷ [PolyPraosValidationErr proto c] → ShowS # | |||||
| (Typeable proto, Crypto c, NoThunks (VoidUnlessLeios proto ())) ⇒ NoThunks (PolyPraosValidationErr proto c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos | |||||
| type Rep (PolyPraosValidationErr proto c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos type Rep (PolyPraosValidationErr proto c) = D1 ('MetaData "PolyPraosValidationErr" "Ouroboros.Consensus.Protocol.PolyPraos" "ouroboros-consensus-5.0.0.0-inplace-protocol" 'False) (((C1 ('MetaCons "VRFKeyUnknown" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'StakePool))) :+: (C1 ('MetaCons "VRFKeyWrongVRFKey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'StakePool)) :*: (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Hash HASH (VerKeyVRF (VRF c)))) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Hash HASH (VerKeyVRF (VRF c)))))) :+: C1 ('MetaCons "VRFKeyBadProof" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo) :*: (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Nonce) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (CertifiedVRF (VRF c) InputVRF)))))) :+: ((C1 ('MetaCons "VRFLeaderValueTooBig" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Natural) :*: (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Rational) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ActiveSlotCoeff))) :+: C1 ('MetaCons "KESBeforeStartOCERT" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 KESPeriod) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 KESPeriod))) :+: (C1 ('MetaCons "KESAfterEndOCERT" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 KESPeriod) :*: (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 KESPeriod) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64))) :+: C1 ('MetaCons "CounterTooSmallOCERT" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64))))) :+: ((C1 ('MetaCons "CounterOverIncrementedOCERT" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64)) :+: (C1 ('MetaCons "InvalidSignatureOCERT" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 KESPeriod) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String))) :+: C1 ('MetaCons "InvalidKesSignatureOCERT" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word)) :*: (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word) :*: (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String)))))) :+: ((C1 ('MetaCons "NoCounterForKeyHashOCERT" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'BlockIssuer))) :+: C1 ('MetaCons "LeiosCertWithoutAnnouncement" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (VoidUnlessLeios proto ())) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 WhyNotCertifiable)) :*: (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (WithOrigin SlotNo)) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo)))) :+: (C1 ('MetaCons "LeiosCertTooYoung" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (VoidUnlessLeios proto ())) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo)) :*: (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo))) :+: C1 ('MetaCons "LeiosEbTooBig" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (VoidUnlessLeios proto ())) :*: (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word32) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word32))))))) | |||||
data PraosCannotForge c Source #
Expresses that, whilst we believe ourselves to be a leader for this slot, we are nonetheless unable to forge a block.
Constructors
| PraosCannotForgeKeyNotUsableYet | The KES key in our operational certificate can't be used because the current (wall clock) period is before the start period of the key. current KES period. Note: the opposite case, i.e., the wall clock period being after the
end period of the key, is caught when trying to update the key in
|
Instances
| Generic (PraosCannotForge c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos Associated Types
Methods from ∷ PraosCannotForge c → Rep (PraosCannotForge c) x # to ∷ Rep (PraosCannotForge c) x → PraosCannotForge c # | |||||
| Crypto c ⇒ Show (PraosCannotForge c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos Methods showsPrec ∷ Int → PraosCannotForge c → ShowS # show ∷ PraosCannotForge c → String # showList ∷ [PraosCannotForge c] → ShowS # | |||||
| type Rep (PraosCannotForge c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos type Rep (PraosCannotForge c) = D1 ('MetaData "PraosCannotForge" "Ouroboros.Consensus.Protocol.PolyPraos" "ouroboros-consensus-5.0.0.0-inplace-protocol" 'False) (C1 ('MetaCons "PraosCannotForgeKeyNotUsableYet" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 KESPeriod) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 KESPeriod))) | |||||
data PraosFields c toSign Source #
Constructors
| PraosFields | |
Fields
| |
Instances
| Generic (PraosFields c toSign) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos Associated Types
Methods from ∷ PraosFields c toSign → Rep (PraosFields c toSign) x # to ∷ Rep (PraosFields c toSign) x → PraosFields c toSign # | |||||
| (Show toSign, Crypto c) ⇒ Show (PraosFields c toSign) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos Methods showsPrec ∷ Int → PraosFields c toSign → ShowS # show ∷ PraosFields c toSign → String # showList ∷ [PraosFields c toSign] → ShowS # | |||||
| (NoThunks toSign, Crypto c) ⇒ NoThunks (PraosFields c toSign) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos | |||||
| type Rep (PraosFields c toSign) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos type Rep (PraosFields c toSign) = D1 ('MetaData "PraosFields" "Ouroboros.Consensus.Protocol.PolyPraos" "ouroboros-consensus-5.0.0.0-inplace-protocol" 'False) (C1 ('MetaCons "PraosFields" 'PrefixI 'True) (S1 ('MetaSel ('Just "praosSignature") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SignedKES (KES c) toSign)) :*: S1 ('MetaSel ('Just "praosToSign") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 toSign))) | |||||
newtype PraosIsLeader c Source #
Assembled proof that the issuer has the right to issue a block in the selected slot.
Constructors
| PraosIsLeader | |
Fields | |
Instances
| Generic (PraosIsLeader c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos Associated Types
Methods from ∷ PraosIsLeader c → Rep (PraosIsLeader c) x # to ∷ Rep (PraosIsLeader c) x → PraosIsLeader c # | |||||
| Crypto c ⇒ NoThunks (PraosIsLeader c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos | |||||
| type Rep (PraosIsLeader c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos type Rep (PraosIsLeader c) = D1 ('MetaData "PraosIsLeader" "Ouroboros.Consensus.Protocol.PolyPraos" "ouroboros-consensus-5.0.0.0-inplace-protocol" 'True) (C1 ('MetaCons "PraosIsLeader" 'PrefixI 'True) (S1 ('MetaSel ('Just "praosIsLeaderVrfRes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (CertifiedVRF (VRF c) InputVRF)))) | |||||
data PraosParams Source #
Praos parameters that are node independent
Constructors
| PraosParams | |
Fields
| |
Instances
| Generic PraosParams Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos Associated Types
| |||||
| NoThunks PraosParams Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos | |||||
| type Rep PraosParams Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos type Rep PraosParams = D1 ('MetaData "PraosParams" "Ouroboros.Consensus.Protocol.PolyPraos" "ouroboros-consensus-5.0.0.0-inplace-protocol" 'False) (C1 ('MetaCons "PraosParams" 'PrefixI 'True) ((S1 ('MetaSel ('Just "praosSlotsPerKESPeriod") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: (S1 ('MetaSel ('Just "praosLeaderF") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ActiveSlotCoeff) :*: S1 ('MetaSel ('Just "praosSecurityParam") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SecurityParam))) :*: (S1 ('MetaSel ('Just "praosMaxKESEvo") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: (S1 ('MetaSel ('Just "praosMaxMajorPV") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 MaxMajorProtVer) :*: S1 ('MetaSel ('Just "praosRandomnessStabilisationWindow") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64))))) | |||||
data PraosToSign c Source #
Fields arising from praos execution which must be included in the block signature.
Constructors
| PraosToSign | |
Fields
| |
Instances
| Generic (PraosToSign c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos Associated Types
| |||||
| Crypto c ⇒ Show (PraosToSign c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos Methods showsPrec ∷ Int → PraosToSign c → ShowS # show ∷ PraosToSign c → String # showList ∷ [PraosToSign c] → ShowS # | |||||
| Crypto c ⇒ NoThunks (PraosToSign c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos | |||||
| type Rep (PraosToSign c) Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos type Rep (PraosToSign c) = D1 ('MetaData "PraosToSign" "Ouroboros.Consensus.Protocol.PolyPraos" "ouroboros-consensus-5.0.0.0-inplace-protocol" 'False) (C1 ('MetaCons "PraosToSign" 'PrefixI 'True) ((S1 ('MetaSel ('Just "praosToSignIssuerVK") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VKey 'BlockIssuer)) :*: S1 ('MetaSel ('Just "praosToSignVrfVK") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VerKeyVRF (VRF c)))) :*: (S1 ('MetaSel ('Just "praosToSignVrfRes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (CertifiedVRF (VRF c) InputVRF)) :*: S1 ('MetaSel ('Just "praosToSignOCert") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (OCert c))))) | |||||
type SerialisePraosState proto = (Typeable proto, Applicative (WhenLeios proto), Traversable (WhenLeios proto)) Source #
What encoding PolyPraosState needs of its protocol.
LeiosOnly decides which fields are written. There is no inner version: the
snapshot version covers it, and the HFC's era index precedes it, so the codec
is already chosen when it is read.
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.
Ticked is used mainly in two ways:
Ticked (Ext)LedgerStatewhere its kind gets concretized toStateKind -> StateKindTicked (HeaderState blk)where its kind gets concretized toType -> Type
Instances
| Show (Ticked ()) Source # | |
| ChainDepStateSupportsPeras (Ticked (ChainDepState (BlockProtocol blk))) ⇒ ChainDepStateSupportsPeras (Ticked (HeaderState blk)) Source # | |
Defined in Ouroboros.Consensus.HeaderValidation Methods getEpochNonce ∷ Ticked (HeaderState blk) → Nonce Source # | |
| ChainDepStateSupportsPeras (Ticked (PolyPraosState proto)) Source # | |
Defined in Ouroboros.Consensus.Protocol.PolyPraos Methods getEpochNonce ∷ Ticked (PolyPraosState proto) → Nonce Source # | |
| ChainDepStateSupportsPeras (Ticked TPraosState) Source # | |
Defined in Ouroboros.Consensus.Protocol.TPraos Methods | |
| ChainDepStateSupportsPeras (Ticked ()) Source # | |
Defined in Ouroboros.Consensus.Protocol.Abstract Methods getEpochNonce ∷ Ticked () → Nonce Source # | |
| (NoThunks (TxIn blk), NoThunks (TxOut blk), HasLedgerTables (Ticked 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 blk mk Source # withLedgerTables ∷ ∀ (mk ∷ MapKind) (any ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked ExtLedgerState blk any → LedgerTables blk mk → Ticked ExtLedgerState blk mk Source # | |
| (Bridge m a, HasLedgerTables (Ticked 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 (DualBlock m a) mk Source # withLedgerTables ∷ ∀ (mk ∷ MapKind) (any ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked LedgerState (DualBlock m a) any → LedgerTables (DualBlock m a) mk → Ticked LedgerState (DualBlock m a) mk 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 # | |
| LedgerStateSupportsPeras (Ticked LedgerState (DualBlock m a)) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual Methods getPoolDistr ∷ Ticked LedgerState (DualBlock m a) EmptyMK → PoolDistr Source # getPerasParams ∷ proxy blk → Ticked LedgerState (DualBlock m a) EmptyMK → PerasParams blk 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 TPraosState 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 | |
| data Ticked (PolyPraosState proto ∷ Type) Source # | |
Defined in Ouroboros.Consensus.Protocol.PolyPraos | |
| type HeaderHash (Ticked l blk ∷ k2) Source # | |
Defined in Ouroboros.Consensus.Ticked | |
| data Ticked ExtLedgerState (blk ∷ Type) (mk ∷ MapKind) Source # | |
Defined in Ouroboros.Consensus.Ledger.Extended data Ticked ExtLedgerState (blk ∷ Type) (mk ∷ MapKind) = TickedExtLedgerState {
| |
| data Ticked LedgerState (HardForkBlock xs ∷ Type) (mk ∷ MapKind) Source # | |
| data Ticked LedgerState (DualBlock m a ∷ Type) (mk ∷ MapKind) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual | |
checkIsLeaderPolyPraos ∷ PolyPraosCrypto proto c ⇒ PraosParams → PraosCanBeLeader c → SlotNo → Ticked (PolyPraosState proto) → Maybe (PraosIsLeader c) Source #
checkIsLeader for every Praos.
forgePraosFields ∷ (Crypto c, Signable (KES c) toSign, Monad m) ⇒ HotKey c m → PraosCanBeLeader c → PraosIsLeader c → (PraosToSign c → toSign) → m (PraosFields c toSign) Source #
getOpCertCountersPolyPraos ∷ PolyPraosState proto → Map (KeyHash 'BlockIssuer) Word64 Source #
getOpCertCounters for every Praos.
getPraosNoncesPolyPraos ∷ PolyPraosState proto → PraosNonces Source #
getPraosNonces for every Praos.
leiosContextFreeHeaderChecks ∷ (Applicative (WhenLeios proto), Foldable (WhenLeios proto), TypeSwitch (LeiosOnly proto)) ⇒ PolyPraosLedgerView proto → PolyPraosValidateView proto c → Except (PolyPraosValidationErr proto c) () Source #
The Leios header checks that read only the header and the ledger view.
Sound out of context: the bound they check is forecast for the header's own slot, so any path that validates the header reads the same value.
They run only for protocols with Leios, which are the ones that fill
typeSwitchR.
markUncertifiable ∷ WhyNotCertifiable → Either WhyNotCertifiable LeiosAnnouncement → Either WhyNotCertifiable LeiosAnnouncement Source #
What the next header may certify after crossing a boundary that rules out certifying the pending announcement, for this reason.
praosCheckCanForge ∷ PraosParams → SlotNo → KESInfo → Either (PraosCannotForge c) () Source #
reupdateChainDepStatePolyPraos ∷ Functor (WhenLeios proto) ⇒ PraosParams → EpochInfo (Except PastHorizonException) → PolyPraosValidateView proto c → SlotNo → Ticked (PolyPraosState proto) → PolyPraosState proto Source #
reupdateChainDepState for every Praos.
Re-update the chain dependent state as a result of processing a header.
This consists of: - Update the last applied block hash. - Update the evolving and (potentially) candidate nonces based on the position in the epoch. - Update the operational certificate counter. - Record the header's announcement, if any, replacing the previous one.
updateChainDepStatePolyPraos ∷ (PolyPraosCrypto proto c, Applicative (WhenLeios proto), Foldable (WhenLeios proto), TypeSwitch (LeiosOnly proto)) ⇒ PraosParams → EpochInfo (Except PastHorizonException) → PolyPraosValidateView proto c → SlotNo → Ticked (PolyPraosState proto) → Except (PolyPraosValidationErr proto c) (PolyPraosState proto) Source #
updateChainDepState for every Praos.
Validate and update the chain dependent state as a result of processing a new header.
This consists of:
- Validate the VRF checks
- Validate the KES checks
- Call reupdateChainDepState
tickChainDepStatePolyPraos ∷ Functor (WhenLeios proto) ⇒ EpochInfo (Except PastHorizonException) → PolyPraosLedgerView proto → SlotNo → PolyPraosState proto → Ticked (PolyPraosState proto) Source #
tickChainDepState for every Praos.
Updating the chain dependent state for Praos.
If we are not in a new epoch, then nothing happens. If we are in a new epoch, we do four things: - Store the existing current epoch nonce as the "previous epoch" nonce. This is needed to validate Peras certificates when they appear in blocks. - Update the epoch nonce to the combination of the candidate nonce and the nonce derived from the last block of the previous epoch. - Update the "last block of previous epoch" nonce to the nonce derived from the last applied block. - Mark the pending announcement as no longer certifiable, since an endorser block may not be certified across an epoch boundary.
validateKESSignature ∷ PolyPraosCrypto proto c ⇒ PraosParams → PolyPraosLedgerView proto → Map (KeyHash 'BlockIssuer) Word64 → PolyPraosValidateView proto c → Except (PolyPraosValidationErr proto c) () Source #
validateVRFSignature ∷ PolyPraosCrypto proto c ⇒ Nonce → PolyPraosLedgerView proto → ActiveSlotCoeff → PolyPraosValidateView proto c → Except (PolyPraosValidationErr proto c) () Source #
For testing purposes
doValidateKESSignature ∷ PolyPraosCrypto proto c ⇒ Word64 → Word64 → Map (KeyHash 'StakePool) IndividualPoolStake → Map (KeyHash 'BlockIssuer) Word64 → PolyPraosValidateView proto c → Except (PolyPraosValidationErr proto c) () Source #
doValidateKESSignature' ∷ PolyPraosCrypto proto c ⇒ WhetherToUpperBoundOCERT → Word64 → Word64 → Map (KeyHash 'StakePool) IndividualPoolStake → Map (KeyHash 'BlockIssuer) Word64 → PolyPraosValidateView proto c → Except (PolyPraosValidationErr proto c) () Source #
doValidateKESSignature, parameterized by whether to
enforce the OCERT counter's upper bound (see WhetherToUpperBoundOCERT).
getLeiosAnnouncementPolyPraos ∷ Foldable (WhenLeios proto) ⇒ PolyPraosValidateView proto c → Maybe LeiosAnnouncement Source #
getLeiosAnnouncement for every Praos.
getLeiosLedgerViewPolyPraos ∷ Foldable (WhenLeios proto) ⇒ PolyPraosLedgerView proto → Maybe LeiosLedgerView Source #
getLeiosLedgerView for every Praos.
validateLeiosAnnouncementPolyPraos ∷ (PolyPraosCrypto proto c, Applicative (WhenLeios proto), Foldable (WhenLeios proto), TypeSwitch (LeiosOnly proto)) ⇒ PraosParams → PolyPraosValidateView proto c → Ticked (PolyPraosState proto) → Except (PolyPraosValidationErr proto c) OCINStaleness Source #
validateLeiosAnnouncement for every Praos.
The election proof (VRF) and the signature (KES and operational certificate)
are checked in full. The operational certificate counter is not upper
bounded, since a counter ahead of our immutable tip's record is honest lag.
A counter below that record, or no record at all, yields StaleOCIN rather
than a rejection, since that lag can explain either too. The certification
gap check is skipped: it needs the header's predecessor, and an
announcement is checked without one.
data WhetherToUpperBoundOCERT Source #
Whether doValidateKESSignature' enforces the OCERT counter's upper
bound, i.e. rejects (with CounterOverIncrementedOCERT) a counter more than
one greater than the one we have recorded for this issuer.
Normal header validation enforces it (UpperBoundOCERT). Validating a
relayed Leios announcement out-of-context against a (possibly lagging)
immutable tip legitimately sees counters that have run ahead of our recorded
view, so that path skips it (DoNotUpperBoundOCERT). The counter's lower
bound (CounterTooSmallOCERT, a revoked key) is enforced either way.
Constructors
| UpperBoundOCERT | |
| DoNotUpperBoundOCERT |
Instances
| Eq WhetherToUpperBoundOCERT Source # | |
Defined in Ouroboros.Consensus.Protocol.PolyPraos | |
| Show WhetherToUpperBoundOCERT Source # | |
Defined in Ouroboros.Consensus.Protocol.PolyPraos Methods showsPrec ∷ Int → WhetherToUpperBoundOCERT → ShowS # | |
data WhyNotCertifiable Source #
Why the next header may certify no announcement.
Constructors
| NothingAnnounced | The most recently applied header carried none. |
| AnnouncedInPreviousEra | It was announced in the previous era, and an endorser block may not be certified across an era boundary. |
| AnnouncedInPreviousEpoch | It was announced in the previous epoch, and an endorser block may not be certified across an epoch boundary. (This restriction avoids some engineering complexity that wouldn't be worthwhile, since this restriction only loses one EB opportunity per epoch.) |
Instances
| Semigroup WhyNotCertifiable Source # | Keeps the more specific reason: An era boundary is also an epoch boundary, and either may be crossed first, so neither may trample the other's more specific reason. | ||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos Methods (<>) ∷ WhyNotCertifiable → WhyNotCertifiable → WhyNotCertifiable # sconcat ∷ NonEmpty WhyNotCertifiable → WhyNotCertifiable # stimes ∷ Integral b ⇒ b → WhyNotCertifiable → WhyNotCertifiable # | |||||
| Eq WhyNotCertifiable Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos Methods | |||||
| Generic WhyNotCertifiable Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos Associated Types
Methods from ∷ WhyNotCertifiable → Rep WhyNotCertifiable x # to ∷ Rep WhyNotCertifiable x → WhyNotCertifiable # | |||||
| Show WhyNotCertifiable Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos Methods showsPrec ∷ Int → WhyNotCertifiable → ShowS # show ∷ WhyNotCertifiable → String # showList ∷ [WhyNotCertifiable] → ShowS # | |||||
| NoThunks WhyNotCertifiable Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos | |||||
| type Rep WhyNotCertifiable Source # | |||||
Defined in Ouroboros.Consensus.Protocol.PolyPraos type Rep WhyNotCertifiable = D1 ('MetaData "WhyNotCertifiable" "Ouroboros.Consensus.Protocol.PolyPraos" "ouroboros-consensus-5.0.0.0-inplace-protocol" 'False) (C1 ('MetaCons "NothingAnnounced" 'PrefixI 'False) (U1 ∷ Type → Type) :+: (C1 ('MetaCons "AnnouncedInPreviousEra" 'PrefixI 'False) (U1 ∷ Type → Type) :+: C1 ('MetaCons "AnnouncedInPreviousEpoch" 'PrefixI 'False) (U1 ∷ Type → Type))) | |||||
doValidateVRFSignature ∷ PolyPraosCrypto proto c ⇒ Nonce → Map (KeyHash 'StakePool) IndividualPoolStake → ActiveSlotCoeff → PolyPraosValidateView proto c → Except (PolyPraosValidationErr proto c) () Source #