Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log get_validators_no_cache #568

Merged
merged 7 commits into from
Dec 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/providers/consensus/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

logger = logging.getLogger(__name__)


LiteralState = Literal['head', 'genesis', 'finalized', 'justified']


Expand Down Expand Up @@ -145,10 +144,10 @@ def get_attestation_committees(
@lru_cache(maxsize=1)
def get_state_block_roots(self, state_id: SlotNumber) -> list[BlockRoot]:
streamed_json = cast(TransientStreamingJSONObject, self._get(
self.API_GET_STATE,
path_params=(state_id,),
stream=True,
))
self.API_GET_STATE,
path_params=(state_id,),
stream=True,
))
return list(streamed_json['data']['block_roots'])

@lru_cache(maxsize=1)
Expand All @@ -159,6 +158,12 @@ def get_validators(self, blockstamp: BlockStamp) -> list[Validator]:
@list_of_dataclasses(Validator.from_response)
def get_validators_no_cache(self, blockstamp: BlockStamp, pub_keys: str | tuple | None = None) -> list[dict]:
"""Spec: https://ethereum.github.io/beacon-APIs/#/Beacon/getStateValidators"""
logger.info({
'msg': 'Getting validators...',
'url': self.API_GET_VALIDATORS,
'slot_number': blockstamp.slot_number,
'state_root': blockstamp.state_root,
})
try:
data, _ = self._get(
self.API_GET_VALIDATORS,
Expand All @@ -168,6 +173,7 @@ def get_validators_no_cache(self, blockstamp: BlockStamp, pub_keys: str | tuple
)
if not isinstance(data, list):
raise ValueError("Expected list response from getStateValidators")
logger.info({'msg': f'Fetched {len(data)} validators'})
return data
except NotOkResponse as error:
if self.PRYSM_STATE_NOT_FOUND_ERROR in error.text:
Expand Down
Loading