-
Notifications
You must be signed in to change notification settings - Fork 36.5k
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
Bloom filters #1795
Bloom filters #1795
Conversation
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/bd93f61c2abe5b19e77030fa5859bc370c789a3a for binaries and test log. |
Very exciting. Did you see this: He has a really interesting looking C++11 headers-only implementation here at github that might give you inspiration (e.g. I think he uses boost to do the hashing; he seems to get a ton done in a very small number of lines of code). |
implementation ACK, I like it a lot. This seems to match the initial sketch from @mikehearn and myself on IRC. |
Poke, let's get some additional review on this. |
Hey Matt, could you rebase this on top of ultraprune? I'm ready to start merging the bitcoinj side but want to test this with the latest code. Will do a review now-ish. |
ACK on this. Most of my comments are purely cosmetic except for the unit test commit being in the wrong place (it wouldn't compile in the order given). I guess we'll need a BIP? I'll start on one that documents what we've come up with. |
Thanks mike for the good review (as usual). I updated the code to addresses most of the issues you mentioned.
|
@mikehearn there are a few comments which note what the protocol defines as spec (these are obviously up for discussion):
|
Automatic sanity-testing: FAILED BUILD/TEST, see http://jenkins.bluematt.me/pull-tester/1860b72e356f0d4279b25bf1ca562ac00511eded for binaries and test log. This could happen for one of several reasons:
|
@BitcoinPullTester hey, I wasnt done yet! |
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/5be9d251b5901399c6f70b99f1c2bddc4e14e7ec for binaries and test log. |
Added the requested nTweak value and merged sipa's work on partial merkle tree representations. The BIP now needs rewritten and this is ready for second (third?) round reviews. |
Mostly ACK;
|
Automatic sanity-testing: FAILED MERGE, see http://jenkins.bluematt.me/pull-tester/21e780e05c7b18ab318e57bd9e24961a34378e2d for test log. This pull does not merge cleanly onto current master |
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/a5a72aa691296af6de92658ff998da120c4b34d8 for binaries and test log. |
|
||
// Nodes must NEVER send a data item > 520 bytes (the max size for a script data object, | ||
// and thus, the maximum size any matched object can have) in a filteradd message | ||
if (vData.size() > 520) |
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.
If vData is too large, it will still be added to the filter. There needs to be an else block here.
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.
yep, fixed.
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.
Wouldn't it be nice if that 520 was a constant somewhere or a define? So it could be used for the max size for a script data object
and in here.
Can you add a new feature that lets clients opt out of auto-adding? Sipa points out that it's only necessary for wallets that contain outputs which don't require predictable data in the corresponding inputs, which (for now) is most of them. This should resolve the excessive expansion issues. |
@mikehearn Kind of an an unfortunate privacy loss for ones who do set it, and it still leaves the feature potentially useless for any who set it. (But I agree on having the option, if for nothing else because it makes the load-balancing lark I suggested viable) |
Well not really, you can still set the FP rate to whatever you want. If all |
Setting that bit or not is still another anonymity set reduction, but I'm splitting hairs there ignore it. I guess I don't have a good feel for how fast the filter fails and needs to be reset. If it's too fast periodic refreshes won't be sufficient (E.g. will the size of the refresh plus the unwanted data end up being more than just not using the filter). |
I think we can explore different algorithms later. The exact choices will On Wed, Jan 9, 2013 at 7:09 PM, Gregory Maxwell [email protected]:
|
Added a nFlags to let the peer pick how/when it wants the filter updated...also added a second two commits to make it possible to match an arbitrary script template as a discussion point (that second part is not yet tested). |
Code review notes: I don't like the entire implementation of CPartialMerkleTree being stuffed into main.h, it should be its own .cpp/.h Message handling looks good from a potential vulnerability point of view. NACK on the script.cpp / script.h changes -- they are unused (yes? I don't see where MatchesTemplate is used outside of script.cpp/.h) and I don't see unit tests for the new features like OP_OPCODE. |
@gavinandresen Yes, after discussion I believe we are currently targeting skipping the 2 MatchesTemplate commits for 0.8 and maybe skipping those entirely depending on what we may need in the future. |
Note that the default value for fRelayTxes is false, meaning we now no longer relay tx inv messages before receiving the remote peer's version message.
This adds a compact representation for a subset of a merkle tree's nodes.
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/e1a4f3778cb90ba9f0d4e736752f78dad1703caa for binaries and test log. |
@gavinandresen moved it to main.cpp, is that ok for you? |
ACK, looks good. |
So.. what was the BIP for these protocol changes? It would be nice if it could be referenced in the pull requests. |
@@ -2815,6 +2969,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) | |||
vRecv >> pfrom->strSubVer; | |||
if (!vRecv.empty()) | |||
vRecv >> pfrom->nStartingHeight; | |||
if (!vRecv.empty()) | |||
vRecv >> pfrom->fRelayTxes; // set to true after we get the first filter* message |
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.
Somehow this doesn't feel like the best way to implement this....
https://en.bitcoin.it/wiki/BIP_0037 as was discussed on the mailing list. Regardless, this code was already merged and shipped months ago, it's a bit late to be commenting on it now. You can always open up new pull reqs if you want to change how the protocol works. |
Bloom filters
Filter tx invs and add MSG_FILTERED_BLOCK to provide blocks as header+vector (not including tx itself)