Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.Block.Forging
Contents
Synopsis
- data BlockForging (m ∷ Type → Type) blk = BlockForging {
- forgeLabel ∷ Text
- canBeLeader ∷ CanBeLeader (BlockProtocol blk)
- updateForgeState ∷ TopLevelConfig blk → SlotNo → Ticked (ChainDepState (BlockProtocol blk)) → m (ForgeStateUpdateInfo blk)
- checkCanForge ∷ TopLevelConfig blk → SlotNo → Ticked (ChainDepState (BlockProtocol blk)) → IsLeader (BlockProtocol blk) → ForgeStateInfo blk → Either (CannotForge blk) ()
- forgeBlock ∷ TopLevelConfig blk → BlockNo → SlotNo → TickedLedgerState blk EmptyMK → [Validated (GenTx blk)] → IsLeader (BlockProtocol blk) → m blk
- finalize ∷ m ()
- newtype MkBlockForging (m ∷ Type → Type) blk = MkBlockForging {
- mkBlockForging ∷ m (BlockForging m blk)
- type family CannotForge blk
- type family ForgeStateInfo blk
- type family ForgeStateUpdateError blk
- data ForgeStateUpdateInfo blk
- data ShouldForge blk
- = ForgeStateUpdateError (ForgeStateUpdateError blk)
- | CannotForge (CannotForge blk)
- | NotLeader
- | ShouldForge (IsLeader (BlockProtocol blk))
- castForgeStateUpdateInfo ∷ (ForgeStateInfo blk ~ ForgeStateInfo blk', ForgeStateUpdateError blk ~ ForgeStateUpdateError blk') ⇒ ForgeStateUpdateInfo blk → ForgeStateUpdateInfo blk'
- checkShouldForge ∷ (Monad m, ConsensusProtocol (BlockProtocol blk), HasCallStack) ⇒ BlockForging m blk → Tracer m (ForgeStateInfo blk) → TopLevelConfig blk → SlotNo → Ticked (ChainDepState (BlockProtocol blk)) → m (ShouldForge blk)
- forgeStateUpdateInfoFromUpdateInfo ∷ UpdateInfo (ForgeStateInfo blk) (ForgeStateUpdateError blk) → ForgeStateUpdateInfo blk
- data UpdateInfo updated failed
- = Updated updated
- | UpdateFailed failed
Documentation
data BlockForging (m ∷ Type → Type) blk Source #
Stateful wrapper around block production
NOTE: do not refer to the consensus or ledger config in the closure of this
record because they might contain an EpochInfo Identity
, which will be
incorrect when used as part of the hard fork combinator.
Constructors
BlockForging | |
Fields
|
Instances
Functor m ⇒ Isomorphic (BlockForging m) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Embed.Unary Methods project ∷ NoHardForks blk ⇒ BlockForging m (HardForkBlock '[blk]) → BlockForging m blk Source # inject ∷ NoHardForks blk ⇒ BlockForging m blk → BlockForging m (HardForkBlock '[blk]) Source # |
newtype MkBlockForging (m ∷ Type → Type) blk Source #
MkBlockForging
is a wrapper around a monadic action that allocates a
BlockForging
, potentially allocating other linked resources like KES
HotKeys, that *MUST* be finalized when the BlockForging
is no longer in
use. Users of this code must call the finalize
function on the returned BlockForging
at least once after terminating otherwise allocated resources
may leak.
Constructors
MkBlockForging | |
Fields
|
Instances
Functor m ⇒ Isomorphic (MkBlockForging m) Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Embed.Unary Methods project ∷ NoHardForks blk ⇒ MkBlockForging m (HardForkBlock '[blk]) → MkBlockForging m blk Source # inject ∷ NoHardForks blk ⇒ MkBlockForging m blk → MkBlockForging m (HardForkBlock '[blk]) Source # |
type family CannotForge blk Source #
Information about why we cannot forge a block, although we are a leader
This should happen only rarely. An example might be that our hot key does not (yet/anymore) match the delegation state.
Instances
type CannotForge (HardForkBlock xs) Source # | |
type CannotForge (DualBlock m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual |
type family ForgeStateInfo blk Source #
Returned when a call to updateForgeState
succeeded and caused the forge
state to change. This info is traced.
Instances
type ForgeStateInfo (HardForkBlock xs) Source # | |
type ForgeStateInfo (DualBlock m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual |
type family ForgeStateUpdateError blk Source #
Returned when a call updateForgeState
failed, e.g., because the KES key
is no longer valid. This info is traced.
Instances
type ForgeStateUpdateError (HardForkBlock xs) Source # | |
type ForgeStateUpdateError (DualBlock m a) Source # | |
Defined in Ouroboros.Consensus.Ledger.Dual |
data ForgeStateUpdateInfo blk Source #
The result of updateForgeState
.
Note: the forge state itself is implicit and not reflected in the types.
Constructors
ForgeStateUpdated (ForgeStateInfo blk) | NB The update might have not changed the forge state. |
ForgeStateUpdateFailed (ForgeStateUpdateError blk) | |
ForgeStateUpdateSuppressed | A node was prevented from forging for an artificial reason, such as testing, benchmarking, etc. It's artificial in that this constructor should never occur in a production deployment. |
Instances
Isomorphic ForgeStateUpdateInfo Source # | |
Defined in Ouroboros.Consensus.HardFork.Combinator.Embed.Unary Methods project ∷ NoHardForks blk ⇒ ForgeStateUpdateInfo (HardForkBlock '[blk]) → ForgeStateUpdateInfo blk Source # inject ∷ NoHardForks blk ⇒ ForgeStateUpdateInfo blk → ForgeStateUpdateInfo (HardForkBlock '[blk]) Source # | |
(Show (ForgeStateInfo blk), Show (ForgeStateUpdateError blk)) ⇒ Show (ForgeStateUpdateInfo blk) Source # | |
Defined in Ouroboros.Consensus.Block.Forging Methods showsPrec ∷ Int → ForgeStateUpdateInfo blk → ShowS # show ∷ ForgeStateUpdateInfo blk → String # showList ∷ [ForgeStateUpdateInfo blk] → ShowS # |
data ShouldForge blk Source #
Constructors
ForgeStateUpdateError (ForgeStateUpdateError blk) | Before check whether we are a leader in this slot, we tried to update
our forge state ( E.g., we could not evolve our KES key. |
CannotForge (CannotForge blk) | We are a leader in this slot, but we cannot forge for a certain reason. E.g., our KES key is not yet valid in this slot or we are not the current delegate of the genesis key we have a delegation certificate from. |
NotLeader | We are not a leader in this slot |
ShouldForge (IsLeader (BlockProtocol blk)) | We are a leader in this slot and we should forge a block. |
castForgeStateUpdateInfo ∷ (ForgeStateInfo blk ~ ForgeStateInfo blk', ForgeStateUpdateError blk ~ ForgeStateUpdateError blk') ⇒ ForgeStateUpdateInfo blk → ForgeStateUpdateInfo blk' Source #
checkShouldForge ∷ (Monad m, ConsensusProtocol (BlockProtocol blk), HasCallStack) ⇒ BlockForging m blk → Tracer m (ForgeStateInfo blk) → TopLevelConfig blk → SlotNo → Ticked (ChainDepState (BlockProtocol blk)) → m (ShouldForge blk) Source #
forgeStateUpdateInfoFromUpdateInfo ∷ UpdateInfo (ForgeStateInfo blk) (ForgeStateUpdateError blk) → ForgeStateUpdateInfo blk Source #
Embed UpdateInfo
into ForgeStateUpdateInfo
UpdateInfo
data UpdateInfo updated failed Source #
The result of updating something, e.g., the forge state.
Constructors
Updated updated | NOTE: The update may have induced no change. |
UpdateFailed failed |
Instances
(Show updated, Show failed) ⇒ Show (UpdateInfo updated failed) Source # | |
Defined in Ouroboros.Consensus.Block.Forging Methods showsPrec ∷ Int → UpdateInfo updated failed → ShowS # show ∷ UpdateInfo updated failed → String # showList ∷ [UpdateInfo updated failed] → ShowS # |