Skip to content

Optimize strategy for onboarding builders at the fork - #5254

Merged
jtraglia merged 4 commits into
ethereum:masterfrom
twoeths:te/onboard_buidlers_defer_validate_signatures
May 15, 2026
Merged

Optimize strategy for onboarding builders at the fork#5254
jtraglia merged 4 commits into
ethereum:masterfrom
twoeths:te/onboard_buidlers_defer_validate_signatures

Conversation

@twoeths

@twoeths twoeths commented May 15, 2026

Copy link
Copy Markdown
Contributor

Description

  • avoid eager signature validation for the whole pending_deposits queue when onboard builders at fork transition
  • this keeps front-running resistance semantic of the current spec while helping the fork transition runs faster

this is under discussion, making this as Draft in the mean time

@github-actions github-actions Bot added testing CI, actions, tests, testing infra gloas labels May 15, 2026
@jtraglia jtraglia changed the title fix: defer signature validation when onboard builders Optimize strategy for onboarding builders at the fork May 15, 2026

@jtraglia jtraglia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jtraglia
jtraglia requested a review from jihoonsong May 15, 2026 04:42
@twoeths

twoeths commented May 15, 2026

Copy link
Copy Markdown
Contributor Author

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
this is just the same to is_pending_validator(), implementation should have different caching strategies there I believe

@jihoonsong

jihoonsong commented May 15, 2026

Copy link
Copy Markdown
Member

Here is another version of onboard_builders_from_pending_deposits. I've refactored it so the flow reads as: filter out deposits for validator and then apply the rest as builder deposits. I believe it's equivalent and all tests pass, but I'd appreciate a cross-check.

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

@jtraglia
jtraglia marked this pull request as ready for review May 15, 2026 13:29
@jtraglia

jtraglia commented May 15, 2026

Copy link
Copy Markdown
Member

There's some support for this from client devs on discord:

Potuz

image

Terence

image

Stefan

image

@jtraglia

Copy link
Copy Markdown
Member

I'm going to make an executive decision to include this PR in the upcoming release.

@jtraglia
jtraglia merged commit 932c6d6 into ethereum:master May 15, 2026
15 checks passed
twoeths added a commit to ChainSafe/lodestar that referenced this pull request May 18, 2026
**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>
@zilm13 zilm13 mentioned this pull request May 18, 2026
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gloas testing CI, actions, tests, testing infra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants