Skip to content

Commit

Permalink
Update logic on checking queued commitments
Browse files Browse the repository at this point in the history
  • Loading branch information
p0p3yee committed Feb 6, 2024
1 parent 65639df commit 342f674
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/fairyringclient/fairyringclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func StartFairyRingClient(cfg config.Config) {
log.Printf("[%d] Current Key Share is valid !", index)
}

if validatorCosmosClients[index].PendingShare != nil && commits.QueuedCommitments != nil {
if validatorCosmosClients[index].PendingShare != nil && len(commits.QueuedCommitments.Commitments) > 0 {
log.Printf("[%d] Verifying Pending Key Share...", index)
valid, err := validatorCosmosClients[index].VerifyShare(commits.QueuedCommitments, true)
if err != nil {
Expand Down Expand Up @@ -388,6 +388,7 @@ func StartFairyRingClient(cfg config.Config) {

if err != nil {
log.Printf("[%d] Submit KeyShare for Height %s ERROR: %s\n", nowI, processHeightStr, err.Error())
return
}
txResp, err := nowEach.CosmosClient.WaitForTx(resp.TxHash, time.Second)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions internal/fairyringclient/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ func (v *ValidatorClients) UpdateAndVerifyPendingShare(currentBlockHeight int64)
func (v *ValidatorClients) VerifyShare(commitments *types.Commitments, verifyPendingShare bool) (bool, error) {
s := bls.NewBLS12381Suite()

if len(commitments.Commitments) == 0 {
return false, errors.New("Commitment provided is empty")
}

targetShare := v.CurrentShare
if verifyPendingShare {
if v.PendingShare == nil {
Expand Down

0 comments on commit 342f674

Please sign in to comment.