hydra-node-0.20.0: The Hydra node
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.HeadLogic

Description

Implements the Head Protocol's state machine as pure functions in an event sourced manner.

More specifically, the update will handle Inputs (or rather "commands" in event sourcing speak) and convert that into a list of side-Effects and StateChanged events, which in turn are aggregated into a single HeadState.

As the specification is using a more imperative way of specifying the protocl behavior, one would find the decision logic in update while state updates can be found in the corresponding aggregate branch.

Synopsis

Documentation

update Source #

Arguments

:: IsChainState tx 
=> Environment 
-> Ledger tx 
-> HeadState tx

Current HeadState to validate the command against.

-> Input tx

Input to be processed.

-> Outcome tx 

Handles inputs and converts them into StateChanged events along with Effects, in case it is processed succesfully. Later, the Node will aggregate the events, resulting in a new HeadState.

aggregateState :: IsChainState tx => HeadState tx -> Outcome tx -> HeadState tx Source #

recoverChainStateHistory :: (Foldable t, IsChainState tx) => ChainStateType tx -> t (StateChanged tx) -> ChainStateHistory tx Source #

recoverState :: (Foldable t, IsChainState tx) => HeadState tx -> t (StateChanged tx) -> HeadState tx Source #

aggregate :: IsChainState tx => HeadState tx -> StateChanged tx -> HeadState tx Source #

Reflect StateChanged events onto the HeadState aggregate.

isLeader :: HeadParameters -> Party -> SnapshotNumber -> Bool Source #

onIdleClientInit :: Environment -> Outcome tx Source #

Client request to init the head. This leads to an init transaction on chain, containing the head parameters.

Transition: IdleStateIdleState

onIdleChainInitTx Source #

Arguments

:: Environment 
-> ChainStateType tx

New chain state.

-> HeadId 
-> HeadSeed 
-> HeadParameters 
-> [OnChainId] 
-> Outcome tx 

Observe an init transaction, initialize parameters in an InitialState and notify clients that they can now commit.

Transition: IdleStateInitialState

onInitialChainCommitTx Source #

Arguments

:: Monoid (UTxOType tx) 
=> InitialState tx 
-> ChainStateType tx

New chain state

-> Party

Comitting party

-> UTxOType tx

Committed UTxO

-> Outcome tx 

Observe a commit transaction and record the committed UTxO in the state. Also, if this is the last commit to be observed, post a collect-com transaction on-chain.

Transition: InitialStateInitialState

onInitialClientAbort :: Monoid (UTxOType tx) => InitialState tx -> Outcome tx Source #

Client request to abort the head. This leads to an abort transaction on chain, reimbursing already committed UTxOs.

Transition: InitialStateInitialState

onInitialChainAbortTx Source #

Arguments

:: Monoid (UTxOType tx) 
=> ChainStateType tx

New chain state

-> Committed tx 
-> HeadId 
-> Outcome tx 

Observe an abort transaction by switching the state and notifying clients about it.

Transition: InitialStateIdleState

onInitialChainCollectTx Source #

Arguments

:: IsChainState tx 
=> InitialState tx 
-> ChainStateType tx

New chain state

-> Outcome tx 

Observe a collectCom transaction. We initialize the OpenState using the head parameters from IdleState and construct an InitialSnapshot holding u0 from the committed UTxOs.

Transition: InitialStateOpenState

onOpenClientNewTx Source #

Arguments

:: tx

The transaction to be submitted to the head.

-> Outcome tx 

Client request to ingest a new transaction into the head.

Transition: OpenStateOpenState

onOpenNetworkReqTx Source #

Arguments

:: IsTx tx 
=> Environment 
-> Ledger tx 
-> OpenState tx 
-> TTL 
-> tx

The transaction to be submitted to the head.

-> Outcome tx 

Process a transaction request (ReqTx) from a party.

We apply this transaction to the seen utxo (ledger state). If not applicable, we wait and retry later. If it applies, this yields an updated seen ledger state. Then, we check whether we are the leader for the next snapshot and emit a snapshot request ReqSn including this transaction if needed.

Transition: OpenStateOpenState

onOpenNetworkReqSn Source #

Arguments

:: IsTx tx 
=> Environment 
-> Ledger tx 
-> OpenState tx 
-> Party

Party which sent the ReqSn.

-> SnapshotVersion

Requested snapshot version.

-> SnapshotNumber

Requested snapshot number.

-> [TxIdType tx]

List of transactions to snapshot.

-> Maybe tx

Optional decommit transaction of removing funds from the head.

-> Maybe (UTxOType tx) 
-> Outcome tx 

Process a snapshot request (ReqSn) from party.

This checks that s is the next snapshot number and that the party is responsible for leading that snapshot. Then, we potentially wait until the previous snapshot is confirmed (no snapshot is in flight), before we apply (or wait until applicable) the requested transactions to the last confirmed snapshot. Only then, we start tracking this new "seen" snapshot, compute a signature of it and send the corresponding AckSn to all parties. Finally, the pending transaction set gets pruned to only contain still applicable transactions.

Transition: OpenStateOpenState

onOpenNetworkAckSn Source #

Arguments

:: IsTx tx 
=> Environment 
-> OpenState tx 
-> Party

Party which sent the AckSn.

-> Signature (Snapshot tx)

Signature from other party.

-> SnapshotNumber

Snapshot number of this AckSn.

-> Outcome tx 

Process a snapshot acknowledgement (AckSn) from a party.

We do require that the is from the last seen or next expected snapshot, and potentially wait wait for the corresponding ReqSn before proceeding. If the party hasn't sent us a signature yet, we store it. Once a signature from each party has been collected, we aggregate a multi-signature and verify it is correct. If everything is fine, the snapshot can be considered as the latest confirmed one. Similar to processing a ReqTx, we check whether we are leading the next snapshot and craft a corresponding ReqSn if needed.

Transition: OpenStateOpenState

onOpenClientRecover :: IsTx tx => HeadId -> ChainSlot -> CoordinatedHeadState tx -> TxIdType tx -> Outcome tx Source #

Client request to recover deposited UTxO.

Transition: OpenStateOpenState

onOpenClientDecommit Source #

Arguments

:: IsTx tx 
=> HeadId 
-> Ledger tx 
-> ChainSlot 
-> CoordinatedHeadState tx 
-> tx

Decommit transaction.

-> Outcome tx 

Client request to decommit UTxO from the head.

Only possible if there is no decommit _in flight_ and if the tx applies cleanly to the local ledger state.

Transition: OpenStateOpenState

onOpenNetworkReqDec :: IsTx tx => Environment -> Ledger tx -> TTL -> OpenState tx -> tx -> Outcome tx Source #

Process the request ReqDec to decommit something from the Open head.

Transition: OpenStateOpenState

When node receives ReqDec network message it should: - Check there is no decommit in flight: - Alter it's state to record what is to be decommitted - Issue a server output DecommitRequested with the relevant utxo - Issue a ReqSn since all parties need to agree in order for decommit to be taken out of a Head. - Check if we are the leader

onOpenChainDepositTx Source #

Arguments

:: IsTx tx 
=> HeadId 
-> Environment 
-> OpenState tx 
-> UTxOType tx

Deposited UTxO

-> TxIdType tx

Deposit TxId

-> UTCTime

Deposit deadline

-> Outcome tx 

onOpenChainRecoverTx :: IsTx tx => HeadId -> OpenState tx -> TxIdType tx -> Outcome tx Source #

onOpenChainIncrementTx Source #

Arguments

:: OpenState tx 
-> SnapshotVersion

New open state version

-> TxIdType tx

Deposit TxId

-> Outcome tx 

Observe a increment transaction. If the outputs match the ones of the pending commit UTxO, then we consider the deposit/increment finalized, and remove the increment UTxO from StateChanged from the local state.

Transition: OpenStateOpenState

onOpenChainDecrementTx Source #

Arguments

:: IsTx tx 
=> OpenState tx 
-> SnapshotVersion

New open state version

-> [TxOutType tx]

Outputs removed by the decrement

-> Outcome tx 

Observe a decrement transaction. If the outputs match the ones of the pending decommit tx, then we consider the decommit finalized, and remove the decommit tx in flight.

Finally, if the client observing happens to be the leader, then a new ReqSn is broadcasted.

Transition: OpenStateOpenState

onOpenClientClose :: OpenState tx -> Outcome tx Source #

Client request to close the head. This leads to a close transaction on chain using the latest confirmed snaphshot of the OpenState.

Transition: OpenStateOpenState

onOpenChainCloseTx Source #

Arguments

:: OpenState tx 
-> ChainStateType tx

New chain state.

-> SnapshotNumber

Closed snapshot number.

-> UTCTime

Contestation deadline.

-> Outcome tx 

Observe a close transaction. If the closed snapshot number is smaller than our last confirmed, we post a contest transaction. Also, we do schedule a notification for clients to fanout at the deadline.

Transition: OpenStateClosedState

onClosedChainContestTx Source #

Arguments

:: ClosedState tx 
-> ChainStateType tx

New chain state.

-> SnapshotNumber 
-> UTCTime

Contestation deadline.

-> Outcome tx 

Observe a contest transaction. If the contested snapshot number is smaller than our last confirmed snapshot, we post a contest transaction.

Transition: ClosedStateClosedState

onClosedClientFanout :: Monoid (UTxOType tx) => ClosedState tx -> Outcome tx Source #

Client request to fanout leads to a fanout transaction on chain using the latest confirmed snapshot from ClosedState.

Transition: ClosedStateClosedState

onClosedChainFanoutTx Source #

Arguments

:: ClosedState tx 
-> ChainStateType tx

New chain state

-> Outcome tx 

Observe a fanout transaction by finalize the head state and notifying clients about it.

Transition: ClosedStateIdleState

data Input tx Source #

Inputs that are processed by the head logic (the "core"). Corresponding to each of the "shell" layers, we distinguish between inputs from the client, the network and the chain.

Constructors

ClientInput

Input received from clients via the Hydra.API.

Fields

NetworkInput

Input received from peers via a Hydra.Network.

  • $sel:ttl:ClientInput is a simple counter that's decreased every time the event is reenqueued due to a wait. It's default value is defaultTTL
ChainInput

Input received from the chain via a Hydra.Chain.

Fields

Instances

