This implements the compact block filter construction in BIP 158. The code is not used anywhere in the Bitcoin Core code base yet. The next step towards BIP 157 support would be to create an indexing module similar to TxIndex
that constructs the basic and extended filters for each validated block.
Filter Sizes
Here is a CSV of filter sizes for blocks in the main chain.
As you can see below, the ratio of filter size to block size drops after the first ~150,000 blocks:
The reason for the relatively large filter sizes is that Golomb-coded sets only achieve good compression with a sufficient number of elements. Empirically, the average element size with 100 elements is 14% larger than with 10,000 elements.
The ratio of filter size to block size is computed without witness data for basic filters. Here is a summary table of filter size ratios for blocks after height 150,000:
Stat | Filter Type |
---|---|
Weighted Size Ratio Mean | 0.0198 |
Size Ratio Mean | 0.0224 |
Size Ratio Std Deviation | 0.0202 |
Mean Element Size (bits) | 21.145 |
Approx Theoretical Min Element Size (bits) | 21.025 |