-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incremental commit #199
Comments
In a discussion I had with @mchakravarty we touched on the fact that it would also be possible to directly |
Incremental decommits may be very interesting to oracle use cases, where the resulting data is getting decomitted upon consumption. |
The use case of Incremental De/Commit really adds so much added value to many of the Use Cases that Hydra seeks solve for end-users. From an end-users perspective, with all of the potential Heads that will be running, they will be locking funds in various places. A stake pool is well understood way of locking in funds, but with Heads, and the varied use cases, they may be more hesitant or unable (because they have commit to previous heads), to participate. By having Incremental De/Commit users are free to allocate their funds as necessary with their goals, and feel more confident with the developers integrating features utilizing Hydra Heads. So I see this as a very important feature for optics to the greater cardano community, and Hydra Pay would definitely be able to make good use of it. |
@Sbcdn mentioned they would love to have this feature as well for their use case so +1 |
We discussed incremental commits/decommits (aka increments/decrements) today with the original authors of the Hydra Head paper:
|
Some use cases that we believe could benefit from this:
|
Notes from @mchakravarty on incremental commits and more general configuration changes (from back in the days): Hydra Head with Incremental Commits Requirements
Configuration change transactions
Adding and removing participants
Committing and decommitting UTxOs
Synchronisation
Multisigs
|
Besides the basic mermaid diagram above, here is another drawing of the potential life-cycle with incremental commits/decommits from our Miro board: |
Grooming discussion:
Next steps:
|
We continued work on this after also starting #1057. We had implemented the off-chain workflow to the point of this diagram shows: sequenceDiagram
Alice->>+API: POST /commit (UTxO)
API->>HeadLogic: Commit UTxO
par broadcast
HeadLogic->>HeadLogic: ReqInc incUTxO
and
HeadLogic->>Node B: ReqInc incUTxO
end
HeadLogic -->> Alice: WS CommitRequested
par Alice isLeader
HeadLogic->>HeadLogic: ReqSn incUTxO
and
HeadLogic->>Node B: ReqSn incUTxO
end
Note over HeadLogic,Chain: PROBLEM: Need to verify incUTxO on L1 as we authorize the TxIns to use (because of on-chain scripts).
HeadLogic->>HeadLogic: sig = sign snapshot incl. inputs(incUTxO)
par broadcast
HeadLogic->>HeadLogic: AckSn sig
and
HeadLogic->>Node B: AckSn sig
end
Node B->>HeadLogic: AckSn sig
HeadLogic -->> Alice: WS SnapshotConfirmed
HeadLogic -->> Alice: WS CommitApproved
HeadLogic -->> API: SnapshotConfirmed
API->>API: draftIncrementTx vk snapshot sig >>= finalizeTx >>= signTx sk
API-->>-Alice: IncrementTx
Alice->>Alice: sign IncrementTx
Alice->>Chain: submit IncrementTx
Chain->>HeadLogic: OnIncrementTx
HeadLogic-->>Alice: CommitFinalized
However, when working on the specification and trying to realize the recommendation of researchers, we hit the problem as indicated in the picture. Namely, that in one of the designs the assumption was made that Hydra participants would sign off on the transaction output references ( We need to discuss this and the alternative of using a Merkle-Tree based |
@GeorgeFlerovsky When typing out the specification for the on-chain checks to be done on There is no actual need for on-chain checks of what a valid deposit is (what I would have encoded in the minting policy). Anyone paying to the deposit validator (off-chain code) should ensure that what they put is a valid datum having a deadline and if a script wants to ensure continuity of its datum, it would need to green light any While the interface between downstream scripts and the deposit protocol would become slightly more involved, it comes at the benefit of greatly simplifying the protocol transactions. But.. How would you describe this interface? I was thinking something similar to the |
@ch1bo TBH, I haven't thought too much about that interface yet. In a hand-wavy sense, we can adapt components from what you've previously been doing for users — serializing utxos, deserializing their datum representation, comparing redeemers to hashes, etc. We're just pushing some of those onchain/offchain mechanisms outside the hydra protocol. The onchain parts become opt-in for scripts, while pubkey users rely on the offchain checks. |
### Why This is a leftover from off-chain changes needed to implement #199 We kept in the local state a map of UTxO we already observed so this simplifies the code around that since the observed UTxO is already to be found in the chain state UTxO. Now we keep a list of `[(TxId, UTxO)]` where UTxO is just there to check off-chain if the next snapshot is snapshotting exactly what we saw already as (`utxoToCommit`). ### What Remove the local map and fields in the observations for increment/recover and rely completely on observed UTxO (`spendableUTxO`) --- <!-- Consider each and tick it off one way or the other --> * [x] CHANGELOG updated or not needed * [x] Documentation updated or not needed * [x] Haddocks updated or not needed * [x] No new TODOs introduced or explained herafter
…mutations (#1710) Subtask of #199 - Implement the `Claim` redeemer branch of the deposit validator. - Add head currency symbol to the `Claim` redeemer in order to check it against the datum value. - Add upper validity bound for increment in order to be able to check if the deposit deadline has not been reached. - Double the amount of contestation period value when setting the deposit deadline in order to give enough room for increment to be valid (before the deadline). - Add appropriate deposit mutations. - Left a FIXME to not forget to fix the specification in terms of changes in the `Claim` redeemer --- <!-- Consider each and tick it off one way or the other --> * [x] CHANGELOG updated or not needed * [x] Documentation updated or not needed * [x] Haddocks updated or not needed * [ ] No new TODOs introduced or explained herafter
Why
Hydra Heads should not need to be closed and re-opened just to add more funds. This will make Hydra Heads more flexible in enables use cases where long-living Heads are beneficial.
Furthermore, it could pave the way for getting rid of the initialization phase altogether, which would result in a much simpler protocol.
What
Implement the protocol extension for more committing additional UTXOs into a Head as already briefly described in the original Hydra Head paper.
"As user, I want to add more funds to the head, such that I can spend them later in the head"
When the head is open, a hydra client can request an incremental commit:
POST /commit
. Just like with the "normal" commit, the user needs to send either a UTxO or a "blueprint transaction".depositTx
corresponding to the requested commit. (This works just the same way as the commit endpoint works so far during initialization phase)depositTx
Submitting the
depositTx
transaction should have the requestedUTxO
eventually added to the headCommitRequested
(TBD: orDepositDetected
?) server output is sent to signal observation of the depositUTxO
and wait for aSnapshotConfirmed
with inclusion approval.incrementTx
, signs and submits that.CommitFinalized
server output is sent to the clients when theincrementTx
is observed.The node provides a list of pending commits via the API using
GET /commits
Each pending commit (deposit) has an id (i.e. the deposit outputs'
TxIn
) and a deadline attached, after which a user can request refund of the commitDELETE /commits/<id>
, which has the node construct and submit arecoverTx
for the user. TBD: okay that node pay fees here?recoverTx
Any UTxO which can be committed, can also be incrementally committed
Scenarios
All of the positive scenarios also ensure correct balance after fanout:
incrementTx
Security
Out of scope
How
Protocol design
Important
Idea: Deposit anything to commit into a
deposit
output. Head participants then re-use theReqSn
off-chain consensus to request inclusion of UTxO (like incremental decommit). Deposits have an asymmetric deadline, such that users need to wait longer before they can reclaim than the head participants have time to ensure the deposit is not rolled back (double spent). Deposits are recording outputs like in thecommitTx
and claiming adeposit
into the head via anincrementTx
ensures the recorded UTxO matches (completely) with what was agreed off-chain. Participants only agree off-chain if they saw a matchingdeposit
.Outline of one deposit being claimed in an increment and one deposit being recovered:
Protocol transitions:
Situation: Head is open,$U_0$ locked, off-chain busy transacting
Deposit:
depositTx
hydra-node
or through a library/tool.depositTx
ensures through minting of a deposit token (DT) that anything to be committeddepositTx
to ensure the transition to L2 is "correct"? Could mean more coupling, but simpler protocol here.Recover:
recoverTx
after the deadline has passedIncrement:
hydra-node
) observe pending deposits using the common deposit addressdepositTx
is not rolled backA node requests inclusion of a pending decommit by sending a$U_\alpha$ ReqSn
message withincrementTx
, which:incrementTx
on L1 with addedTo be discussed
What happens if
incrementTx
is not posted after being signed on L2?fanout
for exampleDo we really need to change
η
to be a merkle-tree-like structure with inclusion proofs?Shall we drop the initialization phase?
How to deal with rollbacks/forward which result in a different$\eta$ ? When is it safe to integrate $U_\alpha$ into confirmed $U$ ?
recoverTx
should be>>
than a safe margin on observingdepositTx
(e.g. deadline = 7 days, delay on deposit observe ~ 1 day); As deposits can only be spent into the head before the deadline passed, we don't need to wait when observingincrementTx
incrementTx
(re-use contestation period?)The text was updated successfully, but these errors were encountered: