Skip to content

Commit

Permalink
Add protocol sequence diagram for deposit-based incremental commits
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1bo committed Aug 1, 2024
1 parent f240225 commit fb701f3
Showing 1 changed file with 55 additions and 11 deletions.
66 changes: 55 additions & 11 deletions docs/docs/dev/protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,59 @@

Additional implementation-specific documentation for the Hydra Head protocol and extensions like incremental decommits.

### Incremental Commits
#### Deposit L1 first

```mermaid
sequenceDiagram
Note over Alice: Alice shows a tx spending on L1 of what she wants to commit to L2
Alice->>+Node A: POST /commit (commitTx)
Node A-->>-Alice: depositTx
Note over Node A: TODO input validation?
Alice ->> Alice: sign depositTx
Alice ->> Chain: submit depositTx
Chain ->>+ Node A: OnDepositTx utxo
Node A -->> Alice: DepositDetected
par
Node A->>Node A: ReqInc utxo
and
Node A->>Node B: ReqInc utxo
end
Node A -->> Alice: CommitRequested
par Alice isLeader
Node A->>Node A: ReqSn utxo
and
Node A->>Node B: ReqSn utxo
end
Node A->>Node A: sig = sign snapshot incl. inputs(commitTx)
par broadcast
Node A->>Node A: AckSn sig
and
Node A->>Node B: AckSn sig
end
Node B->>Node A: AckSn sig
Node A -->> Alice: SnapshotConfirmed
Note over Node A: As decrement
Node A -->> Alice: CommitApproved
Node A ->> Chain: IncrementTx snapshot sig
Chain ->> Node A: OnIncrementTx
Node A -->> Alice: CommitFinalized
```

#### Interactive L2 first

```mermaid
sequenceDiagram
Note over Alice: Alice shows a tx spending on L1 of what she wants to commit to L2
Alice->>+Node A: POST /commit (commitTx)
Note over Node A: TODO input validation?
Note over Node A: get approval through a signed snapshot
par
Node A->>Node A: ReqInc commitTx
Expand All @@ -24,7 +69,7 @@ sequenceDiagram
and
Node A->>Node B: ReqSn commitTx
end
Node A->>Node A: sig = sign snapshot incl. inputs(commitTx)
par broadcast
Expand All @@ -33,24 +78,23 @@ sequenceDiagram
Node A->>Node B: AckSn sig
end
Node B->>Node A: AckSn sig
Node A ->>Node A: construct incrementTx using multi-signed snapshot and commitTx (blueprint)
Node A-->>-Alice: incrementTx
Alice ->> Alice: sign incrementTx
Alice ->> Chain: submit incrementTx
Chain ->> Node B: OnIncrementTx utxo
Chain ->>+ Node A: OnIncrementTx utxo
Node A ->> Node A: localUtxo = localUtxo + utxo
Node A ->>- Alice: CommitFinalized
Note over Alice: Alice can spend on L2 what she committed from L1
```


### Incremental Decommits

```mermaid
Expand Down

0 comments on commit fb701f3

Please sign in to comment.