mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 19:51:47 +00:00
Detailed validator monitoring (#2151)
## Issue Addressed - Resolves #2064 ## Proposed Changes Adds a `ValidatorMonitor` struct which provides additional logging and Grafana metrics for specific validators. Use `lighthouse bn --validator-monitor` to automatically enable monitoring for any validator that hits the [subnet subscription](https://ethereum.github.io/eth2.0-APIs/#/Validator/prepareBeaconCommitteeSubnet) HTTP API endpoint. Also, use `lighthouse bn --validator-monitor-pubkeys` to supply a list of validators which will always be monitored. See the new docs included in this PR for more info. ## TODO - [x] Track validator balance, `slashed` status, etc. - [x] ~~Register slashings in current epoch, not offense epoch~~ - [ ] Publish Grafana dashboard, update TODO link in docs - [x] ~~#2130 is merged into this branch, resolve that~~
This commit is contained in:
@@ -451,4 +451,29 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.value_name("WSS_CHECKPOINT")
|
||||
.takes_value(true)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("validator-monitor-auto")
|
||||
.long("validator-monitor-auto")
|
||||
.help("Enables the automatic detection and monitoring of validators connected to the \
|
||||
HTTP API and using the subnet subscription endpoint. This generally has the \
|
||||
effect of providing additional logging and metrics for locally controlled \
|
||||
validators.")
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("validator-monitor-pubkeys")
|
||||
.long("validator-monitor-pubkeys")
|
||||
.help("A comma-separated list of 0x-prefixed validator public keys. \
|
||||
These validators will receive special monitoring and additional \
|
||||
logging.")
|
||||
.value_name("PUBKEYS")
|
||||
.takes_value(true)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("validator-monitor-file")
|
||||
.long("validator-monitor-file")
|
||||
.help("As per --validator-monitor-pubkeys, but the comma-separated list is \
|
||||
contained within a file at the given path.")
|
||||
.value_name("PATH")
|
||||
.takes_value(true)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ use std::fs;
|
||||
use std::net::{IpAddr, Ipv4Addr, ToSocketAddrs};
|
||||
use std::net::{TcpListener, UdpSocket};
|
||||
use std::path::PathBuf;
|
||||
use types::{ChainSpec, Checkpoint, Epoch, EthSpec, Hash256, GRAFFITI_BYTES_LEN};
|
||||
use std::str::FromStr;
|
||||
use types::{ChainSpec, Checkpoint, Epoch, EthSpec, Hash256, PublicKeyBytes, GRAFFITI_BYTES_LEN};
|
||||
|
||||
/// Gets the fully-initialized global client.
|
||||
///
|
||||
@@ -386,6 +387,39 @@ pub fn get_config<E: EthSpec>(
|
||||
client_config.slasher = Some(slasher_config);
|
||||
}
|
||||
|
||||
if cli_args.is_present("validator-monitor-auto") {
|
||||
client_config.validator_monitor_auto = true;
|
||||
}
|
||||
|
||||
if let Some(pubkeys) = cli_args.value_of("validator-monitor-pubkeys") {
|
||||
let pubkeys = pubkeys
|
||||
.split(',')
|
||||
.map(PublicKeyBytes::from_str)
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.map_err(|e| format!("Invalid --validator-monitor-pubkeys value: {:?}", e))?;
|
||||
client_config
|
||||
.validator_monitor_pubkeys
|
||||
.extend_from_slice(&pubkeys);
|
||||
}
|
||||
|
||||
if let Some(path) = cli_args.value_of("validator-monitor-file") {
|
||||
let string = fs::read(path)
|
||||
.map_err(|e| format!("Unable to read --validator-monitor-file: {}", e))
|
||||
.and_then(|bytes| {
|
||||
String::from_utf8(bytes)
|
||||
.map_err(|e| format!("--validator-monitor-file is not utf8: {}", e))
|
||||
})?;
|
||||
let pubkeys = string
|
||||
.trim_end() // Remove trailing white space
|
||||
.split(',')
|
||||
.map(PublicKeyBytes::from_str)
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.map_err(|e| format!("Invalid --validator-monitor-file contents: {:?}", e))?;
|
||||
client_config
|
||||
.validator_monitor_pubkeys
|
||||
.extend_from_slice(&pubkeys);
|
||||
}
|
||||
|
||||
Ok(client_config)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user