Skip to content

Check pending deposits before applying builder deposits#16532

Open
terencechain wants to merge 6 commits intodevelopfrom
fix-check-pending-deposit-before-builder
Open

Check pending deposits before applying builder deposits#16532
terencechain wants to merge 6 commits intodevelopfrom
fix-check-pending-deposit-before-builder

Conversation

@terencechain
Copy link
Collaborator

@terencechain terencechain commented Mar 13, 2026

Add IsPendingValidator check to processDepositRequest so that deposit requests with builder credentials are routed to the validator pending queue when a pending deposit with a valid signature already exists for the same pubkey

Also updated spec test to alpha3 so we can merge this with green CI/CD

@terencechain terencechain force-pushed the fix-check-pending-deposit-before-builder branch from 735e016 to f93de93 Compare March 15, 2026 21:23
@terencechain terencechain self-assigned this Mar 16, 2026
@@ -0,0 +1,3 @@
### Fixed
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not merging these 2 changelogs in a single changelog file?

Signature: deposit.Signature,
})
if err != nil {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really want to silence this error?
I understand we do not want to immediately return in such a case, but maybe could we print a WARNING/ERROR log?

Comment on lines 135 to 149
_, isValidator := beaconState.ValidatorIndexByPubkey(pubkey)
idx, isBuilder := beaconState.BuilderIndexByPubkey(pubkey)
isBuilderPrefix := helpers.IsBuilderWithdrawalCredential(request.WithdrawalCredentials)
if !isBuilder {
isPending, err := beaconState.IsPendingValidator(request.Pubkey)
if err != nil {
return false, err
}
if isPending {
return false, nil
}
}
if !isBuilder && (!isBuilderPrefix || isValidator) {
return false, nil
}
Copy link
Contributor

@nalepae nalepae Mar 18, 2026

Choose a reason for hiding this comment

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

I feel the whole function (less complex conditions) would be simpler with:

func applyBuilderDepositRequest(beaconState state.BeaconState, request *enginev1.DepositRequest) (bool, error) {
	if beaconState.Version() < version.Gloas {
		return false, nil
	}

	pubkey := bytesutil.ToBytes48(request.Pubkey)
	idx, isBuilder := beaconState.BuilderIndexByPubkey(pubkey)
	if isBuilder {
		if err := beaconState.IncreaseBuilderBalance(idx, request.Amount); err != nil {
			return false, fmt.Errorf("increase builder balance: %w", err)
		}
		return true, nil
	}

	isBuilderPrefix := helpers.IsBuilderWithdrawalCredential(request.WithdrawalCredentials)
	_, isValidator := beaconState.ValidatorIndexByPubkey(pubkey)
	if !isBuilderPrefix || isValidator {
		return false, nil
	}

	isPending, err := beaconState.IsPendingValidator(request.Pubkey)
	if err != nil {
		return false, fmt.Errorf("check pending validator: %w", err)
	}
	if isPending {
		return false, nil
	}

	if err := applyDepositForNewBuilder(
		beaconState,
		request.Pubkey,
		request.WithdrawalCredentials,
		request.Amount,
		request.Signature,
	); err != nil {
		return false, fmt.Errorf("apply deposit for new builder: %w", err)
	}

	return true, nil
}

Copy link
Contributor

@nalepae nalepae left a comment

Choose a reason for hiding this comment

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

Not related to this PR, but it seems that the builderDepositsProcessedTotal metric is increases, event the deposit processed is NOT from a builder.

@terencechain terencechain enabled auto-merge March 18, 2026 14:32
@terencechain terencechain added this pull request to the merge queue Mar 18, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 18, 2026
@terencechain terencechain added this pull request to the merge queue Mar 18, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 18, 2026
@terencechain terencechain added this pull request to the merge queue Mar 18, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 18, 2026
@terencechain terencechain added this pull request to the merge queue Mar 18, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 18, 2026
@terencechain terencechain added this pull request to the merge queue Mar 19, 2026
@terencechain terencechain removed this pull request from the merge queue due to a manual request Mar 19, 2026
@james-prysm james-prysm enabled auto-merge March 19, 2026 16:13
@james-prysm james-prysm disabled auto-merge March 19, 2026 16:16
@james-prysm james-prysm moved this from Unassigned to In review in Gloas Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants