Support getcfilters
requests when -peerblockfilters
is set.
Does not advertise compact filter support in version messages.
Support getcfilters
requests when -peerblockfilters
is set.
Does not advertise compact filter support in version messages.
2046@@ -2045,6 +2047,49 @@ static bool PrepareBlockFilterRequest(CNode* pfrom, const CChainParams& chain_pa
2047 return true;
2048 }
2049
2050+/**
2051+ * Handle a cffilters request.
0 * Handle a cfilters request.
233+extern const char* GETCFILTERS;
234+/**
235+ * cfilter is a response to a getcfilters request containing a single compact
236+ * filter.
237+ */
238+extern const char *CFILTER;
style-nit in commit ee8499d294
0extern const char* CFILTER;
ACK 1231f6b3ba 🔁
Signature:
0-----BEGIN PGP SIGNED MESSAGE-----
1Hash: SHA512
2
3ACK 1231f6b3ba 🔁
4-----BEGIN PGP SIGNATURE-----
5
6iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
7pUhYrQv+IxEs+9TDoo1Lq/ba4oUD2SnLQmHUQmfVTu/+MIjw/cwY9DoZIwg6/iGs
86WwTmf8NwlNjAe9AHnrgDm1BhakIZYaXv+ZgCL7BRqpFujyh2jwjsDjMXWppMvjv
9DSt1NsrRlinXQsjR7WCJXvNt6axnvCeRsqLeua+ZhIyF5kVwTPapaNVbNo91Wjgw
10fRmBwxhI39ZnZpjljKGOF9x7cB5y0ySCeDy2FQqRDpBEkdprUoSu5KloEjD9nNge
11t4dtogwO6rDARHPx9rZOekp5MnAAUS+hdUeUFV3Yiw08VVbTuEOCAeAsIB326fQm
12QORabhfya6K8guMuvCXyThmIi79GmAti93ybgwDREIWmsMJj88H7vHn8AM5adMR8
13Zu839huCzBaeEUk4SbD5CK7j/2E3cGMLQ5l63m+4AEkOCgj/nr5aXqZpIGuxKU4F
14ETGWpimT3U2VioNHBzoov/59uge5rPNoSpnKZukOaSYn00Uum1BFlgrpqDDjY1Pb
150D3QC8b5
16=uTse
17-----END PGP SIGNATURE-----
Timestamp of file with hash 9f5d9f1dfb8cd50d63725419784f2b0521db1d74441352040b1817c8b21ec56f -
3510@@ -3466,6 +3511,12 @@ bool ProcessMessage(CNode* pfrom, const std::string& msg_type, CDataStream& vRec
3511 return true;
3512 }
3513
3514+ if (msg_type == NetMsgType::GETCFILTERS) {
3515+ ProcessGetCFilters(pfrom, vRecv, chainparams, connman);
3516+ return true;
3517+ }
3518+
3519+
2061+ * @param[in] pfrom The peer that we received the request from
2062+ * @param[in] vRecv The raw message received
2063+ * @param[in] chain_params Chain parameters
2064+ * @param[in] connman Pointer to the connection manager
2065+ */
2066+static void ProcessGetCFilters(CNode* pfrom, CDataStream& vRecv, const CChainParams& chain_params,
pfrom
and connman
are assumed, how about pass by reference?
You’re the second reviewer to ask for this so I’ve now made the change (as well as to ProcessGetCFHeaders()
and ProcessGetCFCheckPt
).
See also #19010 (review).
Code Review ACK https://github.com/bitcoin/bitcoin/pull/19044/commits/90a0dfff4ce4dec564f0a4b66504a68215aed27e
nit: for https://github.com/bitcoin/bitcoin/pull/19044/commits/0139a1b17cf6d44531b913443c77492e0881de72, how about noting in the commit message where this was introduced?
Pass CNode and CConnman by reference instead of by pointer to
ProcessGetCFCheckPt() and ProcessGetCFHeaders().
This only changes network serialization. Disk serialization does not
include the filter_type and is defined in
ReadFilterFromDisk()/WriteFilterToDisk().
Handle getcfilters request if -peercfilter is configured.
Thanks for the review @MarcoFalke and @Empact. I’ve addressed all of your review comments.
nit: for 0139a1b, how about noting in the commit message where this was introduced?
The default [de]serialization wasn’t previously used anywhere, so I don’t think this is necessary. It’s trivial to look up the git blame for that line.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
2075+ const BlockFilterType filter_type = static_cast<BlockFilterType>(filter_type_ser);
2076+
2077+ const CBlockIndex* stop_index;
2078+ BlockFilterIndex* filter_index;
2079+ if (!PrepareBlockFilterRequest(pfrom, chain_params, filter_type, start_height, stop_hash,
2080+ MAX_GETCFILTERS_SIZE, stop_index, filter_index)) {
Not sure if there is a mistake in BIP 157, but it reads that the difference must be strictly less than 1000 which implies not equal. Currently, PrepareBlockFilterRequest
would allow 1000.
Likewise for headers.
I think the BIP and code are correct/consistent. If the difference between the start height and stop height in the request is 999, then the number of filters served is 1000. For example, request(1, 1000) results in blocks 1-1000 (1000 blocks) being served.
if (stop_height - start_height >= max_height_diff)
ensures the strictly-less-than.
2080+ MAX_GETCFILTERS_SIZE, stop_index, filter_index)) {
2081+ return;
2082+ }
2083+
2084+ std::vector<BlockFilter> filters;
2085+
ProcessGetCFHeaders
.
1997@@ -1998,7 +1998,7 @@ void static ProcessOrphanTx(CConnman* connman, CTxMemPool& mempool, std::set<uin
1998 * @param[out] filter_index The filter index, if the request can be serviced.
1999 * @return True if the request can be serviced.
2000 */
2001-static bool PrepareBlockFilterRequest(CNode* pfrom, const CChainParams& chain_params,
2002+static bool PrepareBlockFilterRequest(CNode& pfrom, const CChainParams& chain_params,
pfrom
stand for “pointer” or “peer”? Consider renaming if the former.
re-ACK 9e36067d8c , only change is adding commit “[refactor] Pass CNode and CConnman by reference” 🥑
Signature:
0-----BEGIN PGP SIGNED MESSAGE-----
1Hash: SHA512
2
3re-ACK 9e36067d8c , only change is adding commit "[refactor] Pass CNode and CConnman by reference" 🥑
4-----BEGIN PGP SIGNATURE-----
5
6iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
7pUgbKwv+PwO//7eg2MRGhEr5p5hlfuT6GXbIG2KBBj2at35/XQLwuNfi/0S8Jv8a
84oga+orbWYA4bNjZkEt2boyO3mCiML5pKPSHbjaDBaltE/lzzurIE0dfG/O+fPpk
9+Smsj3HbC8BOXxkKdaqYXtQs5519LN9ypbCbIW6mY7SGyov1wG3XsBdNtMlU5Ybt
10G7KkpTsXpSYpXCUy+Q1Rh2+3s7fvYZQrpe3XZ3Z0Ztzyuct3XgMarj+ucJOEKZ6Y
11DKtXl0h4XBqfwlc4ngMZuXqN/6Zk1wEne94Q3Hr19SjbDLkp/oeBbsjqUi69y+5n
124CSmVaqhr8HUtTxqp/+ADSf+PaMchYx/jrOOh/f+2SsA0KLIsTvuGdWPxmDse0so
13LHxFrDmF5mHXt1hECV5zQQcWE5M/nS8WB6nGHEQQ0RO67nxPs6CaqIQmR1WZ1599
14/DAw2B1oagwy+KBQMAZFHjBFGKWa5TXXb7fZsVFSiUIXaMGl9p9xxfe2kJ1mzm5X
15BaTr8GqR
16=/Tog
17-----END PGP SIGNATURE-----
Timestamp of file with hash e987c18ac02e885972b23102e7c1c01949ebe68ab8a6bbda08846816f39e846a -
12@@ -13,6 +13,7 @@
13 hash256,
14 msg_getcfcheckpt,
15 msg_getcfheaders,
16+ msg_getcfilters,
p2p_blockfilters.py
is still missing cfilters
.
Code review ACK 9e36067d8cd02830c7e5a88a391dff6ac3adbe0c
If you have to retouch maybe also fix the commit message in 11106a4722558765a44ae45c7892724a73ce514c. It still says -peercfilter
instead of -peerblockfilter
.
ACK 9e36067d8cd02830c7e5a88a391dff6ac3adbe0c
Two optional nits for follow-ups:
0--- a/src/protocol.cpp
1+++ b/src/protocol.cpp
2@@ -40,12 +40,12 @@ const char *SENDCMPCT="sendcmpct";
3-const char *GETCFILTERS="getcfilters";
4-const char *CFILTER="cfilter";
5-const char *GETCFHEADERS="getcfheaders";
6-const char *CFHEADERS="cfheaders";
7 const char *GETCFCHECKPT="getcfcheckpt";
8 const char *CFCHECKPT="cfcheckpt";
9+const char *GETCFHEADERS="getcfheaders";
10+const char *CFHEADERS="cfheaders";
11+const char *GETCFILTERS="getcfilters";
12+const char *CFILTER="cfilter";
13
14--- a/test/functional/p2p_blockfilters.py
15+++ b/test/functional/p2p_blockfilters.py
16@@ -4,8 +4,8 @@
17 """Tests NODE_COMPACT_FILTERS (BIP 157/158).
18
19-Tests that a node configured with -blockfilterindex and -peerblockfilters can serve
20-cfheaders and cfcheckpts.
21+Tests that a node configured with -blockfilterindex and -peerblockfilters can
22+serve cfcheckpt, cfheaders, and cfilters.
23 """
Thanks for the review @jonatack