spv – What is the distinction between BIP 157 and BIP 158? Are they supported by Bitcoin Core?

0
52


This reply is a slight modification on the outline utilized in Bitcoin Optech E-newsletter #43. Full credit score and due to Dave Harding!

BIP158 introduces Compact block filters, that are are primarily based on an environment friendly technique for encoding
an inventory of equally-sized gadgets. Within the case of the “fundamental” block
filters described within the BIP, this can be a record of all of the
spendable output scriptPubKeys within the present block plus all
the scriptPubKeys for the outputs spent by this block’s inputs
(what builders name earlier outputs (prevouts)). Every of the
scriptPubKeys is hashed to offer every merchandise the identical dimension after which
this stuff are sorted into an inventory that has duplicated components
eliminated. This record is then encoded utilizing the Golomb-Rice Coded
Units
(GCS) algorithm additionally described in BIP158, losslessly
lowering the dimensions of the record. This particular fundamental filter gives
sufficient info for anybody who is aware of a Bitcoin deal with to search out
any block containing a transaction both paying that deal with
(output scriptPubKey) or spending funds beforehand acquired to that
deal with (prevout scriptPubKey). The search might produce false-postive
matches (so blocks which do not include transactions for that deal with
will likely be included within the outcomes), however won’t ever end in false-negatives
(so blocks that do include transactions for that deal with won’t ever
be omitted from the outcomes).

A separate BIP, BIP157, describes how these compact block
filters may be served over the community utilizing the Bitcoin P2P
protocol. BIP157 is designed to work with BIP158 “fundamental” filters
nevertheless it will also be prolonged to help further filters that
encode lists of different gadgets. One notably noteworthy a part of
BIP157 is that it introduces the idea of filter headers the place
the header for every filter commits to a hash of the earlier block’s
filter header plus a hash of the present filter. This creates a
chain of filters just like Bitcoin’s chain of blocks and is
designed to make it straightforward to match filters from a number of friends:
every peer can ship simply the filter header (32 bytes) and, if there
are any headers that do not match, the consumer can request earlier and
earlier headers within the chain till the divergence level is discovered.
Producing a filter header on demand for a selected block
would require hashing all earlier filters, so servers that present
BIP157 filter headers will typically must retailer them prematurely.

Bitcoin Core can generate and retailer
block filters and filter headers, and customers can entry them utilizing the getblockfilter
RPC (carried out with PR#12254 & PR#14121).

Bitcoin Core can serve block filters over the P2P community, however not by default; it may be enabled with -peerblockfilters=1. BIP157 was carried out with a collection of PRs, as proven in PR#18876.

Future Associated Developments

PR#23549(v25.0) and PR#25957(v25.0)
are totally different efforts to attain sooner pockets rescans through the use of the node’s already constructed compact block filter index (-blockfilterindex=1).

LEAVE A REPLY

Please enter your comment!
Please enter your name here