Skip to content

Commit 5c1a131

Browse files
committed
Check for threshold
1 parent 15b9140 commit 5c1a131

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

app/obolapi/deposit.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (c Client) PostPartialDeposits(ctx context.Context, lockHash []byte, shareI
7777

7878
// GetFullDeposit gets the full deposit message for a given validator public key, lock hash and share index.
7979
// It respects the timeout specified in the Client instance.
80-
func (c Client) GetFullDeposit(ctx context.Context, valPubkey string, lockHash []byte) ([]eth2p0.DepositData, error) {
80+
func (c Client) GetFullDeposit(ctx context.Context, valPubkey string, lockHash []byte, threshold int) ([]eth2p0.DepositData, error) {
8181
valPubkeyBytes, err := from0x(valPubkey, len(eth2p0.BLSPubKey{}))
8282
if err != nil {
8383
return []eth2p0.DepositData{}, errors.Wrap(err, "validator pubkey to bytes")
@@ -118,6 +118,15 @@ func (c Client) GetFullDeposit(ctx context.Context, valPubkey string, lockHash [
118118
for _, am := range dr.Amounts {
119119
rawSignatures := make(map[int]tbls.Signature)
120120

121+
if len(am.Partials) < threshold {
122+
submittedPubKeys := []string{}
123+
for _, sigStr := range am.Partials {
124+
submittedPubKeys = append(submittedPubKeys, sigStr.PartialPublicKey)
125+
}
126+
127+
return []eth2p0.DepositData{}, errors.New("not enough partial signatures to meet threshold", z.Any("submitted_public_keys", submittedPubKeys), z.Int("submitted_public_keys_length", len(submittedPubKeys)), z.Int("required_threshold", threshold))
128+
}
129+
121130
for sigIdx, sigStr := range am.Partials {
122131
if len(sigStr.PartialDepositSignature) == 0 {
123132
// ignore, the associated share index didn't push a partial signature yet

cmd/depositfetch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func runDepositFetch(ctx context.Context, config depositFetchConfig) error {
6666
for _, pubkey := range config.ValidatorPublicKeys {
6767
log.Info(ctx, "Fetching full deposit message", z.Str("validator_pubkey", pubkey))
6868

69-
dd, err := oAPI.GetFullDeposit(ctx, pubkey, cl.GetInitialMutationHash())
69+
dd, err := oAPI.GetFullDeposit(ctx, pubkey, cl.GetInitialMutationHash(), int(cl.GetThreshold()))
7070
if err != nil {
7171
return errors.Wrap(err, "fetch full deposit data from Obol API")
7272
}

0 commit comments

Comments
 (0)