Add iter_validators_by_ids - #834
Merged
Merged
Conversation
cyc60
approved these changes
Sep 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
iter_validators_by_idsinsrc/validators/consensus.py— an async generator that fetches beacon validators in chunks ofsettings.validators_fetch_chunk_sizeand yields flatConsensusValidatorinstances. Callers no longer deal with batching or with the raw beacon dict.consensus_clientdefaults to the shared singleton, imported asdefault_consensus_client. It is overridable becausenode-statusdeliberately builds its own non-retry, 10s-timeout client to fail fast.Changes
src/validators/consensus.py— newiter_validators_by_ids;fetch_consensus_validatorsbecomes a one-line async comprehension over it.src/exits/consensus.py— replaces manualrange()slicing;int(beacon_validator['index'])and the raw pubkey lookup becomevalidator.index/validator.public_key.src/commands/recover.py— replaces manualrange()slicing; the pubkey/status normalization collapses tovalidator_statuses[validator.public_key] = validator.status.src/nodewise/status.py—_get_number_of_active_validatorsnow iterates instead of issuing one unbatched request for every keystore public key, passing its own fail-fast client.Normalization (0x-prefixing the pubkey,
int()on the index,ValidatorStatus(...)on the status) now happens in one place:ConsensusValidator.from_consensus_data.Behavior notes
get_validator_public_keysinsrc/exits/consensus.pynow returns 0x-prefixed public keys, consistent with the rest of the codebase.nodewisevalidator activity stats are now batched. Previously all keystore public keys went out in a single request, which could exceed request-size limits on a large keystore directory.Tests
patch_consensus_clienthelper insrc/common/tests/utils.pyreplaces 11 copies of the samepatch('src.validators.consensus...')string across three test files.@contextmanagerfunctions annotated-> Iterator[...]are deprecated in typeshed; switched toGenerator[..., None, None]in the touched test files.