Skip to content

Commit a59d0d5

Browse files
committed
fixup! bolt-taproot-gossip
1 parent 481c125 commit a59d0d5

File tree

2 files changed

+89
-47
lines changed

2 files changed

+89
-47
lines changed

07-routing-gossip.md

Lines changed: 86 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -618,13 +618,13 @@ Nodes can signal that they support extended gossip queries with the `gossip_quer
618618

619619
`encoded_query_flags` is an array of bitfields, one bigsize per bitfield, one bitfield for each `short_channel_id`. Bits have the following meaning:
620620

621-
| Bit Position | Meaning |
622-
| ------------- | ---------------------------------------- |
623-
| 0 | Sender wants `channel_announcement` |
624-
| 1 | Sender wants `channel_update` for node 1 |
625-
| 2 | Sender wants `channel_update` for node 2 |
626-
| 3 | Sender wants `node_announcement` for node 1 |
627-
| 4 | Sender wants `node_announcement` for node 2 |
621+
| Bit Position | Meaning |
622+
|--------------|---------------------------------------------------|
623+
| 0 | Sender wants `channel_announcement`/`_2` |
624+
| 1 | Sender wants `channel_update`/`_2` for node 1 |
625+
| 2 | Sender wants `channel_update`/`_2` for node 2 |
626+
| 3 | Sender wants `node_announcement`/`_2` for node 1 |
627+
| 4 | Sender wants `node_announcement`/`_2` for node 2 |
628628

629629
Query flags must be minimally encoded, which means that one flag will be encoded with a single byte.
630630

@@ -634,11 +634,11 @@ Query flags must be minimally encoded, which means that one flag will be encoded
634634
* [`byte`:`full_information`]
635635

636636
This is a general mechanism which lets a node query for the
637-
`channel_announcement` and `channel_update` messages for specific channels
638-
(identified via `short_channel_id`s). This is usually used either because
639-
a node sees a `channel_update` for which it has no `channel_announcement` or
640-
because it has obtained previously unknown `short_channel_id`s
641-
from `reply_channel_range`.
637+
`channel_announcement`/`_2` and `channel_update`/`_2` messages for specific
638+
channels (identified via `short_channel_id`s). This is usually used either
639+
because a node sees a `channel_update`/`_2` for which it has no
640+
`channel_announcement`/`_2` or because it has obtained previously unknown
641+
`short_channel_id`s from `reply_channel_range`.
642642

643643
#### Requirements
644644

@@ -648,7 +648,7 @@ The sender:
648648
that the `short_channel_id`s refer to.
649649
- MUST set the first byte of `encoded_short_ids` to the encoding type.
650650
- MUST encode a whole number of `short_channel_id`s to `encoded_short_ids`
651-
- MAY send this if it receives a `channel_update` for a
651+
- MAY send this if it receives a `channel_update`/`_2` for a
652652
`short_channel_id` for which it has no `channel_announcement`.
653653
- SHOULD NOT send this if the channel referred to is not an unspent output.
654654
- MAY include an optional `query_flags`. If so:
@@ -675,24 +675,25 @@ The receiver:
675675
- MAY close the connection.
676676
- MUST respond to each known `short_channel_id`:
677677
- if the incoming message does not include `encoded_query_flags`:
678-
- with a `channel_announcement` and the latest `channel_update` for each end
679-
- MUST follow with any `node_announcement`s for each `channel_announcement`
678+
- with a `channel_announcement`/`_2` and the latest `channel_update`/_2`
679+
for each end
680+
- MUST follow with any `node_announcement`/`_2`s for each `channel_announcement`/`_2`
680681
- otherwise:
681682
- We define `query_flag` for the Nth `short_channel_id` in
682683
`encoded_short_ids` to be the Nth bigsize of the decoded
683684
`encoded_query_flags`.
684685
- if bit 0 of `query_flag` is set:
685-
- MUST reply with a `channel_announcement`
686-
- if bit 1 of `query_flag` is set and it has received a `channel_update` from `node_id_1`:
687-
- MUST reply with the latest `channel_update` for `node_id_1`
688-
- if bit 2 of `query_flag` is set and it has received a `channel_update` from `node_id_2`:
689-
- MUST reply with the latest `channel_update` for `node_id_2`
690-
- if bit 3 of `query_flag` is set and it has received a `node_announcement` from `node_id_1`:
691-
- MUST reply with the latest `node_announcement` for `node_id_1`
692-
- if bit 4 of `query_flag` is set and it has received a `node_announcement` from `node_id_2`:
693-
- MUST reply with the latest `node_announcement` for `node_id_2`
686+
- MUST reply with a `channel_announcement`/`_2`
687+
- if bit 1 of `query_flag` is set and it has received a `channel_update`/`_2` from `node_id_1`:
688+
- MUST reply with the latest `channel_update`/`_2` for `node_id_1`
689+
- if bit 2 of `query_flag` is set and it has received a `channel_update`/`_2` from `node_id_2`:
690+
- MUST reply with the latest `channel_update`/`_2` for `node_id_2`
691+
- if bit 3 of `query_flag` is set and it has received a `node_announcement`/`_2` from `node_id_1`:
692+
- MUST reply with the latest `node_announcement`/`_2` for `node_id_1`
693+
- if bit 4 of `query_flag` is set and it has received a `node_announcement`/`_2` from `node_id_2`:
694+
- MUST reply with the latest `node_announcement`/`_2` for `node_id_2`
694695
- SHOULD NOT wait for the next outgoing gossip flush to send these.
695-
- SHOULD avoid sending duplicate `node_announcements` in response to a single `query_short_channel_ids`.
696+
- SHOULD avoid sending duplicate `node_announcements`/`_2` in response to a single `query_short_channel_ids`.
696697
- MUST follow these responses with `reply_short_channel_ids_end`.
697698
- if does not maintain up-to-date channel information for `chain_hash`:
698699
- MUST set `full_information` to 0.
@@ -727,12 +728,12 @@ timeouts. It also causes a natural ratelimiting of queries.
727728

