Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.Shelley.Ledger
Synopsis
- data family BlockQuery blk ∷ Type → Type
- data family GenTx blk
- data family TxId tx
- data family Validated x
- data family LedgerState blk
- data family BlockConfig blk
- data family CodecConfig blk
- data family StorageConfig blk
- data family Header blk
- class HasHeader (Header blk) ⇒ GetHeader blk where
- getHeader ∷ blk → Header blk
- blockMatchesHeader ∷ Header blk → blk → Bool
- headerIsEBB ∷ Header blk → Maybe EpochNo
- data family NestedCtxt_ blk ∷ (Type → Type) → Type → Type
- data family Ticked st
- newtype ApplyTxError era = ApplyTxError [PredicateFailure (EraRule "LEDGER" era)]
- class (EraSegWits era, EraGovernance era, ApplyTx era, ApplyBlock era, CanStartFromGenesis era, GetLedgerView era, NoThunks (StashedAVVMAddresses era), EncCBOR (StashedAVVMAddresses era), DecCBOR (StashedAVVMAddresses era), Show (StashedAVVMAddresses era), Eq (StashedAVVMAddresses era), DecCBOR (PredicateFailure (EraRule "LEDGER" era)), EncCBOR (PredicateFailure (EraRule "LEDGER" era)), DecCBOR (PredicateFailure (EraRule "DELEGS" era)), EncCBOR (PredicateFailure (EraRule "DELEGS" era)), DecCBOR (PredicateFailure (EraRule "UTXOW" era)), EncCBOR (PredicateFailure (EraRule "UTXOW" era)), DSignable (EraCrypto era) (Hash (EraCrypto era) EraIndependentTxBody), NoThunks (PredicateFailure (EraRule "BBODY" era)), NoThunks (TranslationContext era)) ⇒ ShelleyBasedEra era
- verifyHeaderIntegrity ∷ ProtocolHeaderSupportsKES proto ⇒ Word64 → ShelleyProtocolHeader proto → Bool
- newtype ShelleyHash crypto = ShelleyHash {
- unShelleyHash ∷ Hash crypto EraIndependentBlockHeader
- data ShelleyBlock proto era = ShelleyBlock {
- shelleyBlockRaw ∷ !(Block (ShelleyProtocolHeader proto) era)
- shelleyBlockHeaderHash ∷ !(ShelleyHash (ProtoCrypto proto))
- class (ShelleyBasedEra era, ShelleyProtocol proto, Eq (ShelleyProtocolHeader proto), Show (ShelleyProtocolHeader proto), NoThunks (ShelleyProtocolHeader proto), EncCBOR (ShelleyProtocolHeader proto), DecCBOR (Annotator (ShelleyProtocolHeader proto)), Show (CannotForgeError proto), SelectView proto ~ PraosChainSelectView (EraCrypto era), SignedHeader (ShelleyProtocolHeader proto), DecodeDisk (ShelleyBlock proto era) (ChainDepState proto), EncodeDisk (ShelleyBlock proto era) (ChainDepState proto), EraCrypto era ~ ProtoCrypto proto, HasPartialConsensusConfig proto, DecCBOR (PState (ProtoCrypto proto))) ⇒ ShelleyCompatible proto era
- mkShelleyBlock ∷ ShelleyCompatible proto era ⇒ Block (ShelleyProtocolHeader proto) era → ShelleyBlock proto era
- mkShelleyHeader ∷ ShelleyCompatible proto era ⇒ ShelleyProtocolHeader proto → Header (ShelleyBlock proto era)
- fromShelleyPrevHash ∷ EraCrypto era ~ ProtoCrypto proto ⇒ PrevHash (EraCrypto era) → ChainHash (ShelleyBlock proto era)
- toShelleyPrevHash ∷ EraCrypto era ~ ProtoCrypto proto ⇒ ChainHash (Header (ShelleyBlock proto era)) → PrevHash (EraCrypto era)
- encodeShelleyBlock ∷ ∀ proto era. ShelleyCompatible proto era ⇒ ShelleyBlock proto era → Encoding
- decodeShelleyBlock ∷ ∀ proto era. ShelleyCompatible proto era ⇒ ∀ s. Decoder s (ByteString → ShelleyBlock proto era)
- shelleyBinaryBlockInfo ∷ ∀ proto era. ShelleyCompatible proto era ⇒ ShelleyBlock proto era → BinaryBlockInfo
- encodeShelleyHeader ∷ ∀ proto era. ShelleyCompatible proto era ⇒ Header (ShelleyBlock proto era) → Encoding
- decodeShelleyHeader ∷ ∀ proto era. ShelleyCompatible proto era ⇒ ∀ s. Decoder s (ByteString → Header (ShelleyBlock proto era))
- data ShelleyNodeToClientVersion
- data ShelleyNodeToNodeVersion = ShelleyNodeToNodeVersion1
- verifyBlockIntegrity ∷ ShelleyCompatible proto era ⇒ Word64 → ShelleyBlock proto era → Bool
- data CompactGenesis c
- mkShelleyBlockConfig ∷ ShelleyBasedEra era ⇒ ProtVer → ShelleyGenesis (EraCrypto era) → [VKey 'BlockIssuer (EraCrypto era)] → BlockConfig (ShelleyBlock proto era)
- compactGenesis ∷ ShelleyGenesis c → CompactGenesis c
- data ShelleyReapplyException = ∀ era.Show (BlockTransitionError era) ⇒ ShelleyReapplyException (BlockTransitionError era)
- data ShelleyLedgerEvent era
- = ShelleyLedgerEventBBODY (Event (EraRule "BBODY" era))
- | ShelleyLedgerEventTICK (Event (EraRule "TICK" era))
- newtype ShelleyTransition = ShelleyTransitionInfo {}
- data ShelleyTip proto era = ShelleyTip {
- shelleyTipSlotNo ∷ !SlotNo
- shelleyTipBlockNo ∷ !BlockNo
- shelleyTipHash ∷ !(HeaderHash (ShelleyBlock proto era))
- data ShelleyLedgerConfig era = ShelleyLedgerConfig {
- shelleyLedgerCompactGenesis ∷ !(CompactGenesis (EraCrypto era))
- shelleyLedgerGlobals ∷ !Globals
- shelleyLedgerTranslationContext ∷ !(TranslationContext era)
- newtype ShelleyLedgerError era = BBodyError (BlockTransitionError era)
- shelleyLedgerGenesis ∷ ShelleyLedgerConfig era → ShelleyGenesis (EraCrypto era)
- shelleyEraParams ∷ ShelleyGenesis c → EraParams
- shelleyEraParamsNeverHardForks ∷ ShelleyGenesis c → EraParams
- mkShelleyLedgerConfig ∷ ShelleyGenesis (EraCrypto era) → TranslationContext era → EpochInfo (Except PastHorizonException) → MaxMajorProtVer → ShelleyLedgerConfig era
- shelleyTipToPoint ∷ WithOrigin (ShelleyTip proto era) → Point (ShelleyBlock proto era)
- castShelleyTip ∷ HeaderHash (ShelleyBlock proto era) ~ HeaderHash (ShelleyBlock proto' era') ⇒ ShelleyTip proto era → ShelleyTip proto' era'
- shelleyLedgerTipPoint ∷ LedgerState (ShelleyBlock proto era) → Point (ShelleyBlock proto era)
- getPParams ∷ NewEpochState era → PParams era
- encodeShelleyAnnTip ∷ ShelleyCompatible proto era ⇒ AnnTip (ShelleyBlock proto era) → Encoding
- decodeShelleyAnnTip ∷ ShelleyCompatible proto era ⇒ Decoder s (AnnTip (ShelleyBlock proto era))
- encodeShelleyHeaderState ∷ ShelleyCompatible proto era ⇒ HeaderState (ShelleyBlock proto era) → Encoding
- encodeShelleyLedgerState ∷ ShelleyCompatible proto era ⇒ LedgerState (ShelleyBlock proto era) → Encoding
- decodeShelleyLedgerState ∷ ∀ era proto s. ShelleyCompatible proto era ⇒ Decoder s (LedgerState (ShelleyBlock proto era))
- data StakeSnapshots crypto = StakeSnapshots {
- ssStakeSnapshots ∷ !(Map (KeyHash 'StakePool crypto) (StakeSnapshot crypto))
- ssMarkTotal ∷ !Coin
- ssSetTotal ∷ !Coin
- ssGoTotal ∷ !Coin
- data StakeSnapshot crypto = StakeSnapshot {
- ssMarkPool ∷ !Coin
- ssSetPool ∷ !Coin
- ssGoPool ∷ !Coin
- newtype NonMyopicMemberRewards c = NonMyopicMemberRewards {
- unNonMyopicMemberRewards ∷ Map (Either Coin (Credential 'Staking c)) (Map (KeyHash 'StakePool c) Coin)
- querySupportedVersion ∷ BlockQuery (ShelleyBlock proto era) result → ShelleyNodeToClientVersion → Bool
- encodeShelleyQuery ∷ ∀ era proto result. ShelleyBasedEra era ⇒ BlockQuery (ShelleyBlock proto era) result → Encoding
- decodeShelleyQuery ∷ ∀ era proto. ShelleyBasedEra era ⇒ ∀ s. Decoder s (SomeSecond BlockQuery (ShelleyBlock proto era))
- encodeShelleyResult ∷ ∀ proto era result. ShelleyCompatible proto era ⇒ BlockQuery (ShelleyBlock proto era) result → result → Encoding
- decodeShelleyResult ∷ ∀ proto era result. ShelleyCompatible proto era ⇒ BlockQuery (ShelleyBlock proto era) result → ∀ s. Decoder s result
- data WithTop a
- data AlonzoMeasure = AlonzoMeasure {}
- fixedBlockBodyOverhead ∷ Num a ⇒ a
- perTxOverhead ∷ Num a ⇒ a
- mkShelleyTx ∷ ∀ era proto. ShelleyBasedEra era ⇒ Tx era → GenTx (ShelleyBlock proto era)
- mkShelleyValidatedTx ∷ ∀ era proto. ShelleyBasedEra era ⇒ Validated (Tx era) → Validated (GenTx (ShelleyBlock proto era))
- fromExUnits ∷ ExUnits → ExUnits' (WithTop Natural)
- forgeShelleyBlock ∷ ∀ m era proto. (ShelleyCompatible proto era, TxLimits (ShelleyBlock proto era), Monad m) ⇒ HotKey (EraCrypto era) m → CanBeLeader proto → TopLevelConfig (ShelleyBlock proto era) → TxOverrides (ShelleyBlock proto era) → BlockNo → SlotNo → TickedLedgerState (ShelleyBlock proto era) → [Validated (GenTx (ShelleyBlock proto era))] → IsLeader proto → m (ShelleyBlock proto era)
Documentation
data family BlockQuery blk ∷ Type → Type Source #
Different queries supported by the ledger, indexed by the result type.
Instances
data family GenTx blk Source #
Generalized transaction
The mempool (and, accordingly, blocks) consist of "generalized transactions"; this could be "proper" transactions (transferring funds) but also other kinds of things such as update proposals, delegations, etc.
Instances
A generalized transaction, GenTx
, identifier.
Instances
data family Validated x Source #
" Validated " transaction or block
The ledger defines how to validate transactions and blocks. It's possible the type before and after validation may be distinct (eg Alonzo transactions), which originally motivated this family.
We also gain the related benefit that certain interface functions, such as those that reapply blocks, can have a more precise type now. TODO
Similarly, the Node-to-Client mini protocols can explicitly indicate that the
client trusts the blocks from the local server, by having the server send
Validated
blocks to the client. TODO
Note that validation has different implications for a transaction than for a block. In particular, a validated transaction can be " reapplied " to different ledger states, whereas a validated block must only be " reapplied " to the exact same ledger state (eg as part of rebuilding from an on-disk ledger snapshot).
Since the ledger defines validation, see the ledger details for concrete
examples of what determines the validity (wrt to a LedgerState
) of a
transaction and/or block. Example properties include: a transaction's claimed
inputs exist and are still unspent, a block carries a sufficient
cryptographic signature, etc.
Instances
data family LedgerState blk Source #
Ledger state associated with a block
Instances
data family BlockConfig blk Source #
Static configuration required to work with this type of blocks
Instances
data family CodecConfig blk Source #
Static configuration required for serialisation and deserialisation of types pertaining to this type of block.
Data family instead of type family to get better type inference.
Instances
data family StorageConfig blk Source #
Config needed for the
NodeInitStorage
class. Defined here to
avoid circular dependencies.
Instances
data family Header blk Source #
Instances
class HasHeader (Header blk) ⇒ GetHeader blk where Source #
Methods
getHeader ∷ blk → Header blk Source #
blockMatchesHeader ∷ Header blk → blk → Bool Source #
Check whether the header is the header of the block.
For example, by checking whether the hash of the body stored in the header matches that of the block.
headerIsEBB ∷ Header blk → Maybe EpochNo Source #
When the given header is the header of an Epoch Boundary Block, returns its epoch number.
Instances
ShelleyCompatible proto era ⇒ GetHeader (ShelleyBlock proto era) Source # | |
Defined in Ouroboros.Consensus.Shelley.Ledger.Block Methods getHeader ∷ ShelleyBlock proto era → Header (ShelleyBlock proto era) Source # blockMatchesHeader ∷ Header (ShelleyBlock proto era) → ShelleyBlock proto era → Bool Source # headerIsEBB ∷ Header (ShelleyBlock proto era) → Maybe EpochNo Source # |
data family NestedCtxt_ blk ∷ (Type → Type) → Type → Type Source #
Context identifying what kind of block we have
In almost all places we will use NestedCtxt
rather than NestedCtxt_
.
Instances
data family Ticked st Source #
" Ticked " piece of state (LedgerState
, LedgerView
, ChainIndepState
)
Ticking refers to the passage of time (the ticking of the clock). When a piece of state is marked as ticked, it means that time-related changes have been applied to the state (or forecast).
Some examples of time related changes:
- Scheduled delegations might have been applied in Byron
- New leader schedule computed for Shelley
- Transition from Byron to Shelley activated in the hard fork combinator.
- Nonces switched out at the start of a new epoch.
Instances
newtype ApplyTxError era #
Constructors
ApplyTxError [PredicateFailure (EraRule "LEDGER" era)] |
Instances
Eq (PredicateFailure (EraRule "LEDGER" era)) ⇒ Eq (ApplyTxError era) | |
Defined in Cardano.Ledger.Shelley.API.Mempool Methods (==) ∷ ApplyTxError era → ApplyTxError era → Bool Source # (/=) ∷ ApplyTxError era → ApplyTxError era → Bool Source # | |
Show (PredicateFailure (EraRule "LEDGER" era)) ⇒ Show (ApplyTxError era) | |
Defined in Cardano.Ledger.Shelley.API.Mempool | |
(Era era, EncCBOR (PredicateFailure (EraRule "LEDGER" era))) ⇒ ToCBOR (ApplyTxError era) | |
Defined in Cardano.Ledger.Shelley.API.Mempool Methods toCBOR ∷ ApplyTxError era → Encoding encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (ApplyTxError era) → Size encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [ApplyTxError era] → Size | |
(Era era, DecCBOR (PredicateFailure (EraRule "LEDGER" era))) ⇒ DecCBOR (ApplyTxError era) | |
Defined in Cardano.Ledger.Shelley.API.Mempool Methods decCBOR ∷ Decoder s (ApplyTxError era) dropCBOR ∷ Proxy (ApplyTxError era) → Decoder s () label ∷ Proxy (ApplyTxError era) → Text | |
(Era era, EncCBOR (PredicateFailure (EraRule "LEDGER" era))) ⇒ EncCBOR (ApplyTxError era) | |
Defined in Cardano.Ledger.Shelley.API.Mempool Methods encCBOR ∷ ApplyTxError era → Encoding encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy (ApplyTxError era) → Size encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [ApplyTxError era] → Size | |
(Era era, DecCBOR (PredicateFailure (EraRule "LEDGER" era))) ⇒ FromCBOR (ApplyTxError era) | |
Defined in Cardano.Ledger.Shelley.API.Mempool | |
Typeable era ⇒ ShowProxy (ApplyTxError era ∷ Type) Source # | |
Defined in Ouroboros.Consensus.Shelley.Ledger.Mempool | |
ShelleyBasedEra era ⇒ SerialiseNodeToClient (ShelleyBlock proto era) (ApplyTxError era) Source # |
|
Defined in Ouroboros.Consensus.Shelley.Node.Serialisation Methods encodeNodeToClient ∷ CodecConfig (ShelleyBlock proto era) → BlockNodeToClientVersion (ShelleyBlock proto era) → ApplyTxError era → Encoding Source # decodeNodeToClient ∷ CodecConfig (ShelleyBlock proto era) → BlockNodeToClientVersion (ShelleyBlock proto era) → ∀ s. Decoder s (ApplyTxError era) Source # |
class (EraSegWits era, EraGovernance era, ApplyTx era, ApplyBlock era, CanStartFromGenesis era, GetLedgerView era, NoThunks (StashedAVVMAddresses era), EncCBOR (StashedAVVMAddresses era), DecCBOR (StashedAVVMAddresses era), Show (StashedAVVMAddresses era), Eq (StashedAVVMAddresses era), DecCBOR (PredicateFailure (EraRule "LEDGER" era)), EncCBOR (PredicateFailure (EraRule "LEDGER" era)), DecCBOR (PredicateFailure (EraRule "DELEGS" era)), EncCBOR (PredicateFailure (EraRule "DELEGS" era)), DecCBOR (PredicateFailure (EraRule "UTXOW" era)), EncCBOR (PredicateFailure (EraRule "UTXOW" era)), DSignable (EraCrypto era) (Hash (EraCrypto era) EraIndependentTxBody), NoThunks (PredicateFailure (EraRule "BBODY" era)), NoThunks (TranslationContext era)) ⇒ ShelleyBasedEra era Source #
Consensus often needs some more functionality than the ledger currently provides.
Either the functionality shouldn't or can't live in the ledger, in which case
it can be part and remain part of ShelleyBasedEra
. Or, the functionality
should live in the ledger, but hasn't yet been added to the ledger, or it
hasn't yet been propagated to this repository, in which case it can be added
to this class until that is the case.
If this class becomes redundant, We can move it to ledger and re-export it from here.
TODO Currently we include some constraints on the update state which are needed to determine the hard fork point. In the future this should be replaced with an appropriate API - see https://github.com/input-output-hk/ouroboros-network/issues/2890
Minimal complete definition
Instances
verifyHeaderIntegrity Source #
Arguments
∷ ProtocolHeaderSupportsKES proto | |
⇒ Word64 | Slots per KES period |
→ ShelleyProtocolHeader proto | |
→ Bool |
Verify that the signature on a header is correct and valid.
newtype ShelleyHash crypto Source #
Constructors
ShelleyHash | |
Fields
|
Instances
data ShelleyBlock proto era Source #
Shelley-based block type.
This block is parametrised over both the (ledger) era and the protocol.
Constructors
ShelleyBlock | |
Fields
|