Status
Accepted
Context
- The Hydra on-chain-verification scripts are used to validate Hydra protocol transactions and ensure they are lawful.
- At least these three properties need to be enforced:
- Authentication: ensure that only Head participants can, for example,
abort
a Head - Contract continuity: ensure that a Head was
init
ialized before it can be opened by acollectCom
tx. - Completeness: ensure that all Head participants had chance to
commit
funds to a Head.
- Authentication: ensure that only Head participants can, for example,
- The Hydra Head paper introduces participation tokens (PT) and a state thread token (ST) for that matter.
- Such tokens (a.k.a native assets) are identified by the
CurrencySymbol
, that is the hash of theirMintingPolicyScript
(a.k.aPolicyID
in the ledger), and aByteString
, the socalledTokenName
(a.k.a asAssetName
in the ledger, see shelley-ma ledger spec) - There can be multiple Hydra Heads on a network and a
hydra-node
need to distinguish individual Head instances or even (later) keep track of multiple Heads. Concretely, this means that we need to infer a Head identifier (HeadId
) from observing each of the Hydra protocol transactions.
Decision
- We solve both challenges by defining that ST and PTs shall use the same
MintingPolicyScript
and thus have sameCurrencySymbol
- The
MintingPolicyScript
shall be parameterized byTxOutRef
to yield a uniqueCurrencySymbol
per Head (similar to theOneShotCurrency
example) - ST and one PT per participant are minted in the
initTx
- The
TokenName
of the ST can be any well-knownByteString
, e.g."HydraHeadV1"
- The
TokenName
of the PTs needs to be thePubKeyHash
of the respective participant
Consequences
Heads can be identified by looking for the
ST
ininit
,collectCom
,close
,contest
orfanout
transactions, or thePT
incommit
transactions. In both cases, theCurrencySymbol == HeadId
Our scripts become simpler as we only need to check that ST/PT are paid forward, instead of needing to check datums
The datum produced by
commit
txs (and consumed bycollectCom
) isJust SerializedTxOut
, which is simpler than also keeping the participant which committed in the datum (compare to full life-cycle of 0.3.0).The
v_head
script validator does not need to be parameterized, which makes discovering new Heads (and also tracking them for metrics) easier as the address to watch for is common to all Heads (of the samev_head
version).The
v_head
script (path) for the abort life-cycle can be implemented already much safer by checking that all PTs are burned on theabort
transaction (counting inputs in abort life-cycle of 0.3.0).Updated diagrams for the full and abort on-chain life-cycles of a Hydra Head.
Follow-up questions
- What value does the
ST
actually add? We could always look for thePT
to identify a Head and contract continuity would already be achieved by thePT
s! - In discussions it turned out to be not clear where the Head's
CurrencySymbol
is coming from, and consequently how to identify that anST
is indeed anST
?