728729
`query_option_flags` is a bitfield represented as a minimally-encoded bigsize. Bits have the following meaning:
729730

730-
| Bit Position | Meaning |
731-
| ------------- | ----------------------- |
732-
| 0 | Sender wants timestamps |
733-
| 1 | Sender wants checksums |
731+
| Bit Position | Meaning |
732+
|--------------|---------------------------------------|
733+
| 0 | Sender wants timestamps/block heights |
734+
| 1 | Sender wants checksums |
734735

735-
Though it is possible, it would not be very useful to ask for checksums without asking for timestamps too: the receiving node may have an older `channel_update` with a different checksum, asking for it would be useless. And if a `channel_update` checksum is actually 0 (which is quite unlikely) it will not be queried.
736+
Though it is possible, it would not be very useful to ask for checksums without asking for timestamps/block heights too: the receiving node may have an older `channel_update` with a different checksum, asking for it would be useless. And if a `channel_update` checksum is actually 0 (which is quite unlikely) it will not be queried.
736737

737738
1. type: 264 (`reply_channel_range`) (`gossip_queries`)
738739
2. data:
@@ -746,15 +747,21 @@ Though it is possible, it would not be very useful to ask for checksums without
746747

747748
1. `tlv_stream`: `reply_channel_range_tlvs`
748749
2. types:
749-
1. type: 1 (`timestamps_tlv`)
750+
1. type: 1 (`timestamps_blockheights_tlv`)
750751
2. data:
751752
* [`byte`:`encoding_type`]
752-
* [`...*byte`:`encoded_timestamps`]
753+
* [`...*byte`:`encoded_timestamps_blockheights`]
753754
1. type: 3 (`checksums_tlv`)
754755
2. data:
755756
* [`...*channel_update_checksums`:`checksums`]
756757

757-
For a single `channel_update`, timestamps are encoded as:
758+
For the `timestamps_blockheights_tlv` field, the contents depends on whether the
759+
associated channel update message is for a channel announced using
760+
`channel_announcement` or `channel_announcement_2`.
761+
762+
If the channel was announced using `channel_announcement`, then the associated
763+
update will be a `channel_update`, meaning that the contents will represent
764+
timestamps and will be encoded as:
758765

759766
1. subtype: `channel_update_timestamps`
760767
2. data:
@@ -765,18 +772,31 @@ Where:
765772
* `timestamp_node_id_1` is the timestamp of the `channel_update` for `node_id_1`, or 0 if there was no `channel_update` from that node.
766773
* `timestamp_node_id_2` is the timestamp of the `channel_update` for `node_id_2`, or 0 if there was no `channel_update` from that node.
767774

768-
For a single `channel_update`, checksums are encoded as:
775+
If the channel was announced usig `channel_announcement_2`, then the associated
776+
update is a `channel_update_2` and the contents will represent block heights and
777+
will be encoded as:
778+
779+
1. subtype: `channel_update_blockheights`
780+
2. data:
781+
* [`u32`:`block_height_node_id_1`]
782+
* [`u32`:`block_height_node_id_2`]
783+
784+
Where:
785+
* `block_height_node_id_1` is the block height of the `channel_update_2` for `node_id_1`, or 0 if there was no `channel_update_2` from that node.
786+
* `block_height_node_id_2` is the block height of the `channel_update_2` for `node_id_2`, or 0 if there was no `channel_update_2` from that node.
787+
788+
For a single `channel_update`/`_2`, checksums are encoded as:
769789

770790
1. subtype: `channel_update_checksums`
771791
2. data:
772792
* [`u32`:`checksum_node_id_1`]
773793
* [`u32`:`checksum_node_id_2`]
774794

775795
Where:
776-
* `checksum_node_id_1` is the checksum of the `channel_update` for `node_id_1`, or 0 if there was no `channel_update` from that node.
777-
* `checksum_node_id_2` is the checksum of the `channel_update` for `node_id_2`, or 0 if there was no `channel_update` from that node.
796+
* `checksum_node_id_1` is the checksum of the `channel_update`/`_2` for `node_id_1`, or 0 if there was no `channel_update`/`_2` from that node.
797+
* `checksum_node_id_2` is the checksum of the `channel_update`/`_2` for `node_id_2`, or 0 if there was no `channel_update`/`_2` from that node.
778798

