Skip to content

Commit

Permalink
Implement non-reached genesis networks
Browse files Browse the repository at this point in the history
  • Loading branch information
nalepae committed Sep 15, 2023
1 parent f9933bf commit c35f5ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
3 changes: 3 additions & 0 deletions eth_validator_watcher/missed_attestations.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def process_missed_attestations(
inner value : validators
epoch : Epoch where the missed attestations are checked
"""
if epoch < 1:
return set()

index_to_validator: dict[int, Validators.DataItem.Validator] = (
epoch_to_index_to_validator_index[epoch - 1]
if epoch - 1 in epoch_to_index_to_validator_index
Expand Down
16 changes: 5 additions & 11 deletions eth_validator_watcher/rewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
Gauge("net_suboptimal_heads_rate", "Network suboptimal heads rate"),
)

(
net_ideal_sources_count,
net_ideal_targets_count,
net_ideal_heads_count,
) = (
(net_ideal_sources_count, net_ideal_targets_count, net_ideal_heads_count,) = (
Counter("net_ideal_sources_count", "Network ideal sources count"),
Counter("net_ideal_targets_count", "Network ideal targets count"),
Counter("net_ideal_heads_count", "Network ideal heads count"),
Expand Down Expand Up @@ -62,11 +58,7 @@
Gauge("our_suboptimal_heads_rate", "Our suboptimal heads rate"),
)

(
our_ideal_sources_count,
our_ideal_targets_count,
our_ideal_heads_count,
) = (
(our_ideal_sources_count, our_ideal_targets_count, our_ideal_heads_count,) = (
Counter("our_ideal_sources_count", "Our ideal sources count"),
Counter("our_ideal_targets_count", "Our ideal targets count"),
Counter("our_ideal_heads_count", "Our ideal heads count"),
Expand Down Expand Up @@ -140,9 +132,11 @@ def process_rewards(
outer key : epoch
outer value, inner key: validator indexes
inner value : validators
"""

if epoch < 2:
return

# Network validators
# ------------------
net_index_to_validator = (
Expand Down
4 changes: 3 additions & 1 deletion eth_validator_watcher/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ def send_message(self, message: str) -> None:


def slots(genesis_time_sec: int) -> Iterator[Tuple[int, int]]:
next_slot = int((time() - genesis_time_sec) / NB_SECOND_PER_SLOT) + 1
# max(0, ...) is used to avoid negative slot number if genesis time is not yet
# reached
next_slot = max(0, int((time() - genesis_time_sec) / NB_SECOND_PER_SLOT) + 1)

try:
while True:
Expand Down

0 comments on commit c35f5ac

Please sign in to comment.