diff --git a/eth_validator_watcher/beacon.py b/eth_validator_watcher/beacon.py index 5eb7007..41d7bbe 100644 --- a/eth_validator_watcher/beacon.py +++ b/eth_validator_watcher/beacon.py @@ -7,9 +7,8 @@ from requests import Response, Session, codes from requests.adapters import HTTPAdapter, Retry -from requests.exceptions import RetryError +from requests.exceptions import ChunkedEncodingError, RetryError from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_fixed -from requests.exceptions import ChunkedEncodingError from .models import ( BeaconType, diff --git a/eth_validator_watcher/relays.py b/eth_validator_watcher/relays.py index 312b36a..09ca987 100644 --- a/eth_validator_watcher/relays.py +++ b/eth_validator_watcher/relays.py @@ -1,6 +1,7 @@ """Contains the Relays class which is used to interact with the relays.""" from time import sleep + from prometheus_client import Counter from requests import Session, codes from requests.adapters import HTTPAdapter, Retry diff --git a/eth_validator_watcher/rewards.py b/eth_validator_watcher/rewards.py index db63f12..70eec95 100644 --- a/eth_validator_watcher/rewards.py +++ b/eth_validator_watcher/rewards.py @@ -1,11 +1,11 @@ """Contains functions to handle rewards calculation""" from typing import Tuple -from .beacon import Beacon -from .models import BeaconType, Validators -from prometheus_client import Gauge, Counter +from prometheus_client import Counter, Gauge +from .beacon import Beacon +from .models import BeaconType, Validators Validator = Validators.DataItem.Validator @@ -64,7 +64,8 @@ def process_rewards( if len(index_to_validator) == 0: return - data = beacon.get_rewards(beacon_type, epoch - 2, set(index_to_validator)).data + validators_index = set(index_to_validator) + data = beacon.get_rewards(beacon_type, epoch - 2, validators_index).data if len(data.ideal_rewards) == 0 and len(data.total_rewards) == 0: # We probably are connected to a beacon that does not support rewards diff --git a/eth_validator_watcher/utils.py b/eth_validator_watcher/utils.py index ba8a0f7..12d3249 100644 --- a/eth_validator_watcher/utils.py +++ b/eth_validator_watcher/utils.py @@ -1,3 +1,4 @@ +import re from pathlib import Path from time import sleep, time from typing import Any, Iterator, Optional, Tuple @@ -6,8 +7,6 @@ from prometheus_client import Gauge from slack_sdk import WebClient -import re - from .web3signer import Web3Signer NB_SLOT_PER_EPOCH = 32 diff --git a/tests/beacon/test_get_rewards.py b/tests/beacon/test_get_rewards.py index 5e2a27b..9f874f4 100644 --- a/tests/beacon/test_get_rewards.py +++ b/tests/beacon/test_get_rewards.py @@ -4,8 +4,8 @@ from requests_mock import Mocker from eth_validator_watcher.beacon import Beacon -from tests.beacon import assets from eth_validator_watcher.models import BeaconType, Rewards +from tests.beacon import assets def test_get_rewards_not_supported() -> None: diff --git a/tests/entry_queue/test_compute_pessimistic_duration_sec.py b/tests/entry_queue/test_compute_pessimistic_duration_sec.py index f65025e..f496e5f 100644 --- a/tests/entry_queue/test_compute_pessimistic_duration_sec.py +++ b/tests/entry_queue/test_compute_pessimistic_duration_sec.py @@ -1,7 +1,5 @@ from eth_validator_watcher.entry_queue import ( - NB_SECONDS_PER_EPOCH, - compute_pessimistic_duration_sec, -) + NB_SECONDS_PER_EPOCH, compute_pessimistic_duration_sec) def test_compute_pessimistic_duration_sec() -> None: diff --git a/tests/missed_attestations/test_process_missed_attestations.py b/tests/missed_attestations/test_process_missed_attestations.py index 0e74c45..4b9fc8a 100644 --- a/tests/missed_attestations/test_process_missed_attestations.py +++ b/tests/missed_attestations/test_process_missed_attestations.py @@ -1,6 +1,7 @@ from typing import Set -from eth_validator_watcher.missed_attestations import process_missed_attestations +from eth_validator_watcher.missed_attestations import \ + process_missed_attestations from eth_validator_watcher.models import BeaconType, Validators Validator = Validators.DataItem.Validator diff --git a/tests/relays/test_process.py b/tests/relays/test_process.py index e6421a4..2bfe2b5 100644 --- a/tests/relays/test_process.py +++ b/tests/relays/test_process.py @@ -1,7 +1,8 @@ -from eth_validator_watcher.relays import Relays, bad_relay_count -from requests_mock import Mocker from pytest import raises from requests.exceptions import ConnectionError +from requests_mock import Mocker + +from eth_validator_watcher.relays import Relays, bad_relay_count def test_process_no_relay() -> None: diff --git a/tests/rewards/test_process_rewards.py b/tests/rewards/test_process_rewards.py index 9400778..ca7ec0a 100644 --- a/tests/rewards/test_process_rewards.py +++ b/tests/rewards/test_process_rewards.py @@ -1,22 +1,20 @@ -from eth_validator_watcher.models import Rewards, Validators +from math import isclose + +from eth_validator_watcher.models import BeaconType, Rewards, Validators from eth_validator_watcher.rewards import ( - suboptimal_sources_rate_gauge, - suboptimal_targets_rate_gauge, - suboptimal_heads_rate_gauge, - ideal_sources_count, - ideal_targets_count, - ideal_heads_count, - actual_positive_sources_count, + actual_heads_count, actual_negative_sources_count, - actual_positive_targets_count, actual_negative_targets_count, - actual_heads_count, + actual_positive_sources_count, + actual_positive_targets_count, + ideal_heads_count, + ideal_sources_count, + ideal_targets_count, process_rewards, + suboptimal_heads_rate_gauge, + suboptimal_sources_rate_gauge, + suboptimal_targets_rate_gauge, ) -from eth_validator_watcher.models import BeaconType - -from math import isclose - Validator = Validators.DataItem.Validator diff --git a/tests/utils/test_eth1_address_0x_prefixed.py b/tests/utils/test_eth1_address_0x_prefixed.py index 5d526e2..4e1890e 100644 --- a/tests/utils/test_eth1_address_0x_prefixed.py +++ b/tests/utils/test_eth1_address_0x_prefixed.py @@ -1,6 +1,7 @@ -from eth_validator_watcher.utils import eth1_address_0x_prefixed from pytest import raises +from eth_validator_watcher.utils import eth1_address_0x_prefixed + def test_eth1_address_0x_prefixed_invalid() -> None: # Too short diff --git a/tests/utils/test_eth2_address_0x_prefixed.py b/tests/utils/test_eth2_address_0x_prefixed.py index f32a65f..4797bb4 100644 --- a/tests/utils/test_eth2_address_0x_prefixed.py +++ b/tests/utils/test_eth2_address_0x_prefixed.py @@ -1,6 +1,7 @@ -from eth_validator_watcher.utils import eth2_address_0x_prefixed from pytest import raises +from eth_validator_watcher.utils import eth2_address_0x_prefixed + def test_eth2_address_0x_prefixed_invalid() -> None: # Too short