cardano-ledger-byron-1.0.2.0: The blockchain layer of Cardano during the Byron era
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Chain.Block

Synopsis

Documentation

data BlockValidationMode Source #

Indicates what sort of block validation should be performed.

Constructors

BlockValidation

Perform all block validations.

NoBlockValidation

Perform no block validations.

adoptedProtocolParametersStateProtocolParameters Source #

Adopted protocol parameters

updateBody ∷ (MonadError ChainValidationError m, MonadReader ValidationMode m) ⇒ BodyEnvironmentBodyStateABlock 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.

epochTransitionEpochEnvironmentStateSlotNumberState 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) ⇒ StateAHeader ByteString → m () Source #

This is an implementation of the headerIsValid function from the Byron chain specification

updateBlock ∷ (MonadError ChainValidationError m, MonadReader ValidationMode m) ⇒ ConfigChainValidationStateABlock 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.

data BodyState Source #

Constructors

BodyState 

Fields

data ChainValidationState Source #

Constructors

ChainValidationState 

Fields

Instances

Instances details
Generic ChainValidationState Source # 
Instance details

Defined in Cardano.Chain.Block.Validation

Associated Types

type Rep ChainValidationStateTypeType Source #

Show ChainValidationState Source # 
Instance details

Defined in Cardano.Chain.Block.Validation

FromCBOR ChainValidationState Source # 
Instance details

Defined in Cardano.Chain.Block.Validation

ToCBOR ChainValidationState Source # 
Instance details

Defined in Cardano.Chain.Block.Validation

DecCBOR ChainValidationState Source # 
Instance details

Defined in Cardano.Chain.Block.Validation

EncCBOR ChainValidationState Source # 
Instance details

Defined in Cardano.Chain.Block.Validation

NFData ChainValidationState Source # 
Instance details

Defined in Cardano.Chain.Block.Validation

Methods

rnfChainValidationState → () Source #

Eq ChainValidationState Source # 
Instance details

Defined in Cardano.Chain.Block.Validation

NoThunks ChainValidationState Source # 
Instance details

Defined in Cardano.Chain.Block.Validation

type Rep ChainValidationState Source # 
Instance details

Defined in Cardano.Chain.Block.Validation

type Rep ChainValidationState = D1 ('MetaData "ChainValidationState" "Cardano.Chain.Block.Validation" "cardano-ledger-byron-1.0.2.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)))))

initialChainValidationStateMonadError 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.

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 ProtocolMagic in the block doesn't match the configured one

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.

UTxO

newtype HeapSize a Source #

Size of a heap value, in words

Constructors

HeapSize 

Fields

Instances

Instances details
Show (HeapSize a) Source # 
Instance details

Defined in Cardano.Chain.Block.Validation

Buildable (HeapSize a) Source # 
Instance details

Defined in Cardano.Chain.Block.Validation

Methods

buildHeapSize a → Builder Source #

newtype UTxOSize Source #

Number of entries in the UTxO

Constructors

UTxOSize 

Fields

Instances

Instances details
Show UTxOSize Source # 
Instance details

Defined in Cardano.Chain.Block.Validation

Buildable UTxOSize Source # 
Instance details

Defined in Cardano.Chain.Block.Validation

Methods

buildUTxOSizeBuilder Source #

foldUTxOEnvironmentUTxOStream (Of (ABlock ByteString)) (ExceptT ParseError ResIO) () → ExceptT Error (ReaderT ValidationMode ResIO) UTxO Source #

Fold transaction validation over a Stream of Blocks

foldUTxOBlockEnvironmentUTxOABlock ByteStringExceptT Error (ReaderT ValidationMode ResIO) UTxO Source #

Fold updateUTxO over the transactions in a single Block

data Proof Source #

Proof of everything contained in the payload

Constructors

Proof 

Instances

Instances details
ToJSON Proof Source # 
Instance details

Defined in Cardano.Chain.Block.Proof

Generic Proof Source # 
Instance details

Defined in Cardano.Chain.Block.Proof

Associated Types

type Rep ProofTypeType Source #

Methods

fromProofRep Proof x Source #

toRep Proof x → Proof Source #

Show Proof Source # 
Instance details

Defined in Cardano.Chain.Block.Proof

FromCBOR Proof Source # 
Instance details

Defined in Cardano.Chain.Block.Proof

ToCBOR Proof Source # 
Instance details

Defined in Cardano.Chain.Block.Proof

Methods

toCBORProofEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy ProofSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Proof] → Size Source #

