diff --git a/.github/workflows/software-upgrade-test.yml b/.github/workflows/software-upgrade-test.yml index be16de527..2fc51b76e 100644 --- a/.github/workflows/software-upgrade-test.yml +++ b/.github/workflows/software-upgrade-test.yml @@ -101,7 +101,7 @@ jobs: echo "SNAPSHOT_BLOCK_HEIGHT=$SNAPSHOT_BLOCK_HEIGHT" >> $GITHUB_ENV echo "Snapshot block height: $SNAPSHOT_BLOCK_HEIGHT" - APPLIED_URL=https://api.testnet.elys.network/cosmos/upgrade/v1beta1/applied_plan/${LAST_TAG} + APPLIED_URL=https://api.testnet.elys.network/cosmos/upgrade/v1beta1/applied_plan/${LATEST_TAG} curl -L $APPLIED_URL -o /tmp/applied.json echo "Applied.json downloaded to check snapshot version." diff --git a/x/estaking/keeper/query.go b/x/estaking/keeper/query.go index a84e5d78b..0a8775734 100644 --- a/x/estaking/keeper/query.go +++ b/x/estaking/keeper/query.go @@ -47,6 +47,14 @@ func (k Keeper) Rewards(goCtx context.Context, req *types.QueryRewardsRequest) ( if err != nil { return false } + // check if the delegation is valid + startingInfo, err := k.distrKeeper.GetDelegatorStartingInfo(ctx, sdk.ValAddress(valAddr), sdk.AccAddress(delAddr)) + if err != nil { + return false + } + if startingInfo.Stake.IsNil() { + return false + } delReward, err := k.distrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod) if err != nil { return false diff --git a/x/estaking/types/expected_keepers.go b/x/estaking/types/expected_keepers.go index b84e84685..464ff5b29 100644 --- a/x/estaking/types/expected_keepers.go +++ b/x/estaking/types/expected_keepers.go @@ -2,8 +2,10 @@ package types import ( "context" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + disttypes "github.com/cosmos/cosmos-sdk/x/distribution/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" commitmenttypes "github.com/elys-network/elys/x/commitment/types" @@ -39,6 +41,7 @@ type DistrKeeper interface { WithdrawDelegationRewards(ctx context.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (sdk.Coins, error) IncrementValidatorPeriod(ctx context.Context, val stakingtypes.ValidatorI) (uint64, error) CalculateDelegationRewards(ctx context.Context, val stakingtypes.ValidatorI, del stakingtypes.DelegationI, endingPeriod uint64) (rewards sdk.DecCoins, err error) + GetDelegatorStartingInfo(ctx context.Context, val sdk.ValAddress, del sdk.AccAddress) (period disttypes.DelegatorStartingInfo, err error) } // TokenomicsKeeper defines the expected tokenomics keeper used for simulations (noalias)