hydra-node
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.Chain

Description

Specifies the Head-Chain Interaction part of the protocol

Incoming and outgoing on-chain transactions are modelled respectively as OnChainTx and PostChainTx which are data type that abstracts away the details of the structure of the transaction.

Synopsis

Documentation

maximumNumberOfParties :: Int Source #

Hardcoded limit for maximum number of parties in a head protocol. A too high number would be detected by property and acceptance tests.

data PostChainTx tx Source #

Data type used to post transactions on chain. It holds everything to construct corresponding Head protocol transactions. TODO: somehow merge HeadSeed/HeadId

Constructors

InitTx 

Fields

IncrementTx 

Fields

RecoverTx 

Fields

DecrementTx 

Fields

CloseTx 

Fields

ContestTx 

Fields

FanoutTx 

Fields

PartialFanoutTx

Non-final partial fanout of a user-selected subset. Distributes $sel:utxoToDistribute:InitTx (dynamically chunked to fit) and leaves the head in the FanoutProgress state without burning tokens. $sel:utxoForProof:InitTx is the full accumulator UTxO matching the current on-chain datum (everything still in the head plus any pre-settled elements).

Fields

FinalPartialFanoutTx 

Fields

Instances

Instances details
IsTx tx => FromJSON (PostChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

parseJSON :: Value -> Parser (PostChainTx tx)

parseJSONList :: Value -> Parser [PostChainTx tx]

omittedField :: Maybe (PostChainTx tx)

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

Defined in Hydra.Chain

Methods

toJSON :: PostChainTx tx -> Value

toEncoding :: PostChainTx tx -> Encoding

toJSONList :: [PostChainTx tx] -> Value

toEncodingList :: [PostChainTx tx] -> Encoding

omitField :: PostChainTx tx -> Bool

Generic (PostChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Associated Types

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

Methods

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

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

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

Defined in Hydra.Chain

IsTx tx => FromCBOR (PostChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

fromCBOR :: Decoder s (PostChainTx tx)

label :: Proxy (PostChainTx tx) -> Text

IsTx tx => ToCBOR (PostChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

toCBOR :: PostChainTx tx -> Encoding

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy (PostChainTx tx) -> Size

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [PostChainTx tx] -> Size

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

Defined in Hydra.Chain

type Rep (PostChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

type Rep (PostChainTx tx) = D1 ('MetaData "PostChainTx" "Hydra.Chain" "hydra-node-2.3.0-1cgalYNmLJQC1YXlYVq7mp" 'False) (((C1 ('MetaCons "InitTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "participants") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [OnChainId]) :*: S1 ('MetaSel ('Just "headParameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadParameters)) :+: C1 ('MetaCons "IncrementTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadSeed) :*: S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadId)) :*: (S1 ('MetaSel ('Just "headParameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadParameters) :*: (S1 ('MetaSel ('Just "incrementingSnapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (ConfirmedSnapshot tx)) :*: S1 ('MetaSel ('Just "depositTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (TxIdType tx)))))) :+: (C1 ('MetaCons "RecoverTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "recoverTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (TxIdType tx))) :*: (S1 ('MetaSel ('Just "deadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ChainSlot) :*: S1 ('MetaSel ('Just "recoverUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (UTxOType tx)))) :+: C1 ('MetaCons "DecrementTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadSeed) :*: S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadId)) :*: (S1 ('MetaSel ('Just "headParameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadParameters) :*: S1 ('MetaSel ('Just "decrementingSnapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (ConfirmedSnapshot tx)))))) :+: ((C1 ('MetaCons "CloseTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "headParameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadParameters)) :*: (S1 ('MetaSel ('Just "openVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SnapshotVersion) :*: S1 ('MetaSel ('Just "closingSnapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (ConfirmedSnapshot tx)))) :+: C1 ('MetaCons "ContestTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "headParameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadParameters)) :*: (S1 ('MetaSel ('Just "openVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SnapshotVersion) :*: S1 ('MetaSel ('Just "contestingSnapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (ConfirmedSnapshot tx))))) :+: (C1 ('MetaCons "FanoutTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "utxo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (UTxOType tx)) :*: (S1 ('MetaSel ('Just "utxoToCommit") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe (UTxOType tx))) :*: S1 ('MetaSel ('Just "utxoToDecommit") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe (UTxOType tx))))) :*: (S1 ('MetaSel ('Just "utxoForProof") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (UTxOType tx)) :*: (S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadSeed) :*: S1 ('MetaSel ('Just "contestationDeadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 UTCTime)))) :+: (C1 ('MetaCons "PartialFanoutTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "utxoToDistribute") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (UTxOType tx)) :*: S1 ('MetaSel ('Just "utxoForProof") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (UTxOType tx))) :*: (S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadSeed) :*: S1 ('MetaSel ('Just "contestationDeadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 UTCTime))) :+: C1 ('MetaCons "FinalPartialFanoutTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "utxoToDistribute") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (UTxOType tx)) :*: S1 ('MetaSel ('Just "presettledUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (UTxOType tx))) :*: (S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadSeed) :*: S1 ('MetaSel ('Just "contestationDeadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 UTCTime)))))))

data OnChainTx tx Source #

Describes transactions as seen on chain. Holds as minimal information as possible to simplify observing the chain.

Constructors

OnInitTx 

Fields

OnDepositTx 

Fields

OnRecoverTx 

Fields

OnIncrementTx 

Fields

OnDecrementTx 

Fields

OnCloseTx 

Fields

OnContestTx 

Fields

OnFanoutTx 

Fields

OnPartialFanoutTx 

Fields

Instances

Instances details
IsTx tx => FromJSON (OnChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

parseJSON :: Value -> Parser (OnChainTx tx)

parseJSONList :: Value -> Parser [OnChainTx tx]

omittedField :: Maybe (OnChainTx tx)

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

Defined in Hydra.Chain

Methods

toJSON :: OnChainTx tx -> Value

toEncoding :: OnChainTx tx -> Encoding

toJSONList :: [OnChainTx tx] -> Value

toEncodingList :: [OnChainTx tx] -> Encoding

omitField :: OnChainTx tx -> Bool

Generic (OnChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Associated Types

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

Methods

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

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

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

Defined in Hydra.Chain

IsTx tx => FromCBOR (OnChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

fromCBOR :: Decoder s (OnChainTx tx)

label :: Proxy (OnChainTx tx) -> Text

IsTx tx => ToCBOR (OnChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

toCBOR :: OnChainTx tx -> Encoding

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy (OnChainTx tx) -> Size

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [OnChainTx tx] -> Size

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

Defined in Hydra.Chain

Methods

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

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

type Rep (OnChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

type Rep (OnChainTx tx) = D1 ('MetaData "OnChainTx" "Hydra.Chain" "hydra-node-2.3.0-1cgalYNmLJQC1YXlYVq7mp" 'False) (((C1 ('MetaCons "OnInitTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadSeed)) :*: (S1 ('MetaSel ('Just "headParameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadParameters) :*: S1 ('MetaSel ('Just "participants") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [OnChainId]))) :+: C1 ('MetaCons "OnDepositTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "depositTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (TxIdType tx))) :*: (S1 ('MetaSel ('Just "deposited") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (UTxOType tx)) :*: (S1 ('MetaSel ('Just "created") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 UTCTime) :*: S1 ('MetaSel ('Just "deadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 UTCTime))))) :+: (C1 ('MetaCons "OnRecoverTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "recoveredTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (TxIdType tx)) :*: S1 ('MetaSel ('Just "recoveredUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (UTxOType tx)))) :+: C1 ('MetaCons "OnIncrementTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "newVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SnapshotVersion) :*: S1 ('MetaSel ('Just "depositTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (TxIdType tx)))))) :+: ((C1 ('MetaCons "OnDecrementTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "newVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SnapshotVersion) :*: S1 ('MetaSel ('Just "distributedUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (UTxOType tx)))) :+: C1 ('MetaCons "OnCloseTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "snapshotNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SnapshotNumber) :*: S1 ('MetaSel ('Just "contestationDeadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 UTCTime)))) :+: (C1 ('MetaCons "OnContestTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "snapshotNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SnapshotNumber) :*: S1 ('MetaSel ('Just "contestationDeadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 UTCTime))) :+: (C1 ('MetaCons "OnFanoutTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "fanoutUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (UTxOType tx))) :+: C1 ('MetaCons "OnPartialFanoutTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "distributedOutputs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (UTxOType tx)))))))

data PostTxError tx Source #

Exceptions thrown by $sel:postTx:Chain.

Constructors

NoSeedInput 
InvalidSeed 

Fields

InvalidHeadId 

Fields

UnsupportedLegacyOutput

Committing byron addresses is not supported.

Fields

DepositTooLow 

Fields

DepositTooLarge

The deposit is too large: the increment transaction claiming it would exceed layer 1 ledger limits (estimated sizes include a balancing margin).

InvalidStateToPost 

Fields

NotEnoughFuel 

Fields

NoFuelUTXOFound 

Fields

ScriptFailedInWallet

Script execution failed when finalizing a transaction in the wallet. XXX: Ideally we want a cardano-api type with corresponding JSON instance here. But the wallet still uses ledger types and we don't want to copy the conversion from ledger TransactionScriptFailure to the cardano-api ScriptExecutionError type.

Fields

InternalWalletError

A generic error happened when finalizing a transaction in the wallet.

Fields

FailedToPostTx

An error occurred when submitting a transaction to the cardano-node.

Fields

FailedToConstructCloseTx 
FailedToConstructContestTx 
FailedToConstructDepositTx 

Fields

FailedToConstructRecoverTx 

Fields

FailedToConstructIncrementTx 

Fields

FailedToConstructDecrementTx 

Fields

FailedToConstructFanoutTx 
FailedToConstructPartialFanoutTx 
StalePartialFanoutTx

Another node already posted this partial fanout step; the chain observation loop will emit the correct next step automatically.

ContestationDeadlineOutsideTimeHorizon 

Fields

InvalidTokenRequest [(PolicyId, PolicyAssets)] 

Instances

Instances details
IsChainState tx => FromJSON (PostTxError tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

parseJSON :: Value -> Parser (PostTxError tx)

parseJSONList :: Value -> Parser [PostTxError tx]

omittedField :: Maybe (PostTxError tx)

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

Defined in Hydra.Chain

Methods

toJSON :: PostTxError tx -> Value

toEncoding :: PostTxError tx -> Encoding

toJSONList :: [PostTxError tx] -> Value

toEncodingList :: [PostTxError tx] -> Encoding

omitField :: PostTxError tx -> Bool

IsChainState tx => Exception (PostTxError tx) Source # 
Instance details

Defined in Hydra.Chain

Generic (PostTxError tx) Source # 
Instance details

Defined in Hydra.Chain

Associated Types

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

Methods

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

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

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

Defined in Hydra.Chain

IsChainState tx => FromCBOR (PostTxError tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

fromCBOR :: Decoder s (PostTxError tx)

label :: Proxy (PostTxError tx) -> Text

IsChainState tx => ToCBOR (PostTxError tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

toCBOR :: PostTxError tx -> Encoding

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy (PostTxError tx) -> Size

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [PostTxError tx] -> Size

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

Defined in Hydra.Chain

type Rep (PostTxError tx) Source # 
Instance details

Defined in Hydra.Chain

type Rep (PostTxError tx) = D1 ('MetaData "PostTxError" "Hydra.Chain" "hydra-node-2.3.0-1cgalYNmLJQC1YXlYVq7mp" 'False) ((((C1 ('MetaCons "NoSeedInput" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "InvalidSeed" 'PrefixI 'True) (S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadSeed))) :+: (C1 ('MetaCons "InvalidHeadId" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HeadId)) :+: (C1 ('MetaCons "UnsupportedLegacyOutput" 'PrefixI 'True) (S1 ('MetaSel ('Just "byronAddress") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Address ByronAddr))) :+: C1 ('MetaCons "DepositTooLow" 'PrefixI 'True) (S1 ('MetaSel ('Just "providedValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Coin) :*: S1 ('MetaSel ('Just "minimumValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Coin))))) :+: ((C1 ('MetaCons "DepositTooLarge" 'PrefixI 'True) ((S1 ('MetaSel ('Just "estimatedTxSize") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Natural) :*: S1 ('MetaSel ('Just "maximumTxSize") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Natural)) :*: (S1 ('MetaSel ('Just "estimatedValueSize") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Natural) :*: S1 ('MetaSel ('Just "maximumValueSize") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Natural))) :+: (C1 ('MetaCons "InvalidStateToPost" 'PrefixI 'True) (S1 ('MetaSel ('Just "txTried") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (PostChainTx tx)) :*: S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (ChainStateType tx))) :+: C1 ('MetaCons "NotEnoughFuel" 'PrefixI 'True) (S1 ('MetaSel ('Just "failingTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 tx)))) :+: (C1 ('MetaCons "NoFuelUTXOFound" 'PrefixI 'True) (S1 ('MetaSel ('Just "failingTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 tx)) :+: (C1 ('MetaCons "ScriptFailedInWallet" 'PrefixI 'True) (S1 ('MetaSel ('Just "redeemerPtr") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text) :*: (S1 ('MetaSel ('Just "failureReason") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "failingTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 tx))) :+: C1 ('MetaCons "InternalWalletError" 'PrefixI 'True) (S1 ('MetaSel ('Just "headUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (UTxOType tx)) :*: (S1 ('MetaSel ('Just "reason") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "failingTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 tx))))))) :+: (((C1 ('MetaCons "FailedToPostTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "failureReason") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "failingTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 tx)) :+: (C1 ('MetaCons "FailedToConstructCloseTx" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "FailedToConstructContestTx" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "FailedToConstructDepositTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "failureReason") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :+: (C1 ('MetaCons "FailedToConstructRecoverTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "failureReason") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :+: C1 ('MetaCons "FailedToConstructIncrementTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "failureReason") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text))))) :+: ((C1 ('MetaCons "FailedToConstructDecrementTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "failureReason") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :+: (C1 ('MetaCons "FailedToConstructFanoutTx" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "FailedToConstructPartialFanoutTx" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "StalePartialFanoutTx" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ContestationDeadlineOutsideTimeHorizon" 'PrefixI 'True) (S1 ('MetaSel ('Just "failureReason") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :+: C1 ('MetaCons "InvalidTokenRequest" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [(PolicyId, PolicyAssets)])))))))

data ChainStateHistory tx Source #

A non empty sequence of chain states that can be rolled back. This is expected to be constructed by using the smart constructor initHistory.

Constructors

UnsafeChainStateHistory 

Fields

  • history :: NonEmpty (ChainStateType tx)

    The sequence of known chain states, ordered from most recent to oldest. These contain notable state observed on-chain to be able to interact with Hydra heads.

  • lastKnown :: ChainPointType tx

    The last known chain point, which may be used to continue observing the chain.

  • defaultChainState :: ChainStateType tx

    The default chain state to fall back to when rolling back beyond known history.

Instances

Instances details
Generic (ChainStateHistory tx) Source # 
Instance details

Defined in Hydra.Chain

Associated Types

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

(Show (ChainPointType tx), Show (ChainStateType tx)) => Show (ChainStateHistory tx) Source # 
Instance details

Defined in Hydra.Chain

(Eq (ChainPointType tx), Eq (ChainStateType tx)) => Eq (ChainStateHistory tx) Source # 
Instance details

Defined in Hydra.Chain

type Rep (ChainStateHistory tx) Source # 
Instance details

Defined in Hydra.Chain

type Rep (ChainStateHistory tx) = D1 ('MetaData "ChainStateHistory" "Hydra.Chain" "hydra-node-2.3.0-1cgalYNmLJQC1YXlYVq7mp" 'False) (C1 ('MetaCons "UnsafeChainStateHistory" 'PrefixI 'True) (S1 ('MetaSel ('Just "history") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (NonEmpty (ChainStateType tx))) :*: (S1 ('MetaSel ('Just "lastKnown") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (ChainPointType tx)) :*: S1 ('MetaSel ('Just "defaultChainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (ChainStateType tx)))))

currentState :: ChainStateHistory tx -> ChainStateType tx Source #

pushNewState :: IsChainState tx => ChainStateType tx -> ChainStateHistory tx -> ChainStateHistory tx Source #

Record a new chain state in history. Also ensures the $sel:lastKnown:UnsafeChainStateHistory point is updated accordingly.

setLastKnown :: ChainPointType tx -> ChainStateHistory tx -> ChainStateHistory tx Source #

Update the last known chain point. Use pushNewState if you have a full 'ChainStateType tx'.

initHistory :: IsChainState tx => ChainStateType tx -> ChainStateHistory tx Source #

rollbackHistory :: IsChainState tx => ChainSlot -> ChainStateHistory tx -> ChainStateHistory tx Source #

prefixOf :: IsChainState tx => ChainStateHistory tx -> NonEmpty (ChainPointType tx) Source #

Get the known prefix of all the ChainStateHistory.

data Chain tx m Source #

Handle to interface with the main chain network

Constructors

Chain 

Fields

  • postTx :: MonadThrow m => PostChainTx tx -> m ()

    Construct and send a transaction to the main chain corresponding to the given PostChainTx description. This function is not expected to block, so it is only responsible for submitting, but it should validate the created transaction against a reasonable local view of the chain and throw an exception when invalid.

    Does at least throw PostTxError.

  • draftDepositTx :: MonadThrow m => HeadId -> PParams LedgerEra -> ConfirmedSnapshot tx -> CommitBlueprintTx tx -> UTCTime -> Maybe AddressInEra -> m (Either (PostTxError tx) tx)

    Create a deposit transaction using user provided utxos (zero or many) , _blueprint_ transaction which spends these outputs and a deadline for their inclusion into L2. The current confirmed snapshot serves as the basis for a dry-run increment transaction rejecting deposits which could never be claimed. Errors are handled at the call site.

  • submitTx :: MonadThrow m => tx -> m ()

    Submit a cardano transaction.

    Throws at least PostTxError.

    XXX: While technically they could be any of 'PostTxError tx', only FailedToPostTx errors are expected here.

  • checkNonADAAssets :: ConfirmedSnapshot tx -> Either Value ()
     

data ChainEvent tx Source #

Constructors

Observation

Indicates a head protocol transaction has been observed.

Fields

Rollback 

Fields

Tick

Indicate time has advanced on the chain. This is deliberately not a ChainStateType because state updates are only expected upon Observation orRollback.

NOTE: While the type does not guarantee that the UTCTime and the slot in ChainPointType tx are consistent the alternative would be provide the means to do the conversion. For Cardano, this would be a systemStart and eraHistory.. which is annoying and if it's kept in the chain layer, it would mean another round trip / state to keep there.

Fields

PostTxError

Event to re-ingest errors from $sel:postTx:Chain for further processing.

Instances

Instances details
(IsTx tx, IsChainState tx) => FromJSON (ChainEvent tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

parseJSON :: Value -> Parser (ChainEvent tx)

parseJSONList :: Value -> Parser [ChainEvent tx]

omittedField :: Maybe (ChainEvent tx)

(IsTx tx, IsChainState tx) => ToJSON (ChainEvent tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

toJSON :: ChainEvent tx -> Value

toEncoding :: ChainEvent tx -> Encoding

toJSONList :: [ChainEvent tx] -> Value

toEncodingList :: [ChainEvent tx] -> Encoding

omitField :: ChainEvent tx -> Bool

Generic (ChainEvent tx) Source # 
Instance details

Defined in Hydra.Chain

Associated Types

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

Methods

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

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

(IsTx tx, IsChainState tx) => Show (ChainEvent tx) Source # 
Instance details

Defined in Hydra.Chain

IsChainState tx => FromCBOR (ChainEvent tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

fromCBOR :: Decoder s (ChainEvent tx)

label :: Proxy (ChainEvent tx) -> Text

IsChainState tx => ToCBOR (ChainEvent tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

toCBOR :: ChainEvent tx -> Encoding

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy (ChainEvent tx) -> Size

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [ChainEvent tx] -> Size

(IsTx tx, IsChainState tx) => Eq (ChainEvent tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

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

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

type Rep (ChainEvent tx) Source # 
Instance details

Defined in Hydra.Chain

type Rep (ChainEvent tx) = D1 ('MetaData "ChainEvent" "Hydra.Chain" "hydra-node-2.3.0-1cgalYNmLJQC1YXlYVq7mp" 'False) ((C1 ('MetaCons "Observation" 'PrefixI 'True) (S1 ('MetaSel ('Just "observedTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (OnChainTx tx)) :*: S1 ('MetaSel ('Just "newChainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (ChainStateType tx))) :+: C1 ('MetaCons "Rollback" 'PrefixI 'True) (S1 ('MetaSel ('Just "chainTime") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 UTCTime) :*: S1 ('MetaSel ('Just "rolledBackChainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (ChainStateType tx)))) :+: (C1 ('MetaCons "Tick" 'PrefixI 'True) (S1 ('MetaSel ('Just "chainTime") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 UTCTime) :*: S1 ('MetaSel ('Just "chainPoint") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (ChainPointType tx))) :+: C1 ('MetaCons "PostTxError" 'PrefixI 'True) (S1 ('MetaSel ('Just "postChainTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (PostChainTx tx)) :*: (S1 ('MetaSel ('Just "postTxError") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (PostTxError tx)) :*: S1 ('MetaSel ('Just "failingTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe tx))))))

type ChainCallback tx m = ChainEvent tx -> m () Source #

A callback indicating a 'ChainEvent tx' happened. Most importantly the Observation of a relevant Hydra transaction.

type ChainComponent tx m a = ChainCallback tx m -> (Chain tx m -> m a) -> m a Source #

A type tying both posting and observing transactions into a single Component.