Skip to content

Conversation

GAtom22
Copy link
Contributor

@GAtom22 GAtom22 commented Oct 2, 2024

Description

Closes: #XXXX


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...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the correct branch (see PR Targeting)

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...

  • added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • confirmed all author checklist items have been addressed
  • confirmed that this PR does not change production code
  • reviewed content
  • tested instructions (if applicable)
  • confirmed all CI checks have passed

Summary by CodeRabbit

  • New Features
    • Added a governance precompile to enhance application functionality.
  • Improvements
    • Improved performance for eth_headerByHash.
    • Updated the Interpreter interface to support custom Opcodes.
    • Enhanced overall application performance and reliability.
  • Bug Fixes
    • Fixed issues with automatic withdrawal of staking rewards for insufficient funds.
    • Resolved nil community pool issues.
    • Corrected the free delegated amount in the addGrant method.
  • Chores
    • Updated dependency versions for Cosmos-SDK and IBC-Go.
    • Bumped repository version to v20.

Copy link
Contributor

coderabbitai bot commented Oct 2, 2024

Walkthrough

The pull request introduces updates to the CHANGELOG.md file, adding an "Unreleased" section that outlines significant changes, including dependency version upgrades for Cosmos-SDK and IBC-Go, removal of automatic staking rewards withdrawal under certain conditions, and method signature updates across various modules. Additionally, improvements in performance, interface updates, and fixes for previous issues are documented, reflecting a comprehensive enhancement of the application's functionality and structure.

Changes

File Path Change Summary
CHANGELOG.md Added "Unreleased" section detailing updates in dependency versions, method signatures, and new features.
vesting/... Updated addGrant(...) method signature to fix free delegated amount.
rpc/... Updated eth_estimateGas(...) method signature to add revert reason.
x/feemarket/... Updated BaseFee(...) method signature to change BaseFee to Decimal.
app/... Updated useBaseDenom(...) method signature to utilize sdk.BaseDenom and EVM denom.
CHANGELOG.md Documented removal of automatic withdrawal of staking rewards in cases of insufficient funds and replacement of EthAccount with BaseAccount.
CHANGELOG.md Added new governance precompile and various fixes and improvements in performance and functionality.

Possibly related PRs

  • update chlog #2840: This PR is related as it also involves the removal of the EthAccount type and its replacement with BaseAccount, which is a significant change noted in the main PR.
  • chore(evm): add scaling on buildTx fees #2906: This PR is related as it includes updates to the CHANGELOG.md that reflect the same changes regarding the removal of EthAccount, the bumping of Cosmos-SDK and IBC-Go versions, and other modifications mentioned in the main PR.

Suggested reviewers

  • hanchon
  • MalteHerrmann
  • 0xstepit

Poem

In the code where bunnies hop,
New versions leap, we won't stop!
With grants and fees all in line,
Our app shines bright, oh how divine!
So let’s code with joy and cheer,
For every change brings us near! 🐇✨


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.

@GAtom22 GAtom22 marked this pull request as ready for review October 2, 2024 21:44
@GAtom22 GAtom22 requested a review from a team as a code owner October 2, 2024 21:44
@GAtom22 GAtom22 requested review from Vvaradinov and 0xstepit and removed request for a team October 2, 2024 21:44
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: 5

🧹 Outside diff range and nitpick comments (11)
x/evm/types/scaling.go (1)

36-42: LGTM with minor suggestions for improvement

The new ConvertBigIntFrom18DecimalsToLegacyDec function is well-implemented and aligns with the PR objective of supporting 6 decimal places. It correctly converts from 18 decimals to the EVM coin's decimal representation using the appropriate conversion factor.

Consider the following suggestions for improvement:

  1. Add a nil check for the input amt to prevent potential panics.
  2. Consider adding explicit overflow checks during the conversion and division operations.

Example implementation with these improvements:

func ConvertBigIntFrom18DecimalsToLegacyDec(amt *big.Int) (sdkmath.LegacyDec, error) {
    if amt == nil {
        return sdkmath.LegacyDec{}, errors.New("input amount is nil")
    }
    evmCoinDecimal := GetEVMCoinDecimals()
    decAmt := sdkmath.LegacyNewDecFromBigInt(amt)
    
    // Check for potential overflow
    if decAmt.IsNil() {
        return sdkmath.LegacyDec{}, errors.New("overflow occurred during conversion")
    }
    
    result := decAmt.QuoInt(evmCoinDecimal.ConversionFactor())
    
    // Check for potential underflow
    if result.IsNil() {
        return sdkmath.LegacyDec{}, errors.New("underflow occurred during division")
    }
    
    return result, nil
}

These changes would make the function more robust and error-resistant.

rpc/backend/node_info_test.go (1)

