mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-03 04:44:28 +00:00
Fix the validator monitor
This commit is contained in:
@@ -360,13 +360,22 @@ impl ParticipationCache {
|
|||||||
* Active/Unslashed
|
* Active/Unslashed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pub fn is_active_unslashed_in_previous_epoch(&self, _val_index: usize) -> bool {
|
pub fn is_active_unslashed_in_previous_epoch(&self, val_index: usize) -> bool {
|
||||||
false
|
self.validators
|
||||||
|
.info
|
||||||
|
.get(&val_index)
|
||||||
|
.map_or(false, |validator| {
|
||||||
|
validator.is_active_previous_epoch && !validator.is_slashed
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_active_unslashed_in_current_epoch(&self, _val_index: usize) -> bool {
|
pub fn is_active_unslashed_in_current_epoch(&self, val_index: usize) -> bool {
|
||||||
// FIXME(sproul): work out how to serve this for the validator API
|
self.validators
|
||||||
false
|
.info
|
||||||
|
.get(&val_index)
|
||||||
|
.map_or(false, |validator| {
|
||||||
|
validator.is_active_current_epoch && !validator.is_slashed
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_validator(&self, val_index: usize) -> Result<&ValidatorInfo, Error> {
|
pub fn get_validator(&self, val_index: usize) -> Result<&ValidatorInfo, Error> {
|
||||||
@@ -379,35 +388,52 @@ impl ParticipationCache {
|
|||||||
/*
|
/*
|
||||||
* Flags
|
* Flags
|
||||||
*/
|
*/
|
||||||
// FIXME(sproul): broken
|
|
||||||
|
|
||||||
/// Always returns false for a slashed validator.
|
/// Always returns false for a slashed validator.
|
||||||
pub fn is_previous_epoch_timely_source_attester(
|
pub fn is_previous_epoch_timely_source_attester(
|
||||||
&self,
|
&self,
|
||||||
_val_index: usize,
|
val_index: usize,
|
||||||
) -> Result<bool, Error> {
|
) -> Result<bool, Error> {
|
||||||
Ok(false)
|
self.validators
|
||||||
|
.info
|
||||||
|
.get(&val_index)
|
||||||
|
.map_or(Ok(false), |validator| {
|
||||||
|
Ok(!validator.is_slashed
|
||||||
|
&& validator
|
||||||
|
.previous_epoch_participation
|
||||||
|
.has_flag(TIMELY_SOURCE_FLAG_INDEX)
|
||||||
|
.map_err(|_| Error::InvalidFlagIndex(TIMELY_SOURCE_FLAG_INDEX))?)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Always returns false for a slashed validator.
|
/// Always returns false for a slashed validator.
|
||||||
pub fn is_previous_epoch_timely_target_attester(
|
pub fn is_previous_epoch_timely_target_attester(
|
||||||
&self,
|
&self,
|
||||||
_val_index: usize,
|
val_index: usize,
|
||||||
) -> Result<bool, Error> {
|
) -> Result<bool, Error> {
|
||||||
Ok(false)
|
self.validators
|
||||||
|
.info
|
||||||
|
.get(&val_index)
|
||||||
|
.map_or(Ok(false), |validator| {
|
||||||
|
Ok(!validator.is_slashed
|
||||||
|
&& validator
|
||||||
|
.previous_epoch_participation
|
||||||
|
.has_flag(TIMELY_TARGET_FLAG_INDEX)
|
||||||
|
.map_err(|_| Error::InvalidFlagIndex(TIMELY_TARGET_FLAG_INDEX))?)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Always returns false for a slashed validator.
|
/// Always returns false for a slashed validator.
|
||||||
pub fn is_previous_epoch_timely_head_attester(&self, _val_index: usize) -> Result<bool, Error> {
|
pub fn is_previous_epoch_timely_head_attester(&self, val_index: usize) -> Result<bool, Error> {
|
||||||
Ok(false)
|
self.validators
|
||||||
}
|
.info
|
||||||
|
.get(&val_index)
|
||||||
/// Always returns false for a slashed validator.
|
.map_or(Ok(false), |validator| {
|
||||||
pub fn is_current_epoch_timely_source_attester(
|
Ok(!validator.is_slashed
|
||||||
&self,
|
&& validator
|
||||||
_val_index: usize,
|
.previous_epoch_participation
|
||||||
) -> Result<bool, Error> {
|
.has_flag(TIMELY_HEAD_FLAG_INDEX)
|
||||||
Ok(false)
|
.map_err(|_| Error::InvalidFlagIndex(TIMELY_TARGET_FLAG_INDEX))?)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Always returns false for a slashed validator.
|
/// Always returns false for a slashed validator.
|
||||||
@@ -415,6 +441,8 @@ impl ParticipationCache {
|
|||||||
&self,
|
&self,
|
||||||
_val_index: usize,
|
_val_index: usize,
|
||||||
) -> Result<bool, Error> {
|
) -> Result<bool, Error> {
|
||||||
|
// FIXME(sproul): decide whether it's worth storing the current epoch participation flags
|
||||||
|
// *just* for this call. Perhaps the validator API could source it from the state directly.
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user