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

This response is a slight modification in the description used in Bitcoin Optech Newsletter # 43. Full credit and thanks to Dave Harding!

BIP158 introduces Compact block filters, which are based on an efficient method for coding
a list of articles of equal size. In the case of the "basic" block.
The filters described in the BIP, this is a list of all the
scriptPubKeys of expendable output in the current block plus all
thePubKeys script for the outputs spent by the entries in this block
(what developers call previous (previous) exits). Each of the
scriptPubKeys is trimmed to give each element the same size and then
these elements are sorted in a list that has duplicate elements
remote. This list is encoded using the Coded Rice Golomb
The algorithm (GCS) is also described in BIP158, without losses
Reducing the size of the list. This specific basic filter provides
Enough information so that anyone who knows a Bitcoin address can find it.
Any block that contains a transaction either by paying that address.
(exit scriptPubKey) or funds of expenses previously received for that
address (write script of previous page). The search can produce false positives.
matches (so the blocks that do not contain transactions for that address
will be included in the results), but it will never lead to false negatives
(so block that do contain transactions for that address never
omit the results).

A separate BIP, BIP157, describes how these compact blocks
Filters can be served through the network using the Bitcoin P2P
protocol. BIP157 is designed to work with "basic" BIP158 filters
but it can also be expanded to support additional filters that
encode lists of other elements. A particularly remarkable part of
BIP157 is that it introduces the concept of filter headers where
the header of each filter commits to a hash of the previous block
Filter the header plus a hash of the current filter. This creates a
Filter chain similar to the Bitcoin blockchain and is
designed to facilitate comparison of multiple pairs filters:
each pair can send only the filter header (32 bytes) and, if it exists
there are headers that do not match, the client can request them before and
previous headers in the chain until the point of divergence is found.
Generating a filter header on demand for a particular block
it would require hashing all the previous filters, so the servers that are provided
The BIP157 filter headers will generally need to store them in advance.

At the time of writing (April 2019), Bitcoin Core can generate and store
Block filters and filter headers, and users can access them using the getblockfilter
RPC. Bitcoin Core does not currently provide block filters or header filters
about the P2P network.

Here is an example getblockfilter object of return:

$ bitcoin-cli getblockfilter $ (bitcoin-cli getblockhash 170)
"filter": "0357e49590040c79b0",
"header": "349eaecc8bb7793c9f3c28e78df6675ef904515e9a310e4532785aeb45526090"

We select block 170 because its filter is the first to contain
more than one element (contains 3 elements) and because the last
The block from this script (block 572,879) has a filter that contains
8,599 items — too much for us to print with elegance.