| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Hydra.HeadLogic.State
Contents
Synopsis
- data HeadState tx
- = Idle (IdleState tx)
- | Open (OpenState tx)
- | Closed (ClosedState tx)
- | FanoutProgress (PartialFanoutState tx)
- setChainState :: ChainStateType tx -> HeadState tx -> HeadState tx
- getChainState :: HeadState tx -> ChainStateType tx
- getHeadParameters :: HeadState tx -> Maybe HeadParameters
- getOpenStateConfirmedSnapshot :: HeadState tx -> Maybe (ConfirmedSnapshot tx)
- newtype IdleState tx = IdleState {
- chainState :: ChainStateType tx
- data OpenState tx = OpenState {
- parameters :: HeadParameters
- coordinatedHeadState :: CoordinatedHeadState tx
- chainState :: ChainStateType tx
- headId :: HeadId
- headSeed :: HeadSeed
- data CoordinatedHeadState tx = CoordinatedHeadState {
- localUTxO :: UTxOType tx
- localTxs :: Seq tx
- allTxs :: !(Map (TxIdType tx) tx)
- confirmedSnapshot :: ConfirmedSnapshot tx
- seenSnapshot :: SeenSnapshot tx
- currentDepositTxId :: Maybe (TxIdType tx)
- decommitTx :: Maybe tx
- version :: SnapshotVersion
- data SeenSnapshot tx
- = NoSeenSnapshot
- | LastSeenSnapshot {
- lastSeen :: SnapshotNumber
- | RequestedSnapshot { }
- | SeenSnapshot {
- snapshot :: Snapshot tx
- signatories :: Map Party (Signature (Snapshot tx))
- signableBytes :: ~ByteString
- mkSeenSnapshot :: IsTx tx => Snapshot tx -> Map Party (Signature (Snapshot tx)) -> SeenSnapshot tx
- seenSnapshotNumber :: SeenSnapshot tx -> SnapshotNumber
- snapshotInFlight :: SeenSnapshot tx -> Bool
- isCollectingAcks :: SeenSnapshot tx -> Bool
- data ClosedState tx = ClosedState {
- parameters :: HeadParameters
- confirmedSnapshot :: ConfirmedSnapshot tx
- contestationDeadline :: UTCTime
- readyToFanoutSent :: Bool
- chainState :: ChainStateType tx
- headId :: HeadId
- headSeed :: HeadSeed
- version :: SnapshotVersion
- data FanoutMode tx
- = AutoDrain
- | DistributingSelection (UTxOType tx)
- | AwaitingSelection
- data PartialFanoutState tx = PartialFanoutState {
- parameters :: HeadParameters
- confirmedSnapshot :: ConfirmedSnapshot tx
- contestationDeadline :: UTCTime
- chainState :: ChainStateType tx
- headId :: HeadId
- headSeed :: HeadSeed
- version :: SnapshotVersion
- remainingOutputs :: UTxOType tx
- distributedOutputs :: UTxOType tx
- mode :: FanoutMode tx
Documentation
The main state of the Hydra protocol state machine. It holds both, the
overall protocol state, but also the off-chain CoordinatedHeadState.
Each of the sub-types (OpenState, etc.) contain a black-box
IdleState corresponding to the ChainEvent that has been observed leading
to the state.
Note that rollbacks are currently not fully handled in the head logic and only this internal chain state gets replaced with the "rolled back to" version.
TODO: chainState would actually not be needed in the HeadState anymore as we
do not persist the HeadState and not access it in the HeadLogic either.
Constructors
| Idle (IdleState tx) | |
| Open (OpenState tx) | |
| Closed (ClosedState tx) | |
| FanoutProgress (PartialFanoutState tx) | A closed head whose UTxO is being fanned out across multiple
transactions (on-chain in the |
Instances
setChainState :: ChainStateType tx -> HeadState tx -> HeadState tx Source #
Update the chain state in any HeadState.
getChainState :: HeadState tx -> ChainStateType tx Source #
Get the chain state in any HeadState.
getHeadParameters :: HeadState tx -> Maybe HeadParameters Source #
Get the head parameters in any HeadState.
getOpenStateConfirmedSnapshot :: HeadState tx -> Maybe (ConfirmedSnapshot tx) Source #
Get the head parameters in any HeadState.
Idle
An Idle head only having a chain state with things seen on chain so far.
Constructors
| IdleState | |
Fields
| |
Instances
| FromJSON (ChainStateType tx) => FromJSON (IdleState tx) Source # | |
Defined in Hydra.HeadLogic.State Methods parseJSON :: Value -> Parser (IdleState tx) parseJSONList :: Value -> Parser [IdleState tx] omittedField :: Maybe (IdleState tx) | |
| ToJSON (ChainStateType tx) => ToJSON (IdleState tx) Source # | |
Defined in Hydra.HeadLogic.State Methods toJSON :: IdleState tx -> Value toEncoding :: IdleState tx -> Encoding toJSONList :: [IdleState tx] -> Value toEncodingList :: [IdleState tx] -> Encoding | |
| Generic (IdleState tx) Source # | |
| Show (ChainStateType tx) => Show (IdleState tx) Source # | |
| IsChainState tx => FromCBOR (IdleState tx) Source # | |
| IsChainState tx => ToCBOR (IdleState tx) Source # | |
Defined in Hydra.HeadLogic.State Methods toCBOR :: IdleState tx -> Encoding encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy (IdleState tx) -> Size encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [IdleState tx] -> Size | |
| Eq (ChainStateType tx) => Eq (IdleState tx) Source # | |
| type Rep (IdleState tx) Source # | |
Defined in Hydra.HeadLogic.State | |
Open
An Open head with a CoordinatedHeadState tracking off-chain
transactions.
Constructors
| OpenState | |
Fields
| |
Instances
| (IsTx tx, FromJSON (ChainStateType tx)) => FromJSON (OpenState tx) Source # | |
Defined in Hydra.HeadLogic.State Methods parseJSON :: Value -> Parser (OpenState tx) parseJSONList :: Value -> Parser [OpenState tx] omittedField :: Maybe (OpenState tx) | |
| (IsTx tx, ToJSON (ChainStateType tx)) => ToJSON (OpenState tx) Source # | |
Defined in Hydra.HeadLogic.State Methods toJSON :: OpenState tx -> Value toEncoding :: OpenState tx -> Encoding toJSONList :: [OpenState tx] -> Value toEncodingList :: [OpenState tx] -> Encoding | |
| Generic (OpenState tx) Source # | |
| (IsTx tx, Show (ChainStateType tx)) => Show (OpenState tx) Source # | |
| IsChainState tx => FromCBOR (OpenState tx) Source # | |
| IsChainState tx => ToCBOR (OpenState tx) Source # | |
Defined in Hydra.HeadLogic.State Methods toCBOR :: OpenState tx -> Encoding encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy (OpenState tx) -> Size encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [OpenState tx] -> Size | |
| (IsTx tx, Eq (ChainStateType tx)) => Eq (OpenState tx) Source # | |
| type Rep (OpenState tx) Source # | |
Defined in Hydra.HeadLogic.State type Rep (OpenState tx) = D1 ('MetaData "OpenState" "Hydra.HeadLogic.State" "hydra-node-2.3.0-1cgalYNmLJQC1YXlYVq7mp" 'False) (C1 ('MetaCons "OpenState" 'PrefixI 'True) ((S1 ('MetaSel ('Just "parameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadParameters) :*: S1 ('MetaSel ('Just "coordinatedHeadState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (CoordinatedHeadState tx))) :*: (S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (ChainStateType tx)) :*: (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadSeed))))) | |
data CoordinatedHeadState tx Source #
Off-chain state of the Coordinated Head protocol.
Constructors
| CoordinatedHeadState | |
Fields
| |
Instances
data SeenSnapshot tx Source #
Data structure to help in tracking whether we have seen or requested a ReqSn already and if seen, the signatures we collected already.
Constructors
| NoSeenSnapshot | Never saw a ReqSn. |
| LastSeenSnapshot | No snapshot in flight with last seen snapshot number as given. |
Fields
| |
| RequestedSnapshot | ReqSn was sent out and it should be considered already in flight. |
| SeenSnapshot | ReqSn for given snapshot was received. |
Fields
| |
Instances
mkSeenSnapshot :: IsTx tx => Snapshot tx -> Map Party (Signature (Snapshot tx)) -> SeenSnapshot tx Source #
Smart constructor for SeenSnapshot that computes and caches
$sel:signableBytes:NoSeenSnapshot from $sel:snapshot:NoSeenSnapshot, enforcing the invariant that they stay in sync.
seenSnapshotNumber :: SeenSnapshot tx -> SnapshotNumber Source #
Get the last seen snapshot number given a SeenSnapshot.
snapshotInFlight :: SeenSnapshot tx -> Bool Source #
Whether a snapshot is currently in-flight (requested or being signed).
isCollectingAcks :: SeenSnapshot tx -> Bool Source #
Whether AckSns are currently being collected for a snapshot.
Unlike snapshotInFlight, returns False for RequestedSnapshot — a
snapshot sent but not yet echoed is stale once the version bumps and should
not block a fresh request with the new version.
Closed
data ClosedState tx Source #
An Closed head with an current candidate ConfirmedSnapshot, which may
be contested before the ClosedState.
Constructors
| ClosedState | |
Fields
| |
Instances
PartialFanout
data FanoutMode tx Source #
How the node decides which UTxOs to distribute in the next fanout step
while the head is in FanoutProgress.
Constructors
| AutoDrain | Entered only via the |
| DistributingSelection (UTxOType tx) | Manual mode: keep distributing this (content-tracked) user selection, dynamically chunked, until it is exhausted. |
| AwaitingSelection | Manual mode: the previous selection has been fully distributed. Wait for
the next |
Instances
data PartialFanoutState tx Source #
A closed head whose UTxO is being distributed across multiple fanout
transactions (on-chain FanoutProgress). Holds the partial-fanout bookkeeping
that used to live in ClosedState.
Constructors
| PartialFanoutState | |
Fields
| |