Instances details
(ArbitraryIsTx tx, IsChainState tx) => Arbitrary (Input tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Input

Methods

arbitrary :: Gen (Input tx)

shrink :: Input tx -> [Input tx]

IsChainState tx => FromJSON (Input tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Input

Methods

parseJSON :: Value -> Parser (Input tx)

parseJSONList :: Value -> Parser [Input tx]

omittedField :: Maybe (Input tx)

IsChainState tx => ToJSON (Input tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Input

Methods

toJSON :: Input tx -> Value

toEncoding :: Input tx -> Encoding

toJSONList :: [Input tx] -> Value

toEncodingList :: [Input tx] -> Encoding

omitField :: Input tx -> Bool

Generic (Input tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Input

Associated Types

type Rep (Input tx) :: Type -> Type Source #

Methods

from :: Input tx -> Rep (Input tx) x Source #

to :: Rep (Input tx) x -> Input tx Source #

IsChainState tx => Show (Input tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Input

Methods

showsPrec :: Int -> Input tx -> ShowS Source #

show :: Input tx -> String Source #

showList :: [Input tx] -> ShowS Source #

IsChainState tx => Eq (Input tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Input

Methods

(==) :: Input tx -> Input tx -> Bool Source #

(/=) :: Input tx -> Input tx -> Bool Source #

type Rep (Input tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Input

type Rep (Input tx) = D1 ('MetaData "Input" "Hydra.HeadLogic.Input" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) (C1 ('MetaCons "ClientInput" 'PrefixI 'True) (S1 ('MetaSel ('Just "clientInput") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ClientInput tx))) :+: (C1 ('MetaCons "NetworkInput" 'PrefixI 'True) (S1 ('MetaSel ('Just "ttl") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTL) :*: S1 ('MetaSel ('Just "networkEvent") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NetworkEvent (Message tx)))) :+: C1 ('MetaCons "ChainInput" 'PrefixI 'True) (S1 ('MetaSel ('Just "chainEvent") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainEvent tx)))))

data LogicError tx Source #

Instances

Instances details
(Arbitrary (Input tx), Arbitrary (HeadState tx), Arbitrary (RequirementFailure tx)) => Arbitrary (LogicError tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Error

Methods

arbitrary :: Gen (LogicError tx)

shrink :: LogicError tx -> [LogicError tx]

(FromJSON (HeadState tx), FromJSON (Input tx), FromJSON (RequirementFailure tx)) => FromJSON (LogicError tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Error

Methods

parseJSON :: Value -> Parser (LogicError tx)

parseJSONList :: Value -> Parser [LogicError tx]

omittedField :: Maybe (LogicError tx)

(ToJSON (HeadState tx), ToJSON (Input tx), ToJSON (RequirementFailure tx)) => ToJSON (LogicError tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Error

Methods

toJSON :: LogicError tx -> Value

toEncoding :: LogicError tx -> Encoding

toJSONList :: [LogicError tx] -> Value

toEncodingList :: [LogicError tx] -> Encoding

omitField :: LogicError tx -> Bool

(Typeable tx, Show (Input tx), Show (HeadState tx), Show (RequirementFailure tx)) => Exception (LogicError tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Error

Generic (LogicError tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Error

Associated Types

type Rep (LogicError tx) :: Type -> Type Source #

Methods

from :: LogicError tx -> Rep (LogicError tx) x Source #

to :: Rep (LogicError tx) x -> LogicError tx Source #

(Show (HeadState tx), Show (Input tx), Show (RequirementFailure tx)) => Show (LogicError tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Error

(Eq (HeadState tx), Eq (Input tx), Eq (RequirementFailure tx)) => Eq (LogicError tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Error

Methods

(==) :: LogicError tx -> LogicError tx -> Bool Source #

(/=) :: LogicError tx -> LogicError tx -> Bool Source #

type Rep (LogicError tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Error

type Rep (LogicError tx) = D1 ('MetaData "LogicError" "Hydra.HeadLogic.Error" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) ((C1 ('MetaCons "UnhandledInput" 'PrefixI 'True) (S1 ('MetaSel ('Just "input") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Input tx)) :*: S1 ('MetaSel ('Just "currentHeadState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (HeadState tx))) :+: C1 ('MetaCons "RequireFailed" 'PrefixI 'True) (S1 ('MetaSel ('Just "requirementFailure") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (RequirementFailure tx)))) :+: (C1 ('MetaCons "AssertionFailed" 'PrefixI 'True) (S1 ('MetaSel ('Just "message") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: C1 ('MetaCons "NotOurHead" 'PrefixI 'True) (S1 ('MetaSel ('Just "ourHeadId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "otherHeadId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId))))

data RequirementFailure tx Source #

Constructors

ReqSnNumberInvalid 

Fields

ReqSvNumberInvalid 

Fields

ReqSnNotLeader 

Fields

ReqSnDecommitNotSettled 
ReqSnCommitNotSettled 
InvalidMultisignature 

Fields

SnapshotAlreadySigned 

Fields

AckSnNumberInvalid 

Fields

SnapshotDoesNotApply 

Fields

RecoverNotMatchingDeposit 

Instances

Instances details
Arbitrary (TxIdType tx) => Arbitrary (RequirementFailure tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Error

FromJSON (TxIdType tx) => FromJSON (RequirementFailure tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Error

Methods

parseJSON :: Value -> Parser (RequirementFailure tx)

parseJSONList :: Value -> Parser [RequirementFailure tx]

omittedField :: Maybe (RequirementFailure tx)

ToJSON (TxIdType tx) => ToJSON (RequirementFailure tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Error

Generic (RequirementFailure tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Error

Associated Types

type Rep (RequirementFailure tx) :: Type -> Type Source #

Show (TxIdType tx) => Show (RequirementFailure tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Error

Eq (TxIdType tx) => Eq (RequirementFailure tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Error

type Rep (RequirementFailure tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Error

type Rep (RequirementFailure tx) = D1 ('MetaData "RequirementFailure" "Hydra.HeadLogic.Error" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) (((C1 ('MetaCons "ReqSnNumberInvalid" 'PrefixI 'True) (S1 ('MetaSel ('Just "requestedSn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber) :*: S1 ('MetaSel ('Just "lastSeenSn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber)) :+: C1 ('MetaCons "ReqSvNumberInvalid" 'PrefixI 'True) (S1 ('MetaSel ('Just "requestedSv") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotVersion) :*: S1 ('MetaSel ('Just "lastSeenSv") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotVersion))) :+: (C1 ('MetaCons "ReqSnNotLeader" 'PrefixI 'True) (S1 ('MetaSel ('Just "requestedSn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber) :*: S1 ('MetaSel ('Just "leader") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party)) :+: (C1 ('MetaCons "ReqSnDecommitNotSettled" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ReqSnCommitNotSettled" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "InvalidMultisignature" 'PrefixI 'True) (S1 ('MetaSel ('Just "multisig") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "vkeys") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [VerificationKey HydraKey])) :+: C1 ('MetaCons "SnapshotAlreadySigned" 'PrefixI 'True) (S1 ('MetaSel ('Just "knownSignatures") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Party]) :*: S1 ('MetaSel ('Just "receivedSignature") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party))) :+: (C1 ('MetaCons "AckSnNumberInvalid" 'PrefixI 'True) (S1 ('MetaSel ('Just "requestedSn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber) :*: S1 ('MetaSel ('Just "lastSeenSn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber)) :+: (C1 ('MetaCons "SnapshotDoesNotApply" 'PrefixI 'True) (S1 ('MetaSel ('Just "requestedSn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber) :*: (S1 ('MetaSel ('Just "txid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TxIdType tx)) :*: S1 ('MetaSel ('Just "error") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ValidationError))) :+: C1 ('MetaCons "RecoverNotMatchingDeposit" 'PrefixI 'False) (U1 :: Type -> Type)))))

data HeadState tx Source #

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 (InitialState, 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 actualy 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) 
Initial (InitialState tx) 
Open (OpenState tx) 
Closed (ClosedState tx) 

Instances

Instances details
(ArbitraryIsTx tx, Arbitrary (ChainStateType tx)) => Arbitrary (HeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

arbitrary :: Gen (HeadState tx)

shrink :: HeadState tx -> [HeadState tx]

(IsTx tx, FromJSON (ChainStateType tx)) => FromJSON (HeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

parseJSON :: Value -> Parser (HeadState tx)

parseJSONList :: Value -> Parser [HeadState tx]

omittedField :: Maybe (HeadState tx)

(IsTx tx, ToJSON (ChainStateType tx)) => ToJSON (HeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

toJSON :: HeadState tx -> Value

toEncoding :: HeadState tx -> Encoding

toJSONList :: [HeadState tx] -> Value

toEncodingList :: [HeadState tx] -> Encoding

omitField :: HeadState tx -> Bool

Generic (HeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Associated Types

type Rep (HeadState tx) :: Type -> Type Source #

Methods

from :: HeadState tx -> Rep (HeadState tx) x Source #

to :: Rep (HeadState tx) x -> HeadState tx Source #

(IsTx tx, Show (ChainStateType tx)) => Show (HeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

(IsTx tx, Eq (ChainStateType tx)) => Eq (HeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

(==) :: HeadState tx -> HeadState tx -> Bool Source #

(/=) :: HeadState tx -> HeadState tx -> Bool Source #

type Rep (HeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

data ClosedState tx Source #

An Closed head with an current candidate ConfirmedSnapshot, which may be contested before the $sel:contestationDeadline:ClosedState.

Constructors

ClosedState 

Fields

Instances

Instances details
(ArbitraryIsTx tx, Arbitrary (ChainStateType tx)) => Arbitrary (ClosedState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

arbitrary :: Gen (ClosedState tx)

shrink :: ClosedState tx -> [ClosedState tx]

(IsTx tx, FromJSON (ChainStateType tx)) => FromJSON (ClosedState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

parseJSON :: Value -> Parser (ClosedState tx)

parseJSONList :: Value -> Parser [ClosedState tx]

omittedField :: Maybe (ClosedState tx)

(IsTx tx, ToJSON (ChainStateType tx)) => ToJSON (ClosedState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

toJSON :: ClosedState tx -> Value

toEncoding :: ClosedState tx -> Encoding

toJSONList :: [ClosedState tx] -> Value

toEncodingList :: [ClosedState tx] -> Encoding

omitField :: ClosedState tx -> Bool

Generic (ClosedState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Associated Types

type Rep (ClosedState tx) :: Type -> Type Source #

Methods

from :: ClosedState tx -> Rep (ClosedState tx) x Source #

to :: Rep (ClosedState tx) x -> ClosedState tx Source #

(IsTx tx, Show (ChainStateType tx)) => Show (ClosedState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

(IsTx tx, Eq (ChainStateType tx)) => Eq (ClosedState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (ClosedState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (ClosedState tx) = D1 ('MetaData "ClosedState" "Hydra.HeadLogic.State" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) (C1 ('MetaCons "ClosedState" 'PrefixI 'True) (((S1 ('MetaSel ('Just "parameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadParameters) :*: S1 ('MetaSel ('Just "confirmedSnapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ConfirmedSnapshot tx))) :*: (S1 ('MetaSel ('Just "contestationDeadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTCTime) :*: S1 ('MetaSel ('Just "readyToFanoutSent") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool))) :*: ((S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx)) :*: S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId)) :*: (S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadSeed) :*: S1 ('MetaSel ('Just "version") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotVersion)))))

type Committed tx = Map Party (UTxOType tx) Source #

data CoordinatedHeadState tx Source #

Off-chain state of the Coordinated Head protocol.

Constructors

CoordinatedHeadState 

Fields

  • localUTxO :: UTxOType tx

    The latest UTxO resulting from applying $sel:localTxs:CoordinatedHeadState to CoordinatedHeadState. Spec: L̂

  • localTxs :: [tx]

    List of transactions applied locally and pending inclusion in a snapshot. Ordering in this list is important as transactions are added in order of application. Spec: T̂

  • allTxs :: Map (TxIdType tx) tx

    Map containing all the transactions ever seen by this node and not yet included in a snapshot. Spec: Tall

  • confirmedSnapshot :: ConfirmedSnapshot tx

    The latest confirmed snapshot. Spec: S̅

  • seenSnapshot :: SeenSnapshot tx

    Last seen snapshot and signatures accumulator. Spec: Û, ŝ and Σ̂

  • pendingDeposits :: Map (TxIdType tx) (UTxOType tx)

    Pending deposit UTxO. Spec: Uα

  • decommitTx :: Maybe tx

    Pending decommit transaction. Spec: txω

  • version :: SnapshotVersion

    Last seen open state version. Spec: ̂v

Instances

Instances details
ArbitraryIsTx tx => Arbitrary (CoordinatedHeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

IsTx tx => FromJSON (CoordinatedHeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

parseJSON :: Value -> Parser (CoordinatedHeadState tx)

parseJSONList :: Value -> Parser [CoordinatedHeadState tx]

omittedField :: Maybe (CoordinatedHeadState tx)

IsTx tx => ToJSON (CoordinatedHeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Generic (CoordinatedHeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Associated Types

type Rep (CoordinatedHeadState tx) :: Type -> Type Source #

IsTx tx => Show (CoordinatedHeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

IsTx tx => Eq (CoordinatedHeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (CoordinatedHeadState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (CoordinatedHeadState tx) = D1 ('MetaData "CoordinatedHeadState" "Hydra.HeadLogic.State" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) (C1 ('MetaCons "CoordinatedHeadState" 'PrefixI 'True) (((S1 ('MetaSel ('Just "localUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx)) :*: S1 ('MetaSel ('Just "localTxs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [tx])) :*: (S1 ('MetaSel ('Just "allTxs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map (TxIdType tx) tx)) :*: S1 ('MetaSel ('Just "confirmedSnapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ConfirmedSnapshot tx)))) :*: ((S1 ('MetaSel ('Just "seenSnapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SeenSnapshot tx)) :*: S1 ('MetaSel ('Just "pendingDeposits") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map (TxIdType tx) (UTxOType tx)))) :*: (S1 ('MetaSel ('Just "decommitTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe tx)) :*: S1 ('MetaSel ('Just "version") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotVersion)))))

newtype IdleState tx Source #

An Idle head only having a chain state with things seen on chain so far.

Constructors

IdleState 

Fields

Instances

Instances details
Arbitrary (ChainStateType tx) => Arbitrary (IdleState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

arbitrary :: Gen (IdleState tx)

shrink :: IdleState tx -> [IdleState tx]

FromJSON (ChainStateType tx) => FromJSON (IdleState tx) Source # 
Instance details

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 # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

toJSON :: IdleState tx -> Value

toEncoding :: IdleState tx -> Encoding

toJSONList :: [IdleState tx] -> Value

toEncodingList :: [IdleState tx] -> Encoding

omitField :: IdleState tx -> Bool

Generic (IdleState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Associated Types

type Rep (IdleState tx) :: Type -> Type Source #

Methods

from :: IdleState tx -> Rep (IdleState tx) x Source #

to :: Rep (IdleState tx) x -> IdleState tx Source #

Show (ChainStateType tx) => Show (IdleState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Eq (ChainStateType tx) => Eq (IdleState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

(==) :: IdleState tx -> IdleState tx -> Bool Source #

(/=) :: IdleState tx -> IdleState tx -> Bool Source #

type Rep (IdleState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (IdleState tx) = D1 ('MetaData "IdleState" "Hydra.HeadLogic.State" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'True) (C1 ('MetaCons "IdleState" 'PrefixI 'True) (S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx))))

data InitialState tx Source #

An Initial head which already has an identity and is collecting commits.

Constructors

InitialState 

Fields

Instances

Instances details
(ArbitraryIsTx tx, Arbitrary (ChainStateType tx)) => Arbitrary (InitialState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

arbitrary :: Gen (InitialState tx)

shrink :: InitialState tx -> [InitialState tx]

(IsTx tx, FromJSON (ChainStateType tx)) => FromJSON (InitialState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

parseJSON :: Value -> Parser (InitialState tx)

parseJSONList :: Value -> Parser [InitialState tx]

omittedField :: Maybe (InitialState tx)

(IsTx tx, ToJSON (ChainStateType tx)) => ToJSON (InitialState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

toJSON :: InitialState tx -> Value

toEncoding :: InitialState tx -> Encoding

toJSONList :: [InitialState tx] -> Value

toEncodingList :: [InitialState tx] -> Encoding

omitField :: InitialState tx -> Bool

Generic (InitialState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Associated Types

type Rep (InitialState tx) :: Type -> Type Source #

(IsTx tx, Show (ChainStateType tx)) => Show (InitialState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

(IsTx tx, Eq (ChainStateType tx)) => Eq (InitialState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (InitialState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (InitialState tx) = D1 ('MetaData "InitialState" "Hydra.HeadLogic.State" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) (C1 ('MetaCons "InitialState" 'PrefixI 'True) ((S1 ('MetaSel ('Just "parameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadParameters) :*: (S1 ('MetaSel ('Just "pendingCommits") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PendingCommits) :*: S1 ('MetaSel ('Just "committed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Committed tx)))) :*: (S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx)) :*: (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadSeed)))))

data OpenState tx Source #

An Open head with a CoordinatedHeadState tracking off-chain transactions.

Constructors

OpenState 

Fields

Instances

Instances details
(ArbitraryIsTx tx, Arbitrary (ChainStateType tx)) => Arbitrary (OpenState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

arbitrary :: Gen (OpenState tx)

shrink :: OpenState tx -> [OpenState tx]

(IsTx tx, FromJSON (ChainStateType tx)) => FromJSON (OpenState tx) Source # 
Instance details

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 # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

toJSON :: OpenState tx -> Value

toEncoding :: OpenState tx -> Encoding

toJSONList :: [OpenState tx] -> Value

toEncodingList :: [OpenState tx] -> Encoding

omitField :: OpenState tx -> Bool

Generic (OpenState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Associated Types

type Rep (OpenState tx) :: Type -> Type Source #

Methods

from :: OpenState tx -> Rep (OpenState tx) x Source #

to :: Rep (OpenState tx) x -> OpenState tx Source #

(IsTx tx, Show (ChainStateType tx)) => Show (OpenState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

(IsTx tx, Eq (ChainStateType tx)) => Eq (OpenState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

(==) :: OpenState tx -> OpenState tx -> Bool Source #

(/=) :: OpenState tx -> OpenState tx -> Bool Source #

type Rep (OpenState tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (OpenState tx) = D1 ('MetaData "OpenState" "Hydra.HeadLogic.State" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) (C1 ('MetaCons "OpenState" 'PrefixI 'True) ((S1 ('MetaSel ('Just "parameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadParameters) :*: (S1 ('MetaSel ('Just "coordinatedHeadState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (CoordinatedHeadState tx)) :*: S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx)))) :*: (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "currentSlot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChainSlot) :*: S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadSeed)))))

type PendingCommits = Set Party Source #

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.

Fields

SeenSnapshot

ReqSn for given snapshot was received.

Fields

Instances

Instances details
ArbitraryIsTx tx => Arbitrary (SeenSnapshot tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

arbitrary :: Gen (SeenSnapshot tx)

shrink :: SeenSnapshot tx -> [SeenSnapshot tx]

IsTx tx => FromJSON (SeenSnapshot tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

parseJSON :: Value -> Parser (SeenSnapshot tx)

parseJSONList :: Value -> Parser [SeenSnapshot tx]

omittedField :: Maybe (SeenSnapshot tx)

IsTx tx => ToJSON (SeenSnapshot tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Methods

toJSON :: SeenSnapshot tx -> Value

toEncoding :: SeenSnapshot tx -> Encoding

toJSONList :: [SeenSnapshot tx] -> Value

toEncodingList :: [SeenSnapshot tx] -> Encoding

omitField :: SeenSnapshot tx -> Bool

Generic (SeenSnapshot tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

Associated Types

type Rep (SeenSnapshot tx) :: Type -> Type Source #

IsTx tx => Show (SeenSnapshot tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

IsTx tx => Eq (SeenSnapshot tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (SeenSnapshot tx) Source # 
Instance details

Defined in Hydra.HeadLogic.State

type Rep (SeenSnapshot tx) = D1 ('MetaData "SeenSnapshot" "Hydra.HeadLogic.State" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) ((C1 ('MetaCons "NoSeenSnapshot" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LastSeenSnapshot" 'PrefixI 'True) (S1 ('MetaSel ('Just "lastSeen") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber))) :+: (C1 ('MetaCons "RequestedSnapshot" 'PrefixI 'True) (S1 ('MetaSel ('Just "lastSeen") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber) :*: S1 ('MetaSel ('Just "requested") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber)) :+: C1 ('MetaCons "SeenSnapshot" 'PrefixI 'True) (S1 ('MetaSel ('Just "snapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Snapshot tx)) :*: S1 ('MetaSel ('Just "signatories") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Party (Signature (Snapshot tx)))))))

seenSnapshotNumber :: SeenSnapshot tx -> SnapshotNumber Source #

Get the last seen snapshot number given a SeenSnapshot.

setChainState :: ChainStateType tx -> HeadState tx -> HeadState tx Source #

Update the chain state in any HeadState.

data Effect tx Source #

Analogous to inputs, the pure head logic "core" can have effects emited to the "shell" layers and we distinguish the same: effects onto the client, the network and the chain.

Constructors

ClientEffect

Effect to be handled by the Hydra.API, results in sending this ServerOutput.

NetworkEffect

Effect to be handled by a Hydra.Network, results in a broadcast.

Fields

OnChainEffect

Effect to be handled by a Hydra.Chain, results in a postTx.

Fields

Instances

Instances details
(ArbitraryIsTx tx, IsChainState tx) => Arbitrary (Effect tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

arbitrary :: Gen (Effect tx)

shrink :: Effect tx -> [Effect tx]

IsChainState tx => FromJSON (Effect tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

parseJSON :: Value -> Parser (Effect tx)

parseJSONList :: Value -> Parser [Effect tx]

omittedField :: Maybe (Effect tx)

IsChainState tx => ToJSON (Effect tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

toJSON :: Effect tx -> Value

toEncoding :: Effect tx -> Encoding

toJSONList :: [Effect tx] -> Value

toEncodingList :: [Effect tx] -> Encoding

omitField :: Effect tx -> Bool

Generic (Effect tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Associated Types

type Rep (Effect tx) :: Type -> Type Source #

Methods

from :: Effect tx -> Rep (Effect tx) x Source #

to :: Rep (Effect tx) x -> Effect tx Source #

IsChainState tx => Show (Effect tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

IsChainState tx => Eq (Effect tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

(==) :: Effect tx -> Effect tx -> Bool Source #

(/=) :: Effect tx -> Effect tx -> Bool Source #

type Rep (Effect tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

type Rep (Effect tx) = D1 ('MetaData "Effect" "Hydra.HeadLogic.Outcome" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) (C1 ('MetaCons "ClientEffect" 'PrefixI 'True) (S1 ('MetaSel ('Just "serverOutput") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ServerOutput tx))) :+: (C1 ('MetaCons "NetworkEffect" 'PrefixI 'True) (S1 ('MetaSel ('Just "message") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Message tx))) :+: C1 ('MetaCons "OnChainEffect" 'PrefixI 'True) (S1 ('MetaSel ('Just "postChainTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PostChainTx tx)))))

data StateChanged tx Source #

Head state changed event. These events represent all the internal state changes, get persisted and processed in an event sourcing manner.

Constructors

HeadInitialized 

Fields

CommittedUTxO 

Fields

HeadAborted 

Fields

HeadOpened 

Fields

TransactionReceived 

Fields

  • tx :: tx
     
TransactionAppliedToLocalUTxO 

Fields

CommitRecorded 

Fields

CommitRecovered 

Fields

DecommitRecorded 

Fields

SnapshotRequestDecided 

Fields

SnapshotRequested

A snapshot was requested by some party. NOTE: We deliberately already include an updated local ledger state to not need a ledger to interpret this event.

Fields

CommitFinalized 

Fields

DecommitFinalized 

Fields

PartySignedSnapshot 

Fields

SnapshotConfirmed 

Fields

HeadClosed 

Fields

HeadContested 

Fields

HeadIsReadyToFanout 
HeadFannedOut 

Fields

ChainRolledBack 

Fields

TickObserved 

Fields

Instances

Instances details
(ArbitraryIsTx tx, IsChainState tx) => Arbitrary (StateChanged tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

arbitrary :: Gen (StateChanged tx)

shrink :: StateChanged tx -> [StateChanged tx]

(IsTx tx, FromJSON (HeadState tx), FromJSON (ChainStateType tx)) => FromJSON (StateChanged tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

parseJSON :: Value -> Parser (StateChanged tx)

parseJSONList :: Value -> Parser [StateChanged tx]

omittedField :: Maybe (StateChanged tx)

(IsTx tx, ToJSON (ChainStateType tx)) => ToJSON (StateChanged tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

toJSON :: StateChanged tx -> Value

toEncoding :: StateChanged tx -> Encoding

toJSONList :: [StateChanged tx] -> Value

toEncodingList :: [StateChanged tx] -> Encoding

omitField :: StateChanged tx -> Bool

Generic (StateChanged tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Associated Types

type Rep (StateChanged tx) :: Type -> Type Source #

(IsTx tx, Show (HeadState tx), Show (ChainStateType tx)) => Show (StateChanged tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

(IsTx tx, Eq (HeadState tx), Eq (ChainStateType tx)) => Eq (StateChanged tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

(ArbitraryIsTx tx, IsChainState tx) => ToADTArbitrary (StateChanged tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

toADTArbitrarySingleton :: Proxy (StateChanged tx) -> Gen (ADTArbitrarySingleton (StateChanged tx))

toADTArbitrary :: Proxy (StateChanged tx) -> Gen (ADTArbitrary (StateChanged tx))

type Rep (StateChanged tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

type Rep (StateChanged tx) = D1 ('MetaData "StateChanged" "Hydra.HeadLogic.Outcome" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) ((((C1 ('MetaCons "HeadInitialized" 'PrefixI 'True) ((S1 ('MetaSel ('Just "parameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadParameters) :*: S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx))) :*: (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadSeed))) :+: C1 ('MetaCons "CommittedUTxO" 'PrefixI 'True) (S1 ('MetaSel ('Just "party") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party) :*: (S1 ('MetaSel ('Just "committedUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx)) :*: S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx))))) :+: (C1 ('MetaCons "HeadAborted" 'PrefixI 'True) (S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx))) :+: (C1 ('MetaCons "HeadOpened" 'PrefixI 'True) (S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx)) :*: S1 ('MetaSel ('Just "initialUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx))) :+: C1 ('MetaCons "TransactionReceived" 'PrefixI 'True) (S1 ('MetaSel ('Just "tx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 tx))))) :+: ((C1 ('MetaCons "TransactionAppliedToLocalUTxO" 'PrefixI 'True) (S1 ('MetaSel ('Just "tx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 tx) :*: S1 ('MetaSel ('Just "newLocalUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx))) :+: C1 ('MetaCons "CommitRecorded" 'PrefixI 'True) (S1 ('MetaSel ('Just "pendingDeposits") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map (TxIdType tx) (UTxOType tx))) :*: S1 ('MetaSel ('Just "newLocalUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx)))) :+: (C1 ('MetaCons "CommitRecovered" 'PrefixI 'True) (S1 ('MetaSel ('Just "recoveredUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx)) :*: (S1 ('MetaSel ('Just "newLocalUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx)) :*: S1 ('MetaSel ('Just "recoveredTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TxIdType tx)))) :+: (C1 ('MetaCons "DecommitRecorded" 'PrefixI 'True) (S1 ('MetaSel ('Just "decommitTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 tx) :*: S1 ('MetaSel ('Just "newLocalUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx))) :+: C1 ('MetaCons "SnapshotRequestDecided" 'PrefixI 'True) (S1 ('MetaSel ('Just "snapshotNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber)))))) :+: (((C1 ('MetaCons "SnapshotRequested" 'PrefixI 'True) ((S1 ('MetaSel ('Just "snapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Snapshot tx)) :*: S1 ('MetaSel ('Just "requestedTxIds") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TxIdType tx])) :*: (S1 ('MetaSel ('Just "newLocalUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx)) :*: S1 ('MetaSel ('Just "newLocalTxs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [tx]))) :+: C1 ('MetaCons "CommitFinalized" 'PrefixI 'True) (S1 ('MetaSel ('Just "newVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotVersion) :*: S1 ('MetaSel ('Just "depositTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TxIdType tx)))) :+: (C1 ('MetaCons "DecommitFinalized" 'PrefixI 'True) (S1 ('MetaSel ('Just "newVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotVersion)) :+: (C1 ('MetaCons "PartySignedSnapshot" 'PrefixI 'True) (S1 ('MetaSel ('Just "snapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Snapshot tx)) :*: (S1 ('MetaSel ('Just "party") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party) :*: S1 ('MetaSel ('Just "signature") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Signature (Snapshot tx))))) :+: C1 ('MetaCons "SnapshotConfirmed" 'PrefixI 'True) (S1 ('MetaSel ('Just "snapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Snapshot tx)) :*: S1 ('MetaSel ('Just "signatures") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MultiSignature (Snapshot tx))))))) :+: ((C1 ('MetaCons "HeadClosed" 'PrefixI 'True) (S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx)) :*: S1 ('MetaSel ('Just "contestationDeadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTCTime)) :+: (C1 ('MetaCons "HeadContested" 'PrefixI 'True) (S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx)) :*: S1 ('MetaSel ('Just "contestationDeadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTCTime)) :+: C1 ('MetaCons "HeadIsReadyToFanout" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "HeadFannedOut" 'PrefixI 'True) (S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx))) :+: (C1 ('MetaCons "ChainRolledBack" 'PrefixI 'True) (S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx))) :+: C1 ('MetaCons "TickObserved" 'PrefixI 'True) (S1 ('MetaSel ('Just "chainSlot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChainSlot)))))))

data Outcome tx Source #

Constructors

Continue

Continue with the given state updates and side effects.

Fields

Wait

Wait for some condition to be met with optional state updates.

Error

Processing resulted in an error.

Fields

Instances

Instances details
(ArbitraryIsTx tx, IsChainState tx) => Arbitrary (Outcome tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

arbitrary :: Gen (Outcome tx)

shrink :: Outcome tx -> [Outcome tx]

IsChainState tx => FromJSON (Outcome tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

parseJSON :: Value -> Parser (Outcome tx)

parseJSONList :: Value -> Parser [Outcome tx]

omittedField :: Maybe (Outcome tx)

IsChainState tx => ToJSON (Outcome tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

toJSON :: Outcome tx -> Value

toEncoding :: Outcome tx -> Encoding

toJSONList :: [Outcome tx] -> Value

toEncodingList :: [Outcome tx] -> Encoding

omitField :: Outcome tx -> Bool

Semigroup (Outcome tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

(<>) :: Outcome tx -> Outcome tx -> Outcome tx Source #

sconcat :: NonEmpty (Outcome tx) -> Outcome tx Source #

stimes :: Integral b => b -> Outcome tx -> Outcome tx Source #

Generic (Outcome tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Associated Types

type Rep (Outcome tx) :: Type -> Type Source #

Methods

from :: Outcome tx -> Rep (Outcome tx) x Source #

to :: Rep (Outcome tx) x -> Outcome tx Source #

IsChainState tx => Show (Outcome tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

IsChainState tx => Eq (Outcome tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

(==) :: Outcome tx -> Outcome tx -> Bool Source #

(/=) :: Outcome tx -> Outcome tx -> Bool Source #

type Rep (Outcome tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

type Rep (Outcome tx) = D1 ('MetaData "Outcome" "Hydra.HeadLogic.Outcome" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) (C1 ('MetaCons "Continue" 'PrefixI 'True) (S1 ('MetaSel ('Just "stateChanges") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [StateChanged tx]) :*: S1 ('MetaSel ('Just "effects") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Effect tx])) :+: (C1 ('MetaCons "Wait" 'PrefixI 'True) (S1 ('MetaSel ('Just "reason") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (WaitReason tx)) :*: S1 ('MetaSel ('Just "stateChanges") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [StateChanged tx])) :+: C1 ('MetaCons "Error" 'PrefixI 'True) (S1 ('MetaSel ('Just "error") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (LogicError tx)))))

data WaitReason tx Source #

Instances

Instances details
ArbitraryIsTx tx => Arbitrary (WaitReason tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

arbitrary :: Gen (WaitReason tx)

shrink :: WaitReason tx -> [WaitReason tx]

IsTx tx => FromJSON (WaitReason tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

parseJSON :: Value -> Parser (WaitReason tx)

parseJSONList :: Value -> Parser [WaitReason tx]

omittedField :: Maybe (WaitReason tx)

IsTx tx => ToJSON (WaitReason tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

toJSON :: WaitReason tx -> Value

toEncoding :: WaitReason tx -> Encoding

toJSONList :: [WaitReason tx] -> Value

toEncodingList :: [WaitReason tx] -> Encoding

omitField :: WaitReason tx -> Bool

Generic (WaitReason tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Associated Types

type Rep (WaitReason tx) :: Type -> Type Source #

Methods

from :: WaitReason tx -> Rep (WaitReason tx) x Source #

to :: Rep (WaitReason tx) x -> WaitReason tx Source #

IsTx tx => Show (WaitReason tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

IsTx tx => Eq (WaitReason tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

Methods

(==) :: WaitReason tx -> WaitReason tx -> Bool Source #

(/=) :: WaitReason tx -> WaitReason tx -> Bool Source #

type Rep (WaitReason tx) Source # 
Instance details

Defined in Hydra.HeadLogic.Outcome

type Rep (WaitReason tx) = D1 ('MetaData "WaitReason" "Hydra.HeadLogic.Outcome" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) (((C1 ('MetaCons "WaitOnNotApplicableTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "validationError") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ValidationError)) :+: C1 ('MetaCons "WaitOnSnapshotNumber" 'PrefixI 'True) (S1 ('MetaSel ('Just "waitingForNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber))) :+: (C1 ('MetaCons "WaitOnSnapshotVersion" 'PrefixI 'True) (S1 ('MetaSel ('Just "waitingForVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotVersion)) :+: C1 ('MetaCons "WaitOnSeenSnapshot" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "WaitOnTxs" 'PrefixI 'True) (S1 ('MetaSel ('Just "waitingForTxIds") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TxIdType tx])) :+: C1 ('MetaCons "WaitOnContestationDeadline" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "WaitOnNotApplicableDecommitTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "notApplicableReason") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (DecommitInvalidReason tx))) :+: (C1 ('MetaCons "WaitOnUnresolvedCommit" 'PrefixI 'True) (S1 ('MetaSel ('Just "commitUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx))) :+: C1 ('MetaCons "WaitOnUnresolvedDecommit" 'PrefixI 'True) (S1 ('MetaSel ('Just "decommitTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 tx))))))

causes :: [Effect tx] -> Outcome tx Source #