Skip to content

Commit

Permalink
chore: fix overflow height in FinalityProviderCurrentPower (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianElvis authored Jan 9, 2024
1 parent 2490313 commit 9a9be21
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions x/btcstaking/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ func (k Keeper) FinalityProviderCurrentPower(ctx context.Context, req *types.Que
// NOTE: it's possible that the voting power is not recorded at the current height,
// e.g., `EndBlock` is not reached yet
// in this case, we use the last height

// ensure curHeight > 0 thus won't over flow
if curHeight == 0 {
return &types.QueryFinalityProviderCurrentPowerResponse{Height: 0, VotingPower: 0}, nil
}

curHeight -= 1
power = k.GetVotingPower(sdkCtx, fpBTCPK.MustMarshal(), curHeight)
}
Expand Down

0 comments on commit 9a9be21

Please sign in to comment.