Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianElvis committed Oct 25, 2024
1 parent 88ef031 commit 441cc9c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion x/finality/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (k Keeper) FinalityProviderPowerAtHeight(ctx context.Context, req *types.Qu
}

sdkCtx := sdk.UnwrapSDKContext(ctx)
power := k.getVotingPower(sdkCtx, fpBTCPK.MustMarshal(), req.Height)
power := k.GetVotingPower(sdkCtx, fpBTCPK.MustMarshal(), req.Height)

return &types.QueryFinalityProviderPowerAtHeightResponse{VotingPower: power}, nil
}
Expand Down
11 changes: 2 additions & 9 deletions x/finality/keeper/power_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ func (k Keeper) SetVotingPower(ctx context.Context, fpBTCPK []byte, height uint6
store.Set(fpBTCPK, sdk.Uint64ToBigEndian(power))
}

func (k Keeper) getVotingPower(ctx context.Context, fpBTCPK []byte, height uint64) uint64 {
// GetVotingPower gets the voting power of a given finality provider at a given Babylon height
func (k Keeper) GetVotingPower(ctx context.Context, fpBTCPK []byte, height uint64) uint64 {
store := k.votingPowerBbnBlockHeightStore(ctx, height)
powerBytes := store.Get(fpBTCPK)
if len(powerBytes) == 0 {
Expand All @@ -26,14 +27,6 @@ func (k Keeper) getVotingPower(ctx context.Context, fpBTCPK []byte, height uint6
return sdk.BigEndianToUint64(powerBytes)
}

// GetVotingPower gets the voting power of a given finality provider at a given Babylon height
func (k Keeper) GetVotingPower(ctx context.Context, fpBTCPK []byte, height uint64) uint64 {
if !k.BTCStakingKeeper.HasFinalityProvider(ctx, fpBTCPK) {
return 0
}
return k.getVotingPower(ctx, fpBTCPK, height)
}

// GetCurrentVotingPower gets the voting power of a given finality provider at the current height
// NOTE: it's possible that the voting power table is 1 block behind CometBFT, e.g., when `BeginBlock`
// hasn't executed yet
Expand Down

0 comments on commit 441cc9c

Please sign in to comment.