mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Add EIP-7636 support (#6793)
* Add eip7636 support * Add `version()` to the `lighthouse_version` crate and make the `enr.rs` file use it. * Hardcode version, Add `client_name()`, remove unneeded flag. * Make it use the new function. * Make cargo fmt zip it
This commit is contained in:
@@ -116,7 +116,8 @@ pub struct Config {
|
|||||||
pub network_load: u8,
|
pub network_load: u8,
|
||||||
|
|
||||||
/// Indicates if the user has set the network to be in private mode. Currently this
|
/// 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,
|
pub private: bool,
|
||||||
|
|
||||||
/// Shutdown beacon node after sync is completed.
|
/// Shutdown beacon node after sync is completed.
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use crate::types::{Enr, EnrAttestationBitfield, EnrSyncCommitteeBitfield};
|
|||||||
use crate::NetworkConfig;
|
use crate::NetworkConfig;
|
||||||
use alloy_rlp::bytes::Bytes;
|
use alloy_rlp::bytes::Bytes;
|
||||||
use libp2p::identity::Keypair;
|
use libp2p::identity::Keypair;
|
||||||
|
use lighthouse_version::{client_name, version};
|
||||||
use slog::{debug, warn};
|
use slog::{debug, warn};
|
||||||
use ssz::{Decode, Encode};
|
use ssz::{Decode, Encode};
|
||||||
use ssz_types::BitVector;
|
use ssz_types::BitVector;
|
||||||
@@ -188,6 +189,11 @@ pub fn build_enr<E: EthSpec>(
|
|||||||
builder.udp6(udp6_port.get());
|
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.
|
// Add QUIC fields to the ENR.
|
||||||
// Since QUIC is used as an alternative transport for the libp2p protocols,
|
// 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
|
// the related fields should only be added when both QUIC and libp2p are enabled
|
||||||
|
|||||||
@@ -48,6 +48,22 @@ pub fn version_with_platform() -> String {
|
|||||||
format!("{}/{}-{}", VERSION, Target::arch(), Target::os())
|
format!("{}/{}-{}", VERSION, Target::arch(), Target::os())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns semantic versioning information only.
|
||||||
|
///
|
||||||
|
/// ## Example
|
||||||
|
///
|
||||||
|
/// `1.5.1`
|
||||||
|
pub fn version() -> &'static str {
|
||||||
|
"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)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -64,4 +80,14 @@ mod test {
|
|||||||
VERSION
|
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()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user