Skip to content

Commit 9401fba

Browse files
petarjuki7diegomrsantos
authored andcommitted
fix(validator_store): filter inactive validators (sigp#589)
sigp#558 Makes sure if a cluster is liquidated that it doesn't get processed. Closes sigp#576
1 parent 7eff9fa commit 9401fba

File tree

1 file changed

+13
-2
lines changed
  • anchor/validator_store/src

1 file changed

+13
-2
lines changed

anchor/validator_store/src/lib.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ impl<T: SlotClock, E: EthSpec> AnchorValidatorStore<T, E> {
166166

167167
// First, attempt to get the cluster normally
168168
if let Some(cluster) = state.clusters().get_by(&validator.cluster_id) {
169+
if cluster.liquidated {
170+
return Err(Error::SpecificError(SpecificError::ClusterLiquidated));
171+
}
169172
return Ok((validator, cluster.clone()));
170173
}
171174

@@ -745,6 +748,7 @@ pub enum SpecificError {
745748
cluster_id: ClusterId,
746749
},
747750
KeyShareDecryptionFailed,
751+
ClusterLiquidated,
748752
}
749753

750754
impl From<CollectionError> for SpecificError {
@@ -792,12 +796,19 @@ impl<T: SlotClock, E: EthSpec> ValidatorStore for AnchorValidatorStore<T, E> {
792796
I: FromIterator<PublicKeyBytes>,
793797
F: Fn(DoppelgangerStatus) -> Option<PublicKeyBytes>,
794798
{
799+
let state = self.database.state();
800+
795801
// Treat all shares as `SigningEnabled`
796-
self.database
797-
.state()
802+
state
798803
.shares()
799804
.values()
800805
.filter_map(|v| filter_func(DoppelgangerStatus::SigningEnabled(v.validator_pubkey)))
806+
.filter(|public_key| {
807+
state
808+
.clusters()
809+
.get_by(public_key)
810+
.is_some_and(|cluster| !cluster.liquidated)
811+
})
801812
.collect()
802813
}
803814

0 commit comments

Comments
 (0)