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(precompile-funtoken.go): Fixes a bug where the err != nil check is missing in the bankBalance precompile method #2116

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

Unique-Divine
Copy link
Member

@Unique-Divine Unique-Divine commented Nov 26, 2024

Purpose / Abstract

This change makes the error description prefixes more consistent in the precompile/funtoken.go and fixes a bug where there's a missing if err != nil check.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced WASM light clients support on IBC.
    • Enhanced ERC20 metadata during FunToken creation.
    • Added new methods for FunToken precompile.
    • New recipe gen-types for generating TypeScript types for Ethereum smart contracts.
  • Bug Fixes

    • Improved state consistency in precompile execution.
    • Enhanced error handling for gas consumption in ERC20 contract execution.
    • Fixed issues with transaction receipt marshalling.
  • Improvements

    • Refined changelog structure for better clarity and navigation.

…s missing in the bankBalance precompile method
@Unique-Divine Unique-Divine requested a review from a team as a code owner November 26, 2024 03:46
Copy link
Contributor

coderabbitai bot commented Nov 26, 2024

Walkthrough

The changes in this pull request encompass updates to the CHANGELOG.md, enhancements to the evm-funtoken-precompile, and the introduction of a new recipe in the justfile. The CHANGELOG.md reflects new features, bug fixes, and a restructuring for clarity. The funtoken.go file sees improved error handling in several methods, while the justfile now includes a recipe for generating TypeScript types. These modifications aim to enhance functionality and maintainability within the Nibiru EVM ecosystem.

Changes

File Change Summary
CHANGELOG.md Added new features, bug fixes, and improvements related to Nibiru EVM; refactored structure for clarity.
evm-e2e/justfile Introduced a new recipe gen-types to generate TypeScript types using npx hardhat typechain.
x/evm/precompile/funtoken.go Enhanced error handling in sendToBank, bankBalance, and whoAmI methods; updated method signatures.

Possibly related PRs

Suggested labels

x: evm

Suggested reviewers

  • onikonychev

Poem

🐇 In the meadow where changes bloom,
New features sprout, dispelling gloom.
With better handling, we leap and bound,
FunTokens thrive, in joy they're found!
A recipe added, types now align,
In the world of EVM, all is fine! 🌼


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

@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 and nitpick comments (3)
evm-e2e/justfile (1)

27-28: Add documentation for the new recipe

While the recipe is functionally correct, consider adding a comment explaining its purpose, similar to other recipes in the file. Also note that this command is already run during install, so you might want to clarify when developers should use this separate recipe instead.

Consider adding documentation like this:

+# Regenerates TypeScript types from smart contract ABIs
 gen-types:
   npx hardhat typechain
x/evm/precompile/funtoken.go (1)

Line range hint 196-198: Consider implementing the TODO items for event emission

These TODO comments indicate missing event emissions for balance changes. Implementing these events would improve transaction observability and make it easier to track balance changes.

Would you like me to help implement these event emissions or create a GitHub issue to track this enhancement?

CHANGELOG.md (1)

109-109: Consider enhancing the changelog entry with more details.

While the entry correctly documents the fix, it would be helpful to add more context about:

  • The potential impact of the missing error check
  • Why this fix is important for the bankBalance precompile method
  • Any related issues or bugs this fixes

Example enhancement:

- - [#2116](https://github.com/NibiruChain/nibiru/pull/2116) - fix(precompile-funtoken.go): Fixes a bug where the err != nil check is missing in the bankBalance precompile method
+ - [#2116](https://github.com/NibiruChain/nibiru/pull/2116) - fix(precompile-funtoken.go): Fixes a bug where the err != nil check is missing in the bankBalance precompile method. This could lead to incorrect balance reporting or potential panics if the underlying bank query fails. The fix ensures proper error handling and consistent behavior.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b61c103 and 2e29d5c.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • evm-e2e/justfile (1 hunks)
  • x/evm/precompile/funtoken.go (3 hunks)
🔇 Additional comments (4)
evm-e2e/justfile (1)

26-26: LGTM!

The added empty line maintains consistent spacing between recipe blocks.

x/evm/precompile/funtoken.go (3)

121-121: LGTM: Consistent error wrapping

The error wrapping with ErrInvalidArgs aligns with the error handling pattern used throughout the codebase.


463-464: LGTM: Consistent error handling

The error wrapping with ErrInvalidArgs maintains consistency with the error handling pattern used throughout the precompile methods.


380-383: LGTM: Fixed missing error check

This change addresses the critical bug where errors from parseArgsBankBalance were not being handled. The implementation is consistent with error handling patterns in other methods like balance and whoAmI.

Let's verify the consistency of error handling across similar methods:

✅ Verification successful

Let me verify if all methods that parse arguments have consistent error handling by checking for parse functions and their error handling.


Let me try a different pattern to find parse functions and their error handling.


LGTM: Error handling is consistent across all parse functions

The verification confirms that the error handling in bankBalance method is consistent with the codebase's patterns. All methods that use parse functions properly check and wrap errors using ErrInvalidArgs, including:

  • sendToBank using parseArgsSendToBank
  • balance using parseArgsBalance
  • bankBalance using parseArgsBankBalance
  • whoAmI using parseArgsWhoAmI
  • Wasm-related methods using their respective parse functions
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify error handling consistency in precompile methods
# Expected: All precompile methods should check and wrap errors from their parse functions

ast-grep --pattern 'if err != nil {
  err = ErrInvalidArgs(err)
  return
}'

Length of output: 1525


Script:

#!/bin/bash
# Find all parse functions and their callers to verify error handling
ast-grep --pattern 'parse$_Args($$$)'

Length of output: 39


Script:

#!/bin/bash
# Find all parse functions and their usage
rg "parse.*Args.*\(" -A 3 x/evm/precompile/

Length of output: 4345

Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 28.57143% with 5 lines in your changes missing coverage. Please review.

Project coverage is 64.66%. Comparing base (b61c103) to head (2e29d5c).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
x/evm/precompile/funtoken.go 28.57% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2116      +/-   ##
==========================================
- Coverage   64.68%   64.66%   -0.02%     
==========================================
  Files         273      273              
  Lines       21610    21616       +6     
==========================================
+ Hits        13978    13979       +1     
- Misses       6655     6659       +4     
- Partials      977      978       +1     
Files with missing lines Coverage Δ
x/evm/precompile/funtoken.go 56.96% <28.57%> (-0.77%) ⬇️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant