Assert that a natural is bounded by a certain value. Throws an error when this is not the case.
Modulecardano-protocol-tpraos-1.6.0.0
Cardano.Protocol.TPraos.BHeader
Deprecated. Use Cardano.Protocol.TPraos.BlockHeader instead
- 7 types
- 17 values
- Packagecardano-protocol-tpraos-1.6.0.0
- Exports25
- LicenceApache-2.0
- SourceBlockHeader.hs
Hash a given block header
Retrieve the new nonce from the block header body.
checkLeaderNatValue :: BoundedNaturalCertified nat value
-> RationalStake proportion
-> ActiveSlotCoeff-> Bool
Check that the certified input natural is valid for being slot leader. This means we check that
p < 1 - (1 - f)^σ
where p = certNat / certNatMax.
The calculation is done using the following optimization:
let q = 1 - p and c = ln(1 - f)
then p < 1 - (1 - f)^σ = 1 / (1 - p) < exp(-σ * c) = 1 / q < exp(-σ * c)
This can be efficiently be computed by taylorExpCmp which returns ABOVE in case the reference value `1 / (1 - p)` is above the exponential function at `-σ * c`, BELOW if it is below or MaxReached if it couldn't conclusively compute this within the given iteration bounds.
Note that 1 1 1 certNatMax --- = ----- = ---------------------------- = ---------------------- q 1 - p 1 - (certNat / certNatMax) (certNatMax - certNat)
Check that the certified VRF output, when used as a natural, is valid for being slot leader.
HashHeader to Nonce
Retrieve the issuer id (the hash of the cold key) from the body of the block header. This corresponds to either a genesis/core node or a stake pool.
Construct a seed to use in the VRF computation.
Constructors
Instances9Eq, Ord, Show, Generic, NFData, NoThunks, …
Eq HashHeaderDefined in cardano-ledger-core-1.21.0.0 · Cardano.Ledger.HashesOrd HashHeaderDefined in cardano-ledger-core-1.21.0.0 · Cardano.Ledger.HashesShow HashHeaderDefined in cardano-ledger-core-1.21.0.0 · Cardano.Ledger.HashesGeneric HashHeaderDefined in cardano-ledger-core-1.21.0.0 · Cardano.Ledger.HashesNFData HashHeaderDefined in cardano-ledger-core-1.21.0.0 · Cardano.Ledger.HashesNoThunks HashHeaderDefined in cardano-ledger-core-1.21.0.0 · Cardano.Ledger.HashesDecCBOR HashHeaderDefined in cardano-ledger-core-1.21.0.0 · Cardano.Ledger.HashesEncCBOR HashHeaderDefined in cardano-ledger-core-1.21.0.0 · Cardano.Ledger.Hashestype Rep HashHeader = D1 ('MetaDataDefined in cardano-ledger-core-1.21.0.0 · Cardano.Ledger.Hashes"HashHeader"
"Cardano.Ledger.Hashes"
"cardano-ledger-core-1.21.0.0-HG71GU5V9Tb4NBnJzzlL6"
'True) (C1 ('MetaCons"HashHeader"
'PrefixI 'True) (S1 ('MetaSel ('Just"unHashHeader"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Hash HASH EraIndependentBlockHeader))))
Constructors
BHBodybheaderBlockNo :: !BlockNoblock number
bheaderSlotNo :: !SlotNoblock slot
bheaderPrev :: !PrevHashHash of the previous block header
bheaderVk :: !VKey BlockIssuerverification key of block issuer
bheaderVrfVk :: !VerKeyVRF (VRF c)VRF verification key for block issuer
bheaderEta :: !CertifiedVRF (VRF c) Nonceblock nonce
bheaderL :: !CertifiedVRF (VRF c) Naturalleader election value
bsize :: !Word32Size of the block body
bhash :: !Hash HASH EraIndependentBlockBodyHash of block body
bheaderOCert :: !OCert coperational certificate
bprotver :: !ProtVerprotocol version
Instances8Eq, Show, Generic, NoThunks, SignableRepresentation, DecCBOR, …
Crypto c => Eq (BHBody c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderCrypto c => Show (BHBody c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderGeneric (BHBody c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderCrypto c => NoThunks (BHBody c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderCrypto c => SignableRepresentation (BHBody c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderCrypto c => DecCBOR (BHBody c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderCrypto c => EncCBOR (BHBody c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeadertype Rep (BHBody c) = D1 ('MetaDataDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeader"BHBody"
"Cardano.Protocol.TPraos.BlockHeader"
"cardano-protocol-0.1.0.0-JDIdobznlmRDzdQSpP4Snq"
'False) (C1 ('MetaCons"BHBody"
'PrefixI 'True) (((S1 ('MetaSel ('Just"bheaderBlockNo"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 BlockNo) :*: S1 ('MetaSel ('Just"bheaderSlotNo"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 SlotNo)) :*: (S1 ('MetaSel ('Just"bheaderPrev"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PrevHash) :*: (S1 ('MetaSel ('Just"bheaderVk"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 (VKey BlockIssuer)) :*: S1 ('MetaSel ('Just"bheaderVrfVk"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (VerKeyVRF (VRF c)))))) :*: ((S1 ('MetaSel ('Just"bheaderEta"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (CertifiedVRF (VRF c) Nonce)) :*: (S1 ('MetaSel ('Just"bheaderL"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (CertifiedVRF (VRF c) Natural)) :*: S1 ('MetaSel ('Just"bsize"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Word32))) :*: (S1 ('MetaSel ('Just"bhash"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Hash HASH EraIndependentBlockBody)) :*: (S1 ('MetaSel ('Just"bheaderOCert"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (OCert c)) :*: S1 ('MetaSel ('Just"bprotver"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 ProtVer))))))
Constructors
BHeaderConstr (MemoBytes (BHeaderRaw c))
Instances13Eq, Show, Generic, NoThunks, ToCBOR, DecCBOR, …
Crypto c => Eq (BHeader c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderCrypto c => Show (BHeader c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderGeneric (BHeader c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderCrypto c => NoThunks (BHeader c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderTypeable c => ToCBOR (BHeader c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderCrypto c => DecCBOR (Annotator (BHeader c))Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderCrypto c => EncCBOR (BHeader c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderSafeToHash (BHeader c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderMemoized (BHeader c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderHashAnnotated (BHeader c) EraIndependentBlockHeaderDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeader(Crypto c, Era era) => EraBlockHeader (BHeader c) eraDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeadertype Rep (BHeader c) = D1 ('MetaDataDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeader"BHeader"
"Cardano.Protocol.TPraos.BlockHeader"
"cardano-protocol-0.1.0.0-JDIdobznlmRDzdQSpP4Snq"
'True) (C1 ('MetaCons"BHeaderConstr"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MemoBytes (BHeaderRaw c)))))type RawType (BHeader c) = BHeaderRaw cDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeader
Constructors
Instances9Eq, Show, Generic, NoThunks, DecCBOR, EncCBOR, …
Crypto c => Eq (BHeaderRaw c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderCrypto c => Show (BHeaderRaw c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderGeneric (BHeaderRaw c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderCrypto c => NoThunks (BHeaderRaw c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderCrypto c => DecCBOR (Annotator (BHeaderRaw c))Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderCrypto c => DecCBOR (BHeaderRaw c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderCrypto c => EncCBOR (BHeaderRaw c)Defined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeadertype Rep (BHeaderRaw c) = D1 ('MetaDataDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeader"BHeaderRaw"
"Cardano.Protocol.TPraos.BlockHeader"
"cardano-protocol-0.1.0.0-JDIdobznlmRDzdQSpP4Snq"
'False) (C1 ('MetaCons"BHeaderRaw"
'PrefixI 'True) (S1 ('MetaSel ('Just"bhrBody"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (BHBody c)) :*: S1 ('MetaSel ('Just"bhrSignature"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (SignedKES (KES c) (BHBody c)))))type MemoHashIndex (BHeaderRaw c) = EraIndependentBlockHeaderDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeader
Natural value with some additional bound. It must always be the base that 'bvValue <= bvMaxValue'. The creator is responsible for checking this value.
Constructors
Instances8Eq, Show, Generic, NFData, NoThunks, DecCBOR, …
Eq LastAppliedBlockDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderShow LastAppliedBlockDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderGeneric LastAppliedBlockDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderNFData LastAppliedBlockDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderNoThunks LastAppliedBlockDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderDecCBOR LastAppliedBlockDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderEncCBOR LastAppliedBlockDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeadertype Rep LastAppliedBlock = D1 ('MetaDataDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeader"LastAppliedBlock"
"Cardano.Protocol.TPraos.BlockHeader"
"cardano-protocol-0.1.0.0-JDIdobznlmRDzdQSpP4Snq"
'False) (C1 ('MetaCons"LastAppliedBlock"
'PrefixI 'True) (S1 ('MetaSel ('Just"labBlockNo"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 BlockNo) :*: (S1 ('MetaSel ('Just"labSlotNo"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 SlotNo) :*: S1 ('MetaSel ('Just"labHash"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HashHeader))))
The previous hash of a block
Constructors
Instances8Eq, Ord, Show, Generic, NoThunks, DecCBOR, …
Eq PrevHashDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderOrd PrevHashDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderShow PrevHashDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderGeneric PrevHashDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderNoThunks PrevHashDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderDecCBOR PrevHashDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeaderEncCBOR PrevHashDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeadertype Rep PrevHash = D1 ('MetaDataDefined in cardano-protocol-0.1.0.0 · Cardano.Protocol.TPraos.BlockHeader"PrevHash"
"Cardano.Protocol.TPraos.BlockHeader"
"cardano-protocol-0.1.0.0-JDIdobznlmRDzdQSpP4Snq"
'False) (C1 ('MetaCons"GenesisHash"
'PrefixI 'False) U1 :+: C1 ('MetaCons"BlockHash"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HashHeader)))