From 441cc9cdaa4de6cc28015876daa3bbae74c52404 Mon Sep 17 00:00:00 2001 From: Runchao Han Date: Fri, 25 Oct 2024 14:52:39 +1100 Subject: [PATCH] fix --- x/finality/keeper/grpc_query.go | 2 +- x/finality/keeper/power_table.go | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/x/finality/keeper/grpc_query.go b/x/finality/keeper/grpc_query.go index a97a178e9..6b0289e49 100644 --- a/x/finality/keeper/grpc_query.go +++ b/x/finality/keeper/grpc_query.go @@ -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 } diff --git a/x/finality/keeper/power_table.go b/x/finality/keeper/power_table.go index f1d9d9fbb..0d0101dca 100644 --- a/x/finality/keeper/power_table.go +++ b/x/finality/keeper/power_table.go @@ -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 { @@ -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