-
Notifications
You must be signed in to change notification settings - Fork 36.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
p2p: Signal support for compact block filters with NODE_COMPACT_FILTERS #19070
Conversation
This is the final PR in the #18876 series of PRs. Note that there are a couple of differences from @jimpo's original PR:
Of course, both of those decisions are up for debate. If there's a consensus that my changes aren't desirable, I'll happily revert them. |
e038090
to
e1ee720
Compare
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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. |
Both of these changes from the original PR violate BIP 157 as it is currently written. The BIP was designed to expose a consistent interface to clients, which is conceptually simpler, making it easier to implement client code correctly. The guarantee is that if a node has the COMPACT_FILTER service bit on and advertises that some block is in its main chain, then it must be able to serve the block filter and filter header for it in subsequent requests.
Those are my justifications. But this has been debated before, and if others aren't convinced, then we should at least update the BIP to reflect the more laissez faire behavior. |
Thanks for summarising your thoughts @jimpo. As you point out, there's already been debate about this. For the benefit for other reviewers, here are the comments from the original PR relevant to setting the service bits:
To summarize my opposition to dynamically setting service bits:
In fact, BIP 157 and BIP 158 seem inconsistent. BIP 158 states "If enabled, the node MUST respond to all BIP 157 messages for filter type 0x00", but BIP 157 states "A node that receives getcfilters with an unknown StopHash SHOULD NOT respond." (as well as listing several other conditions where the server shouldn't respond). As I said, if the general consensus is that we should restore the behaviour from #16442, then I can do that. If not, I'm happy to open PRs to modify the BIPs. |
If -peerblockfilters is configured, signal the NODE_COMPACT_FILTERS service bit to indicate that we are able to serve compact block filters, headers and checkpoints.
Test that a node configured to serve compact filters will signal NODE_COMPACT_FILTER service bit.
e1ee720
to
f5c003d
Compare
Rebased on master and applied suggested changes by @fjahr (#19044 (comment)) and @jkczyz (#19044 (comment), #19044 (comment)) |
re-review and Concept ACK f5c003d Changes since my previous review #18876 (comment):
|
@jnewbery Does a node serve blocks during IBD? If not, would it be reasonable to simply remain in this state until the index is built? |
Code review ACK f5c003d Concerning the conceptual changes:
|
I believe the behaviour is:
Yes that's possible, but I'm not sure if it's desirable. I don't think we want block filter index building to interfere with block relay, even if it's only temporarily. |
Concept ACK f5c003d I agree that service bits should not signal state. I'm also unsure on the If BIPs 157 and 158 conflict with one another, then there should definitely be a clarification. |
@MarcoFalke : what's the request here? Will you be happy if I changed the behavior when a filter can't be served to just disconnect immediately? |
I haven't written the code, but I am assuming that the disconnect can be done with minimal added complexity and it would indeed make me like the changes here more. Though, looking into the future, p2p filters might not only be serviced to random 3rd party clients, but maybe also to your own light client (via a trusted connection), in which case redundancy is neither required nor possible. So a failure to serve a filter can only be answered with a polling loop. So I'd also argue to bring back the block-until-synced call. Note that the block-until-synced call is a noop if the filter is already synced with the chain. |
f5c003d
to
fe2e6bb
Compare
I've updated this so that we disconnect immediately if we're not able to service a request. @MarcoFalke - care to rereview? |
fe2e6bb
to
f5c003d
Compare
ok, I've reverted back to the version that has 3 ACKs. |
Yeah, sorry for being unclear in what situations to disconnect. I will create a follow-up pull later this week unless someone beats me to it. This might be ready for merge. |
@MarcoFalke ready for merge, or does this require something else? |
This PR has ACKs/concept ACKs from:
I asked for people to speak up if they had any objection two months ago (#19070 (comment)) and there hasn't been any substantial opposition. I think this PR is ready for merge. |
…th NODE_COMPACT_FILTERS f5c003d [test] Add test for NODE_COMPACT_FILTER. (Jim Posen) 132b30d [net] Signal NODE_COMPACT_FILTERS if we're serving compact filters. (Jim Posen) b3fbc94 Apply cfilters review fixups (John Newbery) Pull request description: If -peerblockfilters is configured, signal the `NODE_COMPACT_FILTERS` service bit to indicate that we are able to serve compact block filters, headers and checkpoints. ACKs for top commit: MarcoFalke: re-review and Concept ACK f5c003d fjahr: Code review ACK f5c003d clarkmoody: Concept ACK f5c003d ariard: Concept and Code Review ACK f5c003d jonatack: ACK f5c003d Tree-SHA512: 34d1c153530a0e55d09046fe548c9dc37344b5d6d50e00af1b4e1de1e7b49de770fca8471346a17c151de9fe164776296bb3dd5af331977f0c3ef1e6fc906f85
Summary: Partial backport (1/3) of core [[bitcoin/bitcoin#19070 | PR19070]]: bitcoin/bitcoin@b3fbc94 Depends on D8729. Test Plan: ninja Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Differential Revision: https://reviews.bitcoinabc.org/D8730
Summary: ``` If -peerblockfilters is configured, signal the NODE_COMPACT_FILTERS service bit to indicate that we are able to serve compact block filters, headers and checkpoints. ``` Partial backport (2/3) of core [[bitcoin/bitcoin#19070 | PR19070]]: bitcoin/bitcoin@132b30d Depends on D8730. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Differential Revision: https://reviews.bitcoinabc.org/D8731
Summary: ``` Test that a node configured to serve compact filters will signal NODE_COMPACT_FILTER service bit. ``` Completes backport (3/3) of core [[bitcoin/bitcoin#19070 | PR19070]]: bitcoin/bitcoin@f5c003d Depends on D8731. Test Plan: ninja check-functional Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Differential Revision: https://reviews.bitcoinabc.org/D8732
…DE_COMPACT_FILTERS
If -peerblockfilters is configured, signal the
NODE_COMPACT_FILTERS
service bit to indicate that we are able to serve compact block filters, headers and checkpoints.