Make whitebind/whitelist permissions more flexible
Motivation
In 0.19, bloom filter will be disabled by default. I tried to make a PR to enable bloom filter for whitelisted peers regardless of -peerbloomfilters.
Bloom filter have non existent privacy and server can omit filter's matches. However, both problems are completely irrelevant when you connect to your own node. If you connect to your own node, bloom filters are the most bandwidth efficient way to synchronize your light client without the need of some middleware like Electrum.
It is also a superior alternative to BIP157 as it does not require to maintain an additional index and it would work well on pruned nodes.
When I attempted to allow bloom filters for whitelisted peer, my proposal has been NACKed in favor of a more flexible approach which should allow node operator to set fine grained permissions instead of a global whitelisted attribute.
Doing so will also make follow up idea very easy to implement in a backward compatible way.
Implementation details
The PR propose a new format for --white{list,bind}. I added a way to specify permissions granted to inbound connection matching white{list,bind}.
The following permissions exists:
- ForceRelay
- Relay
- NoBan
- BloomFilter
- Mempool
Example:
-
-whitelist=bloomfilter@127.0.0.1/32. -
-whitebind=bloomfilter,relay,noban@127.0.0.1:10020.
If no permissions are specified, NoBan | Mempool is assumed. (making this PR backward compatible)
When we receive an inbound connection, we calculate the effective permissions for this peer by fetching the permissions granted from whitelist and add to it the permissions granted from whitebind.
To keep backward compatibility, if no permissions are specified in white{list,bind} (e.g. --whitelist=127.0.0.1) then parameters -whitelistforcerelay and -whiterelay will add the permissions ForceRelay and Relay to the inbound node.
-whitelistforcerelay and -whiterelay are ignored if the permissions flags are explicitly set in white{bind,list}.
Follow up idea
Based on this PR, other changes become quite easy to code in a trivially review-able, backward compatible way:
- Changing
connectat rpc and config file level to understand the permissions flags. - Changing the permissions of a peer at RPC level.