ethereum-optimism / op-geth

GNU Lesser General Public License v3.0
254 stars 652 forks source link

feat: support disc v4/v5 mix mode in bootnode #312

Open 2129zxl opened 1 month ago

2129zxl commented 1 month ago

PR to upstream link

Description

The p2p module in op-geth has already implemented sharedUdp to enable coexistence of node discovery protocols for both v4 and v5. However, node discovery in the bootnode currently supports only a single protocol. This PR has achieved a mix of v4 and v5 protocols for the bootnode, allowing it to provide node discovery functionality to geth nodes running different versions simultaneously.

Tests

3 scenarios has been tested:

  1. v4=true and v5=false, it only supported discv4
  2. v5=true and v4=false, it only supported discv5 (defalut config)
  3. v5=true and v4=true, it supported both discv5 and discv4

Additional context

A new configuration option --v4 has been added. The configuration method is similar to that of geth. When both are set to true, both protocols are supported simultaneously. The default values are --v5=true --v4=false, meaning only the v5 protocol is supported by default.

Metadata

N/A

2129zxl commented 1 month ago

This would be a good feature to submit as PR to upstream go-ethereum.

Your proposal is indeed more reasonable; here is the link to the PR for upstream.