779-
The checksum of a `channel_update` is the CRC32C checksum as specified in [RFC3720](https://tools.ietf.org/html/rfc3720#appendix-B.4) of this `channel_update` without its `signature` and `timestamp` fields.
799+
The checksum of a `channel_update`/`_2` is the CRC32C checksum as specified in [RFC3720](https://tools.ietf.org/html/rfc3720#appendix-B.4) of this `channel_update`/`_2` without its `signature` and `timestamp`/`block_height` fields.
780800

781801
This allows querying for channels within specific blocks.
782802

@@ -799,6 +819,10 @@ The receiver of `query_channel_range`:
799819
- MUST limit `number_of_blocks` to the maximum number of blocks whose
800820
results could fit in `encoded_short_ids`
801821
- MAY split block contents across multiple `reply_channel_range`.
822+
- If the sender of `query_channel_range` has not advertised the
823+
`option_taproot_gossip` feature bit then the response MUST only include
824+
short channel IDs for channels announced with the `channel_announcement`
825+
message.
802826
- the first `reply_channel_range` message:
803827
- MUST set `first_blocknum` less than or equal to the `first_blocknum` in `query_channel_range`
804828
- MUST set `first_blocknum` plus `number_of_blocks` greater than `first_blocknum` in `query_channel_range`.
@@ -810,7 +834,7 @@ The receiver of `query_channel_range`:
810834
- MUST set `sync_complete` to `true`.
811835

812836
If the incoming message includes `query_option`, the receiver MAY append additional information to its reply:
813-
- if bit 0 in `query_option_flags` is set, the receiver MAY append a `timestamps_tlv` that contains `channel_update` timestamps for all `short_channel_id`s in `encoded_short_ids`
837+
- if bit 0 in `query_option_flags` is set, the receiver MAY append a `timestamps_blockheights_tlv` that contains `channel_update`/`_2` timestamps for all `short_channel_id`s in `encoded_short_ids`
814838
- if bit 1 in `query_option_flags` is set, the receiver MAY append a `checksums_tlv` that contains `channel_update` checksums for all `short_channel_id`s in `encoded_short_ids`
815839

816840
#### Rationale
@@ -834,6 +858,16 @@ The addition of timestamp and checksum fields allow a peer to omit querying for
834858
* [`chain_hash`:`chain_hash`]
835859
* [`u32`:`first_timestamp`]
836860
* [`u32`:`timestamp_range`]
861+
* [`gossip_timestamps_filter_tlvs`:`tlvs`]
862+
863+
1. `tlv_stream`: `gossip_timestamps_filter_tlvs`
864+
2. types:
865+
1. type: 2 (`first_block`)
866+
2. data:
867+
* [`u32`:`block_height`]
868+
1. type: 4 (`block_height_range`)
869+
2. data:
870+
* [`u32`:`num_blocks`]
837871

838872
This message allows a node to constrain future gossip messages to
839873
a specific range. A node which wants any gossip messages would have
@@ -852,20 +886,26 @@ The sender:
852886
The receiver:
853887
- SHOULD send all gossip messages whose `timestamp` is greater or
854888
equal to `first_timestamp`, and less than `first_timestamp` plus
855-
`timestamp_range`.
889+
`timestamp_range`. This applies to the messages: `channel_announcement`,
890+
`channel_update` and `node_announcement`.
856891
- MAY wait for the next outgoing gossip flush to send these.
857-
- SHOULD send gossip messages as it generates them regardless of `timestamp`.
892+
- SHOULD send all gossip messages whose `block_height` is greater than or
893+
equal to `first_block`, and less than `first_block` plus `num_blocks`.
894+
- SHOULD send gossip messages as it generates them regardless of `timestamp`/`block_height`.
858895
- Otherwise (relayed gossip):
859896
- SHOULD restrict future gossip messages to those whose `timestamp`
860897
is greater or equal to `first_timestamp`, and less than
861-
`first_timestamp` plus `timestamp_range`.
862-
- If a `channel_announcement` has no corresponding `channel_update`s:
863-
- MUST NOT send the `channel_announcement`.
898+
`first_timestamp` plus `timestamp_range` or whose `block_height` is
899+
greater than or equal to `first_block`, and less than `first_block` plus
900+
`num_blocks`.
901+
- If a `channel_announcement`/`_2` has no corresponding `channel_update`/`_2`s:
902+
- MUST NOT send the `channel_announcement`/`_2`.
864903
- Otherwise:
865904
- MUST consider the `timestamp` of the `channel_announcement` to be the `timestamp` of a corresponding `channel_update`.
866-
- MUST consider whether to send the `channel_announcement` after receiving the first corresponding `channel_update`.
867-
- If a `channel_announcement` is sent:
868-
- MUST send the `channel_announcement` prior to any corresponding `channel_update`s and `node_announcement`s.
905+
- MUST consider the `block_height` of the `channel_announcement_2` to be the height of the block it was mined in.
906+
- MUST consider whether to send the `channel_announcement`/`_2` after receiving the first corresponding `channel_update`/`_2`.
907+
- If a `channel_announcement`/`_2` is sent:
908+
- MUST send the `channel_announcement`/`_2` prior to any corresponding `channel_update`/`_2`s and `node_announcement`/`_2`s.
869909

870910
#### Rationale
871911

bolt-taproot-gossip.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,9 @@ The receiving node:
843843
844844
### Query Messages
845845
846-
TODO
846+
TODO:
847+
1. new first block height & block range fields in gossip_timestamp_range
848+
2. add block-height query option (like timestamps query option)
847849
848850
# Appendix A: Algorithms
849851

0 commit comments

Comments
 (0)