You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: node/api/channels_api_usage.md
+85-4Lines changed: 85 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -72,11 +72,58 @@ but are not necessarily part of the channel's life cycle.
72
72
73
73
Only steps 1 and 4 require chain interactions, step 2 and 3 are off-chain.
74
74
75
-
### HTTP requests
76
-
There are two types of HTTP requests:
75
+
### On-chain requests
76
+
There are two types of requests:
77
77
* Total amount-modifying ones - [deposit](#deposit-transaction) and [withdrawal](#withdraw-transaction)
78
78
*[Channel-closing ones](#solo-closing-sequence) - [solo close](#solo-close-on-chain-transaction), [slash](#slash-on-chain-transaction) and [settle](#settle-on-chain-transaction)
79
79
80
+
### Pinned environment
81
+
82
+
While on-chain consensus is reached between miners, in off-chain world we
83
+
don't have those. State channels are two-party systems that are closer to
84
+
proof-of-stake solutions where both participants have equal
85
+
stake in the channel, no matter their balances. The channel can make another
86
+
step forward only if both parties agree upon the new state or it is produced
87
+
via a force progress transaction on-chain that had been based upon a previous
88
+
mutually agreed state. This makes channels both trustless and egalitarian.
89
+
90
+
This trustless model is based upon both participants executing off-chain
91
+
updates locally and reaching the same results. This is how consensus is
92
+
reached between them. Since off-chain smart contracts can read on-chain
93
+
objects like accounts, names, contracts and oracles requests and responses,
94
+
the results of their execution rely heavily on the chain environment they are
95
+
based on.
96
+
97
+
Participants are expected to use their own nodes to support their channels.
98
+
At the moment using a service hosted by a third party is trustful, thus
99
+
potentially undesirable. This leads to both participant's nodes being peers in
100
+
a system with an eventual consistency - due to network constraints and forks
101
+
both participants can have a different view of the chain.
102
+
103
+
The combination of participants having different views on the chain and the
104
+
off-chain consensus being dependent on it could lead to a fragile system with
105
+
a lot of mismatching state hashes of off-chain updates. In order to improve
106
+
this there is an optional functionality of setting `block_hash` that defines
107
+
the on-chain environment that the update is to be executed in. We call this
108
+
shared view of the chain _a pinnned environment_. When a participant wants to
109
+
start a new round of updates, one can optionally specify a pinned environment
110
+
to execute in. This is how the participant communicates to the other party
111
+
what one considers to be a block hash that is safe enough to base an off-chain
112
+
update upon. The other party might decide if the block hash is too old or too
113
+
new depending on their local view of the chain. If the specified pinned
114
+
environment does not meet the expectations, the whole update is rejected as
115
+
invalid.
116
+
117
+
An update might not be pinned to any environment. In that case a placeholder
118
+
value for the blockhash is provided:
119
+
`"kh_11111111111111111111111111111111273Yts"` or
120
+
`"mh_11111111111111111111111111111111273Yts"`. In this case both participants
121
+
use whatever they see to be the latest top block.
122
+
123
+
The `block_hash` is an optional argument to all mutual offchain transactions. If it is
124
+
not explicitly provided by the requester, a suitable value is picked for the
125
+
client by their FSM.
126
+
80
127
## Channel open
81
128
In order to use a channel, it must be opened. Both parties negotiate parameters for the channel - for example the amounts to participate. Some of those are relevant to the chain and end up in a`channel_create_tx` that is posted on the chain. Once a certain amount of blocks have been mined on top of the one that included it, the channel is considered to be opened.
82
129
@@ -92,8 +139,9 @@ Detailed message transcripts from test suites can also be found [here](./example
92
139
Each channel has a set of parameters that is required for opening a
93
140
connection. Most of those are part of the `channel_create_tx` which is included
94
141
in the chain, and the others are metadata used for the connection itself. We
95
-
will describe them in two separate groups: one for the channel establishing
96
-
and another for optional timeouts.
142
+
will describe these in groups which indicate their relation to each other.
143
+
144
+
#### Channel establishing parameters
97
145
98
146
| Name | Type | Description | Required for open | Required/Used in reestablish | Part of the `channel_create_tx`|
0 commit comments