mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 12:11:59 +00:00
Set graffiti per validator (#2044)
## Issue Addressed Resolves #1944 ## Proposed Changes Adds a "graffiti" key to the `validator_definitions.yml`. Setting the key will override anything passed through the validator `--graffiti` flag. Returns an error if the value for the graffiti key is > 32 bytes instead of silently truncating.
This commit is contained in:
@@ -20,7 +20,7 @@ use std::collections::{HashMap, HashSet};
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
use types::{Keypair, PublicKey};
|
||||
use types::{Graffiti, Keypair, PublicKey};
|
||||
|
||||
use crate::key_cache;
|
||||
use crate::key_cache::KeyCache;
|
||||
@@ -86,6 +86,7 @@ pub enum SigningMethod {
|
||||
/// A validator that is ready to sign messages.
|
||||
pub struct InitializedValidator {
|
||||
signing_method: SigningMethod,
|
||||
graffiti: Option<Graffiti>,
|
||||
}
|
||||
|
||||
impl InitializedValidator {
|
||||
@@ -213,6 +214,7 @@ impl InitializedValidator {
|
||||
voting_keystore: voting_keystore.clone(),
|
||||
voting_keypair,
|
||||
},
|
||||
graffiti: def.graffiti.map(Into::into),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -363,6 +365,11 @@ impl InitializedValidators {
|
||||
.map(|def| def.enabled)
|
||||
}
|
||||
|
||||
/// Returns the `graffiti` for a given public key specified in the `ValidatorDefinitions`.
|
||||
pub fn graffiti(&self, public_key: &PublicKey) -> Option<Graffiti> {
|
||||
self.validators.get(public_key).and_then(|v| v.graffiti)
|
||||
}
|
||||
|
||||
/// Sets the `InitializedValidator` and `ValidatorDefinition` `enabled` values.
|
||||
///
|
||||
/// ## Notes
|
||||
@@ -533,7 +540,7 @@ impl InitializedValidators {
|
||||
info!(
|
||||
self.log,
|
||||
"Enabled validator";
|
||||
"voting_pubkey" => format!("{:?}", def.voting_public_key)
|
||||
"voting_pubkey" => format!("{:?}", def.voting_public_key),
|
||||
);
|
||||
|
||||
if let Some(lockfile_path) = existing_lockfile_path {
|
||||
|
||||
Reference in New Issue
Block a user