mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 16:55:46 +00:00
Encode Execution Engine Client Version In Graffiti (#5290)
* Add `engine_clientVersionV1` structs * Implement `engine_clientVersionV1` * Update to latest spec changes * Implement GraffitiCalculator Service * Added Unit Tests for GraffitiCalculator * Address Mac's Comments * Remove need to use clap in beacon chain * Merge remote-tracking branch 'upstream/unstable' into el_client_version_graffiti * Merge branch 'unstable' into el_client_version_graffiti # Conflicts: # beacon_node/beacon_chain/Cargo.toml
This commit is contained in:
@@ -5,9 +5,11 @@ use beacon_node::beacon_chain::chain_config::{
|
||||
DisallowedReOrgOffsets, DEFAULT_RE_ORG_CUTOFF_DENOMINATOR, DEFAULT_RE_ORG_HEAD_THRESHOLD,
|
||||
DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION,
|
||||
};
|
||||
use beacon_node::beacon_chain::graffiti_calculator::GraffitiOrigin;
|
||||
use beacon_processor::BeaconProcessorConfig;
|
||||
use eth1::Eth1Endpoint;
|
||||
use lighthouse_network::PeerId;
|
||||
use lighthouse_version;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
|
||||
@@ -296,13 +298,36 @@ fn graffiti_flag() {
|
||||
.flag("graffiti", Some("nice-graffiti"))
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
assert!(matches!(
|
||||
config.beacon_graffiti,
|
||||
GraffitiOrigin::UserSpecified(_)
|
||||
));
|
||||
assert_eq!(
|
||||
config.graffiti.to_string(),
|
||||
"0x6e6963652d677261666669746900000000000000000000000000000000000000"
|
||||
config.beacon_graffiti.graffiti().to_string(),
|
||||
"0x6e6963652d677261666669746900000000000000000000000000000000000000",
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_graffiti() {
|
||||
use types::GRAFFITI_BYTES_LEN;
|
||||
// test default graffiti when no graffiti flags are provided
|
||||
CommandLineTest::new()
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
assert!(matches!(
|
||||
config.beacon_graffiti,
|
||||
GraffitiOrigin::Calculated(_)
|
||||
));
|
||||
let version_bytes = lighthouse_version::VERSION.as_bytes();
|
||||
let trimmed_len = std::cmp::min(version_bytes.len(), GRAFFITI_BYTES_LEN);
|
||||
let mut bytes = [0u8; GRAFFITI_BYTES_LEN];
|
||||
bytes[..trimmed_len].copy_from_slice(&version_bytes[..trimmed_len]);
|
||||
assert_eq!(config.beacon_graffiti.graffiti().0, bytes);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trusted_peers_flag() {
|
||||
let peers = vec![PeerId::random(), PeerId::random()];
|
||||
@@ -1201,7 +1226,17 @@ fn private_flag() {
|
||||
CommandLineTest::new()
|
||||
.flag("private", None)
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert!(config.network.private));
|
||||
.with_config(|config| {
|
||||
assert!(config.network.private);
|
||||
assert!(matches!(
|
||||
config.beacon_graffiti,
|
||||
GraffitiOrigin::UserSpecified(_)
|
||||
));
|
||||
assert_eq!(
|
||||
config.beacon_graffiti.graffiti().to_string(),
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000000".to_string(),
|
||||
);
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn zero_ports_flag() {
|
||||
|
||||
Reference in New Issue
Block a user