besu icon indicating copy to clipboard operation
besu copied to clipboard

SPIKE Filter discovery peers by fork id

Open macfarla opened this issue 2 years ago • 3 comments

per Meredith's comment I think that using the forkid https://github.com/hyperledger/besu/blob/27fc468624d4a19067b076567ea9e1578217d34e/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgent.java#L200 to filter nodes at the discovery layer would really help a lot.

posted a question on how fork id’s are being used in other clients at the discovery layer to the Eth R&D discord (channel #execution-dev).
https://discord.com/channels/595666850260713488/688075293562503241/994669988747157657

This seems like a pretty easy and very useful feature to add - we could put it behind a feature flag to start.

  • Filter nodes based on forkid at the discovery layer
  • Need to understand forkid comparison
  • Understand what Geth does with forkid and filtering peers
  • Add an experimental flag - ideally use the same option name as geth for ease of use
  • Filter nodes based on forkid (part of ENR) when streaming discovery peers Impact
  • fewer peers discarded (later) at upper layers

macfarla avatar Jul 21 '22 06:07 macfarla

It would be a discovery-level ENR request https://github.com/hyperledger/besu/blob/27fc468624d4a19067b076567ea9e1578217d34e/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/PeerDiscoveryController.java#L338-L349,

not the eth-wire-protocol-level status request. The point would be to focus on discovery peers that are on the same network (have a compatible forkid https://github.com/hyperledger/besu/blob/27fc468624d4a19067b076567ea9e1578217d34e/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgent.java#L200)

and ignore the others, so the connection-oriented rlpx protocol never bothers initiating connections with peers on the wrong network.

macfarla avatar Aug 09 '22 03:08 macfarla

This is the EIP describing the fork ID message: https://eips.ethereum.org/EIPS/eip-2124

pinges avatar Aug 23 '22 07:08 pinges

Response from the geth team: https://discord.com/channels/595666850260713488/688075293562503241/995962621603893300

We don't use the filter on v4 because getting the ENR takes an extra request.

Does that mean this issue is blocked by implementing discv5 then https://github.com/hyperledger/besu/issues/4036?

siladu avatar Sep 26 '22 05:09 siladu

Clients not sending the ForkID:

  • Nethermind v1.14
  • bor/v1.10.9 (Matic network)
  • Geth/v1.10.25 (must be configurable?)
  • Geth/v1.1.16 (old version, most geth clients are sending the fork id)
  • Geth/v4.4.0 (latest geth version is 1.10..., whst is this version? This client only supported les protocol)
  • Geth/v1.1.16 (old version)
  • go-opera (not supporting any eth protocols)

pinges avatar Nov 07 '22 02:11 pinges

I have created issue https://github.com/NethermindEth/nethermind/issues/4875 against Nethermind

pinges avatar Nov 07 '22 23:11 pinges