DecCBOR Proof Source # 
Instance details

Defined in Cardano.Chain.Block.Proof

EncCBOR Proof Source # 
Instance details

Defined in Cardano.Chain.Block.Proof

Methods

encCBORProofEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy ProofSize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [Proof] → Size Source #

NFData Proof Source # 
Instance details

Defined in Cardano.Chain.Block.Proof

Methods

rnfProof → () Source #

Buildable Proof Source # 
Instance details

Defined in Cardano.Chain.Block.Proof

Methods

buildProofBuilder Source #

Eq Proof Source # 
Instance details

Defined in Cardano.Chain.Block.Proof

Methods

(==)ProofProofBool Source #

(/=)ProofProofBool Source #

NoThunks Proof Source # 
Instance details

Defined in Cardano.Chain.Block.Proof

type Rep Proof Source # 
Instance details

Defined in Cardano.Chain.Block.Proof

type Rep Proof = D1 ('MetaData "Proof" "Cardano.Chain.Block.Proof" "cardano-ledger-byron-1.0.2.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))))

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

Header

data AHeader a Source #

Constructors

AHeader 

Fields

Instances

Instances details
Functor AHeader Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

fmap ∷ (a → b) → AHeader a → AHeader b Source #

(<$) ∷ a → AHeader b → AHeader a Source #

ToJSON a ⇒ ToJSON (AHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Generic (AHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Associated Types

type Rep (AHeader a) ∷ TypeType Source #

Methods

fromAHeader a → Rep (AHeader a) x Source #

toRep (AHeader a) x → AHeader a Source #

Show a ⇒ Show (AHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

showsPrecIntAHeader a → ShowS Source #

showAHeader a → String Source #

showList ∷ [AHeader a] → ShowS Source #

Decoded (AHeader ByteString) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Associated Types

type BaseType (AHeader ByteString) Source #

NFData a ⇒ NFData (AHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

rnfAHeader a → () Source #

Buildable (WithEpochSlots Header) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Eq a ⇒ Eq (AHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

(==)AHeader a → AHeader a → Bool Source #

(/=)AHeader a → AHeader a → Bool Source #

NoThunks a ⇒ NoThunks (AHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

type Rep (AHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

type Rep (AHeader a) = D1 ('MetaData "AHeader" "Cardano.Chain.Block.Header" "cardano-ledger-byron-1.0.2.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))))))
type BaseType (AHeader ByteString) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Header Constructors

mkHeader Source #

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 ToSign, where a slot is identified by the epoch to which it belongs and the offset within that epoch (counted in number of slots).

SlotNumber 
SigningKey

The SigningKey used for signing the block

Certificate

A certificate of delegation from a genesis key to the SigningKey

Body 
ProtocolVersion 
SoftwareVersion 
Header 

Smart constructor for Header

mkHeaderExplicit Source #

Arguments

ProtocolMagicId 
HeaderHash

Parent

ChainDifficulty 
EpochSlots

See mkHeader.

SlotNumber 
SigningKey

The SigningKey used for signing the block

Certificate

A certificate of delegation from a genesis key to the SigningKey

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.

Header Accessors

Header Binary Serialization

encCBORHeaderEpochSlotsHeaderEncoding Source #

Encode a header, without taking in to account deprecated epoch boundary blocks.

encCBORHeaderToHashEpochSlotsHeaderEncoding 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

wrapHeaderBytesByteStringByteString 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)`

Header Formatting

Boundary Header

data ABoundaryHeader a Source #

Instances

Instances details
Functor ABoundaryHeader Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

fmap ∷ (a → b) → ABoundaryHeader a → ABoundaryHeader b Source #

(<$) ∷ a → ABoundaryHeader b → ABoundaryHeader a Source #

ToJSON a ⇒ ToJSON (ABoundaryHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Generic (ABoundaryHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Associated Types

type Rep (ABoundaryHeader a) ∷ TypeType Source #

Show a ⇒ Show (ABoundaryHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Decoded (ABoundaryHeader ByteString) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Associated Types

type BaseType (ABoundaryHeader ByteString) Source #

Eq a ⇒ Eq (ABoundaryHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

NoThunks a ⇒ NoThunks (ABoundaryHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

type Rep (ABoundaryHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

type Rep (ABoundaryHeader a) = D1 ('MetaData "ABoundaryHeader" "Cardano.Chain.Block.Header" "cardano-ledger-byron-1.0.2.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))))
type BaseType (ABoundaryHeader ByteString) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

mkABoundaryHeaderEither GenesisHash HeaderHashWord64ChainDifficulty → a → ABoundaryHeader a Source #

Smart constructor for ABoundaryHeader

Makes sure that the hash is forced.

encCBORABoundaryHeaderProtocolMagicIdABoundaryHeader 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).

boundaryHeaderHashAnnotatedABoundaryHeader ByteStringHeaderHash 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.

wrapBoundaryBytesByteStringByteString 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.

HeaderHash

type HeaderHash = Hash Header Source #

Hash of block header

headerHashFFormat r (HeaderHash → r) Source #

Specialized formatter for HeaderHash

hashHeaderEpochSlotsHeaderHeaderHash Source #

Hash the serialised representation of a Header

For backwards compatibility we have to take the hash of the header serialised with encCBORHeaderToHash

genesisHeaderHashGenesisHashHeaderHash Source #

Extract the genesis hash and cast it into a header hash.

BlockSignature

data ABlockSignature a Source #

Signature of the Block

We use a heavyweight delegation scheme, so the signature has two parts:

  1. A delegation certificate from a genesis key to the block signer
  2. The actual signature over ToSign

Instances

Instances details
Functor ABlockSignature Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

fmap ∷ (a → b) → ABlockSignature a → ABlockSignature b Source #

(<$) ∷ a → ABlockSignature b → ABlockSignature a Source #

FromCBOR BlockSignature Source # 
Instance details

Defined in Cardano.Chain.Block.Header

ToCBOR BlockSignature Source # 
Instance details

Defined in Cardano.Chain.Block.Header

DecCBOR BlockSignature Source # 
Instance details

Defined in Cardano.Chain.Block.Header

EncCBOR BlockSignature Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Buildable BlockSignature Source # 
Instance details

Defined in Cardano.Chain.Block.Header

ToJSON a ⇒ ToJSON (ABlockSignature a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Generic (ABlockSignature a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Associated Types

type Rep (ABlockSignature a) ∷ TypeType Source #

Show a ⇒ Show (ABlockSignature a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

FromCBOR (ABlockSignature ByteSpan) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

DecCBOR (ABlockSignature ByteSpan) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

NFData a ⇒ NFData (ABlockSignature a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

rnfABlockSignature a → () Source #

Eq a ⇒ Eq (ABlockSignature a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

NoThunks a ⇒ NoThunks (ABlockSignature a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

type Rep (ABlockSignature a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

type Rep (ABlockSignature a) = D1 ('MetaData "ABlockSignature" "Cardano.Chain.Block.Header" "cardano-ledger-byron-1.0.2.0-inplace" 'False) (C1 ('MetaCons "ABlockSignature" 'PrefixI 'True) (S1 ('MetaSel ('Just "delegationCertificate") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (ACertificate a)) :*: S1 ('MetaSel ('Just "signature") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Signature ToSign))))

ToSign

data ToSign Source #

Data to be signed in Block

Instances

Instances details
Generic ToSign Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Associated Types

type Rep ToSignTypeType Source #

Methods

fromToSignRep ToSign x Source #

toRep ToSign x → ToSign Source #

Show ToSign Source # 
Instance details

Defined in Cardano.Chain.Block.Header

FromCBOR ToSign Source # 
Instance details

Defined in Cardano.Chain.Block.Header

ToCBOR ToSign Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

toCBORToSignEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy ToSignSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [ToSign] → Size Source #

DecCBOR ToSign Source # 
Instance details

Defined in Cardano.Chain.Block.Header

EncCBOR ToSign Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

encCBORToSignEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy ToSignSize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [ToSign] → Size Source #

Eq ToSign Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

(==)ToSignToSignBool Source #

(/=)ToSignToSignBool Source #

type Rep ToSign Source # 
Instance details

Defined in Cardano.Chain.Block.Header

recoverSignedBytesEpochSlotsAHeader ByteStringAnnotated ToSign ByteString Source #

Produces the ByteString that was signed in the block

dropBoundaryExtraHeaderDataRetainGenesisTagDecoder 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.

type Body = ABody () Source #

Body consists of payloads of all block components

pattern BodyTxPayloadSscPayloadPayloadPayloadBody Source #

Constructor for Body

data ABody a Source #

Body consists of payloads of all block components

Constructors

ABody 

Fields

Instances

Instances details
Functor ABody Source # 
Instance details

Defined in Cardano.Chain.Block.Body

Methods

fmap ∷ (a → b) → ABody a → ABody b Source #

(<$) ∷ a → ABody b → ABody a Source #

FromCBOR Body Source # 
Instance details

Defined in Cardano.Chain.Block.Body

ToCBOR Body Source # 
Instance details

Defined in Cardano.Chain.Block.Body

Methods

toCBORBodyEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy BodySize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Body] → Size Source #

DecCBOR Body Source # 
Instance details

Defined in Cardano.Chain.Block.Body

EncCBOR Body Source # 
Instance details

Defined in Cardano.Chain.Block.Body

Methods

encCBORBodyEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy BodySize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [Body] → Size Source #

ToJSON a ⇒ ToJSON (ABody a) Source # 
Instance details

Defined in Cardano.Chain.Block.Body

Generic (ABody a) Source # 
Instance details

Defined in Cardano.Chain.Block.Body

Associated Types

type Rep (ABody a) ∷ TypeType Source #

Methods

fromABody a → Rep (ABody a) x Source #

toRep (ABody a) x → ABody a Source #

Show a ⇒ Show (ABody a) Source # 
Instance details

Defined in Cardano.Chain.Block.Body

Methods

showsPrecIntABody a → ShowS Source #

showABody a → String Source #

showList ∷ [ABody a] → ShowS Source #

FromCBOR (ABody ByteSpan) Source # 
Instance details

Defined in Cardano.Chain.Block.Body

DecCBOR (ABody ByteSpan) Source # 
Instance details

Defined in Cardano.Chain.Block.Body

NFData a ⇒ NFData (ABody a) Source # 
Instance details

Defined in Cardano.Chain.Block.Body

Methods

rnfABody a → () Source #

Eq a ⇒ Eq (ABody a) Source # 
Instance details

Defined in Cardano.Chain.Block.Body

Methods

(==)ABody a → ABody a → Bool Source #

(/=)ABody a → ABody a → Bool Source #

type Rep (ABody a) Source # 
Instance details

Defined in Cardano.Chain.Block.Body

type Rep (ABody a) = D1 ('MetaData "ABody" "Cardano.Chain.Block.Body" "cardano-ledger-byron-1.0.2.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)))))

bodyTxsBody → [Tx] Source #

Block

type Block = ABlock () Source #

data ABlock a Source #

Constructors

ABlock 

Fields

Instances

Instances details
Functor ABlock Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Methods

fmap ∷ (a → b) → ABlock a → ABlock b Source #

(<$) ∷ a → ABlock b → ABlock a Source #

ToJSON a ⇒ ToJSON (ABlock a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Generic (ABlock a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Associated Types

type Rep (ABlock a) ∷ TypeType Source #

Methods

fromABlock a → Rep (ABlock a) x Source #

toRep (ABlock a) x → ABlock a Source #

Show a ⇒ Show (ABlock a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Methods

showsPrecIntABlock a → ShowS Source #

showABlock a → String Source #

showList ∷ [ABlock a] → ShowS Source #

NFData a ⇒ NFData (ABlock a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Methods

rnfABlock a → () Source #

Buildable (WithEpochSlots Block) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Eq a ⇒ Eq (ABlock a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Methods

(==)ABlock a → ABlock a → Bool Source #

(/=)ABlock a → ABlock a → Bool Source #

type Rep (ABlock a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

type Rep (ABlock a) = D1 ('MetaData "ABlock" "Cardano.Chain.Block.Block" "cardano-ledger-byron-1.0.2.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))))

Block Constructors

mkBlock Source #

Arguments

ProtocolMagicId 
ProtocolVersion 
SoftwareVersion 
Either GenesisHash Header 
EpochSlots 
SlotNumber 
SigningKey

The SigningKey used for signing the block

Certificate

A certificate of delegation from a genesis key to the SigningKey

Body 
Block 

Smart constructor for Block

mkBlockExplicit Source #

Arguments

ProtocolMagicId 
ProtocolVersion 
SoftwareVersion 
HeaderHash 
ChainDifficulty 
EpochSlots 
SlotNumber 
SigningKey

The SigningKey used for signing the block

Certificate

A certificate of delegation from a genesis key to the SigningKey

Body 
Block 

Smart constructor for Block, without requiring the entire previous Header. Instead, you give its hash and the difficulty of this block. These are derived from the previous header in mkBlock so if you have the previous header, consider using that one.

Block Accessors

Block Binary Serialization

encCBORBlockEpochSlotsBlockEncoding 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.

Block Formatting

ABlockOrBoundary

data ABlockOrBoundary a Source #

Instances

Instances details
Functor ABlockOrBoundary Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Methods

fmap ∷ (a → b) → ABlockOrBoundary a → ABlockOrBoundary b Source #

(<$) ∷ a → ABlockOrBoundary b → ABlockOrBoundary a Source #

ToJSON a ⇒ ToJSON (ABlockOrBoundary a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Generic (ABlockOrBoundary a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Associated Types

type Rep (ABlockOrBoundary a) ∷ TypeType Source #

Show a ⇒ Show (ABlockOrBoundary a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Eq a ⇒ Eq (ABlockOrBoundary a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

type Rep (ABlockOrBoundary a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

type Rep (ABlockOrBoundary a) = D1 ('MetaData "ABlockOrBoundary" "Cardano.Chain.Block.Block" "cardano-ledger-byron-1.0.2.0-inplace" 'False) (C1 ('MetaCons "ABOBBlock" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ABlock a))) :+: C1 ('MetaCons "ABOBBoundary" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ABoundaryBlock a))))

encCBORABOBBlockEpochSlotsABlock a → Encoding Source #

Encode a Block accounting for deprecated epoch boundary blocks

decCBORABOBBlockEpochSlotsDecoder s (Maybe Block) Source #

Decode a Block accounting for deprecated epoch boundary blocks

decCBORABlockOrBoundaryEpochSlotsDecoder 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.

ABoundaryBlock

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

Instances details
Functor ABoundaryBlock Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Methods

fmap ∷ (a → b) → ABoundaryBlock a → ABoundaryBlock b Source #

(<$) ∷ a → ABoundaryBlock b → ABoundaryBlock a Source #

ToJSON a ⇒ ToJSON (ABoundaryBlock a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Generic (ABoundaryBlock a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Associated Types

type Rep (ABoundaryBlock a) ∷ TypeType Source #

Show a ⇒ Show (ABoundaryBlock a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Decoded (ABoundaryBlock ByteString) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Associated Types

type BaseType (ABoundaryBlock ByteString) Source #

Buildable (ABoundaryBlock a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Eq a ⇒ Eq (ABoundaryBlock a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

type Rep (ABoundaryBlock a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

type Rep (ABoundaryBlock a) = D1 ('MetaData "ABoundaryBlock" "Cardano.Chain.Block.Block" "cardano-ledger-byron-1.0.2.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))))
type BaseType (ABoundaryBlock ByteString) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

boundaryHashAnnotatedABoundaryBlock ByteStringHeaderHash Source #

Extract the hash of a boundary block from its annotation.

encCBORABoundaryBlockProtocolMagicIdABoundaryBlock a → Encoding Source #

See note on encCBORABoundaryHeader. This as well does not necessarily invert the decoder decCBORABoundaryBlock.

encCBORABOBBoundaryProtocolMagicIdABoundaryBlock a → Encoding Source #

encCBORABoundaryBlock but with the list length and tag discriminator bytes.

boundaryBlockSlot Source #

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

Instances details
Functor ABoundaryBody Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Methods

fmap ∷ (a → b) → ABoundaryBody a → ABoundaryBody b Source #

(<$) ∷ a → ABoundaryBody b → ABoundaryBody a Source #

ToJSON a ⇒ ToJSON (ABoundaryBody a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Generic (ABoundaryBody a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Associated Types

type Rep (ABoundaryBody a) ∷ TypeType Source #

Show a ⇒ Show (ABoundaryBody a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Decoded (ABoundaryBody ByteString) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Associated Types

type BaseType (ABoundaryBody ByteString) Source #

Eq a ⇒ Eq (ABoundaryBody a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

type Rep (ABoundaryBody a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

type Rep (ABoundaryBody a) = D1 ('MetaData "ABoundaryBody" "Cardano.Chain.Block.Block" "cardano-ledger-byron-1.0.2.0-inplace" 'False) (C1 ('MetaCons "ABoundaryBody" 'PrefixI 'True) (S1 ('MetaSel ('Just "boundaryBodyAnnotation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)))
type BaseType (ABoundaryBody ByteString) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

ABlockOrBoundaryHdr

data ABlockOrBoundaryHdr a Source #

Instances

Instances details
Functor ABlockOrBoundaryHdr Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Generic (ABlockOrBoundaryHdr a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Associated Types

type Rep (ABlockOrBoundaryHdr a) ∷ TypeType Source #

Show a ⇒ Show (ABlockOrBoundaryHdr a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

Eq a ⇒ Eq (ABlockOrBoundaryHdr a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

NoThunks a ⇒ NoThunks (ABlockOrBoundaryHdr a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

type Rep (ABlockOrBoundaryHdr a) Source # 
Instance details

Defined in Cardano.Chain.Block.Block

type Rep (ABlockOrBoundaryHdr a) = D1 ('MetaData "ABlockOrBoundaryHdr" "Cardano.Chain.Block.Block" "cardano-ledger-byron-1.0.2.0-inplace" 'False) (C1 ('MetaCons "ABOBBlockHdr" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (AHeader a))) :+: C1 ('MetaCons "ABOBBoundaryHdr" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (ABoundaryHeader a))))

aBlockOrBoundaryHdr ∷ (AHeader a → b) → (ABoundaryHeader a → b) → ABlockOrBoundaryHdr a → b Source #

The analogue of either

encCBORABlockOrBoundaryHdrABlockOrBoundaryHdr ByteStringEncoding 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.

abobHdrSlotNoEpochSlotsABlockOrBoundaryHdr a → SlotNumber Source #

Slot number of the header

NOTE: Epoch slot number calculation must match the one in applyBoundary.