Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ping oldest more often #11988

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions crates/net/discv4/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ use alloy_rlp::Encodable;
use reth_net_banlist::BanList;
use reth_net_nat::{NatResolver, ResolveNatInterval};
use reth_network_peers::NodeRecord;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::{
collections::{HashMap, HashSet},
time::Duration,
};

/// Configuration parameters that define the performance of the discovery network.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Discv4Config {
/// Whether to enable the incoming packet filter. Default: false.
pub enable_packet_filter: bool,
Expand Down Expand Up @@ -118,7 +116,7 @@ impl Default for Discv4Config {
// Every outgoing request will eventually lead to an incoming response
udp_ingress_message_buffer: 1024,
max_find_node_failures: 5,
ping_interval: Duration::from_secs(60 * 10),
ping_interval: Duration::from_secs(10),
// Unified expiration and timeout durations, mirrors geth's `expiration` duration
ping_expiration: Duration::from_secs(20),
bond_expiration: Duration::from_secs(60 * 60),
Expand All @@ -144,7 +142,7 @@ impl Default for Discv4Config {

/// Builder type for [`Discv4Config`]
#[derive(Clone, Debug, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Discv4ConfigBuilder {
config: Discv4Config,
}
Expand Down
6 changes: 4 additions & 2 deletions crates/net/discv4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,9 @@ impl Discv4Service {
false
}

/// Update the entry on RE-ping
/// Update the entry on RE-ping.
///
/// Invoked when we received the Pong to our [`PingReason::RePing`] ping.
///
/// On re-ping we check for a changed `enr_seq` if eip868 is enabled and when it changed we sent
/// a followup request to retrieve the updated ENR
Expand Down Expand Up @@ -2259,7 +2261,7 @@ impl NodeEntry {
impl NodeEntry {
/// Returns true if the node should be re-pinged.
fn is_expired(&self) -> bool {
self.last_seen.elapsed() > ENDPOINT_PROOF_EXPIRATION
self.last_seen.elapsed() > (ENDPOINT_PROOF_EXPIRATION / 2)
}
}

Expand Down
Loading