Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Hydra.Chain
Contents
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
- maxMainnetLovelace :: Lovelace
- maximumNumberOfParties :: Int
- data HeadParameters = HeadParameters {}
- data PostChainTx tx
- = InitTx { }
- | AbortTx { }
- | CollectComTx { }
- | CloseTx { }
- | ContestTx { }
- | FanoutTx {
- utxo :: UTxOType tx
- contestationDeadline :: UTCTime
- newtype HeadId = HeadId ByteString
- data OnChainTx tx
- = OnInitTx { }
- | OnCommitTx { }
- | OnAbortTx
- | OnCollectComTx
- | OnCloseTx {
- headId :: HeadId
- snapshotNumber :: SnapshotNumber
- contestationDeadline :: UTCTime
- | OnContestTx { }
- | OnFanoutTx
- data PostTxError tx
- = NoSeedInput
- | CannotFindOwnInitial { }
- | UnsupportedLegacyOutput {
- byronAddress :: Address ByronAddr
- | CannotCommitReferenceScript
- | InvalidStateToPost {
- txTried :: PostChainTx tx
- chainState :: ChainStateType tx
- | NotEnoughFuel
- | NoFuelUTXOFound
- | ScriptFailedInWallet {
- redeemerPtr :: Text
- failureReason :: Text
- | InternalWalletError { }
- | FailedToPostTx {
- failureReason :: Text
- | PlutusValidationFailed {
- plutusFailure :: Text
- plutusDebugInfo :: Text
- | CommittedTooMuchADAForMainnet {
- userCommittedLovelace :: Lovelace
- mainnetLimitLovelace :: Lovelace
- | FailedToDraftTxNotInitializing
- | SpendingNodeUtxoForbidden
- class (IsTx tx, Eq (ChainStateType tx), Show (ChainStateType tx), FromJSON (ChainStateType tx), ToJSON (ChainStateType tx)) => IsChainState tx where
- type ChainStateType tx = c | c -> tx
- chainStateSlot :: ChainStateType tx -> ChainSlot
- data Chain tx m = Chain {
- postTx :: MonadThrow m => PostChainTx tx -> m ()
- draftCommitTx :: MonadThrow m => UTxO' (TxOut CtxUTxO, Witness WitCtxTxIn) -> m (Either (PostTxError Tx) Tx)
- submitTx :: MonadThrow m => Tx -> m ()
- data ChainEvent tx
- = Observation {
- observedTx :: OnChainTx tx
- newChainState :: ChainStateType tx
- | Rollback { }
- | Tick { }
- = Observation {
- type ChainCallback tx m = ChainEvent tx -> m ()
- type ChainComponent tx m a = ChainCallback tx m -> (Chain tx m -> m a) -> m a
Documentation
maxMainnetLovelace :: Lovelace Source #
Hardcoded limit for commit tx on mainnet
maximumNumberOfParties :: Int Source #
Hardcoded limit for maximum number of parties in a head protocol
The value is obtained from calculating the costs of running the scripts
and on-chan validators (see computeCollectComCost
computeAbortCost
)
data HeadParameters Source #
Contains the head's parameters as established in the initial transaction.
Constructors
HeadParameters | |
Fields |
Instances
data PostChainTx tx Source #
Data type used to post transactions on chain. It holds everything to construct corresponding Head protocol transactions.
Constructors
InitTx | |
Fields | |
AbortTx | |
CollectComTx | |
CloseTx | |
Fields | |
ContestTx | |
Fields | |
FanoutTx | |
Fields
|
Instances
Uniquely identifies a Hydra Head.
Constructors
HeadId ByteString |
Instances
Arbitrary HeadId Source # | |
FromJSON HeadId Source # | |
Defined in Hydra.Chain | |
ToJSON HeadId Source # | |
Defined in Hydra.Chain Methods toEncoding :: HeadId -> Encoding toJSONList :: [HeadId] -> Value toEncodingList :: [HeadId] -> Encoding | |
Generic HeadId Source # | |
Show HeadId Source # | |
HasTypeProxy HeadId Source # | |
Defined in Hydra.Chain Methods proxyToAsType :: Proxy HeadId -> AsType HeadId | |
SerialiseAsRawBytes HeadId Source # | |
Defined in Hydra.Chain Methods serialiseToRawBytes :: HeadId -> ByteString deserialiseFromRawBytes :: AsType HeadId -> ByteString -> Either SerialiseAsRawBytesError HeadId | |
Eq HeadId Source # | |
Ord HeadId Source # | |
type Rep HeadId Source # | |
Defined in Hydra.Chain | |
data AsType HeadId Source # | |
Defined in Hydra.Chain |
Describes transactions as seen on chain. Holds as minimal information as possible to simplify observing the chain.
Constructors
OnInitTx | |
Fields
| |
OnCommitTx | |
OnAbortTx | |
OnCollectComTx | |
OnCloseTx | |
Fields
| |
OnContestTx | |
Fields | |
OnFanoutTx |
Instances
data PostTxError tx Source #
Exceptions thrown by $sel:postTx:Chain
.
Constructors
NoSeedInput | |
CannotFindOwnInitial | |
UnsupportedLegacyOutput | Comitting byron addresses is not supported. |
Fields
| |
CannotCommitReferenceScript | Comitting reference scripts is not supported right now. |
InvalidStateToPost | |
Fields
| |
NotEnoughFuel | |
NoFuelUTXOFound | |
ScriptFailedInWallet | Script execution failed when finalizing a transaction in the wallet.
XXX: Ideally we want a cardano-api type with corresonding JSON instance
here. But the wallet still uses ledger types and we don't want to copy the
conversion from ledger |
Fields
| |
InternalWalletError | A generic error happened when finalizing a transction in the wallet. |
FailedToPostTx | An error occurred when submitting a transaction to the cardano-node. |
Fields
| |
PlutusValidationFailed | A plutus script failed in a transaction submitted to the cardano-node. NOTE: PlutusDebugInfo does not have much available instances so we put it in Text form but it's lame |
Fields
| |
CommittedTooMuchADAForMainnet | User tried to commit more than |
Fields
| |
FailedToDraftTxNotInitializing | We can only draft commit tx for the user when in Initializing state |
SpendingNodeUtxoForbidden | Committing UTxO addressed to the internal wallet is forbidden. |
Instances
class (IsTx tx, Eq (ChainStateType tx), Show (ChainStateType tx), FromJSON (ChainStateType tx), ToJSON (ChainStateType tx)) => IsChainState tx where Source #
Interface available from a chain state. Expected to be instantiated by all 'ChainStateType tx'.
Associated Types
type ChainStateType tx = c | c -> tx Source #
Types of what to keep as L1 chain state.
Methods
chainStateSlot :: ChainStateType tx -> ChainSlot Source #
Get the chain slot for a chain state. NOTE: For any sequence of a
encountered, we assume monotonically increasing slots.
Instances
IsChainState Tx Source # | |
Defined in Hydra.Chain.Direct.State Associated Types type ChainStateType Tx = (c :: Type) Source # Methods | |
IsChainState SimpleTx Source # | |
Defined in Hydra.Ledger.Simple Associated Types type ChainStateType SimpleTx = (c :: Type) Source # Methods chainStateSlot :: ChainStateType SimpleTx -> ChainSlot Source # |
Handle to interface with the main chain network
Constructors
Chain | |
Fields
|
data ChainEvent tx Source #
Constructors
Observation | |
Fields
| |
Rollback | |
Fields | |
Tick | Indicate time has advanced on the chain. NOTE: While the type does not guarantee that the UTCTime and ChainSlot 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. |
Instances
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.