Add build_consensus_validators builder - #815
Merged
Merged
Conversation
# Conflicts: # src/withdrawals/tasks.py
cyc60
reviewed
Aug 18, 2026
cyc60
previously approved these changes
Aug 19, 2026
cyc60
approved these changes
Aug 19, 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.
Introduces
build_consensus_validators— a single builder that fetches the vault's consensus validators and enriches them with pending deposits and pending consolidations from one consistent chain snapshot. Callers now read that data offConsensusValidatorinstead of threading parallel dicts and index sets around.ConsensusValidatorFour new optional fields, populated only when the corresponding flag is passed:
pending_balance— total amount queued for the validator in the pending deposit queuetarget_consolidation_balance— balance incoming from the validator's pending consolidation sourcesis_consolidation_source,is_consolidation_targetbuild_consensus_validatorswith_pending_depositsfillspending_balanceand additionally returns validators that are not in the beacon state yet but already have pending deposits. Those getUNKNOWN_VALIDATOR_INDEXand take their withdrawal credentials from the deposit.compounding_deposits_onlycounts only 0x02 deposits, which is what the funding path needs.with_consolidationssets the consolidation flags.target_consolidation_balancestaysNonewhen any of a target's sources is outside the fetched set, i.e. its balance is unknown — previously this exclusion was order-dependent inside the loop, now it is not.Callers
fetch_funding_validators_balancesis reduced to an eligibility filter plus a sum over the built validators. Behavior is unchanged.The withdrawal task drops
get_pending_consolidations/fetch_pending_deposits_amountsand their derived arguments:get_queued_assets(consolidations=...)and_calculate_validators_exits_amount(source_consolidations_indexes=...)→is_consolidation_source_get_withdrawals/_filter_exitable_validatorsloseconsolidation_target_indexes,consolidation_source_indexesandpending_deposits→ flags andpending_balanceThe pending deposit queue is still fetched lazily, only once a withdrawal is known to be needed, via the now-public
apply_pending_deposits. Fetching it as part of the initial build would pull the whole queue on every interval tick, including the common case where the task returns early.Non-mutating helpers
Neither enrichment step touches the validators it is given:
_apply_pending_consolidationsreturns a copy of the list, in the original order, with the consolidation fields filled inapply_pending_depositsreturns a tuple of (a copy of the list withpending_balancefilled in, the validators that are missing from the beacon state but present in the pending deposit queue)fetch_pending_deposits_amountshad no callers left and is removed.