Skip to content

Commit

Permalink
chore: move logic of allowed error to sync of fp status
Browse files Browse the repository at this point in the history
  • Loading branch information
RafilxTenfen committed Sep 13, 2024
1 parent c1ede81 commit f67078c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
9 changes: 1 addition & 8 deletions clientcontroller/babylon.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package clientcontroller
import (
"context"
"fmt"
"strings"
"time"

sdkErr "cosmossdk.io/errors"
Expand Down Expand Up @@ -276,14 +275,8 @@ func (bc *BabylonController) QueryFinalityProviderVotingPower(fpPk *btcec.Public
bbntypes.NewBIP340PubKeyFromBTCPK(fpPk).MarshalHex(),
blockHeight,
)

if err != nil {
allowedErr := fmt.Sprintf("rpc error: code = Unknown desc = %s: unknown request", btcstakingtypes.ErrVotingPowerTableNotUpdated.Wrapf("height: %d", blockHeight).Error())
if strings.EqualFold(err.Error(), allowedErr) {
// if nothing was updated in the voting power table, it should consider as zero VP to start to send pub random
return 0, nil
}
return 0, fmt.Errorf("failed to query BTC delegations: %w", err)
return 0, fmt.Errorf("failed to query Finality Voting Power at Height: %w", err)
}

return res.VotingPower, nil
Expand Down
7 changes: 5 additions & 2 deletions finality-provider/service/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,11 @@ func (app *FinalityProviderApp) SyncFinalityProviderStatus() error {
for _, fp := range fps {
vp, err := app.cc.QueryFinalityProviderVotingPower(fp.BtcPk, latestBlock.Height)
if err != nil {
// if error occured then the finality-provider is not registered in the Babylon chain yet
continue
if !strings.Contains(err.Error(), bstypes.ErrVotingPowerTableNotUpdated.Wrapf("height: %d", latestBlock.Height).Error()) {
// if error occured then the finality-provider is not registered in the Babylon chain yet
continue
}
// if nothing was updated in the voting power table, it should consider as zero VP to start to send pub random
}

if !fp.ShouldSyncStatusFromVotingPower(vp) {
Expand Down

0 comments on commit f67078c

Please sign in to comment.