-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Backport 12254 and 14073 (BIP158) #3416
Conversation
6d26c14
to
374eb49
Compare
374eb49
to
cbb91e5
Compare
254c85b bench: Benchmark GCS filter creation and matching. (Jim Posen) f33b717 blockfilter: Optimization on compilers with int128 support. (Jim Posen) 97b64d6 blockfilter: Unit test against BIP 158 test vectors. (Jim Posen) a4afb9c blockfilter: Additional helper methods to compute hash and header. (Jim Posen) cd09c79 blockfilter: Serialization methods on BlockFilter. (Jim Posen) c1855f6 blockfilter: Construction of basic block filters. (Jim Posen) 53e7874 blockfilter: Simple test for GCSFilter construction and Match. (Jim Posen) 558c536 blockfilter: Implement GCSFilter Match methods. (Jim Posen) cf70b55 blockfilter: Implement GCSFilter constructors. (Jim Posen) c454f0a blockfilter: Declare GCSFilter class for BIP 158 impl. (Jim Posen) 9b622dc streams: Unit tests for BitStreamReader and BitStreamWriter. (Jim Posen) fe943f9 streams: Implement BitStreamReader/Writer classes. (Jim Posen) 87f2d9e streams: Unit test for VectorReader class. (Jim Posen) 947133d streams: Create VectorReader stream interface for vectors. (Jim Posen) Pull request description: This implements the compact block filter construction in [BIP 158](https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki). The code is not used anywhere in the Bitcoin Core code base yet. The next step towards [BIP 157](https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki) 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](https://gateway.ipfs.io/ipfs/QmRqaAAQZ5ZX5eqxP7J2R1MzFrc2WDdKSWJEKtQzyawqog) 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 | Tree-SHA512: 2d045fbfc3fc45490ecb9b08d2f7e4dbbe7cd8c1c939f06bbdb8e8aacfe4c495cdb67c820e52520baebbf8a8305a0efd8e59d3fa8e367574a4b830509a39223f
Signed-off-by: Pasta <pasta@dashboost.org>
Signed-off-by: Pasta <pasta@dashboost.org>
bls dependency defines a macro BASIC as 1 in relic_conf.h. This caused blockfilter.h to not compile after macro expansion when it says BASIC = 0. Maybe there is a fancy C++ way to solve this, but renaming it seemed good to me :) Signed-off-by: Pasta <pasta@dashboost.org>
f055995 blockfilter: Omit empty scripts from filter contents. (Jim Posen) Pull request description: Caught during review of bitcoin#12254 by @TheBlueMatt. bitcoin#12254 (comment) Tree-SHA512: cfc9e3eeaba12a14fd3d2e1ccce1a1f89e8cf44cc340ceec05d2d5fa61d27ff64e355603f4ad2184ff73c0ed23dfdab6e2103bddc48f3b76cb13b88d428770ac
cbb91e5
to
ea90d1b
Compare
functional tests looking good, code looks good to me however Unit Tests fail with
I'm not sure if this is dependant on earlier PRs. I can't find any. This is low priority for review. |
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.
Block filters rely on block hashes and we use X11, not sha256d. Also test data should have no segwit txes and no tests for witness also. UdjinM6@dbddd36 should fix these issues.
Drop segwit txes and witness test case. Update block hashes (x11 instead of sha256d), block filters and block filter headers.
Cherry-picked 👍 That makes sense |
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.
utACK
builds on #3415, currently failing. Will rebase after #3415
Backports bitcoin#12254 and bitcoin#14073