Skip to content

Commit

Permalink
feat: increase timeouts towards beacons to handle Holesky scale
Browse files Browse the repository at this point in the history
  • Loading branch information
aimxhaisse committed Nov 9, 2023
1 parent 9d58a5a commit 3044c6c
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions eth_validator_watcher/beacon.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@

StatusEnum = Validators.DataItem.StatusEnum


# Hard-coded for now, will need to move this to a config.
TIMEOUT_BEACON_SEC = 90


print = functools.partial(print, flush=True)


Expand Down Expand Up @@ -109,7 +114,7 @@ def __post_retry_not_found(self, *args: Any, **kwargs: Any) -> Response:
def get_genesis(self) -> Genesis:
"""Get genesis data."""
response = self.__get_retry_not_found(
f"{self.__url}/eth/v1/beacon/genesis", timeout=5
f"{self.__url}/eth/v1/beacon/genesis", timeout=TIMEOUT_BEACON_SEC
)
response.raise_for_status()
genesis_dict = response.json()
Expand All @@ -124,7 +129,7 @@ def get_header(self, block_identifier: Union[BlockIdentierType, int]) -> Header:
"""
try:
response = self.__get(
f"{self.__url}/eth/v1/beacon/headers/{block_identifier}", timeout=5
f"{self.__url}/eth/v1/beacon/headers/{block_identifier}", timeout=TIMEOUT_BEACON_SEC
)

response.raise_for_status()
Expand All @@ -148,7 +153,7 @@ def get_block(self, slot: int) -> Block:
"""
try:
response = self.__get(
f"{self.__url}/eth/v2/beacon/blocks/{slot}", timeout=5
f"{self.__url}/eth/v2/beacon/blocks/{slot}", timeout=TIMEOUT_BEACON_SEC
)

response.raise_for_status()
Expand All @@ -171,7 +176,7 @@ def get_proposer_duties(self, epoch: int) -> ProposerDuties:
epoch: Epoch corresponding to the proposer duties to retrieve
"""
response = self.__get_retry_not_found(
f"{self.__url}/eth/v1/validator/duties/proposer/{epoch}", timeout=10
f"{self.__url}/eth/v1/validator/duties/proposer/{epoch}", timeout=TIMEOUT_BEACON_SEC
)

response.raise_for_status()
Expand All @@ -188,7 +193,7 @@ def get_status_to_index_to_validator(
inner value : Validator
"""
response = self.__get_retry_not_found(
f"{self.__url}/eth/v1/beacon/states/head/validators", timeout=25
f"{self.__url}/eth/v1/beacon/states/head/validators", timeout=TIMEOUT_BEACON_SEC
)

response.raise_for_status()
Expand Down Expand Up @@ -221,7 +226,7 @@ def get_duty_slot_to_committee_index_to_validators_index(
response = self.__get_retry_not_found(
f"{self.__url}/eth/v1/beacon/states/head/committees",
params=dict(epoch=epoch),
timeout=10,
timeout=TIMEOUT_BEACON_SEC,
)

response.raise_for_status()
Expand Down Expand Up @@ -284,7 +289,7 @@ def get_rewards(
if validators_index is not None
else []
),
timeout=10,
timeout=TIMEOUT_BEACON_SEC,
)

response.raise_for_status()
Expand Down Expand Up @@ -387,7 +392,7 @@ def __get_validators_liveness_lighthouse(
json=ValidatorsLivenessRequestLighthouse(
epoch=epoch, indices=sorted(list(validators_index))
).model_dump(),
timeout=10,
timeout=TIMEOUT_BEACON_SEC,
)

def __get_validators_liveness_old_teku(
Expand All @@ -407,7 +412,7 @@ def __get_validators_liveness_old_teku(
json=ValidatorsLivenessRequestTeku(
indices=sorted(list(validators_index))
).model_dump(),
timeout=10,
timeout=TIMEOUT_BEACON_SEC,
)

def __get_validators_liveness_beacon_api(
Expand All @@ -428,5 +433,5 @@ def __get_validators_liveness_beacon_api(
str(validator_index)
for validator_index in sorted(list(validators_index))
],
timeout=10,
timeout=TIMEOUT_BEACON_SEC,
)

0 comments on commit 3044c6c

Please sign in to comment.