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 2 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
4 changes: 4 additions & 0 deletions beacon_node/lighthouse_network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
}
}
}
Expand Down
13 changes: 13 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, VERSION};
use slog::{debug, warn};
use ssz::{Decode, Encode};
use ssz_types::BitVector;
Expand Down Expand Up @@ -188,6 +189,18 @@ pub fn build_enr<E: EthSpec>(
builder.udp6(udp6_port.get());
}

// Add EIP 7636 client information
if config.send_eip_7636_info {
JKincorperated marked this conversation as resolved.
Show resolved Hide resolved
let name = VERSION
.split("/")
.collect::<Vec<&str>>()
.first()
.unwrap_or(&"Lighthouse")
.to_string();
JKincorperated marked this conversation as resolved.
Show resolved Hide resolved

builder.client_info(name, 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
29 changes: 29 additions & 0 deletions common/lighthouse_version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,25 @@ 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
let mut out = "";
let mut start = 0;
for (i, c) in VERSION.chars().enumerate() {
if c == '-' {
break;
} else if c == 'v' {
start = i + 1;
}
out = &VERSION[start..i + 1];
}
out
}

#[cfg(test)]
mod test {
use super::*;
Expand All @@ -64,4 +83,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