diff --git a/eth_validator_watcher/beacon.py b/eth_validator_watcher/beacon.py index c3576de..febecd0 100644 --- a/eth_validator_watcher/beacon.py +++ b/eth_validator_watcher/beacon.py @@ -41,17 +41,17 @@ def __init__(self, url: str) -> None: self.__http = Session() self.__nimbus_first_liveness_call = False - self.__http.mount( - "http://", - HTTPAdapter( - max_retries=Retry( - backoff_factor=0.5, - total=3, - status_forcelist=[codes.not_found], - ) - ), + adapter = HTTPAdapter( + max_retries=Retry( + backoff_factor=0.5, + total=3, + status_forcelist=[codes.not_found], + ) ) + self.__http.mount("http://", adapter) + self.__http.mount("https://", adapter) + def get_genesis(self) -> Genesis: """Get genesis data.""" response = self.__http.get(f"{self.__url}/eth/v1/beacon/genesis") @@ -67,6 +67,7 @@ def get_block(self, slot: int) -> Block: """ try: response = self.__http.get(f"{self.__url}/eth/v2/beacon/blocks/{slot}") + except RetryError as e: # If we are here, it means the block does not exist raise NoBlockError from e diff --git a/eth_validator_watcher/execution.py b/eth_validator_watcher/execution.py index a0da29a..476b6fe 100644 --- a/eth_validator_watcher/execution.py +++ b/eth_validator_watcher/execution.py @@ -18,17 +18,17 @@ def __init__(self, url: str) -> None: self.__url = url self.__http = Session() - self.__http.mount( - "http://", - HTTPAdapter( - max_retries=Retry( - backoff_factor=0.5, - total=3, - status_forcelist=[codes.not_found], - ) - ), + adapter = HTTPAdapter( + max_retries=Retry( + backoff_factor=0.5, + total=3, + status_forcelist=[codes.not_found], + ) ) + self.__http.mount("http://", adapter) + self.__http.mount("https://", adapter) + def eth_get_block_by_hash(self, hash: str) -> ExecutionBlock: """Get execution block. diff --git a/eth_validator_watcher/relays.py b/eth_validator_watcher/relays.py index 1f44281..312b36a 100644 --- a/eth_validator_watcher/relays.py +++ b/eth_validator_watcher/relays.py @@ -27,17 +27,17 @@ def __init__(self, urls: list[str]) -> None: self.__urls = urls self.__http = Session() - self.__http.mount( - "http://", - HTTPAdapter( - max_retries=Retry( - backoff_factor=0.5, - total=3, - status_forcelist=[codes.not_found], - ) - ), + adapter = HTTPAdapter( + max_retries=Retry( + backoff_factor=0.5, + total=3, + status_forcelist=[codes.not_found], + ) ) + self.__http.mount("http://", adapter) + self.__http.mount("https://", adapter) + def process(self, slot: int) -> None: """Detect if the block was built by a known relay. diff --git a/eth_validator_watcher/slashed_validators.py b/eth_validator_watcher/slashed_validators.py index f8c23e3..2f3fdf0 100644 --- a/eth_validator_watcher/slashed_validators.py +++ b/eth_validator_watcher/slashed_validators.py @@ -105,7 +105,7 @@ def process( for index in not_our_new_exited_slashed_indexes: print( - f"✂️ validator {total_exited_slashed_index_to_validator[index].pubkey[:10]} is slashed" + f"✂️ validator {total_exited_slashed_index_to_validator[index].pubkey[:10]} is slashed" ) for index in our_new_exited_slashed_indexes: