| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Cardano.Chain.Block
Synopsis
- type Block = ABlock ()
- data ABlockSignature a = ABlockSignature {
- delegationCertificate ∷ !(ACertificate a)
- signature ∷ !(Signature ToSign)
- data Proof = Proof {
- proofUTxO ∷ !TxProof
- proofSsc ∷ !SscProof
- proofDelegation ∷ !(Hash Payload)
- proofUpdate ∷ !Proof
- mkProof ∷ Body → Proof
- type Header = AHeader ()
- data BodyState = BodyState {
- utxo ∷ !UTxO
- updateState ∷ !State
- delegationState ∷ !State
- type Body = ABody ()
- pattern Body ∷ TxPayload → SscPayload → Payload → Payload → Body
- data EpochEnvironment = EpochEnvironment {}
- data ABlockOrBoundary a
- = ABOBBlock (ABlock a)
- | ABOBBoundary (ABoundaryBlock a)
- decCBORABlockOrBoundary ∷ EpochSlots → Decoder s (ABlockOrBoundary ByteSpan)
- data ChainValidationError
- = ChainValidationBoundaryTooLarge
- | ChainValidationBlockAttributesTooLarge
- | ChainValidationBlockTooLarge Natural Natural
- | ChainValidationHeaderAttributesTooLarge
- | ChainValidationHeaderTooLarge Natural Natural
- | ChainValidationDelegationPayloadError Text
- | ChainValidationInvalidDelegation VerificationKey VerificationKey
- | ChainValidationGenesisHashMismatch GenesisHash GenesisHash
- | ChainValidationExpectedGenesisHash GenesisHash HeaderHash
- | ChainValidationExpectedHeaderHash HeaderHash GenesisHash
- | ChainValidationInvalidHash HeaderHash HeaderHash
- | ChainValidationMissingHash HeaderHash
- | ChainValidationUnexpectedGenesisHash HeaderHash
- | ChainValidationInvalidSignature BlockSignature
- | ChainValidationDelegationSchedulingError Error
- | ChainValidationProtocolMagicMismatch ProtocolMagicId ProtocolMagicId
- | ChainValidationSignatureLight
- | ChainValidationTooManyDelegations VerificationKey
- | ChainValidationUpdateError SlotNumber Error
- | ChainValidationUTxOValidationError UTxOValidationError
- | ChainValidationProofValidationError ProofValidationError
- data ChainValidationState = ChainValidationState {}
- blockSlot ∷ ABlock a → SlotNumber
- updateChainBlockOrBoundary ∷ (MonadError ChainValidationError m, MonadReader ValidationMode m) ⇒ Config → ChainValidationState → ABlockOrBoundary ByteString → m ChainValidationState
- recoverSignedBytes ∷ EpochSlots → AHeader ByteString → Annotated ToSign ByteString
- data BlockValidationMode
- toTxValidationMode ∷ BlockValidationMode → TxValidationMode
- data ABlock a = ABlock {
- blockHeader ∷ AHeader a
- blockBody ∷ ABody a
- blockAnnotation ∷ a
- mkBlock ∷ ProtocolMagicId → ProtocolVersion → SoftwareVersion → Either GenesisHash Header → EpochSlots → SlotNumber → SigningKey → Certificate → Body → Block
- mkBlockExplicit ∷ ProtocolMagicId → ProtocolVersion → SoftwareVersion → HeaderHash → ChainDifficulty → EpochSlots → SlotNumber → SigningKey → Certificate → Body → Block
- blockHash ∷ EpochSlots → Block → HeaderHash
- blockHashAnnotated ∷ ABlock ByteString → HeaderHash
- blockAProtocolMagicId ∷ ABlock a → Annotated ProtocolMagicId a
- blockProtocolMagicId ∷ ABlock a → ProtocolMagicId
- blockPrevHash ∷ ABlock a → HeaderHash
- blockProof ∷ ABlock a → Proof
- blockGenesisKey ∷ ABlock a → VerificationKey
- blockIssuer ∷ ABlock a → VerificationKey
- blockDifficulty ∷ ABlock a → ChainDifficulty
- blockToSign ∷ EpochSlots → ABlock a → ToSign
- blockSignature ∷ ABlock a → ABlockSignature a
- blockProtocolVersion ∷ ABlock a → ProtocolVersion
- blockSoftwareVersion ∷ ABlock a → SoftwareVersion
- blockTxPayload ∷ ABlock a → ATxPayload a
- blockSscPayload ∷ ABlock a → SscPayload
- blockDlgPayload ∷ ABlock a → APayload a
- blockUpdatePayload ∷ ABlock a → APayload a
- blockLength ∷ ABlock ByteString → Natural
- encCBORBlock ∷ EpochSlots → Block → Encoding
- decCBORABlock ∷ EpochSlots → Decoder s (ABlock ByteSpan)
- renderBlock ∷ EpochSlots → Block → Builder
- encCBORABOBBlock ∷ EpochSlots → ABlock a → Encoding
- decCBORABOBBlock ∷ EpochSlots → Decoder s (Maybe Block)
- encCBORABlockOrBoundary ∷ ProtocolMagicId → EpochSlots → ABlockOrBoundary a → Encoding
- data ABoundaryBlock a = ABoundaryBlock {
- boundaryBlockLength ∷ !Int64
- boundaryHeader ∷ !(ABoundaryHeader a)
- boundaryBody ∷ !(ABoundaryBody a)
- boundaryAnnotation ∷ !a
- boundaryHashAnnotated ∷ ABoundaryBlock ByteString → HeaderHash
- decCBORABoundaryBlock ∷ Decoder s (ABoundaryBlock ByteSpan)
- encCBORABoundaryBlock ∷ ProtocolMagicId → ABoundaryBlock a → Encoding
- encCBORABOBBoundary ∷ ProtocolMagicId → ABoundaryBlock a → Encoding
- boundaryBlockSlot ∷ EpochSlots → Word64 → SlotNumber
- data ABoundaryBody a = ABoundaryBody {}
- data ABlockOrBoundaryHdr a
- = ABOBBlockHdr !(AHeader a)
- | ABOBBoundaryHdr !(ABoundaryHeader a)
- aBlockOrBoundaryHdr ∷ (AHeader a → b) → (ABoundaryHeader a → b) → ABlockOrBoundaryHdr a → b
- decCBORABlockOrBoundaryHdr ∷ EpochSlots → Decoder s (ABlockOrBoundaryHdr ByteSpan)
- encCBORABlockOrBoundaryHdr ∷ ABlockOrBoundaryHdr ByteString → Encoding
- encCBORABlockOrBoundaryHdrSize ∷ Proxy (ABlockOrBoundaryHdr a) → Size
- abobHdrFromBlock ∷ ABlockOrBoundary a → ABlockOrBoundaryHdr a
- abobHdrSlotNo ∷ EpochSlots → ABlockOrBoundaryHdr a → SlotNumber
- abobHdrChainDifficulty ∷ ABlockOrBoundaryHdr a → ChainDifficulty
- abobHdrHash ∷ ABlockOrBoundaryHdr ByteString → HeaderHash
- abobHdrPrevHash ∷ ABlockOrBoundaryHdr a → Maybe HeaderHash
- data ABody a = ABody {
- bodyTxPayload ∷ !(ATxPayload a)
- bodySscPayload ∷ !SscPayload
- bodyDlgPayload ∷ !(APayload a)
- bodyUpdatePayload ∷ !(APayload a)
- bodyTxs ∷ Body → [Tx]
- dropBoundaryBody ∷ Dropper s
- dropBoundaryExtraBodyData ∷ Dropper s
- data ABoundaryHeader a = UnsafeABoundaryHeader {}
- data AHeader a = AHeader {
- aHeaderProtocolMagicId ∷ !(Annotated ProtocolMagicId a)
- aHeaderPrevHash ∷ !(Annotated HeaderHash a)
- aHeaderSlot ∷ !(Annotated SlotNumber a)
- aHeaderDifficulty ∷ !(Annotated ChainDifficulty a)
- headerProtocolVersion ∷ !ProtocolVersion
- headerSoftwareVersion ∷ !SoftwareVersion
- aHeaderProof ∷ !(Annotated Proof a)
- headerGenesisKey ∷ !VerificationKey
- headerSignature ∷ !(ABlockSignature a)
- headerAnnotation ∷ !a
- headerExtraAnnotation ∷ !a
- type HeaderHash = Hash Header
- data ToSign = ToSign {}
- boundaryHeaderHashAnnotated ∷ ABoundaryHeader ByteString → HeaderHash
- decCBORABoundaryHeader ∷ Decoder s (ABoundaryHeader ByteSpan)
- decCBORAHeader ∷ EpochSlots → Decoder s (AHeader ByteSpan)
- encCBORABoundaryHeader ∷ ProtocolMagicId → ABoundaryHeader a → Encoding
- encCBORABoundaryHeaderSize ∷ Proxy ProtocolMagicId → Proxy (ABoundaryHeader a) → Size
- encCBORHeader ∷ EpochSlots → Header → Encoding
- encCBORHeaderSize ∷ Proxy EpochSlots → Proxy (AHeader a) → Size
- genesisHeaderHash ∷ GenesisHash → HeaderHash
- hashHeader ∷ EpochSlots → Header → HeaderHash
- headerDifficulty ∷ AHeader a → ChainDifficulty
- headerHashAnnotated ∷ AHeader ByteString → HeaderHash
- headerIssuer ∷ AHeader a → VerificationKey
- headerPrevHash ∷ AHeader a → HeaderHash
- headerProof ∷ AHeader a → Proof
- headerProtocolMagicId ∷ AHeader a → ProtocolMagicId
- headerSlot ∷ AHeader a → SlotNumber
- headerToSign ∷ EpochSlots → AHeader a → ToSign
- mkHeaderExplicit ∷ ProtocolMagicId → HeaderHash → ChainDifficulty → EpochSlots → SlotNumber → SigningKey → Certificate → Body → ProtocolVersion → SoftwareVersion → Header
- bodyWitnesses ∷ Body → [TxWitness]
- decCBORBoundaryConsensusData ∷ Decoder s (Word64, ChainDifficulty)
- dropBoundaryExtraHeaderData ∷ Dropper s
- dropBoundaryExtraHeaderDataRetainGenesisTag ∷ Decoder s Bool
- mkHeader ∷ ProtocolMagicId → Either GenesisHash Header → EpochSlots → SlotNumber → SigningKey → Certificate → Body → ProtocolVersion → SoftwareVersion → Header
- headerLength ∷ AHeader ByteString → Natural
- encCBORHeaderToHash ∷ EpochSlots → Header → Encoding
- decCBORHeader ∷ EpochSlots → Decoder s Header
- decCBORHeaderToHash ∷ EpochSlots → Decoder s (Maybe Header)
- wrapHeaderBytes ∷ ByteString → ByteString
- encCBORBlockVersions ∷ ProtocolVersion → SoftwareVersion → Encoding
- encCBORBlockVersionsSize ∷ Proxy ProtocolVersion → Proxy SoftwareVersion → Size
- renderHeader ∷ EpochSlots → Header → Builder
- mkABoundaryHeader ∷ Either GenesisHash HeaderHash → Word64 → ChainDifficulty → a → ABoundaryHeader a
- wrapBoundaryBytes ∷ ByteString → ByteString
- headerHashF ∷ Format r (HeaderHash → r)
- type BlockSignature = ABlockSignature ()
- data ProofValidationError
- recoverProof ∷ ABody ByteString → Proof
- updateBody ∷ (MonadError ChainValidationError m, MonadReader ValidationMode m) ⇒ BodyEnvironment → BodyState → ABlock ByteString → m BodyState
- updateChainBoundary ∷ MonadError ChainValidationError m ⇒ ChainValidationState → ABoundaryBlock ByteString → m ChainValidationState
- epochTransition ∷ EpochEnvironment → State → SlotNumber → State
- headerIsValid ∷ (MonadError ChainValidationError m, MonadReader ValidationMode m) ⇒ State → AHeader ByteString → m ()
- validateHeaderMatchesBody ∷ MonadError ProofValidationError m ⇒ AHeader ByteString → ABody ByteString → m ()
- updateBlock ∷ (MonadError ChainValidationError m, MonadReader ValidationMode m) ⇒ Config → ChainValidationState → ABlock ByteString → m ChainValidationState
- adoptedProtocolParameters ∷ State → ProtocolParameters
- data BodyEnvironment = BodyEnvironment {}
- initialChainValidationState ∷ MonadError Error m ⇒ Config → m ChainValidationState
- newtype HeapSize a = HeapSize {}
- newtype UTxOSize = UTxOSize {}
- calcUTxOSize ∷ UTxO → (HeapSize UTxO, UTxOSize)
- foldUTxO ∷ Environment → UTxO → Stream (Of (ABlock ByteString)) (ExceptT ParseError ResIO) () → ExceptT Error (ReaderT ValidationMode ResIO) UTxO
- foldUTxOBlock ∷ Environment → UTxO → ABlock ByteString → ExceptT Error (ReaderT ValidationMode ResIO) UTxO
Documentation
data ABlockSignature a Source #
Signature of the Block
We use a heavyweight delegation scheme, so the signature has two parts:
- A delegation certificate from a genesis key to the block signer
- The actual signature over
ToSign
Constructors
| ABlockSignature | |
Fields
| |
Instances
Proof of everything contained in the payload
Constructors
| Proof | |
Fields
| |
Instances
| ToJSON Proof Source # | |||||
| FromCBOR Proof Source # | |||||
| ToCBOR Proof Source # | |||||
| DecCBOR Proof Source # | |||||
| EncCBOR Proof Source # | |||||
| NFData Proof Source # | |||||
Defined in Cardano.Chain.Block.Proof | |||||
| Buildable Proof Source # | |||||
| Generic Proof Source # | |||||
Defined in Cardano.Chain.Block.Proof Associated Types
| |||||
| Show Proof Source # | |||||
| Eq Proof Source # | |||||
| NoThunks Proof Source # | |||||
| type Rep Proof Source # | |||||
Defined in Cardano.Chain.Block.Proof type Rep Proof = D1 ('MetaData "Proof" "Cardano.Chain.Block.Proof" "cardano-ledger-byron-1.3.0.0-inplace" 'False) (C1 ('MetaCons "Proof" 'PrefixI 'True) ((S1 ('MetaSel ('Just "proofUTxO") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TxProof) :*: S1 ('MetaSel ('Just "proofSsc") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SscProof)) :*: (S1 ('MetaSel ('Just "proofDelegation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Hash Payload)) :*: S1 ('MetaSel ('Just "proofUpdate") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Proof)))) | |||||
Constructors
| BodyState | |
Fields
| |
data EpochEnvironment Source #
Constructors
| EpochEnvironment | |
Fields
| |
data ABlockOrBoundary a Source #
Constructors
| ABOBBlock (ABlock a) | |
| ABOBBoundary (ABoundaryBlock a) |
Instances
| Functor ABlockOrBoundary Source # | |||||
Defined in Cardano.Chain.Block.Block Methods fmap ∷ (a → b) → ABlockOrBoundary a → ABlockOrBoundary b # (<$) ∷ a → ABlockOrBoundary b → ABlockOrBoundary a # | |||||
| ToJSON a ⇒ ToJSON (ABlockOrBoundary a) Source # | |||||
Defined in Cardano.Chain.Block.Block Methods toJSON ∷ ABlockOrBoundary a → Value Source # toEncoding ∷ ABlockOrBoundary a → Encoding Source # toJSONList ∷ [ABlockOrBoundary a] → Value Source # toEncodingList ∷ [ABlockOrBoundary a] → Encoding Source # omitField ∷ ABlockOrBoundary a → Bool Source # | |||||
| Generic (ABlockOrBoundary a) Source # | |||||
Defined in Cardano.Chain.Block.Block Associated Types
Methods from ∷ ABlockOrBoundary a → Rep (ABlockOrBoundary a) x # to ∷ Rep (ABlockOrBoundary a) x → ABlockOrBoundary a # | |||||
| Show a ⇒ Show (ABlockOrBoundary a) Source # | |||||
Defined in Cardano.Chain.Block.Block Methods showsPrec ∷ Int → ABlockOrBoundary a → ShowS # show ∷ ABlockOrBoundary a → String # showList ∷ [ABlockOrBoundary a] → ShowS # | |||||
| Eq a ⇒ Eq (ABlockOrBoundary a) Source # | |||||
Defined in Cardano.Chain.Block.Block Methods (==) ∷ ABlockOrBoundary a → ABlockOrBoundary a → Bool # (/=) ∷ ABlockOrBoundary a → ABlockOrBoundary a → Bool # | |||||
| type Rep (ABlockOrBoundary a) Source # | |||||
Defined in Cardano.Chain.Block.Block type Rep (ABlockOrBoundary a) = D1 ('MetaData "ABlockOrBoundary" "Cardano.Chain.Block.Block" "cardano-ledger-byron-1.3.0.0-inplace" 'False) (C1 ('MetaCons "ABOBBlock" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ABlock a))) :+: C1 ('MetaCons "ABOBBoundary" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ABoundaryBlock a)))) | |||||
decCBORABlockOrBoundary ∷ EpochSlots → Decoder s (ABlockOrBoundary ByteSpan) Source #
Decode a Block accounting for deprecated epoch boundary blocks
Previous versions of Cardano had an explicit boundary block between epochs.
A Block was then represented as 'Either BoundaryBlock MainBlock'. We have
now deprecated these explicit boundary blocks, but we still need to decode
blocks in the old format. In the case that we find a boundary block, we
drop it using dropBoundaryBlock and return a Nothing.
data ChainValidationError Source #
Constructors
| ChainValidationBoundaryTooLarge | The size of an epoch boundary block exceeds the limit |
| ChainValidationBlockAttributesTooLarge | The size of a block's attributes is non-zero |
| ChainValidationBlockTooLarge Natural Natural | The size of a regular block exceeds the limit |
| ChainValidationHeaderAttributesTooLarge | The size of a block header's attributes is non-zero |
| ChainValidationHeaderTooLarge Natural Natural | The size of a block header exceeds the limit |
| ChainValidationDelegationPayloadError Text | There is a problem with the delegation payload signature |
| ChainValidationInvalidDelegation VerificationKey VerificationKey | The delegation used in the signature is not valid according to the ledger |
| ChainValidationGenesisHashMismatch GenesisHash GenesisHash | Genesis hash mismatch |
| ChainValidationExpectedGenesisHash GenesisHash HeaderHash | Expected GenesisHash but got HeaderHash |
| ChainValidationExpectedHeaderHash HeaderHash GenesisHash | Expected HeaderHash but GenesisHash |
| ChainValidationInvalidHash HeaderHash HeaderHash | The hash of the previous block does not match the value in the header |
| ChainValidationMissingHash HeaderHash | The hash of the previous block is missing and should be given hash. |
| ChainValidationUnexpectedGenesisHash HeaderHash | There should not be a hash of the previous but there is. |
| ChainValidationInvalidSignature BlockSignature | The signature of the block is invalid |
| ChainValidationDelegationSchedulingError Error | A delegation certificate failed validation in the ledger layer |
| ChainValidationProtocolMagicMismatch ProtocolMagicId ProtocolMagicId | The |
| ChainValidationSignatureLight | A block is using unsupported lightweight delegation |
| ChainValidationTooManyDelegations VerificationKey | The delegator for this block has delegated in too many recent blocks |
| ChainValidationUpdateError SlotNumber Error | Something failed to register in the update interface |
| ChainValidationUTxOValidationError UTxOValidationError | A transaction failed validation in the ledger layer |
| ChainValidationProofValidationError ProofValidationError | A payload proof did not match. |
Instances
| Show ChainValidationError Source # | |
Defined in Cardano.Chain.Block.Validation Methods showsPrec ∷ Int → ChainValidationError → ShowS # show ∷ ChainValidationError → String # showList ∷ [ChainValidationError] → ShowS # | |
| Eq ChainValidationError Source # | |
Defined in Cardano.Chain.Block.Validation Methods | |
data ChainValidationState Source #
Constructors
| ChainValidationState | |
Fields
| |
Instances
| FromCBOR ChainValidationState Source # | |||||
Defined in Cardano.Chain.Block.Validation | |||||
| ToCBOR ChainValidationState Source # | |||||
Defined in Cardano.Chain.Block.Validation Methods toCBOR ∷ ChainValidationState → Encoding Source # encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy ChainValidationState → Size Source # encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [ChainValidationState] → Size Source # | |||||
| DecCBOR ChainValidationState Source # | |||||
Defined in Cardano.Chain.Block.Validation | |||||
| EncCBOR ChainValidationState Source # | |||||
Defined in Cardano.Chain.Block.Validation Methods | |||||
| NFData ChainValidationState Source # | |||||
Defined in Cardano.Chain.Block.Validation Methods rnf ∷ ChainValidationState → () # | |||||
| Generic ChainValidationState Source # | |||||
Defined in Cardano.Chain.Block.Validation Associated Types
Methods | |||||
| Show ChainValidationState Source # | |||||
Defined in Cardano.Chain.Block.Validation Methods showsPrec ∷ Int → ChainValidationState → ShowS # show ∷ ChainValidationState → String # showList ∷ [ChainValidationState] → ShowS # | |||||
| Eq ChainValidationState Source # | |||||
Defined in Cardano.Chain.Block.Validation Methods | |||||
| NoThunks ChainValidationState Source # | |||||
Defined in Cardano.Chain.Block.Validation | |||||
| type Rep ChainValidationState Source # | |||||
Defined in Cardano.Chain.Block.Validation type Rep ChainValidationState = D1 ('MetaData "ChainValidationState" "Cardano.Chain.Block.Validation" "cardano-ledger-byron-1.3.0.0-inplace" 'False) (C1 ('MetaCons "ChainValidationState" 'PrefixI 'True) ((S1 ('MetaSel ('Just "cvsLastSlot") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNumber) :*: S1 ('MetaSel ('Just "cvsPreviousHash") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Either GenesisHash HeaderHash))) :*: (S1 ('MetaSel ('Just "cvsUtxo") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 UTxO) :*: (S1 ('MetaSel ('Just "cvsUpdateState") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 State) :*: S1 ('MetaSel ('Just "cvsDelegationState") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 State))))) | |||||
blockSlot ∷ ABlock a → SlotNumber Source #
updateChainBlockOrBoundary ∷ (MonadError ChainValidationError m, MonadReader ValidationMode m) ⇒ Config → ChainValidationState → ABlockOrBoundary ByteString → m ChainValidationState Source #
recoverSignedBytes ∷ EpochSlots → AHeader ByteString → Annotated ToSign ByteString Source #
Produces the ByteString that was signed in the block
data BlockValidationMode Source #
Indicates what sort of block validation should be performed.
Constructors
| BlockValidation | Perform all block validations. |
| NoBlockValidation | Perform no block validations. |
Instances
| Show BlockValidationMode Source # | |
Defined in Cardano.Chain.Block.ValidationMode Methods showsPrec ∷ Int → BlockValidationMode → ShowS # show ∷ BlockValidationMode → String # showList ∷ [BlockValidationMode] → ShowS # | |
| Eq BlockValidationMode Source # | |
Defined in Cardano.Chain.Block.ValidationMode Methods | |
toTxValidationMode ∷ BlockValidationMode → TxValidationMode Source #
Translate a BlockValidationMode to an appropriate TxValidationMode.
Constructors
| ABlock | |
Fields
| |
Instances
| Functor ABlock Source # | |||||
| ToJSON a ⇒ ToJSON (ABlock a) Source # | |||||
| NFData a ⇒ NFData (ABlock a) Source # | |||||
Defined in Cardano.Chain.Block.Block | |||||
| Buildable (WithEpochSlots Block) Source # | |||||
Defined in Cardano.Chain.Block.Block | |||||
| Generic (ABlock a) Source # | |||||
Defined in Cardano.Chain.Block.Block Associated Types
| |||||
| Show a ⇒ Show (ABlock a) Source # | |||||
| Eq a ⇒ Eq (ABlock a) Source # | |||||
| type Rep (ABlock a) Source # | |||||
Defined in Cardano.Chain.Block.Block type Rep (ABlock a) = D1 ('MetaData "ABlock" "Cardano.Chain.Block.Block" "cardano-ledger-byron-1.3.0.0-inplace" 'False) (C1 ('MetaCons "ABlock" 'PrefixI 'True) (S1 ('MetaSel ('Just "blockHeader") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (AHeader a)) :*: (S1 ('MetaSel ('Just "blockBody") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ABody a)) :*: S1 ('MetaSel ('Just "blockAnnotation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))) | |||||
Arguments
| ∷ ProtocolMagicId | |
| → ProtocolVersion | |
| → SoftwareVersion | |
| → Either GenesisHash Header | |
| → EpochSlots | |
| → SlotNumber | |
| → SigningKey | The |
| → Certificate | A certificate of delegation from a genesis key to the |
| → Body | |
| → Block |
Smart constructor for Block
Arguments
| ∷ ProtocolMagicId | |
| → ProtocolVersion | |
| → SoftwareVersion | |
| → HeaderHash | |
| → ChainDifficulty | |
| → EpochSlots | |
| → SlotNumber | |
| → SigningKey | The |
| → Certificate | A certificate of delegation from a genesis key to the |
| → Body | |
| → Block |
blockHash ∷ EpochSlots → Block → HeaderHash Source #
blockPrevHash ∷ ABlock a → HeaderHash Source #
blockProof ∷ ABlock a → Proof Source #
blockIssuer ∷ ABlock a → VerificationKey Source #
blockToSign ∷ EpochSlots → ABlock a → ToSign Source #
blockSignature ∷ ABlock a → ABlockSignature a Source #
blockTxPayload ∷ ABlock a → ATxPayload a Source #
blockSscPayload ∷ ABlock a → SscPayload Source #
blockDlgPayload ∷ ABlock a → APayload a Source #
blockUpdatePayload ∷ ABlock a → APayload a Source #
encCBORBlock ∷ EpochSlots → Block → Encoding Source #
Encode a block, given a number of slots-per-epoch.
Unlike encCBORABOBBlock, this function does not take the deprecated epoch
boundary blocks into account.
decCBORABlock ∷ EpochSlots → Decoder s (ABlock ByteSpan) Source #
renderBlock ∷ EpochSlots → Block → Builder Source #
encCBORABOBBlock ∷ EpochSlots → ABlock a → Encoding Source #
Encode a Block accounting for deprecated epoch boundary blocks
decCBORABOBBlock ∷ EpochSlots → Decoder s (Maybe Block) Source #
Decode a Block accounting for deprecated epoch boundary blocks
data ABoundaryBlock a Source #
For a boundary block, we keep the header, body, and an annotation for the whole thing (commonly the bytes from which it was decoded).
Constructors
| ABoundaryBlock | |
Fields
| |
Instances
| Functor ABoundaryBlock Source # | |||||
Defined in Cardano.Chain.Block.Block Methods fmap ∷ (a → b) → ABoundaryBlock a → ABoundaryBlock b # (<$) ∷ a → ABoundaryBlock b → ABoundaryBlock a # | |||||
| ToJSON a ⇒ ToJSON (ABoundaryBlock a) Source # | |||||
Defined in Cardano.Chain.Block.Block Methods toJSON ∷ ABoundaryBlock a → Value Source # toEncoding ∷ ABoundaryBlock a → Encoding Source # toJSONList ∷ [ABoundaryBlock a] → Value Source # toEncodingList ∷ [ABoundaryBlock a] → Encoding Source # omitField ∷ ABoundaryBlock a → Bool Source # | |||||
| Decoded (ABoundaryBlock ByteString) Source # | |||||
Defined in Cardano.Chain.Block.Block Associated Types
Methods recoverBytes ∷ ABoundaryBlock ByteString → ByteString Source # | |||||
| Buildable (ABoundaryBlock a) Source # | |||||
Defined in Cardano.Chain.Block.Block Methods build ∷ ABoundaryBlock a → Builder Source # | |||||
| Generic (ABoundaryBlock a) Source # | |||||
Defined in Cardano.Chain.Block.Block Associated Types
Methods from ∷ ABoundaryBlock a → Rep (ABoundaryBlock a) x # to ∷ Rep (ABoundaryBlock a) x → ABoundaryBlock a # | |||||
| Show a ⇒ Show (ABoundaryBlock a) Source # | |||||
Defined in Cardano.Chain.Block.Block Methods showsPrec ∷ Int → ABoundaryBlock a → ShowS # show ∷ ABoundaryBlock a → String # showList ∷ [ABoundaryBlock a] → ShowS # | |||||
| Eq a ⇒ Eq (ABoundaryBlock a) Source # | |||||
Defined in Cardano.Chain.Block.Block Methods (==) ∷ ABoundaryBlock a → ABoundaryBlock a → Bool # (/=) ∷ ABoundaryBlock a → ABoundaryBlock a → Bool # | |||||
| type BaseType (ABoundaryBlock ByteString) Source # | |||||
Defined in Cardano.Chain.Block.Block | |||||
| type Rep (ABoundaryBlock a) Source # | |||||
Defined in Cardano.Chain.Block.Block type Rep (ABoundaryBlock a) = D1 ('MetaData "ABoundaryBlock" "Cardano.Chain.Block.Block" "cardano-ledger-byron-1.3.0.0-inplace" 'False) (C1 ('MetaCons "ABoundaryBlock" 'PrefixI 'True) ((S1 ('MetaSel ('Just "boundaryBlockLength") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int64) :*: S1 ('MetaSel ('Just "boundaryHeader") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (ABoundaryHeader a))) :*: (S1 ('MetaSel ('Just "boundaryBody") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (ABoundaryBody a)) :*: S1 ('MetaSel ('Just "boundaryAnnotation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)))) | |||||
boundaryHashAnnotated ∷ ABoundaryBlock ByteString → HeaderHash Source #
Extract the hash of a boundary block from its annotation.
encCBORABoundaryBlock ∷ ProtocolMagicId → ABoundaryBlock a → Encoding Source #
See note on encCBORABoundaryHeader. This as well does not necessarily
invert the decoder decCBORABoundaryBlock.
encCBORABOBBoundary ∷ ProtocolMagicId → ABoundaryBlock a → Encoding Source #
encCBORABoundaryBlock but with the list length and tag discriminator bytes.
Arguments
| ∷ EpochSlots | |
| → Word64 | Epoch number |
| → SlotNumber |
Compute the slot number assigned to a boundary block
data ABoundaryBody a Source #
For boundary body data, we only keep an annotation. It's the body and extra body data.
Constructors
| ABoundaryBody | |
Fields | |
Instances
| Functor ABoundaryBody Source # | |||||
Defined in Cardano.Chain.Block.Block Methods fmap ∷ (a → b) → ABoundaryBody a → ABoundaryBody b # (<$) ∷ a → ABoundaryBody b → ABoundaryBody a # | |||||
| ToJSON a ⇒ ToJSON (ABoundaryBody a) Source # | |||||
Defined in Cardano.Chain.Block.Block Methods toJSON ∷ ABoundaryBody a → Value Source # toEncoding ∷ ABoundaryBody a → Encoding Source # toJSONList ∷ [ABoundaryBody a] → Value Source # toEncodingList ∷ [ABoundaryBody a] → Encoding Source # omitField ∷ ABoundaryBody a → Bool Source # | |||||
| Decoded (ABoundaryBody ByteString) Source # | |||||
Defined in Cardano.Chain.Block.Block Associated Types
Methods recoverBytes ∷ ABoundaryBody ByteString → ByteString Source # | |||||
| Generic (ABoundaryBody a) Source # | |||||
Defined in Cardano.Chain.Block.Block Associated Types
Methods from ∷ ABoundaryBody a → Rep (ABoundaryBody a) x # to ∷ Rep (ABoundaryBody a) x → ABoundaryBody a # | |||||
| Show a ⇒ Show (ABoundaryBody a) Source # | |||||
Defined in Cardano.Chain.Block.Block Methods showsPrec ∷ Int → ABoundaryBody a → ShowS # show ∷ ABoundaryBody a → String # showList ∷ [ABoundaryBody a] → ShowS # | |||||
| Eq a ⇒ Eq (ABoundaryBody a) Source # | |||||
Defined in Cardano.Chain.Block.Block Methods (==) ∷ ABoundaryBody a → ABoundaryBody a → Bool # (/=) ∷ ABoundaryBody a → ABoundaryBody a → Bool # | |||||
| type BaseType (ABoundaryBody ByteString) Source # | |||||
Defined in Cardano.Chain.Block.Block | |||||
| type Rep (ABoundaryBody a) Source # | |||||
Defined in Cardano.Chain.Block.Block type Rep (ABoundaryBody a) = D1 ('MetaData "ABoundaryBody" "Cardano.Chain.Block.Block" "cardano-ledger-byron-1.3.0.0-inplace" 'False) (C1 ('MetaCons "ABoundaryBody" 'PrefixI 'True) (S1 ('MetaSel ('Just "boundaryBodyAnnotation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a))) | |||||
data ABlockOrBoundaryHdr a Source #
Constructors
| ABOBBlockHdr !(AHeader a) | |
| ABOBBoundaryHdr !(ABoundaryHeader a) |
Instances
| Functor ABlockOrBoundaryHdr Source # | |||||
Defined in Cardano.Chain.Block.Block Methods fmap ∷ (a → b) → ABlockOrBoundaryHdr a → ABlockOrBoundaryHdr b # (<$) ∷ a → ABlockOrBoundaryHdr b → ABlockOrBoundaryHdr a # | |||||
| Generic (ABlockOrBoundaryHdr a) Source # | |||||
Defined in Cardano.Chain.Block.Block Associated Types
Methods from ∷ ABlockOrBoundaryHdr a → Rep (ABlockOrBoundaryHdr a) x # to ∷ Rep (ABlockOrBoundaryHdr a) x → ABlockOrBoundaryHdr a # | |||||
| Show a ⇒ Show (ABlockOrBoundaryHdr a) Source # | |||||
Defined in Cardano.Chain.Block.Block Methods showsPrec ∷ Int → ABlockOrBoundaryHdr a → ShowS # show ∷ ABlockOrBoundaryHdr a → String # showList ∷ [ABlockOrBoundaryHdr a] → ShowS # | |||||
| Eq a ⇒ Eq (ABlockOrBoundaryHdr a) Source # | |||||
Defined in Cardano.Chain.Block.Block Methods (==) ∷ ABlockOrBoundaryHdr a → ABlockOrBoundaryHdr a → Bool # (/=) ∷ ABlockOrBoundaryHdr a → ABlockOrBoundaryHdr a → Bool # | |||||
| NoThunks a ⇒ NoThunks (ABlockOrBoundaryHdr a) Source # | |||||
Defined in Cardano.Chain.Block.Block | |||||
| type Rep (ABlockOrBoundaryHdr a) Source # | |||||
Defined in Cardano.Chain.Block.Block type Rep (ABlockOrBoundaryHdr a) = D1 ('MetaData "ABlockOrBoundaryHdr" "Cardano.Chain.Block.Block" "cardano-ledger-byron-1.3.0.0-inplace" 'False) (C1 ('MetaCons "ABOBBlockHdr" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (AHeader a))) :+: C1 ('MetaCons "ABOBBoundaryHdr" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (ABoundaryHeader a)))) | |||||
aBlockOrBoundaryHdr ∷ (AHeader a → b) → (ABoundaryHeader a → b) → ABlockOrBoundaryHdr a → b Source #
The analogue of either
encCBORABlockOrBoundaryHdr ∷ ABlockOrBoundaryHdr ByteString → Encoding Source #
Encoder for ABlockOrBoundaryHdr which is using the annotation.
It is right inverse of decCBORAblockOrBoundaryHdr.
TODO: add a round trip test, e.g.
decCBORABlockOrBoundaryHdr . encCBORABlockOrBoundaryHdr = id
which does not type check, but convey the meaning.
encCBORABlockOrBoundaryHdrSize ∷ Proxy (ABlockOrBoundaryHdr a) → Size Source #
The size computation is compatible with encCBORABlockOrBoundaryHdr
abobHdrSlotNo ∷ EpochSlots → ABlockOrBoundaryHdr a → SlotNumber Source #
Slot number of the header
NOTE: Epoch slot number calculation must match the one in applyBoundary.
Body consists of payloads of all block components
Constructors
| ABody | |
Fields
| |
Instances
| FromCBOR Body Source # | |||||
| ToCBOR Body Source # | |||||
| DecCBOR Body Source # | |||||
| EncCBOR Body Source # | |||||
| Functor ABody Source # | |||||
| ToJSON a ⇒ ToJSON (ABody a) Source # | |||||
| FromCBOR (ABody ByteSpan) Source # | |||||
| DecCBOR (ABody ByteSpan) Source # | |||||
| NFData a ⇒ NFData (ABody a) Source # | |||||
Defined in Cardano.Chain.Block.Body | |||||
| Generic (ABody a) Source # | |||||
Defined in Cardano.Chain.Block.Body Associated Types
| |||||
| Show a ⇒ Show (ABody a) Source # | |||||
| Eq a ⇒ Eq (ABody a) Source # | |||||
| type Rep (ABody a) Source # | |||||
Defined in Cardano.Chain.Block.Body type Rep (ABody a) = D1 ('MetaData "ABody" "Cardano.Chain.Block.Body" "cardano-ledger-byron-1.3.0.0-inplace" 'False) (C1 ('MetaCons "ABody" 'PrefixI 'True) ((S1 ('MetaSel ('Just "bodyTxPayload") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (ATxPayload a)) :*: S1 ('MetaSel ('Just "bodySscPayload") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SscPayload)) :*: (S1 ('MetaSel ('Just "bodyDlgPayload") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (APayload a)) :*: S1 ('MetaSel ('Just "bodyUpdatePayload") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (APayload a))))) | |||||
data ABoundaryHeader a Source #
Constructors
| UnsafeABoundaryHeader | |
Fields | |
Instances
| Functor ABoundaryHeader Source # | |||||
Defined in Cardano.Chain.Block.Header Methods fmap ∷ (a → b) → ABoundaryHeader a → ABoundaryHeader b # (<$) ∷ a → ABoundaryHeader b → ABoundaryHeader a # | |||||
| ToJSON a ⇒ ToJSON (ABoundaryHeader a) Source # | |||||
Defined in Cardano.Chain.Block.Header Methods toJSON ∷ ABoundaryHeader a → Value Source # toEncoding ∷ ABoundaryHeader a → Encoding Source # toJSONList ∷ [ABoundaryHeader a] → Value Source # toEncodingList ∷ [ABoundaryHeader a] → Encoding Source # omitField ∷ ABoundaryHeader a → Bool Source # | |||||
| Decoded (ABoundaryHeader ByteString) Source # | |||||
Defined in Cardano.Chain.Block.Header Associated Types
Methods recoverBytes ∷ ABoundaryHeader ByteString → ByteString Source # | |||||
| Generic (ABoundaryHeader a) Source # | |||||
Defined in Cardano.Chain.Block.Header Associated Types
Methods from ∷ ABoundaryHeader a → Rep (ABoundaryHeader a) x # to ∷ Rep (ABoundaryHeader a) x → ABoundaryHeader a # | |||||
| Show a ⇒ Show (ABoundaryHeader a) Source # | |||||
Defined in Cardano.Chain.Block.Header Methods showsPrec ∷ Int → ABoundaryHeader a → ShowS # show ∷ ABoundaryHeader a → String # showList ∷ [ABoundaryHeader a] → ShowS # | |||||
| Eq a ⇒ Eq (ABoundaryHeader a) Source # | |||||
Defined in Cardano.Chain.Block.Header Methods (==) ∷ ABoundaryHeader a → ABoundaryHeader a → Bool # (/=) ∷ ABoundaryHeader a → ABoundaryHeader a → Bool # | |||||
| NoThunks a ⇒ NoThunks (ABoundaryHeader a) Source # | |||||
Defined in Cardano.Chain.Block.Header | |||||
| type BaseType (ABoundaryHeader ByteString) Source # | |||||
Defined in Cardano.Chain.Block.Header | |||||
| type Rep (ABoundaryHeader a) Source # | |||||
Defined in Cardano.Chain.Block.Header type Rep (ABoundaryHeader a) = D1 ('MetaData "ABoundaryHeader" "Cardano.Chain.Block.Header" "cardano-ledger-byron-1.3.0.0-inplace" 'False) (C1 ('MetaCons "UnsafeABoundaryHeader" 'PrefixI 'True) ((S1 ('MetaSel ('Just "boundaryPrevHash") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Either GenesisHash HeaderHash)) :*: S1 ('MetaSel ('Just "boundaryEpoch") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64)) :*: (S1 ('MetaSel ('Just "boundaryDifficulty") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ChainDifficulty) :*: S1 ('MetaSel ('Just "boundaryHeaderAnnotation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)))) | |||||
Constructors
| AHeader | |
Fields
| |
Instances
| Functor AHeader Source # | |||||
| ToJSON a ⇒ ToJSON (AHeader a) Source # | |||||
| Decoded (AHeader ByteString) Source # | |||||
Defined in Cardano.Chain.Block.Header Associated Types
Methods | |||||
| NFData a ⇒ NFData (AHeader a) Source # | |||||
Defined in Cardano.Chain.Block.Header | |||||
| Buildable (WithEpochSlots Header) Source # | |||||
Defined in Cardano.Chain.Block.Header | |||||
| Generic (AHeader a) Source # | |||||
Defined in Cardano.Chain.Block.Header Associated Types
| |||||
| Show a ⇒ Show (AHeader a) Source # | |||||
| Eq a ⇒ Eq (AHeader a) Source # | |||||
| NoThunks a ⇒ NoThunks (AHeader a) Source # | |||||
| type BaseType (AHeader ByteString) Source # | |||||
Defined in Cardano.Chain.Block.Header | |||||
| type Rep (AHeader a) Source # | |||||
Defined in Cardano.Chain.Block.Header type Rep (AHeader a) = D1 ('MetaData "AHeader" "Cardano.Chain.Block.Header" "cardano-ledger-byron-1.3.0.0-inplace" 'False) (C1 ('MetaCons "AHeader" 'PrefixI 'True) (((S1 ('MetaSel ('Just "aHeaderProtocolMagicId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Annotated ProtocolMagicId a)) :*: S1 ('MetaSel ('Just "aHeaderPrevHash") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Annotated HeaderHash a))) :*: (S1 ('MetaSel ('Just "aHeaderSlot") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Annotated SlotNumber a)) :*: (S1 ('MetaSel ('Just "aHeaderDifficulty") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Annotated ChainDifficulty a)) :*: S1 ('MetaSel ('Just "headerProtocolVersion") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ProtocolVersion)))) :*: ((S1 ('MetaSel ('Just "headerSoftwareVersion") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SoftwareVersion) :*: (S1 ('MetaSel ('Just "aHeaderProof") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Annotated Proof a)) :*: S1 ('MetaSel ('Just "headerGenesisKey") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 VerificationKey))) :*: (S1 ('MetaSel ('Just "headerSignature") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (ABlockSignature a)) :*: (S1 ('MetaSel ('Just "headerAnnotation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "headerExtraAnnotation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)))))) | |||||
Data to be signed in Block
Constructors
| ToSign | |
Fields
| |
Instances
| FromCBOR ToSign Source # | |||||
| ToCBOR ToSign Source # | |||||
| DecCBOR ToSign Source # | |||||
| EncCBOR ToSign Source # | |||||
| Generic ToSign Source # | |||||
Defined in Cardano.Chain.Block.Header Associated Types
| |||||
| Show ToSign Source # | |||||
| Eq ToSign Source # | |||||
| type Rep ToSign Source # | |||||
Defined in Cardano.Chain.Block.Header type Rep ToSign = D1 ('MetaData "ToSign" "Cardano.Chain.Block.Header" "cardano-ledger-byron-1.3.0.0-inplace" 'False) (C1 ('MetaCons "ToSign" 'PrefixI 'True) ((S1 ('MetaSel ('Just "tsHeaderHash") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HeaderHash) :*: (S1 ('MetaSel ('Just "tsBodyProof") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Proof) :*: S1 ('MetaSel ('Just "tsSlot") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 EpochAndSlotCount))) :*: (S1 ('MetaSel ('Just "tsDifficulty") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ChainDifficulty) :*: (S1 ('MetaSel ('Just "tsProtocolVersion") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ProtocolVersion) :*: S1 ('MetaSel ('Just "tsSoftwareVersion") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SoftwareVersion))))) | |||||
boundaryHeaderHashAnnotated ∷ ABoundaryHeader ByteString → HeaderHash Source #
Compute the hash of a boundary block header from its annotation.
It uses wrapBoundaryBytes, for the hash must be computed on the header
bytes tagged with the CBOR list length and tag discriminator, which is
the encoding chosen by cardano-sl.
decCBORAHeader ∷ EpochSlots → Decoder s (AHeader ByteSpan) Source #
encCBORABoundaryHeader ∷ ProtocolMagicId → ABoundaryHeader a → Encoding Source #
Encode from a boundary header with any annotation. This does not
necessarily invert decCBORBoundaryHeader, because that decoder drops
information that this encoder replaces, such as the body proof (assumes
the body is empty) and the extra header data (sets it to empty map).
encCBORHeader ∷ EpochSlots → Header → Encoding Source #
Encode a header, without taking in to account deprecated epoch boundary blocks.
encCBORHeaderSize ∷ Proxy EpochSlots → Proxy (AHeader a) → Size Source #
genesisHeaderHash ∷ GenesisHash → HeaderHash Source #
Extract the genesis hash and cast it into a header hash.
hashHeader ∷ EpochSlots → Header → HeaderHash Source #
Hash the serialised representation of a Header
For backwards compatibility we have to take the hash of the header
serialised with encCBORHeaderToHash
headerPrevHash ∷ AHeader a → HeaderHash Source #
headerProof ∷ AHeader a → Proof Source #
headerSlot ∷ AHeader a → SlotNumber Source #
headerToSign ∷ EpochSlots → AHeader a → ToSign Source #
Arguments
| ∷ ProtocolMagicId | |
| → HeaderHash | Parent |
| → ChainDifficulty | |
| → EpochSlots | See |
| → SlotNumber | |
| → SigningKey | The |
| → Certificate | A certificate of delegation from a genesis key to the |
| → Body | |
| → ProtocolVersion | |
| → SoftwareVersion | |
| → Header |
Make a Header for a given slot, with a given body, parent hash,
and difficulty. This takes care of some signing and consensus data.
bodyWitnesses ∷ Body → [TxWitness] Source #
dropBoundaryExtraHeaderDataRetainGenesisTag ∷ Decoder s Bool Source #
When starting a new chain in ourorobos-consensus, we often start from a non-zero epoch. This is done in order to ensure synchronisation between nodes - we assume that the chain started at some fixed point in the past (e.g. midnight) which all nodes can agree on despite different node start times. However, the standard deserialisation assumes that the genesis EBB is precisely that in epoch zero.
In order to successfully round-trip a genesis EBB in a non-zero epoch, then, we add a "magic" tag which indicates the presense of the genesis hash. The choice of 255 and the word Genesis is completely arbitrary, and only done to correspond with the matching encoder. This encoding will only ever be seen when processing blocks from a demo.
Arguments
| ∷ ProtocolMagicId | |
| → Either GenesisHash Header | |
| → EpochSlots | Number of slots per epoch. This is needed to convert the slot number to
the legacy format used in |
| → SlotNumber | |
| → SigningKey | The |
| → Certificate | A certificate of delegation from a genesis key to the |
| → Body | |
| → ProtocolVersion | |
| → SoftwareVersion | |
| → Header |
Smart constructor for Header
encCBORHeaderToHash ∷ EpochSlots → Header → Encoding Source #
Encode a Header accounting for deprecated epoch boundary blocks
This encoding is only used when hashing the header for backwards compatibility, but should not be used when serializing a header within a block
decCBORHeader ∷ EpochSlots → Decoder s Header Source #
decCBORHeaderToHash ∷ EpochSlots → Decoder s (Maybe Header) Source #
wrapHeaderBytes ∷ ByteString → ByteString Source #
These bytes must be prepended when hashing raw boundary header data
In the Byron release, hashes were taken over a data type that was never directly serialized to the blockchain, so these magic bytes cannot be determined from the raw header data.
These bytes are from `encodeListLen 2 <> encCBOR (1 :: Word8)`
renderHeader ∷ EpochSlots → Header → Builder Source #
mkABoundaryHeader ∷ Either GenesisHash HeaderHash → Word64 → ChainDifficulty → a → ABoundaryHeader a Source #
Smart constructor for ABoundaryHeader
Makes sure that the hash is forced.
wrapBoundaryBytes ∷ ByteString → ByteString Source #
These bytes must be prepended when hashing raw boundary header data
In the Byron release, hashes were taken over a data type that was never directly serialized to the blockchain, so these magic bytes cannot be determined from the raw header data.
headerHashF ∷ Format r (HeaderHash → r) Source #
Specialized formatter for HeaderHash
type BlockSignature = ABlockSignature () Source #
data ProofValidationError Source #
Error which can result from attempting to validate an invalid payload proof.
Constructors
| DelegationProofValidationError | The delegation payload proof did not match |
| UTxOProofValidationError | The UTxO payload proof did not match |
| UpdateProofValidationError | The update payload proof did not match |
Instances
| Show ProofValidationError Source # | |
Defined in Cardano.Chain.Block.Proof Methods showsPrec ∷ Int → ProofValidationError → ShowS # show ∷ ProofValidationError → String # showList ∷ [ProofValidationError] → ShowS # | |
| Eq ProofValidationError Source # | |
Defined in Cardano.Chain.Block.Proof Methods | |
updateBody ∷ (MonadError ChainValidationError m, MonadReader ValidationMode m) ⇒ BodyEnvironment → BodyState → ABlock ByteString → m BodyState Source #
This is an implementation of the BBODY rule as per the chain specification.
Compared to updateChain, this does not validate any header level checks,
nor does it carry out anything which might be considered part of the
protocol.
updateChainBoundary ∷ MonadError ChainValidationError m ⇒ ChainValidationState → ABoundaryBlock ByteString → m ChainValidationState Source #
epochTransition ∷ EpochEnvironment → State → SlotNumber → State Source #
Perform epoch transition if we have moved across the epoch boundary
We pass through to the update interface UPIEC rule, which adopts any confirmed proposals and cleans up the state. This corresponds to the EPOCH rules from the Byron chain specification.
headerIsValid ∷ (MonadError ChainValidationError m, MonadReader ValidationMode m) ⇒ State → AHeader ByteString → m () Source #
This is an implementation of the headerIsValid function from the Byron chain specification
validateHeaderMatchesBody ∷ MonadError ProofValidationError m ⇒ AHeader ByteString → ABody ByteString → m () Source #
updateBlock ∷ (MonadError ChainValidationError m, MonadReader ValidationMode m) ⇒ Config → ChainValidationState → ABlock ByteString → m ChainValidationState Source #
This represents the CHAIN rule. It is intended more for use in tests than in a real implementation, which will want to invoke its constituent rules directly.
Note that this also updates the previous block hash, which would usually be done as part of the PBFT rule.
adoptedProtocolParameters ∷ State → ProtocolParameters Source #
Adopted protocol parameters
data BodyEnvironment Source #
Constructors
| BodyEnvironment | |
initialChainValidationState ∷ MonadError Error m ⇒ Config → m ChainValidationState Source #
Create the state needed to validate the zeroth epoch of the chain. The zeroth epoch starts with a boundary block where the previous hash is the genesis hash.
Number of entries in the UTxO
Constructors
| UTxOSize | |
Fields | |
foldUTxO ∷ Environment → UTxO → Stream (Of (ABlock ByteString)) (ExceptT ParseError ResIO) () → ExceptT Error (ReaderT ValidationMode ResIO) UTxO Source #
Fold transaction validation over a Stream of Blocks
foldUTxOBlock ∷ Environment → UTxO → ABlock ByteString → ExceptT Error (ReaderT ValidationMode ResIO) UTxO Source #
Fold updateUTxO over the transactions in a single Block