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

Add EIP-7636 support #6793

Open
wants to merge 5 commits into
base: unstable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
3 changes: 2 additions & 1 deletion beacon_node/lighthouse_network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ pub struct Config {
pub network_load: u8,

/// Indicates if the user has set the network to be in private mode. Currently this
/// prevents sending client identifying information over identify.
/// prevents sending client identifying information over identify and prevents
/// EIP-7636 indentifiable information being provided in the ENR.
pub private: bool,

/// Shutdown beacon node after sync is completed.
Expand Down
6 changes: 6 additions & 0 deletions beacon_node/lighthouse_network/src/discovery/enr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, client_name};
use slog::{debug, warn};
use ssz::{Decode, Encode};
use ssz_types::BitVector;
Expand Down Expand Up @@ -188,6 +189,11 @@ pub fn build_enr<E: EthSpec>(
builder.udp6(udp6_port.get());
}

// Add EIP 7636 client information
if !config.private {
builder.client_info(client_name().to_string(), 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
Expand Down
27 changes: 27 additions & 0 deletions common/lighthouse_version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ pub fn version_with_platform() -> String {
format!("{}/{}-{}", VERSION, Target::arch(), Target::os())
}

/// Returns semantic versioning information only.
///
/// ## Example
///
/// `1.5.1`
pub fn version() -> &'static str {
JKincorperated marked this conversation as resolved.
Show resolved Hide resolved
"6.0.1"
}

/// Returns the name of the current client running.
///
/// This will usually be "Lighthouse"
pub fn client_name() -> &'static str {
"Lighthouse"
}


#[cfg(test)]
mod test {
use super::*;
Expand All @@ -64,4 +81,14 @@ mod test {
VERSION
);
}

#[test]
fn semantic_version_formatting() {
let re = Regex::new(r"^[0-9]+\.[0-9]+\.[0-9]+").unwrap();
assert!(
re.is_match(version()),
"semantic version doesn't match regex: {}",
version()
);
}
}
Loading