-
Notifications
You must be signed in to change notification settings - Fork 47
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
blip-0038: block header gossip #38
Open
t-bast
wants to merge
1
commit into
lightning:master
Choose a base branch
from
t-bast:block-header-init
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
``` | ||
bLIP: 38 | ||
Title: Block header gossip | ||
Status: Active | ||
Author: Bastien Teinturier <[email protected]> | ||
Created: 2024-07-03 | ||
License: CC0 | ||
``` | ||
|
||
## Abstract | ||
|
||
Lightning nodes must stay in sync with the blockchain to protect themselves | ||
against malicious peers that could publish revoked commitment transactions. | ||
Honest nodes should help their peers by letting them know about the latest | ||
block header they have received: this allows detecting when a node is behind | ||
and may need to fix their bitcoin node. | ||
|
||
## Copyright | ||
|
||
This bLIP is licensed under the CC0 license. | ||
|
||
## Motivation | ||
|
||
We have several messages that are frequently exchanged between lightning nodes. | ||
They are a good opportunity to include some blockchain data. | ||
|
||
## Specification | ||
|
||
We add the following TLV field to the `init` message: | ||
|
||
1. `tlv_stream`: `init_tlvs` | ||
2. types: | ||
1. type: 32411 (`latest_block_header`) | ||
2. data: | ||
- [`u32`:`block_height`] | ||
- [`80*bytes`:`block_header`] | ||
|
||
### Requirements | ||
|
||
The sender of `init`: | ||
|
||
- SHOULD include the `latest_block_header` field. | ||
- MUST set `block_header` to the latest valid block header its bitcoin node has received. | ||
- MUST set `block_height` to the corresponding height in the blockchain. | ||
|
||
The reader of `init`: | ||
|
||
- If the received `block_height` is greater than the local block height: | ||
- SHOULD verify the received `block_header`'s proof of work. | ||
- SHOULD alert the node operator if it is missing many blocks. | ||
|
||
### Rationale | ||
|
||
This extension only allows detecting that we're behind: there is no easy way | ||
to automatically fix a connection issue to the bitcoin network. Node operators | ||
should troubleshoot their bitcoin node to figure out how to resolve the issue. | ||
|
||
We use an odd TLV field, which will automatically be ignored by readers who | ||
don't support this extension: senders can thus always include this field. | ||
|
||
### Test vectors | ||
|
||
The following test vector describes how an `init` message containing a block | ||
header is encoded: | ||
|
||
```json | ||
{ | ||
"features": [], | ||
"network": "mainnet", | ||
"latest_block_header": { | ||
"height": 800000, | ||
"header": "00601d3455bb9fbd966b3ea2dc42d0c22722e4c0c1729fad17210100000000000000000055087fab0c8f3f89f8bcfd4df26c504d81b0a88e04907161838c0c53001af09135edbd64943805175e955e06" | ||
}, | ||
"encoded": "0010 0000 0000 01206fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 fd7e9b54000c350000601d3455bb9fbd966b3ea2dc42d0c22722e4c0c1729fad17210100000000000000000055087fab0c8f3f89f8bcfd4df26c504d81b0a88e04907161838c0c53001af09135edbd64943805175e955e06" | ||
} | ||
``` | ||
|
||
## Reference Implementations | ||
|
||
- eclair: <https://github.com/ACINQ/eclair/pull/2874> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An
init
message is only sent once when the connection is established. Putting the payload inping
would mean that the new headers can continually be sent and monitored.To allow implementations to more easily distinguish the header message amidst a string of other random bytes in the payload, perhaps we can add special marker/magic bytes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see two possible designs for this:
ping
messages random and include the block header in the message's tlv streamping
message a TLV stream, that contains the block header (+ padding)