Skip to content

Commit

Permalink
fix possible nil performance address panic in participation rewards (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Bowman authored Jul 19, 2023
1 parent a40e473 commit c27bff6
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions x/participationrewards/keeper/rewards_validatorSelection.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,25 @@ import (
// individually in a callback.
func (k Keeper) AllocateValidatorSelectionRewards(ctx sdk.Context) {
k.icsKeeper.IterateZones(ctx, func(_ int64, zone *icstypes.Zone) (stop bool) {
k.Logger(ctx).Info("zones", "chain_id", zone.ChainId, "performance address", zone.PerformanceAddress.Address)

// obtain zone performance account rewards
rewardsQuery := distrtypes.QueryDelegationTotalRewardsRequest{DelegatorAddress: zone.PerformanceAddress.Address}
bz := k.cdc.MustMarshal(&rewardsQuery)

k.IcqKeeper.MakeRequest(
ctx,
zone.ConnectionId,
zone.ChainId,
"cosmos.distribution.v1beta1.Query/DelegationTotalRewards",
bz,
sdk.NewInt(-1),
types.ModuleName,
ValidatorSelectionRewardsCallbackID,
0,
)
if zone.PerformanceAddress != nil {

This comment has been minimized.

Copy link
@odeke-em

odeke-em Sep 15, 2023

Contributor

Would be nice to log nil PerformanceAddresses as an error so that later they can be debugged.

k.Logger(ctx).Info("zones", "chain_id", zone.ChainId, "performance address", zone.PerformanceAddress.Address)

// obtain zone performance account rewards
rewardsQuery := distrtypes.QueryDelegationTotalRewardsRequest{DelegatorAddress: zone.PerformanceAddress.Address}
bz := k.cdc.MustMarshal(&rewardsQuery)

k.IcqKeeper.MakeRequest(
ctx,
zone.ConnectionId,
zone.ChainId,
"cosmos.distribution.v1beta1.Query/DelegationTotalRewards",
bz,
sdk.NewInt(-1),
types.ModuleName,
ValidatorSelectionRewardsCallbackID,
0,
)
}
return false
})
}
Expand Down

0 comments on commit c27bff6

Please sign in to comment.