From 8124e5ca5a1f6b67a5137bfa25be18285d7b80ee Mon Sep 17 00:00:00 2001 From: JKincorperated <73645805+JKincorperated@users.noreply.github.com> Date: Fri, 10 Jan 2025 13:01:36 +0000 Subject: [PATCH] Add eip7636 support --- beacon_node/lighthouse_network/src/config.rs | 4 ++++ .../lighthouse_network/src/discovery/enr.rs | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/beacon_node/lighthouse_network/src/config.rs b/beacon_node/lighthouse_network/src/config.rs index 8a93b1185db..c376e7034ea 100644 --- a/beacon_node/lighthouse_network/src/config.rs +++ b/beacon_node/lighthouse_network/src/config.rs @@ -146,6 +146,9 @@ pub struct Config { /// Configuration for the minimum message size for which IDONTWANT messages are send in the mesh. /// Lower the value reduces the optimization effect of the IDONTWANT messages. pub idontwant_message_size_threshold: usize, + + /// Whether to send EIP 7636 information to clients. + pub send_eip_7636_info: bool, } impl Config { @@ -358,6 +361,7 @@ impl Default for Config { invalid_block_storage: None, inbound_rate_limiter_config: None, idontwant_message_size_threshold: DEFAULT_IDONTWANT_MESSAGE_SIZE_THRESHOLD, + send_eip_7636_info: true, } } } diff --git a/beacon_node/lighthouse_network/src/discovery/enr.rs b/beacon_node/lighthouse_network/src/discovery/enr.rs index ce29480ffdb..3e107ac5f4e 100644 --- a/beacon_node/lighthouse_network/src/discovery/enr.rs +++ b/beacon_node/lighthouse_network/src/discovery/enr.rs @@ -8,6 +8,7 @@ use crate::types::{Enr, EnrAttestationBitfield, EnrSyncCommitteeBitfield}; use crate::NetworkConfig; use alloy_rlp::bytes::Bytes; use libp2p::identity::Keypair; +use lighthouse_version::VERSION; use slog::{debug, warn}; use ssz::{Decode, Encode}; use ssz_types::BitVector; @@ -188,6 +189,19 @@ pub fn build_enr( builder.udp6(udp6_port.get()); } + // Add EIP 7636 client information + if config.send_eip_7636_info { + let version = VERSION.split("/").collect::>(); + builder.client_info( + version.first().unwrap_or(&"Lighthouse").to_string(), + version + .get(1) + .unwrap_or(&env!("CARGO_PKG_VERSION")) + .to_string(), + None, + ); + } + // Add QUIC fields to the ENR. // Since QUIC is used as an alternative transport for the libp2p protocols, // the related fields should only be added when both QUIC and libp2p are enabled