26-26: LGTM! Consider adding a comment explaining the change.

The change from int64 to *big.Int for expMinGasPrice is appropriate and aligns with the PR objective of supporting 6 decimal places for gas prices. The update to use big.NewInt(types.DefaultGasPrice) in the test cases is correct and consistent.

Consider adding a brief comment above the expMinGasPrice field to explain why *big.Int is now used, e.g.:

// expMinGasPrice is now *big.Int to support higher precision (6 decimal places)
expMinGasPrice *big.Int

This would help future developers understand the reasoning behind using *big.Int instead of int64.

Also applies to: 33-33, 40-40

x/evm/types/scaling_test.go (1)

279-282: Consider adding more edge cases.

While the current test cases cover a good range, consider adding a few more edge cases to enhance the robustness of the test suite. For example:

  1. A very large number close to the maximum supported value.
  2. A number with many trailing zeros after the decimal point.

These additional cases could help ensure the conversion function handles extreme scenarios correctly.

Also applies to: 289-292

proto/ethermint/evm/v1/query.proto (2)

80-87: LGTM with a minor suggestion for the comment.

The new GlobalMinGasPrice RPC method is well-defined and aligns with the PR objective. The HTTP GET endpoint is correctly specified.

Consider updating the comment to be more specific about the decimal conversion:

-  // GlobalMinGasPrice queries the MinGasPrice
-  // it's similar to feemarket module's method,
-  // but makes the conversion to 18 decimals
-  // when the evm denom is 6 decimals
+  // GlobalMinGasPrice queries the minimum gas price.
+  // It's similar to the feemarket module's method,
+  // but converts the result to 18 decimal places
+  // when the EVM denomination uses 6 decimal places.

This change improves clarity and maintains consistency with the existing code style.


325-329: LGTM with a minor suggestion for the field comment.

The QueryGlobalMinGasPriceResponse message is well-defined and consistent with similar response messages in the file. The use of cosmossdk.io/math.Int as a custom type and the non-nullable attribute are appropriate.

Consider updating the field comment to be more specific:

-  // min_gas_price is the feemarket's min_gas_price
+  // min_gas_price is the global minimum gas price from the feemarket module, converted to 18 decimal places if necessary.

This change provides more context about the field's content and aligns with the functionality described in the RPC method comment.

rpc/backend/evm_query_client_test.go (1)

280-283: LGTM! Consider adding a test for this new mock function.

The RegisterGlobalMinGasPrice function is well-implemented and aligns with the existing code structure. It correctly sets up a mock response for the GlobalMinGasPrice method, using math.OneInt() as the minimum gas price, which supports the PR objective of handling 6 decimal places.

To ensure the reliability of this new mock function, consider adding a test case similar to the existing ones (e.g., TestRegisterBaseFee). This would validate that the mock behaves as expected when called.

rpc/backend/call_tx.go (1)

393-402: Summary of changes to GasPrice function

The modifications to the GasPrice function appear to simplify the code and potentially improve performance. However, these changes warrant careful consideration:

  1. The direct assignment result = b.RPCMinGasPrice() eliminates the creation of a new big.Int object.
  2. The comparison logic has been simplified to directly compare result with minGasPrice.

While these changes may improve code readability and performance, it's crucial to ensure that:

  1. The precision of gas price calculations is maintained, especially if there's a change in the underlying types (e.g., from sdk.Dec to *big.Int).
  2. The behavior of the function remains consistent with its previous implementation.

Consider adding comprehensive unit tests to verify that the gas price calculations and comparisons produce the same results as the previous implementation across various scenarios. This will help ensure that the refactoring doesn't introduce any unintended changes in behavior.

rpc/backend/call_tx_test.go (1)

464-464: LGTM. Consider adding a test case for non-default global min gas price.

The addition of RegisterGlobalMinGasPrice mock registration is a good enhancement to the test setup. It aligns well with the PR objective of refactoring RPC gas prices to support 6 decimal places.

To further improve test coverage, consider adding a test case where the global minimum gas price is set to a non-default value (e.g., with 6 decimal places) to ensure the new functionality is thoroughly tested.

CHANGELOG.md (3)

Line range hint 38-39: API Breaking Changes

  1. The inflation module has been renamed from inflation to inflation/v1.
  2. The legacy EIP-712 ante handler has been deprecated.

These changes may require updates to client software and integrations. Ensure that:

  1. Documentation is updated to reflect the new module name.
  2. A migration path or alternative is provided for users of the legacy EIP-712 ante handler.

Consider adding a deprecation notice in the code for the legacy EIP-712 ante handler to warn developers about its future removal.

Also applies to: 40-41

🧰 Tools
🪛 Markdownlint

68-68: Expected: 120; Actual: 150
Line length

(MD013, line-length)


