-
Notifications
You must be signed in to change notification settings - Fork 411
Closed
Labels
new featureNew feature or requestNew feature or request
Description
This is an overview issue (based on same issue for murmel) for discussion and tracking the addition of a fully functional compact filters Blockchain backend to bdk. Ideally we'll have additional issues and/or PRs for each missing feature to link to this issue and we check off each feature as it's completed.
The below BIP-157/158 protocol features are based on the BIP-157 Client Operation section. Please suggest additions and corrections in the comments.
Missing protocol features for bdk are indicated below with an unchecked box [ ], completed features with a checked box [x].
Terminology
- peer: bitcoin full node peer
- block header: bitcoin standard block header
- filter header: BIP-157 compact block filter header
- block filter: BIP-157/158 compact block filter
Peer Discovery
-
- Allow user to specify peer addresses
-
- Receive peer addresses via [addr] messages from connected peers
-
- Store new peer addresses
-
- If no provided or previously stored peers, find seed peer addresses via DNS
Connect to Peers
-
- Allow user to specify number of peers to connect to
-
- Allow user to specify minimum number of BIP-157 peers to connect to
-
- Connect to peers and request signalling bits via [version] message
-
- Keep track of peers signalling service bit NODE_COMPACT_FILTERS
-
- Connect to specified number of peers
-
- Connect to minimum number of BIP-157 peers
Request Block Headers
-
- Request block headers via [getheaders] message to connected peers
-
- Request block headers from genesis to most work block, 1 to 2000 blocks per request
-
- Optional: Request block headers from stored checkpoint block instead of genesis block
-
- Optional: Request block headers from DNS (see https://bitcoinheaders.net/)
Receive Block Headers
-
- Receive block headers [headers] from peers
-
- Build chain of block headers from stored and received new block headers
-
- Store new block headers and new block header tip
-
- Disconnect peers whose longest chain has significantly less work than known tip
-
- Request block filter headers from all peers for any new block header received
Request Filter Headers
-
- Allow user to specify start block height for block filter sync
-
- Request filter headers via [getcfheaders] message to peers
-
- Request from start block height to end block hash (1-1000 per request)
-
- Request filter headers for the same block from more than one peer
-
- Optional: First request filter headers at intervals of 1000 via [getcfcheckpt] message
-
- Optional: Request filter headers from DNS (see https://bitcoinheaders.net/)
Receive Filter Headers
-
- Receive filter headers [cfheaders] from peers
-
- Verify filter headers from multiple peers are the same
-
- If any received filter headers for a block are different,
-
- request full block and compute correct block filter and filter header
-
- ban peers that provided incorrect filter header
-
- Build chain of filter headers from stored and received new filter headers
-
- Store verified filter headers, at least to depth of 100
-
- Request block filter for any new verified filter header
-
- Optional: store more than 100 verified filter headers
Request Block Filters
-
- Request block filters after all filter headers are received and verified
-
- Request block filters from start block via [getcfilters] message to peers
-
- Request from start block height to end block hash (1-1000 per request)
-
- Optional: Check if filter header is for empty block filter if so skip request
-
- Optional: Request different block filters in parallel from multiple peers
Receive Block Filters
-
- Receive block filter [cfilter] from peers
-
- Verify block filters sequentially, must link to corresponding filter header
-
- Ban any peer that sends an invalid block filter
-
- Check block filters for relevance
-
- Previous output scripts for transaction inputs
-
- ScriptPubKey for transaction outputs
Fetch Full Blocks
-
- If fetching full blocks, download from random peers
-
- Fetch full blocks from peers even if they don’t support compact block filters
-
- Fetch full blocks that correspond to relevant block filters
Metadata
Metadata
Assignees
Labels
new featureNew feature or requestNew feature or request