-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eip6110 queue deposit requests #14430
Changes from all commits
2cc1ff3
b008a3b
8d0d444
4a87609
a0bef32
46e88f0
6cf54bc
5334144
3c25797
330cfa3
3566543
41ba44b
0690e44
f697f65
792a4f7
af3f8d0
8bb1fcc
5dda6df
1e4e826
29cf448
f1a2dca
944afd1
5fb1e10
1a55937
fe2598d
26216ef
582444c
8776421
f6e06d7
9110135
9abebd7
41f1406
f95f87c
377f5a6
134fe8c
fe5c942
b5d2d90
446cba2
c3fb312
7a5ff1a
f976c26
c2e6686
abd0e1e
5b40a23
64545de
c37cd17
de43591
dc38cf9
7abdd5d
6677634
4e310e7
d52d819
c66c2e9
44a41c4
197163b
1c0d70e
0eb8e79
c48a58b
cc3e941
a637027
fa23924
cd39461
9b96fa6
d786dc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,21 @@ func BatchVerifyDepositsSignatures(ctx context.Context, deposits []*ethpb.Deposi | |
return true, nil | ||
} | ||
|
||
// BatchVerifyPendingDepositsSignatures batch verifies pending deposit signatures. | ||
func BatchVerifyPendingDepositsSignatures(ctx context.Context, deposits []*ethpb.PendingDeposit) (bool, error) { | ||
var err error | ||
domain, err := signing.ComputeDomain(params.BeaconConfig().DomainDeposit, nil, nil) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
if err := verifyPendingDepositDataWithDomain(ctx, deposits, domain); err != nil { | ||
log.WithError(err).Debug("Failed to batch verify deposits signatures, will try individual verify") | ||
return false, nil | ||
} | ||
return true, nil | ||
} | ||
|
||
// IsValidDepositSignature returns whether deposit_data is valid | ||
// def is_valid_deposit_signature(pubkey: BLSPubkey, withdrawal_credentials: Bytes32, amount: uint64, signature: BLSSignature) -> bool: | ||
// | ||
|
@@ -158,3 +173,44 @@ func verifyDepositDataWithDomain(ctx context.Context, deps []*ethpb.Deposit, dom | |
} | ||
return nil | ||
} | ||
|
||
func verifyPendingDepositDataWithDomain(ctx context.Context, deps []*ethpb.PendingDeposit, domain []byte) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general, all of these may benefit from unit tests, but I’ll leave that decision to you:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added one for batch ProcessNewPendingDeposits, can add more There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added more tests |
||
if len(deps) == 0 { | ||
return nil | ||
} | ||
pks := make([]bls.PublicKey, len(deps)) | ||
sigs := make([][]byte, len(deps)) | ||
msgs := make([][32]byte, len(deps)) | ||
for i, dep := range deps { | ||
if ctx.Err() != nil { | ||
return ctx.Err() | ||
} | ||
if dep == nil { | ||
return errors.New("nil deposit") | ||
} | ||
dpk, err := bls.PublicKeyFromBytes(dep.PublicKey) | ||
if err != nil { | ||
return err | ||
} | ||
pks[i] = dpk | ||
sigs[i] = dep.Signature | ||
depositMessage := ðpb.DepositMessage{ | ||
PublicKey: dep.PublicKey, | ||
WithdrawalCredentials: dep.WithdrawalCredentials, | ||
Amount: dep.Amount, | ||
} | ||
sr, err := signing.ComputeSigningRoot(depositMessage, domain) | ||
if err != nil { | ||
return err | ||
} | ||
msgs[i] = sr | ||
} | ||
verify, err := bls.VerifyMultipleSignatures(sigs, msgs, pks) | ||
if err != nil { | ||
return errors.Errorf("could not verify multiple signatures: %v", err) | ||
} | ||
if !verify { | ||
return errors.New("one or more deposit signatures did not verify") | ||
} | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can someone double check this one for me