Skip to content

cmd, p2p: filter peers by regex on name#2404

Merged
zzzckck merged 1 commit intobnb-chain:developfrom
weiihann:develop/filter-node
Apr 18, 2024
Merged

cmd, p2p: filter peers by regex on name#2404
zzzckck merged 1 commit intobnb-chain:developfrom
weiihann:develop/filter-node

Conversation

@weiihann
Copy link
Copy Markdown
Contributor

Description

This PR adds a new feature to filter peers by their names based on a set of customized regex patterns.

Rationale

Some outdated versions of nodes running on BSC may keep connecting to a healthy set of peers and only consume information, but not return any useful data. Such nodes should be filtered out to save network bandwidth.

Example

In the config file:

...
[Node.P2P]
PeerFilterPatterns = ["(?!)geth"]
...

An example of a false regexp pattern error message:

t=2024-04-18T06:02:10+0000 lvl=error msg="Failed to compile peer filter patterns" err="error parsing regexp: missing closing ): `abc(def`"

@weiihann weiihann requested a review from zzzckck as a code owner April 18, 2024 06:45
@zzzckck zzzckck merged commit 3b7f0e4 into bnb-chain:develop Apr 18, 2024
@wellgamer789
Copy link
Copy Markdown

"may keep connecting to a healthy set of peers and only consume information, but not return any useful data."

I may be wrong, but i think what you are fighting are "fake nodes" and they can easily bypass this "check".

@zzzckck
Copy link
Copy Markdown
Collaborator

zzzckck commented May 11, 2024

"may keep connecting to a healthy set of peers and only consume information, but not return any useful data."

I may be wrong, but i think what you are fighting are "fake nodes" and they can easily bypass this "check".

yes, it is just optional feature, can not solve the case you mentioned. But could be useful in some cases.

@kaber2
Copy link
Copy Markdown

kaber2 commented May 13, 2024

Obsolete peers should be filtered based on the fork ID. This seems really useless.

@zzzckck
Copy link
Copy Markdown
Collaborator

zzzckck commented Jun 20, 2024

1.to filter out specified nodes that the name contains "alice"

[Node.P2P]
PeerFilterPatterns = ["^alice.*"]

This will reject connection from client with name "alice*"

2.to filter out specified nodes that the name contains either "alice" or "bob"

[Node.P2P]
PeerFilterPatterns = ["^alice.*|^bob.*"]

3.Some Examples

[Node.P2P]
PeerFilterPatterns = ["Geth/v1.3.*|Geth/v1.4.4.*|Geth/v1.4.5.*|Geth/v1.4.6.*"]

@setunapo
Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants