diff --git a/app/ante/fee.go b/app/ante/fee.go index d54837ae..9228043c 100644 --- a/app/ante/fee.go +++ b/app/ante/fee.go @@ -226,18 +226,15 @@ func (svcd SettlusValidatorCheckDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx func getValidatorFromOracleMsg(msg sdk.Msg) (sdk.ValAddress, error) { switch msg := msg.(type) { - case *oracletypes.MsgVote: - val, err := sdk.ValAddressFromBech32(msg.Validator) - if err != nil { - return nil, err - } - return val, nil - case *oracletypes.MsgPrevote: - val, err := sdk.ValAddressFromBech32(msg.Validator) - if err != nil { - return nil, err + case *oracletypes.MsgVote, *oracletypes.MsgPrevote, *oracletypes.MsgFeederDelegationConsent: + if validatorMsg, ok := msg.(interface{ GetValidator() string }); ok { + val, err := sdk.ValAddressFromBech32(validatorMsg.GetValidator()) + if err != nil { + return nil, err + } + return val, nil } - return val, nil + return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "Cannot extract validator from oracle msg") default: return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "Invalid oracle msg type") } diff --git a/x/oracle/keeper/feeder.go b/x/oracle/keeper/feeder.go index a14274fa..84df59b6 100644 --- a/x/oracle/keeper/feeder.go +++ b/x/oracle/keeper/feeder.go @@ -316,10 +316,10 @@ func (k Keeper) RewardBallotWinners(ctx sdk.Context, validatorClaimMap map[strin probonoRate := receiverVal.GetProbonoRate() probonoContribution := sdk.NewDecCoinsFromCoins(rewardCoins...).MulDecTruncate(probonoRate) totalContribution = totalContribution.Add(probonoContribution...) - + finalReward := sdk.NewDecCoinsFromCoins(rewardCoins...).Sub(probonoContribution) finalRewardCoins, _ := finalReward.TruncateDecimal() - + k.DistributionKeeper.AllocateTokensToValidator(ctx, receiverVal, finalReward) distributedReward = distributedReward.Add(finalRewardCoins...) } else { @@ -334,7 +334,7 @@ func (k Keeper) RewardBallotWinners(ctx sdk.Context, validatorClaimMap map[strin feePool := k.DistributionKeeper.GetFeePool(ctx) feePool.CommunityPool = feePool.CommunityPool.Add(totalContribution...) k.DistributionKeeper.SetFeePool(ctx, feePool) - + totalContributionCoins, _ := totalContribution.TruncateDecimal() // Move both distributed reward and contribution reward to distribution module diff --git a/x/oracle/keeper/keeper_test.go b/x/oracle/keeper/keeper_test.go index 7b43ae1b..2da31f50 100644 --- a/x/oracle/keeper/keeper_test.go +++ b/x/oracle/keeper/keeper_test.go @@ -403,11 +403,11 @@ func (suite *OracleTestSuite) TestKeeper_RewardBallotWinners() { func (suite *OracleTestSuite) TestKeeper_RewardBallotWinners_WithProbono() { tests := []struct { - name string - vcm map[string]types.Claim - totalCoin sdk.Coins - rewardMap map[string]sdk.DecCoins - probonoMap map[int]sdk.Dec + name string + vcm map[string]types.Claim + totalCoin sdk.Coins + rewardMap map[string]sdk.DecCoins + probonoMap map[int]sdk.Dec }{ { name: "Probono validators send rewards to community pool with their probono rate, normal validators get rewards", @@ -515,10 +515,10 @@ func (suite *OracleTestSuite) TestKeeper_RewardBallotWinners_WithProbono() { contribution := tt.rewardMap[validator.GetOperator().String()].MulDec(validator.GetProbonoRate()) probonoRewards = probonoRewards.Add(contribution...) - + rewards := s.app.DistrKeeper.GetValidatorCurrentRewards(s.ctx, validator.GetOperator()) s.Equal(tt.rewardMap[validator.GetOperator().String()].Sub(contribution).AmountOf("asetl"), rewards.Rewards.AmountOf("asetl")) - + s.app.DistrKeeper.DeleteValidatorCurrentRewards(s.ctx, validator.GetOperator()) }