Skip to content
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

Compact Client Side Filtering for Light Clients (Neutrino server-side support) #11863

Closed
Sjors opened this issue Dec 11, 2017 · 16 comments
Closed

Comments

@Sjors
Copy link
Member

Sjors commented Dec 11, 2017

@Roasbeef, @martelletto and @aakselrod implemented server-side support for this protocol in the btcd client, and the lnd Lightning client is able to use this.

Are there any prerequisites for implementing server-side support for this protocol in Bitcoin Core, at least as a proof of concept?

@TheBlueMatt
Copy link
Contributor

TheBlueMatt commented Dec 11, 2017 via email

@jonasschnelli
Copy link
Contributor

@Sjors: the SPV concept PR #9483 (needs rebasing) could be an initial step for client side filtering.
What the PR above does is just fetching all blocks relevant for the wallet(s).

@TheBlueMatt
Copy link
Contributor

@jonasschnelli I believe the question was about server-side support (ie serving neutrino headers/filters), not client-side SPV support.

@Sjors
Copy link
Member Author

Sjors commented Dec 11, 2017

@TheBlueMatt correct. The other way around should be a separate Github issue if anyone is interested, as it has completely different trade-offs.

@Sjors
Copy link
Member Author

Sjors commented Dec 29, 2017

Note that in the btcd implementation branch the word "neutrino" isn't used. Look for committed filters and SFNodeCF instead.

@jonasschnelli
Copy link
Contributor

Sorry for the confusion.
Yes. Server side support should be added to Bitcoin Core.
I think the BIP needs to be overhauled and merged first (bitcoin/bips#609).

@jonasschnelli
Copy link
Contributor

Related: #12254

@ysangkok
Copy link

ysangkok commented Apr 9, 2018

The replacement pull request of the linked PR (609) was merged and test vectors have been added to BIP 158.

@Sjors
Copy link
Member Author

Sjors commented Feb 19, 2019

#14121 adds an index for these filters

The step after that is probably implementing p2p messages that use this index if it's enabled.

@Kixunil
Copy link

Kixunil commented Mar 12, 2019

I don't think adding more code to Core is the best design we can have since this can be developed as an external service by fetching blocks from Core. The users that don't want to provide this service (for security or performance reasons) shouldn't be forced to have such code compiled-in.

But maybe I'm missing something?

@jimpo
Copy link
Contributor

jimpo commented Mar 12, 2019

@Kixunil I agree that an external service is a valid alternative design choice. However, I believe adding BIP 157 support directly into Core is the better design.

The security of light clients using the protocol improves with the number of nodes on the network serving filters (at least until filters are committed into block headers if/when that happens). Adding support into Core gives all node operators an easy ability to support light clients with a single configuration flag without having to install/audit/trust a new project. Furthermore, keeping an index of block filters improves rescan speed for full node wallets (by 80+% by my measurements for a 1,000 key wallet). The code is designed to be minimally invasive by using the asynchronous CValidationInterface callbacks and does not modify consensus code or core data structures at all. If you have specific security or performance concerns, please comment on the PR.

I also think you are underestimating how much work would be involved in creating an external service. Such a service would need to expose the full Bitcoin P2P network interface (or at least a lot of it), which is very non-trivial and arguably much riskier for the network as a whole than Core adding support for a few more requests. Reimplementing the network layer as a proxy node has been discussed before and I'd love to see someone do it, but I'm skeptical that it would reach the same level of stability or support that Core has any time soon.

@greenaddress
Copy link
Contributor

My two cents: I don't think this should be part of core (but nice rescan perf improvements). In my view it makes more sense as a thin shin in front of core. And if this had to be part of core I think it should be off by default anyway.

I am not sure if the protocol has to be based on bitcoin p2p but if we assume it has to then something like https://github.com/basil00/PseudoNode or https://github.com/rust-bitcoin/rust-bitcoin may be a good starting point to handle bitcoin p2p messages?

@Kixunil
Copy link

Kixunil commented Mar 13, 2019

@jimpo Thanks for detailed answer!

TBH, I'd love to see the wallet get removed from Core as well, but since that's almost certainly not going to happen anytime soon, I consider the argument about increased rescan speed convincing enough to implement block filters. Once they are implemented, it makes a lot of sense to expose them as well (ideally behind configuration flag).

Installing/trusting other pieces of software is already a problem that people need to solve (e.g. for Btcpay server, HW wallets with ElectrumX/EPS...) Docker, scripts, or manual install (tons of tutorials) are popular methods when it comes to installing. If there's something missing, maybe making better tools would help the ecosystem overall. When it comes to audit, I wouldn't object to Core developers also auditing external service and provide their signatures, if they want to.

I didn't want to suggest to use the Bitcoin P2P protocol, but some other protocol. Electrum uses the same approach and I don't see anything wrong with it. But again, I may be missing something.

Finally, I'm wondering if it's possible to use block filters with pruned node. It seems possible to me (build filters during sync, keep filters, throw away old blocks). The advantage is obviously being able to rescan quickly and efficiently if it's needed later. Is this feature implemented/planned/a bad idea?

@maflcko
Copy link
Member

maflcko commented Apr 29, 2019

Finally, I'm wondering if it's possible to use block filters with pruned node.

Yes, but that needs to be implemented: #15867

@maflcko
Copy link
Member

maflcko commented Apr 29, 2019

I am going to close this issue, as it is unclear what is being discussed here exactly.

@Sjors
Copy link
Member Author

Sjors commented Sep 1, 2019

#16442 implements this

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants