Skip to content

Commit e96412a

Browse files
committed
FIX! Clarifications and typo fixes due to Pierre.
Signed-off-by: Rusty Russell <[email protected]>
1 parent 2e93a41 commit e96412a

File tree

1 file changed

+62
-43
lines changed

1 file changed

+62
-43
lines changed

07-routing-gossip.md

Lines changed: 62 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ its fee levels and expiry using `channel_update`.
2323

2424
1. type: 256 (`MSG_CHANNEL_ANNOUNCEMENT`)
2525
2. data:
26-
* [4:blockheight]
27-
* [3:blockindex]
28-
* [1:outputindex]
29-
* [33:node-id-1]
30-
* [33:node-id-2]
31-
* [33:bitcoin-key-1]
32-
* [33:bitcoin-key-2]
33-
* [64:bitcoin-signature-1]
34-
* [64:bitcoin-signature-2]
35-
* [64:node-signature-1]
36-
* [64:node-signature-2]
26+
* [4:blockheight]
27+
* [3:blockindex]
28+
* [1:outputindex]
29+
* [33:node-id-1]
30+
* [33:node-id-2]
31+
* [33:bitcoin-key-1]
32+
* [33:bitcoin-key-2]
33+
* [64:bitcoin-signature-1]
34+
* [64:bitcoin-signature-2]
35+
* [64:node-signature-1]
36+
* [64:node-signature-2]
3737

3838
### Requirements
3939

@@ -51,14 +51,14 @@ ascending numerical order, and MUST set `bitcoin-key-1` and
5151
respectively.
5252

5353
The creating node MUST set `bitcoin-signature-1` to the signature of
54-
the double-SHA of `node-id-1` using `bitcoin-key-1`, and set
55-
`bitcoin-signature-2` to the signature of the double-SHA of
54+
the double-SHA256 of `node-id-1` using `bitcoin-key-1`, and set
55+
`bitcoin-signature-2` to the signature of the double-SHA256 of
5656
`node-id-2` using `bitcoin-key-2`
5757

5858
The creating node MUST set `node-signature-1` to the signature of the
59-
double-SHA of every data field up to and including
59+
double-SHA256 of every data field up to and including
6060
`bitcoin-signature-2` using `node-id-1`, and `node-signature-2` to the
61-
signature of the double-SHA of every data field up to and including
61+
signature of the double-SHA256 of every data field up to and including
6262
`bitcoin-signature-2` using `node-id-2`.
6363

6464
The receiving node MUST ignore the message if the output `outputindex`
@@ -78,9 +78,9 @@ Otherwise, if the transaction referred to was not previously announced
7878
as a channel, the receiving node SHOULD queue the message for
7979
rebroadcasting. If it has previously received a valid
8080
`channel_announcement` for the same transaction in the same block, but
81-
different `node-id-1` or `node-id-2`, it SHOULD blacklist the the
81+
different `node-id-1` or `node-id-2`, it SHOULD blacklist the
8282
previous message's `node-id-1` and `node-id-2` as well as this
83-
`node-id-1` and `node-id-2` and forget channels conntected to them,
83+
`node-id-1` and `node-id-2` and forget channels connected to them,
8484
otherwise it SHOULD store this `channel_announcement`.
8585

8686
The receiving node SHOULD forget a channel once its funding output has
@@ -115,8 +115,7 @@ nodes for which a channel is not already known are ignored.
115115
* [33:node-id]
116116
* [3:rgb-color]
117117
* [2:pad]
118-
* [4:len]
119-
* [len:alias]
118+
* [32:alias]
120119