Line range hint 1-83: Summary of v16.0.0 Release

This release introduces significant changes to the Evmos ecosystem:

  1. State Machine Breaking Changes: New precompiles, module removals, and changes to core functionality.
  2. API Breaking Changes: Module renaming and deprecations.
  3. Numerous Improvements: Enhanced testing, documentation, and module refactoring.
  4. Critical Bug Fixes: Addressing issues in various components.

While these changes bring important new features and improvements, they also require careful consideration for upgrading:

  1. A comprehensive upgrade guide should be provided, detailing necessary steps for node operators and developers.
  2. Thorough testing of all new features and changes in a testnet environment is crucial before mainnet deployment.
  3. Clear communication to all stakeholders about the breaking changes and their implications is essential.

Overall, this release represents a significant step forward for Evmos, but requires careful planning and execution for a smooth upgrade process.

Consider implementing a more gradual deprecation process for future breaking changes, allowing for smoother transitions in subsequent releases.

🧰 Tools
🪛 Markdownlint

68-68: Expected: 120; Actual: 150
Line length

(MD013, line-length)


Residual References to Removed Modules and Precompiles Detected

The following files still reference removed modules or new precompiles and require attention:

  • utils/utils_test.go
  • wallets/ledger/ledger_test.go
  • x/inflation/v1/keeper/inflation.go
  • utils/utils.go
  • x/evm/keeper/static_precompiles.go
  • precompiles/p256/p256.go
  • precompiles/staking/integration_test.go
  • precompiles/bech32/setup_test.go
  • precompiles/bank/utils_test.go
  • precompiles/bech32/methods_test.go
  • precompiles/bech32/methods.go
  • precompiles/bech32/bech32.go
  • ibc/utils.go
  • client/keys/add.go
  • client/debug/debug.go
  • precompiles/distribution/types.go
  • crypto/secp256r1/verify.go
  • precompiles/distribution/integration_test.go
  • precompiles/distribution/query_test.go
  • app/ante/sigverify_test.go
  • api/ethermint/evm/v1/query.pulsar.go
  • api/evmos/erc20/v1/tx.pulsar.go

Please ensure that all references to x/recovery, x/incentives, secp256r1, bech32, and bank precompile are appropriately removed or updated to reflect the intended changes.

🔗 Analysis chain

Line range hint 15-16: Multiple State Machine Breaking Changes

Several significant changes have been introduced:

  1. New precompiles: secp256r1 curve, bech32 conversion, and bank precompile.
  2. Removal of x/recovery and x/incentives modules.
  3. Changes to inflation and fee handling.

These changes will require careful testing and a well-planned upgrade strategy. Ensure that:

  1. All new precompiles are thoroughly tested for security and correctness.
  2. The removal of modules doesn't break existing functionality or leave orphaned data.
  3. Changes to inflation and fees are well-documented and communicated to stakeholders.

To verify the impact of these changes, run the following script:

Also applies to: 17-18, 19-20, 21-22, 23-24, 25-26, 27-28, 29-30, 31-32, 33-34, 35-36

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for references to removed modules and new precompiles
rg --type go 'x/recovery|x/incentives|secp256r1|bech32|bank precompile'

Length of output: 13806

🧰 Tools
🪛 Markdownlint

68-68: Expected: 120; Actual: 150
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 c1b2b6a and 6c6864e.

