Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Fix attestation performance API InvalidValidatorIndex error #3503

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions beacon_node/http_api/src/attestation_performance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ pub fn get_attestation_performance<T: BeaconChainTypes>(
}

// Either use the global validator set, or the specified index.
//
// Does no further validation of the indices, so in the event an index has not yet been
// activated or does not yet exist (according to the head state), it will return all fields as
// `false`.
let index_range = if target.to_lowercase() == "global" {
chain
.with_head(|head| Ok((0..head.beacon_state.validators().len() as u64).collect()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ impl<T: EthSpec> EpochProcessingSummary<T> {
EpochProcessingSummary::Altair {
participation_cache,
..
} => participation_cache.is_current_epoch_timely_target_attester(val_index),
} => participation_cache
.is_current_epoch_timely_target_attester(val_index)
.or_else(|e| match e {
ParticipationCacheError::InvalidValidatorIndex(_) => Ok(false),
e => Err(e),
}),
}
}

Expand Down Expand Up @@ -222,7 +227,12 @@ impl<T: EthSpec> EpochProcessingSummary<T> {
EpochProcessingSummary::Altair {
participation_cache,
..
} => participation_cache.is_previous_epoch_timely_target_attester(val_index),
} => participation_cache
.is_previous_epoch_timely_target_attester(val_index)
.or_else(|e| match e {
ParticipationCacheError::InvalidValidatorIndex(_) => Ok(false),
e => Err(e),
}),
}
}

Expand All @@ -248,7 +258,12 @@ impl<T: EthSpec> EpochProcessingSummary<T> {
EpochProcessingSummary::Altair {
participation_cache,
..
} => participation_cache.is_previous_epoch_timely_head_attester(val_index),
} => participation_cache
.is_previous_epoch_timely_head_attester(val_index)
.or_else(|e| match e {
ParticipationCacheError::InvalidValidatorIndex(_) => Ok(false),
e => Err(e),
}),
}
}

Expand All @@ -274,7 +289,12 @@ impl<T: EthSpec> EpochProcessingSummary<T> {
EpochProcessingSummary::Altair {
participation_cache,
..
} => participation_cache.is_previous_epoch_timely_source_attester(val_index),
} => participation_cache
.is_previous_epoch_timely_source_attester(val_index)
.or_else(|e| match e {
ParticipationCacheError::InvalidValidatorIndex(_) => Ok(false),
e => Err(e),
}),
}
}

Expand Down