Skip to content

Commit

Permalink
fix: defaultdict access dont raise KeyError
Browse files Browse the repository at this point in the history
  • Loading branch information
madlabman committed Sep 9, 2024
1 parent dbd4a62 commit 47a888e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/modules/csm/csm.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,18 @@ def calculate_distribution(
continue

for v in validators:
try:
aggr = self.state.data[ValidatorIndex(int(v.index))]
except KeyError:
aggr = self.state.data.get(ValidatorIndex(int(v.index)))

if aggr is None:
# It's possible that the validator is not assigned to any duty, hence it's performance
# is not presented in the aggregates (e.g. exited, pending for activation etc).
continue
else:
if v.validator.slashed is True:
# It means that validator was active during the frame and got slashed and didn't meet the exit
# epoch, so we should not count such validator for operator's share.
log.operators[no_id].validators[v.index].slashed = True
continue

if v.validator.slashed is True:
# It means that validator was active during the frame and got slashed and didn't meet the exit
# epoch, so we should not count such validator for operator's share.
log.operators[no_id].validators[v.index].slashed = True
continue

if aggr.perf > threshold:
# Count of assigned attestations used as a metrics of time
Expand Down

0 comments on commit 47a888e

Please sign in to comment.