⛔ Files ignored due to path filters (3)
  • api/ethermint/evm/v1/query_grpc.pb.go is excluded by !**/*.pb.go
  • x/evm/types/query.pb.go is excluded by !**/*.pb.go
  • x/evm/types/query.pb.gw.go is excluded by !**/*.pb.gw.go
📒 Files selected for processing (18)
  • CHANGELOG.md (1 hunks)
  • api/ethermint/evm/v1/query.pulsar.go (6 hunks)
  • client/docs/swagger-ui/swagger.json (166 hunks)
  • proto/ethermint/evm/v1/query.proto (2 hunks)
  • proto/ethermint/feemarket/v1/feemarket.proto (1 hunks)
  • proto/ethermint/types/v1/dynamic_fee.proto (1 hunks)
  • rpc/backend/backend.go (2 hunks)
  • rpc/backend/call_tx.go (1 hunks)
  • rpc/backend/call_tx_test.go (1 hunks)
  • rpc/backend/chain_info.go (1 hunks)
  • rpc/backend/chain_info_test.go (1 hunks)
  • rpc/backend/evm_query_client_test.go (1 hunks)
  • rpc/backend/mocks/evm_query_client.go (1 hunks)
  • rpc/backend/node_info.go (3 hunks)
  • rpc/backend/node_info_test.go (1 hunks)
  • x/evm/keeper/grpc_query.go (1 hunks)
  • x/evm/types/scaling.go (1 hunks)
  • x/evm/types/scaling_test.go (1 hunks)
🔥 Files not summarized due to errors (1)
  • api/ethermint/evm/v1/query.pulsar.go: Error: Server error: no LLM provider could handle the message
✅ Files skipped from review due to trivial changes (3)
  • client/docs/swagger-ui/swagger.json
  • proto/ethermint/feemarket/v1/feemarket.proto
  • proto/ethermint/types/v1/dynamic_fee.proto
🔇 Additional comments (27)
x/evm/types/scaling.go (1)

Line range hint 1-42: Summary of changes and impact

The addition of the ConvertBigIntFrom18DecimalsToLegacyDec function enhances the scaling capabilities of the module by providing a way to convert from 18 decimals to the EVM coin's decimal representation. This change aligns well with the PR objective of refactoring RPC gas prices to support 6 decimal places.

The new function complements the existing ConvertAmountTo18DecimalsLegacy function, providing a reverse operation. It maintains the flexibility to work with different decimal configurations as determined by GetEVMCoinDecimals().

Overall, this change improves the module's ability to handle various decimal representations, which is crucial for accurate gas price calculations and conversions in the EVM context.

rpc/backend/backend.go (3)

51-51: Overall impact of gas price refactoring

The changes to RPCMinGasPrice and GlobalMinGasPrice methods consistently use *big.Int for gas price representation, which aligns with the PR objective to "refactor rpc gas prices to support 6 dec". This refactoring allows for more precise gas price handling, supporting up to 6 decimal places as mentioned in the PR title.

Given the significance of these changes:

  1. Ensure comprehensive unit and integration tests are in place to verify the correct behavior of gas price calculations and representations throughout the system.
  2. Update any documentation, including API docs and developer guides, to reflect these changes.
  3. Consider adding a migration guide if this change affects external integrations or APIs.

To ensure a smooth transition, run the following script to identify potential areas that might need updates:

#!/bin/bash
# Description: Identify potential areas affected by the gas price refactoring

# Test: Search for usages of int64 or math.LegacyDec in relation to gas prices
echo "Searching for potential areas that might need updates:"
rg --type go -e '(int64|math\.LegacyDec).*gas.*price'

# Test: Search for any remaining usages of math.LegacyDec
echo "Searching for any remaining usages of math.LegacyDec:"
rg --type go -e 'math\.LegacyDec'

Please review the output of this script to ensure all relevant areas have been updated to use *big.Int for gas price representation.

Also applies to: 86-86


86-86: Approve change to GlobalMinGasPrice return type.

The modification of the return type from (math.LegacyDec, error) to (*big.Int, error) for GlobalMinGasPrice is a good improvement. This change aligns with the RPCMinGasPrice method, standardizing on *big.Int for gas price representation.

Please ensure that all implementations of this interface method and any code that calls this method have been updated accordingly. Run the following script to verify the usage:

Consider updating the documentation to reflect this change in return type, especially if there are any API docs or developer guides that mention the GlobalMinGasPrice method.

✅ Verification successful

Change to GlobalMinGasPrice return type verified.

The update of GlobalMinGasPrice to return (*big.Int, error) has been successfully verified with no existing implementations or usages conflicting with this change. This ensures that the modification aligns with the intended standardization without introducing issues.

Consider updating the documentation to reflect this change in return type, ensuring that all relevant API docs and developer guides are consistent with the new method signature.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all implementations and usages of GlobalMinGasPrice method

# Test: Search for GlobalMinGasPrice method implementations
echo "Searching for GlobalMinGasPrice implementations:"
rg --type go -e 'func \(.*\) GlobalMinGasPrice\(\) \(\*big\.Int, error\)'

# Test: Search for GlobalMinGasPrice method calls
echo "Searching for GlobalMinGasPrice method calls:"
rg --type go -e 'GlobalMinGasPrice\(\)'

Length of output: 10966


51-51: Approve change to RPCMinGasPrice return type.

The modification of the return type from int64 to *big.Int for RPCMinGasPrice is a good improvement. This change allows for more precise representation of gas prices and can handle arbitrarily large values, which is beneficial for cryptocurrency applications.

Please ensure that all implementations of this interface method and any code that calls this method have been updated accordingly. Run the following script to verify the usage:

✅ Verification successful

RPCMinGasPrice Return Type Updated Correctly

The return type of RPCMinGasPrice has been successfully updated to *big.Int across all implementations and usages. All assignments and operations involving this method handle the *big.Int type appropriately, ensuring type safety and correctness.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all implementations and usages of RPCMinGasPrice method

# Test: Search for RPCMinGasPrice method implementations
echo "Searching for RPCMinGasPrice implementations:"
rg --type go -e 'func \(.*\) RPCMinGasPrice\(\) \*big\.Int'

# Test: Search for RPCMinGasPrice method calls
echo "Searching for RPCMinGasPrice method calls:"
rg --type go -e 'RPCMinGasPrice\(\)'

Length of output: 701


Script:

#!/bin/bash
# Description: Verify handling of RPCMinGasPrice return type in all usage locations

# Function to check usage in a specific file
check_usage() {
  local file=$1
  echo "Checking RPCMinGasPrice usage in $file:"

  # Check for correct type handling (expecting *big.Int)
  rg --type go -A 5 'RPCMinGasPrice\(\)' "$file" | grep -E '(*big\.Int)|(&big\.Int)|big\.NewInt'
  
  echo ""
}

# List of files with RPCMinGasPrice calls
files=(
  "rpc/backend/node_info_test.go"
  "rpc/backend/node_info.go"
  "rpc/backend/call_tx.go"
  "rpc/backend/backend.go"
)

for file in "${files[@]}"; do
  check_usage "$file"
done

Length of output: 1810


Script:

#!/bin/bash
# Description: Verify handling of RPCMinGasPrice return type in all usage locations with corrected regex

# Function to check usage in a specific file
check_usage() {
  local file=$1
  echo "Checking RPCMinGasPrice usage in $file:"

  # Corrected regex patterns to match literal *big.Int, &big.Int, or big.NewInt
  rg --type go -A 5 'RPCMinGasPrice\(\)' "$file" | grep -E '(\*big\.Int)|(&big\.Int)|big\.NewInt'
  
  echo ""
}

# List of files with RPCMinGasPrice calls
files=(
  "rpc/backend/node_info_test.go"
  "rpc/backend/node_info.go"
  "rpc/backend/call_tx.go"
  "rpc/backend/backend.go"
)

for file in "${files[@]}"; do
  check_usage "$file"
done

Length of output: 1654


Script:

#!/bin/bash
# Description: Inspect usage of RPCMinGasPrice return type in all usage locations

# Function to analyze how RPCMinGasPrice is used in a specific file
analyze_usage() {
  local file=$1
  echo "Analyzing RPCMinGasPrice usage in $file:"
  
  # Extract lines where RPCMinGasPrice is called along with surrounding context
  rg --type go -C 3 'RPCMinGasPrice\(\)' "$file" | while read -r line; do
    echo "$line"
  done
  
  echo ""
}

# List of files with RPCMinGasPrice calls
files=(
  "rpc/backend/node_info_test.go"
  "rpc/backend/node_info.go"
  "rpc/backend/call_tx.go"
  "rpc/backend/backend.go"
)

for file in "${files[@]}"; do
  analyze_usage "$file"
done

Length of output: 4667

rpc/backend/node_info_test.go (1)

Line range hint 1-1: Summary of changes in rpc/backend/node_info_test.go

The changes made to this file are appropriate and align with the PR objective of supporting 6 decimal places for gas prices. The modifications are localized to the TestRPCMinGasPrice function, changing the expMinGasPrice field from int64 to *big.Int. This change allows for higher precision in gas price representation.

Key points:

  1. The change is minimal and doesn't affect other test functions in this file.
  2. The use of big.NewInt(types.DefaultGasPrice) ensures consistency with the new data type.
  3. A suggestion was made to add a comment explaining the reason for using *big.Int.
  4. A verification script was provided to check for any inconsistencies in gas price type usage across the codebase.

Overall, the changes look good, but it's important to ensure that this modification is consistent with the rest of the codebase and doesn't introduce any unexpected behavior in other components that might be expecting int64 gas prices.

x/evm/types/scaling_test.go (2)

272-323: Well-structured and comprehensive test function.

The TestConvertBigIntFrom18DecimalsToLegacyDec function is well-designed and covers a good range of test cases. It tests the conversion functionality for both 6 and 18 decimal configurations, which aligns well with the PR objective of supporting 6 decimal places.

Some noteworthy aspects:

  1. The test cases cover important scenarios such as the smallest amount, values close to 1, and larger values like "one ether".
  2. The function tests both 6 and 18 decimal configurations, ensuring compatibility with different setups.
  3. The use of evmtypes.NewEVMConfigurator() for each test case ensures a clean environment for each test.

272-323: Overall, the new test function enhances the test coverage significantly.

The addition of TestConvertBigIntFrom18DecimalsToLegacyDec is a valuable contribution to the test suite. It directly supports the PR's objective of refactoring RPC gas prices to support 6 decimal places by thoroughly testing the conversion function for both 6 and 18 decimal configurations.

The test cases are well-chosen and cover a good range of scenarios. The structure of the test function, with its nested loops for different configurations, ensures comprehensive coverage.

This new test function will help maintain the reliability of the conversion logic as the codebase evolves, which is crucial for accurate gas price handling in both 6 and 18 decimal scenarios.

rpc/backend/chain_info_test.go (1)

Line range hint 1-465: Overall assessment of changes

The modifications to the TestGlobalMinGasPrice function align well with the PR objective of refactoring RPC gas prices to support 6 decimal places. The switch from math.LegacyDec to *big.Int allows for more precise representation of gas prices.

However, to ensure robustness and complete coverage of the new functionality:

  1. Consider expanding the test cases as suggested in the previous comment.
  2. Review other parts of the codebase that might be affected by this change, especially any code that interacts with GlobalMinGasPrice.
  3. Ensure that the precision of 6 decimal places is consistently maintained and verified throughout the relevant parts of the codebase.

To ensure consistency across the codebase, let's check for other files that might need similar updates:

#!/bin/bash
# Search for files using math.LegacyDec in relation to gas prices
rg "math\.LegacyDec.*gas.*price" --type go

# Search for files using GlobalMinGasPrice
rg "GlobalMinGasPrice" --type go

This will help identify any other areas that might need attention due to this refactoring.

proto/ethermint/evm/v1/query.proto (2)

322-323: LGTM: QueryGlobalMinGasPriceRequest is correctly defined.

The empty QueryGlobalMinGasPriceRequest message is appropriate for this query, as it doesn't require any input parameters. This approach is consistent with similar request messages in the file.


Line range hint 80-329: Summary: Changes are well-implemented and align with PR objectives.

The new GlobalMinGasPrice RPC method and associated request/response messages have been correctly implemented. They are consistent with the existing code structure and follow appropriate protobuf conventions. The changes support the PR objective of refactoring RPC gas prices to accommodate six decimal places.

A few minor suggestions were made to improve comment clarity, but overall, the implementation is sound and ready for integration.

rpc/backend/evm_query_client_test.go (1)

278-283: Overall changes look good and maintain code consistency.

The addition of the RegisterGlobalMinGasPrice function at the end of the file and the extra newline maintain the existing code structure and improve readability. These changes are consistent with the file's organization and coding style.

rpc/backend/call_tx.go (2)

401-402: Ensure precision is maintained in gas price comparison

The simplified comparison result.Cmp(minGasPrice) < 0 assumes that minGasPrice is now of type *big.Int. Please verify that this change doesn't affect the precision of the gas price calculation, especially if minGasPrice was previously of a different type (e.g., sdk.Dec).

#!/bin/bash
# Search for the definition of GlobalMinGasPrice to verify its return type
rg --type go "func.*GlobalMinGasPrice.*\) \*big\.Int" .

Consider adding a comment explaining the reasoning behind this simplified comparison and any potential implications on gas price precision.


393-393: Verify return type of b.RPCMinGasPrice()

The direct assignment result = b.RPCMinGasPrice() assumes that b.RPCMinGasPrice() returns a *big.Int. Please verify that this is indeed the case to ensure type compatibility.

Consider adding a comment explaining why this direct assignment is preferred over creating a new big.Int.

rpc/backend/mocks/evm_query_client.go (1)

242-270: LGTM: New GlobalMinGasPrice method added correctly

The new GlobalMinGasPrice method has been implemented correctly following the established pattern for mock methods in this file. It properly handles the input parameters and return values, maintaining consistency with other methods.

x/evm/keeper/grpc_query.go (1)

711-717: Implementation looks good, but consider adding documentation and verifying truncation.

The GlobalMinGasPrice method is implemented correctly and follows the expected pattern for gRPC query methods. However, I have a few suggestions for improvement:

  1. Consider adding a comment block above the method to explain its purpose and behavior. This will improve code readability and maintainability.

  2. The truncation of the minimum gas price to an integer (line 715) might lead to loss of precision. Please verify if this is the intended behavior. If precision is important, you might want to return the full decimal value instead.

Here's a suggested improvement with added documentation:

+// GlobalMinGasPrice implements the Query/GlobalMinGasPrice gRPC method.
+// It returns the global minimum gas price as an integer.
+// Note: The returned value is truncated, which may lead to loss of precision.
 func (k Keeper) GlobalMinGasPrice(c context.Context, _ *types.QueryGlobalMinGasPriceRequest) (*types.QueryGlobalMinGasPriceResponse, error) {
 	ctx := sdk.UnwrapSDKContext(c)
 	minGasPrice := k.GetMinGasPrice(ctx).TruncateInt()
 	return &types.QueryGlobalMinGasPriceResponse{MinGasPrice: minGasPrice}, nil
 }

To verify the intentional truncation of the gas price and its potential impact, we can run the following script:

This script will help us understand if the truncation is consistent with other parts of the codebase and if there's any documentation about the precision of the minimum gas price.

CHANGELOG.md (3)

Line range hint 43-44: Notable Improvements

  1. Enhanced testing: Lint tests, new e2e tests, and improved integration test utils.
  2. CI improvements: Added Golang dependency vulnerability checker.
  3. Documentation updates: Added audits page and improved existing docs.
  4. Module refactoring: vesting, ERC-20, and outpost modules have been improved.
  5. Performance enhancements: Improved efficiency in various modules.

These improvements should lead to better code quality, security, and developer experience. Ensure that:

  1. The new tests are comprehensive and cover critical paths.
  2. The vulnerability checker is properly configured and integrated into the CI pipeline.
  3. Documentation accurately reflects the latest changes and new features.

Also applies to: 45-46, 47-48, 49-50, 51-52, 53-54, 55-56, 57-58, 59-60, 61-62, 63-64, 65-66, 67-68, 69-70

🧰 Tools
🪛 Markdownlint

68-68: Expected: 120; Actual: 150
Line length

(MD013, line-length)


71-71: New feature: Refactor JSON-RPC gas prices

This change could have significant implications for users interacting with the JSON-RPC interface. It's important to ensure that this refactoring doesn't break existing integrations.

To verify the impact of this change, we should run the following script:

✅ Verification successful

Verified: No changes found in GasPrice functions.

The refactor does not modify any GasPrice-related functions, ensuring existing JSON-RPC integrations remain unaffected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any changes in gas price related functions
rg --type go 'func.*GasPrice'

Length of output: 13806


Script:

#!/bin/bash
# Search for any function definitions or modifications related to GasPrice using ast-grep
ast-grep --lang go --pattern 'func GasPrice($_)' .

Length of output: 52


72-73: Critical Bug Fixes

Several important bugs have been addressed:

  1. Fixed Ledger support for EthSecp256k1.
  2. Corrected snapshot configuration and CLI version output.
  3. Fixed setup of gRPC node service.
  4. Resolved issues with unbound metrics.
  5. Fixed the problem of users unable to send transactions with 0 gasPrice to precompiled contracts.

These fixes should significantly improve the stability and usability of the system. Ensure that:

  1. Regression tests are added for each of these bug fixes to prevent future recurrence.
  2. The fixes are well-documented, especially those affecting user interactions like the gasPrice issue.

To verify the impact of these bug fixes, run the following script:

Also applies to: 74-75, 76-77, 78-79, 80-81, 82-83

api/ethermint/evm/v1/query.pulsar.go (6)

11962-12316: LGTM: New QueryGlobalMinGasPriceRequest structures and methods added correctly.

The new code for QueryGlobalMinGasPriceRequest has been properly integrated into the file. It follows the standard pattern for protocol buffer generated code, including all necessary reflection-related methods and structures.


12317-12737: LGTM: QueryGlobalMinGasPriceResponse correctly implemented.

The QueryGlobalMinGasPriceResponse structure and its associated methods have been properly implemented. The MinGasPrice field is correctly defined as a string type and is handled appropriately in all generated methods. The code adheres to the standard protocol buffer generated code pattern.


13892-13954: LGTM: QueryGlobalMinGasPrice request and response structs properly defined.

The QueryGlobalMinGasPriceRequest and QueryGlobalMinGasPriceResponse structs are correctly defined with their associated methods. The MinGasPrice field in the response struct is properly typed as a string. All necessary Go struct methods (Reset, String, ProtoMessage, etc.) are present and correctly implemented.


14288-14336: LGTM: Message types correctly updated for GlobalMinGasPrice query.

The file_ethermint_evm_v1_query_proto_msgTypes and file_ethermint_evm_v1_query_proto_goTypes slices have been properly updated to include the new QueryGlobalMinGasPriceRequest and QueryGlobalMinGasPriceResponse types. The additions are consistent with the existing pattern and indices in the file.


Line range hint 14349-14689: LGTM: Dependency indices and exporters correctly updated for GlobalMinGasPrice.

The file_ethermint_evm_v1_query_proto_depIdxs slice has been properly updated to include the new GlobalMinGasPrice query method. The exporter functions for QueryGlobalMinGasPriceRequest and QueryGlobalMinGasPriceResponse have been correctly implemented. These changes are consistent with the existing pattern in the file.


Line range hint 11962-14697: LGTM: GlobalMinGasPrice query successfully integrated.

The new GlobalMinGasPrice query has been successfully integrated into the generated protocol buffer code. All necessary structures, methods, and type information have been correctly added and are consistent with the existing codebase.

However, as this is generated code, it's important to ensure that the actual implementation of the GlobalMinGasPrice query is correctly handled in the corresponding service files.

To verify the complete implementation, please check the following:

rpc/backend/chain_info.go (1)

50-55: Ensure all callers of GlobalMinGasPrice handle the new return type

The return type of GlobalMinGasPrice has been changed from math.LegacyDec to *big.Int. Please verify that all code invoking this method has been updated accordingly to handle the new return type, preventing any potential runtime errors or type mismatches.

Run the following script to find all usages of GlobalMinGasPrice in the codebase:

rpc/backend/node_info.go (2)

290-294: Correctly scales gas price to denomination precision

The gas price is properly converted from 18 decimals to the denomination's precision using ConvertBigIntFrom18DecimalsToLegacyDec, ensuring accurate fee calculations.


341-350: Properly updates RPCMinGasPrice to return *big.Int

The method RPCMinGasPrice now correctly returns a *big.Int, converting the minimum gas price to 18-decimal precision. This change enhances compatibility with Ethereum clients that expect gas prices in 18-decimal format.

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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6c6864e and 88aeefb.

📒 Files selected for processing (1)
  • rpc/backend/chain_info.go (1 hunks)
🔇 Additional comments (1)
rpc/backend/chain_info.go (1)

55-58: Add a nil check for res.MinGasPrice before calling BigInt()

To prevent a potential nil pointer dereference, ensure that res.MinGasPrice is not nil before calling res.MinGasPrice.BigInt().

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 (1)
CHANGELOG.md (1)

Changelog Missing Removed or Replaced Code Details

The CHANGELOG.md does not include information about removed or replaced code in lines 69-75. It's recommended to update the changelog to explicitly reflect these changes to ensure comprehensive documentation.

🔗 Analysis chain

Line range hint 15-16: Multiple breaking changes and significant updates

This release includes several state machine breaking changes:

  1. Refactoring of the RPC gas prices to support 6 decimal places
  2. Addition of a new governance precompile
  3. Refactoring of the application to use sdk.BaseDenom and EVM denom
  4. Changes to the x/feemarket BaseFee to use Decimal
  5. Removal of automatic withdrawal of staking rewards in case of insufficient funds
  6. Replacement of EthAccount type with BaseAccount

These changes are likely to have significant impacts on the network and may require careful consideration during the upgrade process. Ensure that all node operators and developers are aware of these changes and update their systems accordingly.

To verify the impact of these changes, especially the BaseDenom and EVM denom changes, run the following command:

Also applies to: 17-18, 19-20, 21-22, 23-24, 25-26, 27-28, 29-30, 31-32

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for references to the old denom and potential conflicts with the new BaseDenom
rg -i 'aevmos|stake|basedenom'

Length of output: 97251

🧰 Tools
🪛 Markdownlint

69-69: Expected: 120; Actual: 150
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 25b9986 and c977de1.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
🔇 Additional comments (3)
CHANGELOG.md (3)

72-73: New feature: JSON-RPC gas prices support for different precision

This improvement adds support for JSON-RPC gas prices with different precision. This could have significant implications for how gas prices are handled and may require updates to client applications interacting with the JSON-RPC interface.


Line range hint 34-35: Various improvements and bug fixes

This release includes several improvements and bug fixes:

  1. Performance improvements for eth_headerByHash
  2. Updates to the Interpreter interface to support custom Opcodes
  3. Fix for the community pool being nil
  4. Updates to CLI commands and removal of unnecessary fee ante handlers
  5. Changes to how the ChainID is handled in the EVM module
  6. Adjustments to extra decimals handling in EVM state operations

These changes should enhance the overall performance and functionality of the system. However, developers should review these changes to ensure compatibility with their applications, especially those interacting with the EVM module or using the CLI commands.

Also applies to: 36-37, 38-39, 40-41, 42-43, 44-45, 46-47, 48-49, 50-51, 52-53, 54-55, 56-57, 58-59, 60-61, 62-63, 64-65, 66-67, 68-69, 70-71

🧰 Tools
🪛 Markdownlint

69-69: Expected: 120; Actual: 150
Line length

(MD013, line-length)


Line range hint 1-2147: Well-structured and informative changelog

The CHANGELOG.md file is well-organized and provides a detailed history of changes across multiple versions of the Evmos project. It consistently categorizes changes into State Machine Breaking, API Breaking, Improvements, and Bug Fixes, which is helpful for users and developers to understand the impact of each release.

For future updates, consider adding more context or rationale for major changes, especially those that are state machine breaking. This could help users and developers better understand the motivations behind significant changes and prepare for upgrades more effectively.

🧰 Tools
🪛 Markdownlint

69-69: Expected: 120; Actual: 150
Line length

(MD013, line-length)

@GAtom22 GAtom22 merged commit 50c7684 into main Oct 4, 2024
52 of 55 checks passed
@GAtom22 GAtom22 deleted the GAtom22/evm-grpc-query branch October 4, 2024 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants