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

feat: add coins burned to slash event #9458

Merged
merged 18 commits into from
Jul 5, 2021
Merged

feat: add coins burned to slash event #9458

merged 18 commits into from
Jul 5, 2021

Conversation

technicallyty
Copy link
Contributor

@technicallyty technicallyty commented Jun 3, 2021

Description

Adds the amount of coins slashed from the validator to the Slash event. Additionally, before this PR, the jail/slash events were emitted BEFORE the slash/jail functions were even ran, which could result in a false positive event if an error occurred in these functions. These events were moved to the end of the functions that implement the logic for them instead. This PR moves the events to be emitted after the logic is executed.

Closes: #9138

  • +Add amount_slashed to slash event
  • +Slash now returns the amount of tokens burned
  • +Events moved to be emitted after the logic is executed
  • +Add test to test the slash return amount
    - +Add EventType Jail to separate it from the Slash event
    - +Move slash/jail events into the functions that execute the logic for it
    - -Remove Reason attribute from slash event (didn't appear to be consistent with what was happening in code)

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 - @ryanchristo
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic - not applicable
  • reviewed API design and naming - @ryanchristo
  • reviewed documentation is accurate - @ryanchristo
  • reviewed tests and test coverage - @ryanchristo
  • manually tested (if applicable)

*adds new attribute "amount_slashed" to event
*adds new event type "jail"
*removes reason attribute
*moves slashing event to the end of the function that implements the slashing logic itself
*moves jail/slashing events to be AFTER the functions are called
@codecov
Copy link

codecov bot commented Jun 3, 2021

Codecov Report

Merging #9458 (b569843) into master (0027111) will increase coverage by 25.13%.
The diff coverage is 62.90%.

❗ Current head b569843 differs from pull request most recent head 5defa72. Consider uploading reports for the commit 5defa72 to get more accurate results
Impacted file tree graph

@@             Coverage Diff             @@
##           master    #9458       +/-   ##
===========================================
+ Coverage   35.48%   60.62%   +25.13%     
===========================================
  Files         332      588      +256     
  Lines       32620    37405     +4785     
===========================================
+ Hits        11575    22675    +11100     
+ Misses      19819    12746     -7073     
- Partials     1226     1984      +758     
Impacted Files Coverage Δ
client/keys/show.go 83.67% <ø> (-0.24%) ⬇️
client/keys/types.go 100.00% <ø> (+100.00%) ⬆️
client/keys/utils.go 42.85% <ø> (+2.50%) ⬆️
client/query.go 16.98% <ø> (ø)
client/rpc/block.go 10.00% <ø> (ø)
client/rpc/routes.go 100.00% <ø> (ø)
client/rpc/status.go 47.72% <ø> (ø)
client/rpc/validators.go 0.00% <ø> (ø)
client/test_helpers.go 0.00% <ø> (ø)
client/tx/factory.go 27.00% <ø> (ø)
... and 699 more

@technicallyty technicallyty marked this pull request as draft June 4, 2021 14:31
@clevinson clevinson self-assigned this Jun 4, 2021
+slash now returns the amount of coins burned
+events now emit both reason and coins burned
+events moved to be emitted after the logic is executed
@github-actions github-actions bot added C:x/distribution distribution module related T:Docs Changes and features related to documentation. labels Jun 4, 2021
@technicallyty technicallyty changed the title refactor: slash and jail events feat: add coins burned to slash event Jun 5, 2021
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Looks great! By chance and while you're at it, do you think you can fix/change the header in x/slashing/spec/06_events.md to say Events and not Tags please?

@technicallyty technicallyty marked this pull request as ready for review June 7, 2021 16:04
Copy link
Contributor

@ryanchristo ryanchristo left a comment

Choose a reason for hiding this comment

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

Nice! Looks good to me. Changelog entry?

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.

nice! Putting a block as this introduces an API-brekaing change

x/staking/keeper/slash.go Show resolved Hide resolved
@amaury1093 amaury1093 added the S: DO NOT MERGE Status: DO NOT MERGE label Jun 8, 2021
@amaury1093
Copy link
Contributor

@technicallyty could you solve the conflicts? This is ready to get merged

@amaury1093 amaury1093 removed the S: DO NOT MERGE Status: DO NOT MERGE label Jun 28, 2021
CHANGELOG.md Outdated Show resolved Hide resolved
@amaury1093 amaury1093 self-assigned this Jun 29, 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.

utACK

@amaury1093 amaury1093 added the A:automerge Automatically merge PR once all prerequisites pass. label Jul 5, 2021
@mergify mergify bot merged commit 2188dd0 into master Jul 5, 2021
@mergify mergify bot deleted the ty/9138-slash_event branch July 5, 2021 14:33
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 C:x/slashing C:x/staking T:Docs Changes and features related to documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Include the slashed amount in slash event
6 participants