Optimize strategy for onboarding builders at the fork - #5254
Conversation
jtraglia
left a comment
There was a problem hiding this comment.
Hey @twoeths thanks for the PR! I actually really like this change. There could be a lot of new validator deposits at the fork and being forced to verify all of these then is impractical. Your change makes that a little better; it will only do a signature check when there are validator/builder deposits with the same pubkey (which is unlikely). The only concern I have with this approach is that we will iterate over the list of pending deposits a lot, but I expect this is still much faster than the signature checks.
implementations should cache pending deposits by pubkey, lodestar implementation: ChainSafe/lodestar#9374 |
|
Here is another version of def onboard_builders_from_pending_deposits(state: BeaconState) -> None:
"""
Applies any pending deposit for builders, effectively
onboarding builders at the fork.
"""
validator_pubkeys = [v.pubkey for v in state.validators]
pending_deposits = []
for deposit in state.pending_deposits:
# Deposits for existing validators stay in pending queue
if deposit.pubkey in validator_pubkeys:
pending_deposits.append(deposit)
continue
# Note that the function apply_deposit_for_builder can mutate the
# state and may add a builder to the registry. For this reason, the
# list of builder pubkeys must be recomputed each iteration.
builder_pubkeys = [b.pubkey for b in state.builders]
if deposit.pubkey not in builder_pubkeys:
# Deposits for new validators stay in pending queue
if not is_builder_withdrawal_credential(deposit.withdrawal_credentials):
pending_deposits.append(deposit)
continue
# If there is a valid pending deposit for a new validator with this pubkey,
# keep this deposit in the pending queue to be applied to that validator later
if is_pending_validator(pending_deposits, deposit.pubkey):
pending_deposits.append(deposit)
continue
# Apply a deposit for a builder
apply_deposit_for_builder(
state,
deposit.pubkey,
deposit.withdrawal_credentials,
deposit.amount,
deposit.signature,
deposit.slot,
)
state.pending_deposits = pending_deposits |
|
I'm going to make an executive decision to include this PR in the upcoming release. |
**Motivation** - Implements [ethereum/consensus-specs#5254](ethereum/consensus-specs#5254). Avoid eager BLS signature verification of the whole `pending_deposits` queue when onboarding builders at the Gloas fork transition. - Also improve `processDepositRequest()` in Gloas to avoid eager BLS signature verification of the whole `pending_deposits` queue. This does not need a spec change. **Description** - implement `PendingDepositsLookup` grouped by pubkey, track verified deposits so we will never do it again. This is also a preparation when we move it to EpochCache or higher level cache. - Reworks `onboardBuildersFromPendingDeposits` at the Fulu→Gloas fork transition to mirror the new spec structure. Behavior change from the spec PR: invalid-signature validator deposits now stay in the pending queue (previously dropped). - Threads a shared lookup through `applyParentExecutionPayload → processDepositRequest` so successive deposit-requests in the same envelope share verification results. The lookup is kept as a faithful mirror of `state.pendingDeposits`. - Adds unit tests for `PendingDepositsLookup`. **AI Assistance Disclosure** Used Claude Code. --------- Co-authored-by: Tuyen Nguyen <twoeths@users.noreply.github.com>



Description
pending_depositsqueue when onboard builders at fork transitionthis is under discussion, making this as Draft in the mean time