8000 imp(ante): Remove automatic withdrawal of staking rewards in case of insufficient funds by MalteHerrmann · Pull Request #2719 · evmos/evmos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

imp(ante): Remove automatic withdrawal of staking rewards in case of insufficient funds #2719

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

Merged
merged 2 commits into from
Aug 1, 2024

Conversation

MalteHerrmann
Copy link
Contributor
@MalteHerrmann MalteHerrmann commented Aug 1, 2024

This PR removes the logic associated with the automatic withdrawal of staking rewards in case a user has not enough funds to pay for the transaction fees.
This feature is not going to work with ICS and has also been a point of critique for the taxable event that is created and subsequently removed from different partner's forks.

Summary by CodeRabbit

  • New Features

    • Simplified fee deduction process with improved error handling.
    • Enhanced clarity in error messages related to fee deduction failures.
  • Bug Fixes

    • Clarified test cases for better focus on insufficient funds scenarios.
    • Improved consistency in expected error messages across tests.
  • Refactor

    • Removed unnecessary helper functions to streamline logic.
    • Shifted from structured error types to descriptive string messages in tests.
  • Documentation

    • Updated CHANGELOG to reflect significant changes in staking reward management.

@MalteHerrmann MalteHerrmann requested a review from a team as a code owner August 1, 2024 14:30
8000 @MalteHerrmann MalteHerrmann requested review from 0xstepit and GAtom22 and removed request for a team August 1, 2024 14:30
Copy link
Contributor
coderabbitai bot commented Aug 1, 2024

Walkthrough

The recent changes focus on optimizing fee deduction processes and error handling across multiple files. Key modifications include streamlining the logic, enhancing test clarity, and simplifying error messages. By removing unnecessary functions and improving the maintainability of the code, these updates ensure that fee deductions are handled more directly and intuitively, ultimately improving the user experience.

Changes

Files Change Summary
app/ante/cosmos/fees.go Simplified deductFee method; improved error handling; removed helper function.
app/ante/cosmos/fees_test.go Renamed and restructured test cases for clarity; focused on specific failure conditions.
app/ante/evm/09_gas_consume.go Removed logic for claiming staking rewards on insufficient balance; simplified control flow.
app/ante/evm/09_gas_consume_test.go Changed error handling in tests from structured errors to descriptive strings for clarity.
CHANGELOG.md Added entry highlighting removal of automatic staking rewards withdrawal on insufficient funds.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DeductFeeDecorator
    participant Authante

    User->>DeductFeeDecorator: Request transaction with fees
    DeductFeeDecorator->>Authante: Invoke DeductFees
    Authante-->>DeductFeeDecorator: Return error or success
    DeductFeeDecorator-->>User: Respond with fee deduction result
Loading

🐰 In fields of code where changes now bloom,
A rabbit hops joyfully, dispelling the gloom.
Simplified paths and clearer ways,
For fees and tests, brighter days!
With each little tweak, our code doth sing,
Hopping along, to better things! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor
@GAtom22 GAtom22 left a comment

Choose a reason for hiding this comment

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

LGTM! Great work @MalteHerrmann!

can you please add a changelog entry?

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ef112b6 and c173632.

Files selected for processing (4)
  • app/ante/cosmos/fees.go (2 hunks)
  • app/ante/cosmos/fees_test.go (2 hunks)
  • app/ante/evm/09_gas_consume.go (1 hunks)
  • app/ante/evm/09_gas_consume_test.go (4 hunks)
Additional comments not posted (9)
app/ante/evm/09_gas_consume.go (1)

89-89: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to deductFees handle the scenario where the user's balance is insufficient.

Verification successful

Ensure proper error handling for insufficient funds in deductFees calls.

The function deductFees is called in:

  • app/ante/evm/09_gas_consume.go (line 89)
  • app/ante/cosmos/fees.go

Both instances have error handling in place. Verify that these handlers properly address scenarios where the user's balance is insufficient.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `deductFees` handle the scenario where the user's balance is insufficient.

# Test: Search for the function usage. Expect: Proper error handling for insufficient funds.
rg --type go -A 5 $'deductFees'

Length of output: 2055

app/ante/evm/09_gas_consume_test.go (5)

94-94: Improved error handling in tests.

The change to use a string for expectedError instead of an error type improves the clarity of the test cases.


99-100: Descriptive error messages enhance test clarity.

Using a string for expectedError allows for more descriptive error messages, improving debugging and understanding of test failures.


107-107: Descriptive error messages enhance test clarity.

Using a string for expectedError allows for more descriptive error messages, improving debugging and understanding of test failures.


118-118: Descriptive error messages enhance test clarity.

Using a string for expectedError allows for more descriptive error messages, improving debugging and understanding of test failures.


152-154: Improved error handling in tests.

The change to use a string for expectedError instead of an error type improves the clarity of the test cases.

app/ante/cosmos/fees.go (1)

132-133: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to deductFee handle the scenario where the user's balance is insufficient.

Verification successful

Let's verify that all calls to deductFee and related functions handle insufficient funds properly. We will search for instances where deductFee is called and check for proper error handling.


LGTM! Proper error handling for insufficient funds is present in all instances of deductFee.

The code changes are approved.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `deductFee` handle the scenario where the user's balance is insufficient.

# Test: Search for the function usage. Expect: Proper error handling for insufficient funds.
rg --type go -A 5 $'deductFee'

Length of output: 4974


Script:

#!/bin/bash
# Description: Verify all function calls to `deductFee` handle the scenario where the user's balance is insufficient.

# Test: Search for the function usage and check for error handling. Expect: Proper error handling for insufficient funds.
rg --type go -A 5 $'deductFee' | grep -B 5 -A 5 'err'

Length of output: 3045

app/ante/cosmos/fees_test.go (2)

66-73: LGTM! Improved test case clarity.

The test case name and expected error message have been updated to focus on the insufficient funds condition and provide a clearer understanding of the failure reason.


86-93: LGTM! Consistent error message.

The test case has been updated to align with the modified error message, ensuring consistency in the test logic and expected outcomes.

8000
Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
CHANGELOG.md (1)

71-71: Fix line length to adhere to Markdownlint standards.

The line length exceeds the recommended limit of 120 characters.

- - (ante) [#2719](https://github.com/evmos/evmos/pull/2719) Remove automatic withdrawal of staking rewards in case of insufficient funds.
+ - (ante) [#2719](https://github.com/evmos/evmos/pull/2719) Remove automatic withdrawal of staking rewards 
+ in case of insufficient funds.
Tools
Markdownlint

71-71: Expected: 120; Actual: 136
Line length

(MD013, line-length)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c173632 and c4ec527.

Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Additional context used
Markdownlint
CHANGELOG.md

71-71: Expected: 120; Actual: 136
Line length

(MD013, line-length)

@MalteHerrmann MalteHerrmann merged commit b591299 into main Aug 1, 2024
51 checks passed
@MalteHerrmann MalteHerrmann deleted the malte/remove-automatic-rewards-withdrawal branch August 1, 2024 19:07
@GAtom22
Copy link
Contributor
GAtom22 commented Aug 30, 2024

https://github.com/Mergifyio backport Vvaradinov/ics-devnet

Copy link
Contributor
mergify bot commented Aug 30, 2024

backport Vvaradinov/ics-devnet

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Aug 30, 2024
…insufficient funds (#2719)

* remove automatic withdrawal of staking rewards in case of insufficient funds

* add changelog entry

(cherry picked from commit b591299)

# Conflicts:
#	CHANGELOG.md
GAtom22 pushed a commit that referenced this pull request Aug 30, 2024
…insufficient funds (#2719)

* remove automatic withdrawal of staking rewards in case of insufficient funds

* add changelog entry
Vvaradinov pushed a commit that referenced this pull request Sep 2, 2024
…insufficient funds (backport #2719) (#2801)

* imp(ante): Remove automatic withdrawal of staking rewards in case of insufficient funds (#2719)

* remove automatic withdrawal of staking rewards in case of insufficient funds

* add changelog entry

(cherry picked from commit b591299)

# Conflicts:
#	CHANGELOG.md

* fix conflicts

---------

Co-authored-by: MalteHerrmann <42640438+MalteHerrmann@users.noreply.github.com>
Co-authored-by: tom <tomasguerraalda@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0