-
Notifications
You must be signed in to change notification settings - Fork 200
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
refactor(evm): clean up EVM module address #1989
Conversation
WalkthroughThe recent changes in the Nibiru project introduce a new feature for the Ethereum Virtual Machine (EVM), specifically utilizing the atto denomination for wei units. This means 1 NIBI is treated as equivalent to 1 ether, facilitating clearer transaction processes for clients. Additionally, there has been a refactoring of the EVM module address handling, shifting from function calls to constant references, enhancing code readability and performance. Changes
Possibly related issues
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this 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
Files selected for processing (9)
- CHANGELOG.md (1 hunks)
- x/evm/const.go (1 hunks)
- x/evm/evm_test.go (1 hunks)
- x/evm/keeper/erc20.go (3 hunks)
- x/evm/keeper/erc20_test.go (2 hunks)
- x/evm/keeper/funtoken_from_coin.go (1 hunks)
- x/evm/keeper/msg_server.go (1 hunks)
- x/evm/precompile/funtoken.go (3 hunks)
- x/evm/precompile/funtoken_test.go (2 hunks)
Files skipped from review due to trivial changes (4)
- x/evm/evm_test.go
- x/evm/keeper/erc20.go
- x/evm/keeper/erc20_test.go
- x/evm/precompile/funtoken_test.go
Additional comments not posted (6)
x/evm/keeper/funtoken_from_coin.go (1)
83-83
: Use of Constant Improves Readability and PerformanceReplacing the function call
evm.ModuleAddressEVM()
with the constantevm.EVM_MODULE_ADDRESS
improves readability and potentially enhances performance by eliminating the function call overhead. This change is well-aligned with the refactoring goals.x/evm/const.go (1)
79-83
: Simplified Initialization of EVM Module AddressThe introduction of the constant
EVM_MODULE_ADDRESS
and the removal of the lazy initialization pattern streamline the code. This change enhances clarity and reduces complexity by ensuring the module address is initialized once and is immediately available. This approach also minimizes the risk of accessing an uninitialized address.x/evm/precompile/funtoken.go (1)
Line range hint
156-187
: Consistent Use of Constant for EVM Module AddressThe replacement of
evm.ModuleAddressEVM()
withevm.EVM_MODULE_ADDRESS
across multiple instances in thebankSend
function aligns with the refactoring goals. This change improves readability and potentially enhances performance by reducing function call overhead. The error messages have been updated accordingly, maintaining their informativeness and accuracy.x/evm/keeper/msg_server.go (1)
615-615
: Simplify module address access.The change from
evm.ModuleAddressEVM()
toevm.EVM_MODULE_ADDRESS
simplifies the code and may improve performance by reducing function call overhead.Ensure that
evm.EVM_MODULE_ADDRESS
is correctly defined and used consistently across the codebase.Verification successful
Consistent use of
EVM_MODULE_ADDRESS
verified.The constant
evm.EVM_MODULE_ADDRESS
is correctly defined and consistently used across the codebase. This change simplifies the code and is correctly implemented.
- Definition found in
x/evm/const.go
.- Consistent usage in files like
x/evm/keeper/msg_server.go
,x/evm/keeper/erc20.go
, and others.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition and usage of `evm.EVM_MODULE_ADDRESS`. # Test: Search for the constant definition. Expect: A single definition. rg --type go --word-regexp 'EVM_MODULE_ADDRESS' # Test: Search for all occurrences of `EVM_MODULE_ADDRESS`. Expect: Consistent usage across the codebase. rg --type go --word-regexp 'EVM_MODULE_ADDRESS'Length of output: 2221
CHANGELOG.md (2)
103-103
: Verify the simplification of the EVM module address.Ensure that the changelog entry accurately reflects the simplification made in the codebase regarding the EVM module address.
101-101
: Verify the accuracy of the denomination changes.Ensure that the changelog entry accurately reflects the changes made in the codebase regarding the atto denomination for wei units and the constraints for NIBI, unibi, and wei.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1989 +/- ##
==========================================
- Coverage 65.76% 65.75% -0.01%
==========================================
Files 261 261
Lines 16475 16471 -4
==========================================
- Hits 10834 10830 -4
Misses 4837 4837
Partials 804 804
|
Purpose / Abstract
Simplifies the EVM module address initialization
Summary by CodeRabbit
New Features
Bug Fixes
Refactor