Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: WithdrawRewards event emit value when no rewards #9599

Merged
merged 5 commits into from
Jul 5, 2021

Conversation

technicallyty
Copy link
Contributor

@technicallyty technicallyty commented Jun 28, 2021

Description

Rewards values of 0 were omitted from the WithdrawRewards event. To provide consistency in event responses, this is caught in the keeper and emitted as a value of 0[baseDenom].

Closes: #8581


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

*returns 0baseDenom in the case of 0 rewards so that a default value is present in event
*add test for the case of 0 rewards via 100% commission
@github-actions github-actions bot added the C:x/distribution distribution module related label Jun 28, 2021
@@ -99,6 +99,14 @@ func (k Keeper) WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddres
return nil, err
}

if rewards.IsZero() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A zero coin technically isn't valid. I don't have strong feeling here though in terms of emitting the event. I'd have to defer to others.

Copy link
Contributor Author

@technicallyty technicallyty Jun 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsZero doubles as an IsEmpty check so 0 rewards is the same as no rewards here 🤷🏻‍♂️

but yeah just to clarify, without the added check, the value simply gets axed from the event

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally. I meant in the state-machine we do not allow zero coins. However, since this is for UX/client purposes only, I suppose it's OK.

@codecov
Copy link

codecov bot commented Jun 28, 2021

Codecov Report

Merging #9599 (e595132) into master (c91f3b2) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #9599   +/-   ##
=======================================
  Coverage   60.57%   60.57%           
=======================================
  Files         588      588           
  Lines       37452    37458    +6     
=======================================
+ Hits        22686    22692    +6     
  Misses      12776    12776           
  Partials     1990     1990           
Impacted Files Coverage Δ
x/distribution/keeper/keeper.go 82.92% <100.00%> (+1.34%) ⬆️

@technicallyty technicallyty changed the title fix: WithdrawRewards event emit value when 0 rewards fix: WithdrawRewards event emit value when no rewards Jun 28, 2021
@clevinson clevinson self-assigned this Jun 30, 2021
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a changelog entry?

@amaury1093 amaury1093 added the A:automerge Automatically merge PR once all prerequisites pass. label Jul 5, 2021
@mergify mergify bot merged commit 2c6b866 into master Jul 5, 2021
@mergify mergify bot deleted the ty/8581-reward_json branch July 5, 2021 18:28
@amaury1093 amaury1093 mentioned this pull request May 23, 2022
72 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:x/distribution distribution module related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

non consistent form of withdraw reward json key(value)
4 participants