Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.Ledger.Dual
Synopsis
-
class
(
HasHeader
m,
GetHeader
m,
HasHeader
(
Header
m),
LedgerSupportsProtocol
m,
HasHardForkHistory
m,
LedgerSupportsMempool
m,
CommonProtocolParams
m,
HasTxId
(
GenTx
m),
Show
(
ApplyTxErr
m),
Typeable
a,
UpdateLedger
a,
LedgerSupportsMempool
a,
Show
(
ApplyTxErr
a),
NoThunks
(
LedgerConfig
a),
NoThunks
(
CodecConfig
a),
NoThunks
(
StorageConfig
a),
Show
(
BridgeLedger
m a),
Eq
(
BridgeLedger
m a),
Serialise
(
BridgeLedger
m a),
Serialise
(
BridgeBlock
m a),
Serialise
(
BridgeTx
m a),
Show
(
BridgeTx
m a)) =>
Bridge
m a
where
- type BridgeLedger m a :: Type
- type BridgeBlock m a :: Type
- type BridgeTx m a :: Type
- updateBridgeWithBlock :: DualBlock m a -> BridgeLedger m a -> BridgeLedger m a
- updateBridgeWithTx :: Validated ( GenTx ( DualBlock m a)) -> BridgeLedger m a -> BridgeLedger m a
-
data
DualBlock
m a =
DualBlock
{
- dualBlockMain :: m
- dualBlockAux :: Maybe a
- dualBlockBridge :: BridgeBlock m a
-
data
DualGenTxErr
m a =
DualGenTxErr
{
- dualGenTxErrMain :: ApplyTxErr m
- dualGenTxErrAux :: ApplyTxErr a
- type DualHeader m a = Header ( DualBlock m a)
- data DualLedgerConfig m a = DualLedgerConfig { }
- data DualLedgerError m a = DualLedgerError { }
- ctxtDualMain :: NestedCtxt_ ( DualBlock m a) f x -> NestedCtxt_ m f x
- dualExtValidationErrorMain :: ExtValidationError ( DualBlock m a) -> ExtValidationError m
- dualTopLevelConfigMain :: TopLevelConfig ( DualBlock m a) -> TopLevelConfig m
- data family BlockConfig blk :: Type
- data family CodecConfig blk :: Type
- data family GenTx blk :: Type
- data family Header blk :: Type
- data family LedgerState blk :: Type
- data family NestedCtxt_ blk :: ( Type -> Type ) -> Type -> Type
- data family StorageConfig blk :: Type
- data family Ticked st :: Type
- data family TxId tx :: Type
- data family Validated x :: Type
- decodeDualBlock :: ( Bridge m a, Serialise a) => Decoder s ( ByteString -> m) -> Decoder s ( ByteString -> DualBlock m a)
- decodeDualGenTx :: ( Bridge m a, Serialise ( GenTx a)) => Decoder s ( GenTx m) -> Decoder s ( GenTx ( DualBlock m a))
- decodeDualGenTxErr :: Serialise ( ApplyTxErr a) => Decoder s ( ApplyTxErr m) -> Decoder s ( ApplyTxErr ( DualBlock m a))
- decodeDualGenTxId :: Decoder s ( GenTxId m) -> Decoder s ( GenTxId ( DualBlock m a))
- decodeDualHeader :: Decoder s ( ByteString -> Header m) -> Decoder s ( ByteString -> Header ( DualBlock m a))
- decodeDualLedgerState :: ( Bridge m a, Serialise ( LedgerState a)) => Decoder s ( LedgerState m) -> Decoder s ( LedgerState ( DualBlock m a))
- encodeDualBlock :: ( Bridge m a, Serialise a) => (m -> Encoding ) -> DualBlock m a -> Encoding
- encodeDualGenTx :: ( Bridge m a, Serialise ( GenTx a)) => ( GenTx m -> Encoding ) -> GenTx ( DualBlock m a) -> Encoding
- encodeDualGenTxErr :: Serialise ( ApplyTxErr a) => ( ApplyTxErr m -> Encoding ) -> ApplyTxErr ( DualBlock m a) -> Encoding
- encodeDualGenTxId :: ( GenTxId m -> Encoding ) -> GenTxId ( DualBlock m a) -> Encoding
- encodeDualHeader :: ( Header m -> Encoding ) -> Header ( DualBlock m a) -> Encoding
- encodeDualLedgerState :: ( Bridge m a, Serialise ( LedgerState a)) => ( LedgerState m -> Encoding ) -> LedgerState ( DualBlock m a) -> Encoding
Documentation
class ( HasHeader m, GetHeader m, HasHeader ( Header m), LedgerSupportsProtocol m, HasHardForkHistory m, LedgerSupportsMempool m, CommonProtocolParams m, HasTxId ( GenTx m), Show ( ApplyTxErr m), Typeable a, UpdateLedger a, LedgerSupportsMempool a, Show ( ApplyTxErr a), NoThunks ( LedgerConfig a), NoThunks ( CodecConfig a), NoThunks ( StorageConfig a), Show ( BridgeLedger m a), Eq ( BridgeLedger m a), Serialise ( BridgeLedger m a), Serialise ( BridgeBlock m a), Serialise ( BridgeTx m a), Show ( BridgeTx m a)) => Bridge m a where Source #
Bridge the two ledgers
Associated Types
type BridgeLedger m a :: Type Source #
Additional information relating both ledgers
type BridgeBlock m a :: Type Source #
Information required to update the bridge when applying a block
type BridgeTx m a :: Type Source #
Information required to update the bridge when applying a transaction
Methods
updateBridgeWithBlock :: DualBlock m a -> BridgeLedger m a -> BridgeLedger m a Source #
updateBridgeWithTx :: Validated ( GenTx ( DualBlock m a)) -> BridgeLedger m a -> BridgeLedger m a Source #
Pair types
Dual block
The dual block is used to instantiate the consensus with a dual ledger, consisting of two ledger states associated with two types of blocks. The (consensus) chain state will still be updated based on one block type only, which is therefore designed as the main block, while the other block is designated as the auxiliary block.
The auxiliary block is optional; this can be used if some " main " blocks should have no effect on the auxiliary ledger state at all. The motivating example is EBBs: if the main blocks are real Byron blocks, and the auxiliary blocks are Byron spec blocks, then regular Byron blocks correspond to Byron spec blocks, but EBBs don't correspond to a spec block at all and should leave the Byron spec ledger state unchanged.
NOTE: The dual ledger is used for testing purposes only; we do not do any
meaningful
NoThunks
checks here.
Constructors
DualBlock | |
Fields
|
Instances
data DualGenTxErr m a Source #
Constructors
DualGenTxErr | |
Fields
|
Instances
( Typeable m, Typeable a) => ShowProxy ( DualGenTxErr m a :: Type ) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual |
|
Bridge m a => Show ( DualGenTxErr m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual |
type DualHeader m a = Header ( DualBlock m a) Source #
data DualLedgerConfig m a Source #
Constructors
DualLedgerConfig | |
Fields |
Instances
NoThunks ( DualLedgerConfig m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual |
data DualLedgerError m a Source #
Both ledger rules threw an error
We do not verify that the errors agree, merely that they both report some error.
If only
one
of the two semantics reports an error, we fail with an
error
(see
agreeOnError
), rather than a regular chain failure; if this happens,
it indicates a bug, and the node should fail (rather than just, for example,
reject a block).
Constructors
DualLedgerError | |
Fields |
Instances
( Eq ( LedgerError m), Eq ( LedgerError a)) => Eq ( DualLedgerError m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual Methods (==) :: DualLedgerError m a -> DualLedgerError m a -> Bool Source # (/=) :: DualLedgerError m a -> DualLedgerError m a -> Bool Source # |
|
( Show ( LedgerError m), Show ( LedgerError a)) => Show ( DualLedgerError m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual |
|
NoThunks ( DualLedgerError m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual |
Lifted functions
ctxtDualMain :: NestedCtxt_ ( DualBlock m a) f x -> NestedCtxt_ m f x Source #
dualExtValidationErrorMain :: ExtValidationError ( DualBlock m a) -> ExtValidationError m Source #
dualTopLevelConfigMain :: TopLevelConfig ( DualBlock m a) -> TopLevelConfig m Source #
This is only used for block production
Type class family instances
data family BlockConfig blk :: Type Source #
Static configuration required to work with this type of blocks
Instances
Isomorphic BlockConfig Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Embed.Unary Methods project :: NoHardForks blk => BlockConfig ( HardForkBlock '[blk]) -> BlockConfig blk Source # inject :: NoHardForks blk => BlockConfig blk -> BlockConfig ( HardForkBlock '[blk]) Source # |
|
NoThunks ( BlockConfig ( DualBlock m a)) Source # | |
CanHardFork xs => NoThunks ( BlockConfig ( HardForkBlock xs)) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Basics Methods noThunks :: Context -> BlockConfig ( HardForkBlock xs) -> IO ( Maybe ThunkInfo ) Source # wNoThunks :: Context -> BlockConfig ( HardForkBlock xs) -> IO ( Maybe ThunkInfo ) Source # showTypeOf :: Proxy ( BlockConfig ( HardForkBlock xs)) -> String Source # |
|
newtype BlockConfig ( HardForkBlock xs) Source # | |
|
|
data BlockConfig ( DualBlock m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual |
data family CodecConfig blk :: Type 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 GenTx blk :: Type 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
data family Header blk :: Type Source #
Instances
data family LedgerState blk :: Type Source #
Ledger state associated with a block
Instances
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 StorageConfig blk :: Type Source #
Config needed for the
NodeInitStorage
class. Defined here to
avoid circular dependencies.
Instances
data family Ticked st :: Type 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
data family TxId tx :: Type Source #
A generalized transaction,
GenTx
, identifier.
Instances
data family Validated x :: Type 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
Serialisation
decodeDualBlock :: ( Bridge m a, Serialise a) => Decoder s ( ByteString -> m) -> Decoder s ( ByteString -> DualBlock m a) Source #
decodeDualGenTx :: ( Bridge m a, Serialise ( GenTx a)) => Decoder s ( GenTx m) -> Decoder s ( GenTx ( DualBlock m a)) Source #
decodeDualGenTxErr :: Serialise ( ApplyTxErr a) => Decoder s ( ApplyTxErr m) -> Decoder s ( ApplyTxErr ( DualBlock m a)) Source #
decodeDualHeader :: Decoder s ( ByteString -> Header m) -> Decoder s ( ByteString -> Header ( DualBlock m a)) Source #
decodeDualLedgerState :: ( Bridge m a, Serialise ( LedgerState a)) => Decoder s ( LedgerState m) -> Decoder s ( LedgerState ( DualBlock m a)) Source #
encodeDualBlock :: ( Bridge m a, Serialise a) => (m -> Encoding ) -> DualBlock m a -> Encoding Source #
encodeDualGenTx :: ( Bridge m a, Serialise ( GenTx a)) => ( GenTx m -> Encoding ) -> GenTx ( DualBlock m a) -> Encoding Source #
encodeDualGenTxErr :: Serialise ( ApplyTxErr a) => ( ApplyTxErr m -> Encoding ) -> ApplyTxErr ( DualBlock m a) -> Encoding Source #
encodeDualLedgerState :: ( Bridge m a, Serialise ( LedgerState a)) => ( LedgerState m -> Encoding ) -> LedgerState ( DualBlock m a) -> Encoding Source #