Skip to content

Commit

Permalink
fix(discv5): change default discv5 port (#11051)
Browse files Browse the repository at this point in the history
Co-authored-by: Oliver <onbjerg@users.noreply.github.com>
  • Loading branch information
Rjected and onbjerg authored Sep 20, 2024
1 parent ec56530 commit 84db469
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 24 deletions.
4 changes: 2 additions & 2 deletions book/cli/reth/debug/execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ Networking:
--discovery.v5.port <DISCOVERY_V5_PORT>
The UDP IPv4 port to use for devp2p peer discovery version 5. Not used unless `--addr` is IPv4, or `--discovery.v5.addr` is set
[default: 9000]
[default: 9200]
--discovery.v5.port.ipv6 <DISCOVERY_V5_PORT_IPV6>
The UDP IPv6 port to use for devp2p peer discovery version 5. Not used unless `--addr` is IPv6, or `--discovery.addr.ipv6` is set
[default: 9000]
[default: 9200]
--discovery.v5.lookup-interval <DISCOVERY_V5_LOOKUP_INTERVAL>
The interval in seconds at which to carry out periodic lookup queries, for the whole run of the program
Expand Down
4 changes: 2 additions & 2 deletions book/cli/reth/debug/in-memory-merkle.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ Networking:
--discovery.v5.port <DISCOVERY_V5_PORT>
The UDP IPv4 port to use for devp2p peer discovery version 5. Not used unless `--addr` is IPv4, or `--discovery.v5.addr` is set
[default: 9000]
[default: 9200]
--discovery.v5.port.ipv6 <DISCOVERY_V5_PORT_IPV6>
The UDP IPv6 port to use for devp2p peer discovery version 5. Not used unless `--addr` is IPv6, or `--discovery.addr.ipv6` is set
[default: 9000]
[default: 9200]
--discovery.v5.lookup-interval <DISCOVERY_V5_LOOKUP_INTERVAL>
The interval in seconds at which to carry out periodic lookup queries, for the whole run of the program
Expand Down
4 changes: 2 additions & 2 deletions book/cli/reth/debug/merkle.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ Networking:
--discovery.v5.port <DISCOVERY_V5_PORT>
The UDP IPv4 port to use for devp2p peer discovery version 5. Not used unless `--addr` is IPv4, or `--discovery.v5.addr` is set
[default: 9000]
[default: 9200]
--discovery.v5.port.ipv6 <DISCOVERY_V5_PORT_IPV6>
The UDP IPv6 port to use for devp2p peer discovery version 5. Not used unless `--addr` is IPv6, or `--discovery.addr.ipv6` is set
[default: 9000]
[default: 9200]
--discovery.v5.lookup-interval <DISCOVERY_V5_LOOKUP_INTERVAL>
The interval in seconds at which to carry out periodic lookup queries, for the whole run of the program
Expand Down
4 changes: 2 additions & 2 deletions book/cli/reth/debug/replay-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ Networking:
--discovery.v5.port <DISCOVERY_V5_PORT>
The UDP IPv4 port to use for devp2p peer discovery version 5. Not used unless `--addr` is IPv4, or `--discovery.v5.addr` is set
[default: 9000]
[default: 9200]
--discovery.v5.port.ipv6 <DISCOVERY_V5_PORT_IPV6>
The UDP IPv6 port to use for devp2p peer discovery version 5. Not used unless `--addr` is IPv6, or `--discovery.addr.ipv6` is set
[default: 9000]
[default: 9200]
--discovery.v5.lookup-interval <DISCOVERY_V5_LOOKUP_INTERVAL>
The interval in seconds at which to carry out periodic lookup queries, for the whole run of the program
Expand Down
4 changes: 2 additions & 2 deletions book/cli/reth/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ Networking:
--discovery.v5.port <DISCOVERY_V5_PORT>
The UDP IPv4 port to use for devp2p peer discovery version 5. Not used unless `--addr` is IPv4, or `--discovery.v5.addr` is set
[default: 9000]
[default: 9200]
--discovery.v5.port.ipv6 <DISCOVERY_V5_PORT_IPV6>
The UDP IPv6 port to use for devp2p peer discovery version 5. Not used unless `--addr` is IPv6, or `--discovery.addr.ipv6` is set
[default: 9000]
[default: 9200]
--discovery.v5.lookup-interval <DISCOVERY_V5_LOOKUP_INTERVAL>
The interval in seconds at which to carry out periodic lookup queries, for the whole run of the program
Expand Down
4 changes: 2 additions & 2 deletions book/cli/reth/p2p.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ Networking:
--discovery.v5.port <DISCOVERY_V5_PORT>
The UDP IPv4 port to use for devp2p peer discovery version 5. Not used unless `--addr` is IPv4, or `--discovery.v5.addr` is set
[default: 9000]
[default: 9200]
--discovery.v5.port.ipv6 <DISCOVERY_V5_PORT_IPV6>
The UDP IPv6 port to use for devp2p peer discovery version 5. Not used unless `--addr` is IPv6, or `--discovery.addr.ipv6` is set
[default: 9000]
[default: 9200]
--discovery.v5.lookup-interval <DISCOVERY_V5_LOOKUP_INTERVAL>
The interval in seconds at which to carry out periodic lookup queries, for the whole run of the program
Expand Down
4 changes: 2 additions & 2 deletions book/cli/reth/stage/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ Networking:
--discovery.v5.port <DISCOVERY_V5_PORT>
The UDP IPv4 port to use for devp2p peer discovery version 5. Not used unless `--addr` is IPv4, or `--discovery.v5.addr` is set
[default: 9000]
[default: 9200]
--discovery.v5.port.ipv6 <DISCOVERY_V5_PORT_IPV6>
The UDP IPv6 port to use for devp2p peer discovery version 5. Not used unless `--addr` is IPv6, or `--discovery.addr.ipv6` is set
[default: 9000]
[default: 9200]
--discovery.v5.lookup-interval <DISCOVERY_V5_LOOKUP_INTERVAL>
The interval in seconds at which to carry out periodic lookup queries, for the whole run of the program
Expand Down
4 changes: 2 additions & 2 deletions book/cli/reth/stage/unwind.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ Networking:
--discovery.v5.port <DISCOVERY_V5_PORT>
The UDP IPv4 port to use for devp2p peer discovery version 5. Not used unless `--addr` is IPv4, or `--discovery.v5.addr` is set
[default: 9000]
[default: 9200]
--discovery.v5.port.ipv6 <DISCOVERY_V5_PORT_IPV6>
The UDP IPv6 port to use for devp2p peer discovery version 5. Not used unless `--addr` is IPv6, or `--discovery.addr.ipv6` is set
[default: 9000]
[default: 9200]
--discovery.v5.lookup-interval <DISCOVERY_V5_LOOKUP_INTERVAL>
The interval in seconds at which to carry out periodic lookup queries, for the whole run of the program
Expand Down
19 changes: 13 additions & 6 deletions crates/net/discv5/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ pub const DEFAULT_DISCOVERY_V5_ADDR_IPV6: Ipv6Addr = Ipv6Addr::UNSPECIFIED;

/// The default port for discv5 via UDP.
///
/// Default is port 9000. See [`discv5::ListenConfig`] default.
pub const DEFAULT_DISCOVERY_V5_PORT: u16 = 9000;
/// Default is port 9200.
pub const DEFAULT_DISCOVERY_V5_PORT: u16 = 9200;

/// The default [`discv5::ListenConfig`].
///
/// This is different from the upstream default.
pub const DEFAULT_DISCOVERY_V5_LISTEN_CONFIG: ListenConfig =
ListenConfig::Ipv4 { ip: DEFAULT_DISCOVERY_V5_ADDR, port: DEFAULT_DISCOVERY_V5_PORT };

/// Default interval in seconds at which to run a lookup up query.
///
Expand Down Expand Up @@ -222,8 +228,9 @@ impl ConfigBuilder {
discovered_peer_filter,
} = self;

let mut discv5_config = discv5_config
.unwrap_or_else(|| discv5::ConfigBuilder::new(ListenConfig::default()).build());
let mut discv5_config = discv5_config.unwrap_or_else(|| {
discv5::ConfigBuilder::new(DEFAULT_DISCOVERY_V5_LISTEN_CONFIG).build()
});

discv5_config.listen_config =
amend_listen_config_wrt_rlpx(&discv5_config.listen_config, tcp_socket.ip());
Expand Down Expand Up @@ -528,7 +535,7 @@ mod test {
fn overwrite_ipv4_addr() {
let rlpx_addr: Ipv4Addr = "192.168.0.1".parse().unwrap();

let listen_config = ListenConfig::default();
let listen_config = DEFAULT_DISCOVERY_V5_LISTEN_CONFIG;

let amended_config = amend_listen_config_wrt_rlpx(&listen_config, rlpx_addr.into());

Expand All @@ -543,7 +550,7 @@ mod test {
fn overwrite_ipv6_addr() {
let rlpx_addr: Ipv6Addr = "fe80::1".parse().unwrap();

let listen_config = ListenConfig::default();
let listen_config = DEFAULT_DISCOVERY_V5_LISTEN_CONFIG;

let amended_config = amend_listen_config_wrt_rlpx(&listen_config, rlpx_addr.into());

Expand Down
4 changes: 2 additions & 2 deletions crates/net/discv5/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub use discv5::{self, IpMode};

pub use config::{
BootNode, Config, ConfigBuilder, DEFAULT_COUNT_BOOTSTRAP_LOOKUPS, DEFAULT_DISCOVERY_V5_ADDR,
DEFAULT_DISCOVERY_V5_ADDR_IPV6, DEFAULT_DISCOVERY_V5_PORT,
DEFAULT_DISCOVERY_V5_ADDR_IPV6, DEFAULT_DISCOVERY_V5_LISTEN_CONFIG, DEFAULT_DISCOVERY_V5_PORT,
DEFAULT_SECONDS_BOOTSTRAP_LOOKUP_INTERVAL, DEFAULT_SECONDS_LOOKUP_INTERVAL,
};
pub use enr::enr_to_discv4_id;
Expand Down Expand Up @@ -666,7 +666,7 @@ mod test {
discv5::Discv5::new(
Enr::empty(&sk).unwrap(),
sk,
discv5::ConfigBuilder::new(ListenConfig::default()).build(),
discv5::ConfigBuilder::new(DEFAULT_DISCOVERY_V5_LISTEN_CONFIG).build(),
)
.unwrap(),
),
Expand Down

0 comments on commit 84db469

Please sign in to comment.