121120
The `timestamp` allows ordering in the case of multiple announcements;
122121
the `ipv6` and `port` allow the node to announce its willingness to
@@ -130,21 +129,19 @@ The creating node MUST set `timestamp` to be greater than any previous
130129
`node_announcement` it has created. It MAY base it on a UNIX
131130
timestamp. It MUST set the `ipv6` and `port` fields to all zeroes, or
132131
a non-zero `port` and `ipv6` set to a valid IPv6 address or an IPv4-Mapped IPv6 Address format as defined in [RFC 4291 section 2.5.5.2](https://tools.ietf.org/html/rfc4291#section-2.5.5.2). It MUST set `signature` to the signature of
133-
the double-SHA of the entire remaining packet after `signature` using the
134-
key given by `node-id`. It MUST set `pad` to zero. It MAY set `alias` and `rgb-color` to customize their node's appearance in maps and graphs, where the first byte of `rgb` is the red value, the second byte is the green value and the last byte is the blue value. It MUST set `alias` to a valid UTF-8 string.
135-
136-
The receiving node SHOULD fail the connection if the message is of
137-
insufficent length to contain `alias`.
132+
the double-SHA256 of the entire remaining packet after `signature` using the
133+
key given by `node-id`. It MUST set `pad` to zero. It MAY set `alias` and `rgb-color` to customize their node's appearance in maps and graphs, where the first byte of `rgb` is the red value, the second byte is the green value and the last byte is the blue value. It MUST set `alias` to a valid UTF-8 string of up to 21 bytes in length, with all `alias` bytes following equal to zero.
138134

139135
The receiving node SHOULD fail the connection if `signature` is
140136
invalid or incorrect for the entire message including unknown fields
141137
following `alias`, and MUST NOT further process the message. The
142-
receiving node SHOULD ignore `ipv6` if `port` is zero. It MUST ignore
138+
receiving node SHOULD ignore `ipv6` if `port` is zero. It SHOULD fail
139+
the connection if the final byte of `alias` is not zero. It MUST ignore
143140
the contents of `pad`.
144141

145142
The receiving node SHOULD ignore the message if `node-id` is not
146143
previously known from a `channel_announcement` message, or if
147-
`timestamp` is not greater than than the last-received
144+
`timestamp` is not greater than the last-received
148145
`node_announcement` from this `node-id`. Otherwise, if the
149146
`timestamp` is greater than the last-received `node_announcement` from
150147
this `node-id` the receiving node SHOULD queue the message for
@@ -173,22 +170,22 @@ it wants to change fees.
173170

174171
1. type: 258 (`MSG_CHANNEL_UPDATE`)
175172
2. data:
176-
* [64:signature]
177-
* [4:blockheight]
178-
* [3:blockindex]
179-
* [1:outputindex]
180-
* [4:timestamp]
181-
* [1:side]
182-
* [1:pad]
173+
* [64:signature]
174+
* [4:blockheight]
175+
* [3:blockindex]
176+
* [1:outputindex]
177+
* [4:timestamp]
178+
* [1:side]
179+
* [1:pad]
183180
* [2:expiry]
184-
* [4:htlc-minimum-msat]
185-
* [4:fee-base-msat]
186-
* [4:fee-proportional-millionths]
181+
* [4:htlc-minimum-msat]
182+
* [4:fee-base-msat]
183+
* [4:fee-proportional-millionths]
187184

188185
### Requirements
189186

190187
The creating node MUST set `signature` to the signature of the
191-
double-SHA of the entire remaining packet after `signature` using its own `node-id`.
188+
double-SHA256 of the entire remaining packet after `signature` using its own `node-id`.
192189

193190
The creating node MUST set `blockheight`, `blockindex` and `outputindex` to
194191
match those in the already-sent `channel_announcement` message, and MUST set `side` to 0 if the creating node is `node-id-1` in that message, otherwise 1.
@@ -197,10 +194,6 @@ The creating node MUST set `timestamp` to greater than zero, and MUST set it to
197194

198195
It MUST set `expiry` to the number of blocks it will subtract from an incoming HTLC's `expiry`. It MUST set `htlc-minimum-msat` to the minimum HTLC value it will accept, in millisatoshi. It MUST set `fee-base-msat` to the base fee it will charge for any HTLC, in millisatoshi, and `fee-proportional-millionths` to the amount it will charge per millionth of a satoshi.
199196

200-
The node SHOULD accept HTLCs which pay a fee equal or greater than:
201-
202-
fee-base-msat + htlc-amount-msat * fee-proportional-millionths / 1000000
203-
204197
The receiving node SHOULD fail the connection if `side` is not 0 or 1.
205198
It MUST ignore the contents of `pad`. The receiving node SHOULD fail
206199
the connection if `signature` is invalid or incorrect for the entire
@@ -218,9 +211,10 @@ queue the message for rebroadcasting.
218211

219212
## Rebroadcasting
220213

221-
Nodes receiving an announcement verify that this is the latest update from the announcing node by comparing the included timestamp and update their local view of the network's topology accordingly.
214+
Nodes receiving a new `channel_announcement` or a `channel_update` or
215+
`node_update` with an updated timestamp update their local view of the network's topology accordingly.
222216

223-
Once the announcement has been processed it is added to a list of outgoing announcements to the processing node's peers, which will be flushed at regular intervals.
217+
Once the announcement has been processed it is added to a list of outgoing announcements (perhaps replacing older updates) to the processing node's peers, which will be flushed at regular intervals.
224218
This store and delayed forward broadcast is called a _staggered broadcast_
225219

226220
If, after applying the changes from the announcement, there are no channels associated with the announcing node, then the receiving node MAY purge the announcing node from the set of known nodes.
@@ -247,6 +241,31 @@ The sending of all announcements on reconnection is naive, but simple,
247241
and allows bootstrap for new nodes as well as updating for nodes which
248242
have been offline for some time.
249243

244+
## HTLC Fees
245+
246+
The node creating `channel_update` SHOULD accept HTLCs which pay a fee equal or greater than:
247+
248+
fee-base-msat + htlc-amount-msat * fee-proportional-millionths / 1000000
249+
250+
The node creating `channel_update` SHOULD accept HTLCs which pay an
251+
older fee for some time after sending `channel_update` to allow for
252+
propagation delay.
253+
254+
## Recommendations for Routing
255+
256+
As the fee is proportional, it must be calculated backwards from the
257+
destination to the source: only the amount required at the final
258+
destination is known initially.
259+
260+
When calculating a route for an HTLC, the `expiry` and the fee both
261+
need to be considered: the `expiry` contributes to the time that funds
262+
will be unavailable on worst-case failure. The tradeoff between these
263+
two is unclear, as it depends on the reliability of nodes.
264+
265+
Other more advanced considerations involve diversity of routes to
266+
avoid single points of failure and detection, and channel balance
267+
of local channels.
268+
250269
## References
251270

252271
- [RFC 4291](https://tools.ietf.org/html/rfc4291)

0 commit comments

Comments
 (0)