Check pending deposits before applying builder deposits#16532
Open
terencechain wants to merge 6 commits intodevelopfrom
Open
Check pending deposits before applying builder deposits#16532terencechain wants to merge 6 commits intodevelopfrom
terencechain wants to merge 6 commits intodevelopfrom
Conversation
735e016 to
f93de93
Compare
nalepae
reviewed
Mar 18, 2026
| @@ -0,0 +1,3 @@ | |||
| ### Fixed | |||
Contributor
There was a problem hiding this comment.
Why not merging these 2 changelogs in a single changelog file?
nalepae
reviewed
Mar 18, 2026
| Signature: deposit.Signature, | ||
| }) | ||
| if err != nil { | ||
| continue |
Contributor
There was a problem hiding this comment.
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?
nalepae
reviewed
Mar 18, 2026
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 | ||
| } |
Contributor
There was a problem hiding this comment.
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
}
nalepae
reviewed
Mar 18, 2026
Contributor
nalepae
left a comment
There was a problem hiding this comment.
Not related to this PR, but it seems that the builderDepositsProcessedTotal metric is increases, event the deposit processed is NOT from a builder.
nalepae
approved these changes
Mar 18, 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.
Add
IsPendingValidatorcheck toprocessDepositRequestso 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 pubkeyAlso updated spec test to alpha3 so we can merge this with green CI/CD