Skip to content

Conversation

0xstepit
Copy link
Contributor

@0xstepit 0xstepit commented Sep 23, 2024

Given the refactor made with #2860, we do not need the ChainID in the EVM keeper anymore. This PR:

  • Remove the BeginBlock of x/evm.
  • Remove ChainID tests.
  • Replace getter to evm ChainID with getters to global config.

Summary by CodeRabbit

  • New Features

    • Centralized configuration for ChainID management across the application.
  • Bug Fixes

    • Removed deprecated BeginBlock functionality in the EVM component.
  • Refactor

    • Updated various components to retrieve ChainID from the new configuration method, enhancing consistency and maintainability.
    • Simplified the AppModule interface by eliminating the BeginBlock functionality.
  • Chores

    • Cleaned up test cases and removed unnecessary methods related to ChainID handling.

Copy link
Contributor

coderabbitai bot commented Sep 23, 2024

Walkthrough

The changes in this pull request focus on the removal of the BeginBlock functionality from the Ethereum Virtual Machine (EVM) component and the transition from using a block-specific ChainID to a globally configured ChainID. This update simplifies the management of operational parameters within the blockchain, ensuring that the chain ID is consistently accessed through a centralized configuration across various components and tests.

Changes

File(s) Change Summary
app/ante/evm/*.go Updated retrieval of ChainID to use config.GetChainConfig().ChainID instead of EvmKeeper.
app/app.go Removed evmtypes.ModuleName from the NewEvmos function.
x/evm/keeper/*.go Removed BeginBlock method and ChainID handling from Keeper, simplifying chain ID management.
x/evm/module.go Removed BeginBlock method from AppModule, simplifying the interface.
x/evm/genesis.go Removed line setting chain ID in the genesis initialization process.
testutil/*.go Updated ChainID retrieval to use configuration instead of EvmKeeper.
precompiles/*.go Updated ChainID retrieval in precompile tests to use configuration instead of EvmKeeper.
x/evm/keeper/*.go Centralized ChainID retrieval to configuration across various functions and tests.

Possibly related PRs

  • fix linter #2839: The changes in this PR focus on fixing linter issues, which do not directly relate to the modifications made in the main PR regarding the removal of BeginBlock functionality and the replacement of ChainID with a global configuration setting.

Suggested labels

types

Suggested reviewers

  • MalteHerrmann
  • fedekunze

🐰 In the code, we hop and play,
With ChainID now here to stay.
No more blocks to hold it tight,
A global config feels just right!
Simplified paths, oh what a thrill,
In our EVM, we jump and chill! 🌟


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c4c2770 and 999b395.

Files selected for processing (3)
  • testutil/abci.go (3 hunks)
  • testutil/tx/eth.go (3 hunks)
  • x/vesting/keeper/integration_test.go (8 hunks)
Files skipped from review as they are similar to previous changes (1)
  • testutil/tx/eth.go
Additional comments not posted (8)
testutil/abci.go (4)

123-123: LGTM: Consistent removal of appEvmos parameter.

This change in the DeliverEthTxWithoutCheck function is consistent with the previous modification in DeliverEthTx. It further supports the removal of the ChainID dependency from the EVM keeper.


172-172: LGTM: Comprehensive removal of appEvmos parameter.

This change in the CheckEthTx function completes the consistent removal of the appEvmos parameter from all PrepareEthTx calls in this file. The uniform application of this change across different transaction handling functions (deliver, deliver without check, and check) demonstrates a comprehensive approach to removing the ChainID dependency from the EVM keeper.


Line range hint 96-172: Summary: Consistent removal of appEvmos parameter from PrepareEthTx calls

The changes in this file consistently remove the appEvmos parameter from all PrepareEthTx function calls across three different methods: DeliverEthTx, DeliverEthTxWithoutCheck, and CheckEthTx. This modification aligns with the PR objective of removing the ChainID from the EVM keeper.

These changes suggest that the PrepareEthTx function no longer requires direct access to the appEvmos object, likely because it no longer needs to access the ChainID through this object. This refactoring appears to be part of a larger effort to streamline the EVM-related functionality and remove unnecessary dependencies.

The consistency of these changes across different transaction handling functions indicates a thorough approach to this refactoring effort. However, to ensure the completeness of this change:

  1. Verify that the PrepareEthTx function signature in its definition has been updated accordingly.
  2. Check if there are any other files or components that might be affected by this change and ensure they have been updated as well.

To ensure the completeness of these changes, please run the following script:

#!/bin/bash
# Check the PrepareEthTx function signature
echo "PrepareEthTx function signature:"
rg 'func PrepareEthTx' --type go -A 1

# Check for any remaining uses of appEvmos with PrepareEthTx
echo "\nAny remaining uses of appEvmos with PrepareEthTx:"
rg 'PrepareEthTx.*appEvmos' --type go

96-96: LGTM: Removed appEvmos parameter from PrepareEthTx call.

This change aligns with the PR objective of removing the ChainID from the EVM keeper. The removal of the appEvmos parameter suggests that the ChainID is no longer needed in the PrepareEthTx function.

To ensure consistency, let's verify that this change has been applied uniformly across the codebase:

Verification successful

[/run_scripts]


Verification Successful: No remaining calls to PrepareEthTx use appEvmos.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining calls to PrepareEthTx that still use appEvmos
rg 'PrepareEthTx\s*\(\s*\w+\s*,\s*\w+\s*,' --type go

Length of output: 348


Script:

#!/bin/bash
# Search for all calls to PrepareEthTx and check if appEvmos is among the arguments
rg 'PrepareEthTx\s*\(' --type go --context 2 | grep 'appEvmos'

Length of output: 221

x/vesting/keeper/integration_test.go (4)

608-608: LGTM! Consistent change.

This modification to the PrepareEthTx function call is consistent with the previous change, removing the s.network.App parameter. This consistency suggests a systematic update to the function's usage throughout the codebase.


Line range hint 567-783: Summary: Consistent refactoring of PrepareEthTx function calls

The changes in this file demonstrate a consistent refactoring of the PrepareEthTx function calls across multiple test cases. The removal of the s.network.App parameter simplifies the function usage and likely reflects changes in the underlying implementation of PrepareEthTx.

Key points:

  1. All instances of PrepareEthTx have been updated to remove the s.network.App parameter.
  2. The changes are consistent throughout the file, indicating a systematic refactoring approach.
  3. No new functionality appears to have been added or removed; this seems to be a simplification of the existing code.

These modifications should lead to cleaner and more maintainable test code. However, it's crucial to ensure that this refactoring has been applied consistently across the entire codebase and that the PrepareEthTx function's new signature is properly documented.


671-672: LGTM! Consistent changes across multiple test cases.

These modifications to the PrepareEthTx function calls are consistent throughout the file, removing the s.network.App parameter in all instances. This systematic update across multiple test cases indicates a thorough refactoring of the PrepareEthTx function usage.

To ensure the refactoring is complete and consistent, please run the following command to check for any remaining instances of PrepareEthTx that might have been missed:

This will help identify any potential inconsistencies in the usage of PrepareEthTx across the entire Go codebase.

Also applies to: 697-698, 725-726, 755-756, 782-783


567-568: LGTM! Verify PrepareEthTx function signature.

The removal of the s.network.App parameter from the PrepareEthTx function call looks good. This change likely simplifies the API and reduces unnecessary dependencies.

To ensure this change is consistent across the codebase, please run the following command to check for any remaining uses of PrepareEthTx with the old signature:

Verification successful

Verified PrepareEthTx function signature.

All instances of PrepareEthTx using s.network.App have been successfully removed from the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

rg 'PrepareEthTx.*s\.network\.App'

Length of output: 36


Script:

#!/bin/bash
# Find the definition of PrepareEthTx and display its signature
ast-grep --lang go --pattern $'func PrepareEthTx($_, $_, $_) $_' .

Length of output: 2650


Script:

#!/bin/bash
# Find all calls to PrepareEthTx with s.network.App as the second argument
ast-grep --lang go --pattern $'PrepareEthTx($_, s\.network\.App, $_)' .

Length of output: 72


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.

@0xstepit
Copy link
Contributor Author

The changelog checker complains because of x/evm instead of x/EVM so it should be ignored.

@0xstepit 0xstepit changed the title chore(evm): Remove unused chain from Evm keeper. chore(evm): Remove unused ChainID from Evm keeper. Sep 23, 2024
@0xstepit 0xstepit marked this pull request as ready for review September 23, 2024 15:55
@0xstepit 0xstepit requested a review from a team as a code owner September 23, 2024 15:55
@0xstepit 0xstepit requested review from hanchon and GAtom22 and removed request for a team September 23, 2024 15:55
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 (5)
app/ante/evm/eth_benchmark_test.go (1)

32-35: Approved: Chain ID retrieval simplified and centralized.

The change to use config.GetChainConfig().ChainID instead of s.GetNetwork().App.EvmKeeper.ChainID() aligns with the PR objective of removing ChainID from the EVM keeper. This approach ensures consistency in chain ID usage across the codebase.

Consider adding a brief comment explaining the purpose of evmChainID for improved code readability:

+// Retrieve the chain ID from the global configuration
 evmChainID := config.GetChainConfig().ChainID
precompiles/gov/gov_test.go (1)

90-93: LGTM: Updated ChainID retrieval method

The change from s.network.App.EvmKeeper.ChainID() to config.GetChainConfig().ChainID aligns with the PR's objective of using a globally configured ChainID. This modification ensures consistency between the test environment and the main application code.

Consider adding a brief comment explaining the reason for this change, to improve code readability:

- 
+ // Use the globally configured ChainID instead of the block-specific one
  evmChainID := config.GetChainConfig().ChainID
app/post/setup_test.go (1)

Line range hint 1-150: Overall assessment: Changes align with PR objectives

The modifications in this file successfully transition from using the EVM keeper's ChainID to a globally configured ChainID. This change is consistent with the PR's objective of removing unused ChainID from the EVM keeper following the recent refactor.

A few points to consider:

  1. Ensure that the global chain configuration is properly set up in all test environments.
  2. Update any other test files that might be using the old ChainID retrieval method.
  3. Consider adding a comment explaining the reason for this change, to provide context for future developers.

As part of this refactoring effort, it might be beneficial to review other parts of the codebase that interact with the ChainID to ensure consistency. Consider creating a centralized method or helper function for ChainID retrieval to make future updates easier and maintain consistency across the codebase.

testutil/tx/eth.go (1)

32-32: LGTM! Consider removing the unused parameter.

The changes align with the PR objectives by removing the dependency on appEvmos.EvmKeeper.ChainID() and using evmconfig.GetChainConfig().ChainID instead. This centralizes the chain ID configuration and removes unused code.

Consider removing the unused _ *app.Evmos parameter entirely from the function signature for better code clarity:

-func PrepareEthTx(txCfg client.TxConfig, _ *app.Evmos, priv cryptotypes.PrivKey, msgs ...sdk.Msg) (authsigning.Tx, error) {
+func PrepareEthTx(txCfg client.TxConfig, priv cryptotypes.PrivKey, msgs ...sdk.Msg) (authsigning.Tx, error) {

Also applies to: 38-38

testutil/contract.go (1)

63-63: LGTM: Updated chain ID retrieval method.

The change to use config.GetChainConfig().ChainID is appropriate and aligns with the PR objectives. It centralizes the chain ID configuration, improving maintainability.

Consider adding a brief comment explaining why we're using the config package for chain ID, for better code readability:

// Retrieve chain ID from the global configuration
chainID := config.GetChainConfig().ChainID
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f382725 and c4c2770.

Files selected for processing (25)
  • CHANGELOG.md (1 hunks)
  • app/ante/evm/ante_test.go (11 hunks)
  • app/ante/evm/eth_benchmark_test.go (1 hunks)
  • app/ante/evm/interfaces.go (0 hunks)
  • app/ante/evm/setup_ctx_test.go (1 hunks)
  • app/ante/evm/signverify_test.go (1 hunks)
  • app/ante/evm/sigs_test.go (2 hunks)
  • app/app.go (0 hunks)
  • app/post/setup_test.go (2 hunks)
  • precompiles/distribution/distribution_test.go (2 hunks)
  • precompiles/gov/gov_test.go (2 hunks)
  • precompiles/staking/staking_test.go (2 hunks)
  • precompiles/testutil/contracts/contracts.go (2 hunks)
  • testutil/contract.go (3 hunks)
  • testutil/tx/eth.go (3 hunks)
  • x/evm/genesis.go (0 hunks)
  • x/evm/keeper/abci.go (0 hunks)
  • x/evm/keeper/benchmark_test.go (10 hunks)
  • x/evm/keeper/keeper.go (0 hunks)
  • x/evm/keeper/keeper_test.go (0 hunks)
  • x/evm/keeper/state_transition_benchmark_test.go (6 hunks)
  • x/evm/keeper/state_transition_test.go (1 hunks)
  • x/evm/keeper/statedb_test.go (2 hunks)
  • x/evm/keeper/utils_test.go (6 hunks)
  • x/evm/module.go (1 hunks)
Files not reviewed due to no reviewable changes (6)
  • app/ante/evm/interfaces.go
  • app/app.go
  • x/evm/genesis.go
  • x/evm/keeper/abci.go
  • x/evm/keeper/keeper.go
  • x/evm/keeper/keeper_test.go
Additional comments not posted (78)
app/ante/evm/sigs_test.go (3)

7-7: LGTM: Import statement added for accessing chain configuration

The addition of the config package import aligns with the PR objective of using global configuration for ChainID.


Line range hint 1-54: Summary: Changes align with PR objectives and improve consistency

The modifications in this file successfully implement the PR objective of removing the unused ChainID from the EVM keeper. By retrieving the ChainID from the global configuration, the test now ensures consistency with the rest of the system. This change simplifies ChainID management and reduces potential discrepancies between different parts of the codebase.


18-21: LGTM: ChainID now retrieved from global configuration

The change to retrieve the ChainID from the global configuration aligns with the PR objective of removing unused ChainID from the EVM keeper. This ensures consistency across the system and simplifies ChainID management.

To ensure this change is consistent throughout the codebase, let's verify that other occurrences of ChainID retrieval have been updated similarly:

Verification successful

Verification Complete: ChainID Retrieval Updated Consistently

The ChainID retrieval has been successfully updated across the codebase to use the global configuration, with no remaining references to EvmKeeper. This ensures consistency and aligns with the PR objectives.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining uses of EvmKeeper for ChainID retrieval

# Test: Search for EvmKeeper ChainID usage
rg --type go 'EvmKeeper.*ChainID'

# Test: Search for new config ChainID usage
rg --type go 'config\.GetChainConfig\(\)\.ChainID'

Length of output: 3626

app/ante/evm/setup_ctx_test.go (4)

12-12: LGTM: Import statement addition is appropriate.

The addition of the config package import aligns with the PR objectives to use global configuration for ChainID instead of retrieving it from the EVM keeper.


22-22: LGTM: Test case updated to use new ChainID source.

The update to use evmChainID in the ethContractCreationTxParams is consistent with the earlier changes and ensures that the test case uses the globally configured chain ID.


Line range hint 1-62: Overall assessment: Changes align with PR objectives and maintain test integrity.

The modifications in this file successfully transition from using the EVM keeper's ChainID to the globally configured ChainID. This change is consistent across the file and maintains the overall structure and integrity of the test. The updates align well with the PR's objective of removing the unused ChainID from the EVM keeper.


18-19: LGTM: ChainID retrieval updated to use global configuration.

The change to retrieve evmChainID from the global configuration is in line with the PR objectives. This ensures consistency with the rest of the system.

To ensure this change doesn't inadvertently affect test behavior, please verify that the global configuration's ChainID matches the previously used value from the EVM keeper. You can run the following script to check this:

Verification successful

Verified: ChainID is correctly updated to use global configuration without remnants from EvmKeeper.

The change ensures that evmChainID is now sourced from the global configuration, aligning with the PR objectives. No usages of ChainID related to EvmKeeper were found, confirming the update does not affect test behavior adversely.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Compare the ChainID from global config with the one previously used in EVM keeper

# Search for previous ChainID usage in EVM keeper
old_chain_id=$(rg --type go -g '!*_test.go' 'ChainID.*EvmKeeper' x/evm)

# Get the new ChainID from global config
new_chain_id=$(rg --type go 'func GetChainConfig\(\).*ChainID' x/evm/config)

echo "Old ChainID usage: $old_chain_id"
echo "New ChainID from config: $new_chain_id"

# Note: Manual comparison might be needed as the exact format may vary

Length of output: 264


Script:

#!/bin/bash
# Description: Comprehensive search for ChainID usage in EVM keeper and global configuration

echo "Searching for 'ChainID' in the EVM package..."
rg --type go 'ChainID' x/evm

echo "Searching for 'ChainID' in the configuration files..."
rg --type go 'ChainID' x/evm/config

echo "Using ast-grep to find ChainID declarations in Go files..."
ast-grep --lang go --pattern 'var $_ = $_ChainID' x/...

Length of output: 12671


Script:

#!/bin/bash
# Description: Comprehensive search for ChainID declarations in EVM keeper and global configuration

echo "Searching for 'ChainID' in the EVM package..."
rg --type go 'ChainID' x/evm

echo "Searching for 'ChainID' in the configuration files..."
rg --type go 'ChainID' x/evm/config

echo "Using ast-grep to find ChainID declarations in Go files..."
ast-grep --lang go --pattern 'var $_ = $_ChainID' x/

Length of output: 12615

app/ante/evm/signverify_test.go (4)

11-11: LGTM: New import for EVM configuration

The addition of the config import from the EVM module aligns with the PR objective of using global configuration for ChainID retrieval.


23-23: LGTM: Updated ChainID in test parameters

The ChainID in the ethContractCreationTxParams struct is correctly updated to use the evmChainID obtained from the global configuration. This change maintains consistency with the new ChainID retrieval method and ensures the test cases remain valid.


Line range hint 1-94: Overall assessment: Changes successfully implement PR objectives

The modifications in this file consistently replace the direct ChainID retrieval from the EVM keeper with the new method using global configuration. These changes align well with the PR's goal of removing the unused ChainID from the EVM keeper. The test cases have been appropriately updated to reflect these changes, maintaining the integrity of the tests.


17-20: LGTM: Updated ChainID retrieval method

The changes correctly implement the PR objective by retrieving the ChainID from the global configuration instead of the EVM keeper. This centralization improves consistency across the codebase.

To ensure this change is consistently applied throughout the codebase, let's verify other occurrences of ChainID retrieval:

Verification successful

Verified: ChainID retrieval is consistently centralized

All instances of ChainID retrieval have been successfully updated to use config.GetChainConfig().ChainID. No direct accesses to EvmKeeper.*ChainID were found, ensuring consistency across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining direct ChainID retrievals from EvmKeeper

# Test: Search for direct ChainID access from EvmKeeper
rg --type go 'EvmKeeper.*ChainID'

# Test: Search for new config-based ChainID retrieval
rg --type go 'config\.GetChainConfig\(\)\.ChainID'

Length of output: 3626

app/ante/evm/eth_benchmark_test.go (1)

32-35: Verify benchmark integrity after chain ID retrieval change.

While the change to use a globally configured chain ID is an improvement, it's crucial to ensure that this modification doesn't inadvertently affect the benchmark's ability to accurately measure performance.

Please run the benchmark tests before and after this change to confirm that there's no significant impact on the performance metrics. You can use the following command:

Compare the results to ensure that the performance characteristics remain consistent.

precompiles/testutil/contracts/contracts.go (1)

73-73: Approve change with verification suggestion

The modification from app.EvmKeeper.ChainID() to config.GetChainConfig().ChainID aligns with the PR objective of removing ChainID from the EVM keeper and using a global configuration. This change promotes consistency in ChainID retrieval across the codebase.

To ensure this change is consistently applied throughout the codebase, please run the following verification script:

This script will help identify any inconsistencies in ChainID retrieval across the codebase, ensuring that the refactoring is complete and consistent.

Verification successful

ChainID Retrieval Consistently Updated

All instances of app.EvmKeeper.ChainID() have been successfully replaced with config.GetChainConfig().ChainID. This refactoring ensures consistent ChainID retrieval across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistent usage of ChainID retrieval method

# Test 1: Check for any remaining usage of EvmKeeper.ChainID()
echo "Checking for remaining usage of EvmKeeper.ChainID():"
rg --type go 'EvmKeeper\.ChainID\(\)'

# Test 2: Verify the new usage of config.GetChainConfig().ChainID
echo "Verifying usage of config.GetChainConfig().ChainID:"
rg --type go 'config\.GetChainConfig\(\)\.ChainID'

# Test 3: Check for any other methods of retrieving ChainID that might need updating
echo "Checking for other ChainID retrieval methods:"
rg --type go 'ChainID'

Length of output: 45428

precompiles/gov/gov_test.go (2)

11-11: LGTM: New import aligns with PR objectives

The addition of the config package import is consistent with the PR's goal of transitioning to a globally configured ChainID.


Line range hint 1-145: Overall impact: Minimal and focused changes

The modifications in this file are limited to importing the config package and updating the ChainID retrieval method. These changes align well with the PR objectives and the recent refactor, while maintaining the overall structure and functionality of the test suite.

To ensure that these changes haven't inadvertently affected other parts of the codebase, please run the following verification script:

This script will help identify any inconsistencies in ChainID retrieval methods across the codebase.

Verification successful

Verification Successful: ChainID Retrieval Method Consistently Updated

The shell script results confirm that the old EvmKeeper.ChainID() method is no longer present and the new config.GetChainConfig().ChainID method is consistently used across the codebase. This ensures that the changes are fully integrated without affecting other parts of the system.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the ChainID is consistently retrieved using the new method across the codebase.

# Test: Search for any remaining instances of the old ChainID retrieval method
rg --type go 'EvmKeeper\.ChainID\(\)'

# Test: Confirm that the new ChainID retrieval method is used consistently
rg --type go 'config\.GetChainConfig\(\)\.ChainID'

Length of output: 3630

app/post/setup_test.go (2)

23-24: LGTM: Import addition is appropriate

The addition of the config package import from the evm module is consistent with the PR's objective of transitioning to a globally configured ChainID. This import is necessary for the subsequent changes in the BuildEthTx method.


73-74: LGTM: ChainID retrieval updated correctly

The modification to use config.GetChainConfig().ChainID instead of s.unitNetwork.App.EvmKeeper.ChainID() is in line with the PR's objective of removing the ChainID from the EVM keeper. This change ensures consistency in ChainID retrieval across the application.

To ensure this change doesn't introduce any unexpected behavior, please verify that the global chain configuration is properly set up in the test environment. You can add a simple assertion before this line to check if the ChainID is set correctly:

chainID := config.GetChainConfig().ChainID
s.Require().NotNil(chainID, "ChainID should not be nil")
s.Require().NotEqual(chainID.Int64(), int64(0), "ChainID should not be zero")

This will help catch any potential issues with the global configuration in the test setup.

testutil/tx/eth.go (2)

32-32: Summary: Successful removal of EvmKeeper.ChainID() dependency

The changes in this file successfully remove the dependency on EvmKeeper.ChainID() and replace it with evmconfig.GetChainConfig().ChainID. This modification:

  1. Centralizes the chain ID configuration management.
  2. Removes unused code from the Evm keeper.
  3. Maintains consistency across the affected functions.

These changes align well with the PR objectives and contribute to a more streamlined codebase.

Also applies to: 38-38, 106-106, 125-125


106-106: LGTM! Verify chain ID consistency across the codebase.

The changes align with the PR objectives by replacing appEvmos.EvmKeeper.ChainID() with evmconfig.GetChainConfig().ChainID. This centralizes the chain ID configuration and removes the dependency on the Evm keeper for this information.

To ensure consistency across the codebase, let's verify that all instances of EvmKeeper.ChainID() have been replaced:

Also applies to: 125-125

Verification successful

Verified: Chain ID consistency confirmed across the codebase.

All instances of EvmKeeper.ChainID() have been successfully replaced with GetChainConfig().ChainID, including in the test files. This ensures centralized configuration of the chain ID and removes dependencies on the Evm keeper.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining instances of EvmKeeper.ChainID()

# Test: Search for EvmKeeper.ChainID(). Expect: No results.
rg --type go 'EvmKeeper\.ChainID\(\)'

# Test: Search for GetChainConfig().ChainID. Expect: Multiple results including the changes in this file.
rg --type go 'GetChainConfig\(\)\.ChainID'

Length of output: 3622

testutil/contract.go (2)

23-23: LGTM: New import for chain configuration.

The addition of the config package import is appropriate and necessary for the changes made in this file.


109-109: LGTM: Consistent chain ID retrieval method.

The change to use config.GetChainConfig().ChainID is consistent with the modification in the DeployContract function. This ensures uniformity in how the chain ID is obtained throughout the file.

x/evm/module.go (3)

Line range hint 1-185: Verify chain ID management after BeginBlock removal.

The changes appear consistent throughout the file, with no obvious issues introduced. The EndBlock method remains intact, suggesting that necessary end-of-block operations are preserved.

To ensure the removal of BeginBlock hasn't impacted chain ID management:

  1. Confirm that the chain ID is now being managed correctly through global configuration.
  2. Verify that all parts of the system that previously relied on BeginBlock for chain ID updates have been adjusted.

Run the following script to check for chain ID references that might need attention:

#!/bin/bash
# Description: Check for chain ID references that might need attention after BeginBlock removal

# Test: Search for chain ID references in go files
rg --type go 'ChainID|chainID|chain_id' x/

Line range hint 1-185: Confirm all BeginBlock functionality has been appropriately handled.

The BeginBlock method has been successfully removed from the AppModule struct, which aligns with the PR objectives. This simplification is good for maintainability.

To ensure no critical functionality has been lost, please confirm:

  1. Any important operations previously performed in BeginBlock have been relocated to appropriate places or are no longer needed.
  2. The removal doesn't break any assumptions in other parts of the system.

Run the following script to check for any BeginBlock references in other modules that might have depended on the EVM module's BeginBlock:

#!/bin/bash
# Description: Check for BeginBlock references in other modules that might depend on EVM

# Test: Search for BeginBlock references in go files, excluding the x/evm directory
rg --type go 'BeginBlock.*evm' --glob '!x/evm/**'

37-37: LGTM! Verify system-wide impact of removing BeginBlock.

The removal of appmodule.HasBeginBlocker is consistent with the PR objectives and aligns with the recent refactor. The appmodule.HasEndBlocker interface implementation is correctly retained.

To ensure this change doesn't have unintended consequences, please run the following script to check for any remaining references to BeginBlock in the EVM module:

Verification successful

BeginBlock references have been successfully removed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to BeginBlock in the EVM module

# Test: Search for BeginBlock references in the x/evm directory
rg --type go 'BeginBlock' x/evm

Length of output: 17961


Script:

#!/bin/bash
# Description: Check for any remaining references to BeginBlock in the EVM module

# Test: Search for BeginBlock references in the x/evm directory
rg --type go 'BeginBlock' x/evm || echo "No matches found or an error occurred"

Length of output: 116

x/evm/keeper/utils_test.go (5)

7-8: LGTM: Import statements reorganized and new imports added.

The reorganization of import statements improves readability, and the new imports are appropriately added for the required functionality.

Also applies to: 16-19


93-93: LGTM: Updated chainID retrieval in TransferERC20Token function.

The change is consistent with the update in the DeployTestContract function, maintaining consistency across the codebase.


149-149: LGTM: Updated chainID retrieval and gas cap configuration in DeployTestMessageCall function.

The changes are consistent with the updates in other functions, maintaining consistency across different test utility functions.

Also applies to: 164-164


Line range hint 1-200: Overall changes align with PR objectives and improve consistency.

The modifications successfully implement the removal of ChainID from the EVM keeper and the transition to using a globally configured ChainID. These changes improve consistency across the codebase and centralize the chain ID configuration. The updates to gas cap configuration also contribute to a more standardized approach.

To ensure comprehensive test coverage for these changes, consider adding or updating tests that specifically verify:

  1. The correct retrieval of the chain ID from the global configuration.
  2. The proper application of the default gas cap in various scenarios.
  3. The behavior of the system when the chain ID or gas cap configurations are modified.

34-34: LGTM: Updated chainID retrieval and gas cap configuration.

The changes align with the PR objective of using a globally configured ChainID and are consistent with the updates mentioned in the summary.

To ensure these changes are consistently applied across the codebase, let's verify the usage:

Also applies to: 54-54

Verification successful

Verified: ChainID retrieval and gas cap configuration are consistently applied across the codebase.

All instances have been appropriately updated, ensuring consistency and alignment with the PR objectives.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify chainID retrieval and gas cap configuration

# Check for any remaining uses of suite.network.App.EvmKeeper.ChainID()
echo "Checking for remaining uses of suite.network.App.EvmKeeper.ChainID():"
rg --type go "suite\.network\.App\.EvmKeeper\.ChainID\(\)"

# Check for consistent use of evmconfig.GetChainConfig().ChainID
echo "Checking for consistent use of evmconfig.GetChainConfig().ChainID:"
rg --type go "evmconfig\.GetChainConfig\(\)\.ChainID"

# Check for consistent use of servercfg.DefaultGasCap
echo "Checking for consistent use of servercfg.DefaultGasCap:"
rg --type go "servercfg\.DefaultGasCap"

Length of output: 1198

x/evm/keeper/benchmark_test.go (7)

96-96: LGTM: Consistent update of ChainID retrieval.

The change to use config.GetChainConfig().ChainID is consistent with the previous modification and aligns with the PR objective of using a globally configured ChainID.


117-117: LGTM: Consistent update of ChainID retrieval.

The change to use config.GetChainConfig().ChainID is consistent with the previous modifications and aligns with the PR objective of using a globally configured ChainID.


138-138: LGTM: Consistent update of ChainID retrieval.

The change to use config.GetChainConfig().ChainID is consistent with the previous modifications and aligns with the PR objective of using a globally configured ChainID.


159-159: LGTM: Consistent update of ChainID retrieval.

The change to use config.GetChainConfig().ChainID is consistent with the previous modifications and aligns with the PR objective of using a globally configured ChainID.


181-181: LGTM: Consistent updates of ChainID retrieval.

Both changes to use config.GetChainConfig().ChainID are consistent with the previous modifications and align with the PR objective of using a globally configured ChainID. This ensures that the ChainID is retrieved consistently throughout the benchmark tests.

Also applies to: 193-193


Line range hint 1-214: Summary: Consistent update of ChainID retrieval across benchmark tests

The changes in this file consistently update the ChainID retrieval method from directly accessing the EvmKeeper to using config.GetChainConfig().ChainID. This modification:

  1. Aligns with the PR objective of removing the unused ChainID from the Evm keeper.
  2. Improves consistency in how the ChainID is accessed throughout the benchmark tests.
  3. Centralizes the ChainID configuration, which can make future updates easier to manage.

These changes contribute to a more maintainable and consistent codebase.


65-65: LGTM: Updated ChainID retrieval method.

The change from using the EvmKeeper's ChainID to config.GetChainConfig().ChainID aligns with the PR objective of removing the unused ChainID from the Evm keeper. This update ensures consistency with the global configuration.

To ensure this change is consistent across the codebase, let's verify other occurrences:

Verification successful

[Verified] All direct accesses to EvmKeeper's ChainID have been successfully removed and replaced with config.GetChainConfig().ChainID. The change is consistent across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining direct accesses to ChainID from EvmKeeper
rg --type go 'EvmKeeper.*ChainID'

# Search for new usage of GetChainConfig().ChainID
rg --type go 'GetChainConfig\(\)\.ChainID'

Length of output: 3618

precompiles/distribution/distribution_test.go (3)

14-14: LGTM: New import for chain configuration.

The addition of the config import is appropriate and necessary for the changes made in the TestRun function.


Line range hint 1-290: Overall assessment: Changes look good and align with PR objectives.

The modifications to retrieve the ChainID from the global configuration are consistent with the PR's goal of removing unused ChainID from the EVM keeper. The test cases remain intact, and the changes should not affect the overall functionality of the tests.


225-229: LGTM: Updated ChainID retrieval method.

The change from using s.network.App.EvmKeeper.ChainID() to config.GetChainConfig().ChainID aligns with the PR objectives and uses a globally consistent configuration. This is a good improvement.

To ensure consistency across the codebase, let's verify the usage of ChainID:

This will help ensure that all instances have been updated consistently.

Verification successful

Verified: All ChainID usages have been updated appropriately.

All instances of EvmKeeper.ChainID() have been successfully replaced with config.GetChainConfig().ChainID, ensuring consistent configuration across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of EvmKeeper.ChainID() and compare with the new config.GetChainConfig().ChainID usage

echo "Checking for remaining EvmKeeper.ChainID() usage:"
rg --type go 'EvmKeeper\.ChainID\(\)'

echo "\nChecking new config.GetChainConfig().ChainID usage:"
rg --type go 'config\.GetChainConfig\(\)\.ChainID'

Length of output: 3856

x/evm/keeper/state_transition_benchmark_test.go (7)

167-167: LGTM: Consistent use of global chain configuration

This change aligns with the PR objectives by replacing the EVM keeper's ChainID getter with the global chain configuration. This modification enhances consistency across the codebase and removes the dependency on the unused ChainID in the EVM keeper.


196-196: LGTM: Consistent change for legacy transactions

This modification mirrors the change made in the previous benchmark function, ensuring consistency in how the chain ID is obtained for different transaction types. This approach aligns with the overall goal of standardizing chain ID retrieval across the codebase.


225-225: LGTM: Consistent change applied to dynamic fee transactions

This change extends the standardized chain ID retrieval to dynamic fee transactions, which were introduced in Ethereum's London hard fork. This consistency across all transaction types, including the newest ones, ensures a uniform approach throughout the codebase.


256-256: LGTM: Consistent change applied to message-level operations

This modification extends the standardized chain ID retrieval to message-level operations, which are more granular than full transactions. This consistency ensures that the new approach is applied uniformly across different levels of the EVM implementation.


292-292: LGTM: Consistent change applied to legacy transaction messages

This change maintains the standardized chain ID retrieval for legacy transaction messages, ensuring that the new approach is applied consistently even for older transaction types at the message level.


327-327: LGTM: Comprehensive application of change to all transaction types and levels

This final change completes the standardization of chain ID retrieval across all transaction types and levels, including the newest dynamic fee transactions at the message level. This comprehensive approach ensures consistency throughout the entire EVM implementation in the codebase.


Line range hint 167-327: Summary: Successful standardization of chain ID retrieval

The changes in this file consistently replace the use of suite.network.App.EvmKeeper.ChainID() with config.GetChainConfig().ChainID across all benchmark functions. This modification:

  1. Removes the dependency on the unused ChainID in the EVM keeper.
  2. Standardizes chain ID retrieval across different transaction types (legacy, access list, and dynamic fee) and levels (full transactions and messages).
  3. Enhances code consistency and maintainability by using a global configuration.

These changes align perfectly with the PR objectives and contribute to a more streamlined and consistent codebase.

precompiles/staking/staking_test.go (1)

449-449: LGTM: Simplified ChainID retrieval

The change from s.network.App.EvmKeeper.ChainID() to config.GetChainConfig().ChainID aligns with the PR objective of removing the unused ChainID from the Evm keeper. This modification centralizes the ChainID retrieval to a single configuration source, which can improve consistency across the codebase.

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

262-262: LGTM! Simplified chain ID retrieval

The change to obtain the chain ID directly from the configuration (config.GetChainConfig().ChainID) instead of using the EvmKeeper instance is a good improvement. This simplification aligns with the PR objective of removing unused ChainID from the EVM keeper and reduces unnecessary dependencies.

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

693-693: LGTM! Change aligns with PR objectives.

The modification to use config.GetChainConfig().ChainID instead of suite.network.App.EvmKeeper.ChainID() is consistent with the PR's goal of removing the unused ChainID from the EVM keeper. This change centralizes the ChainID retrieval to the global configuration, improving consistency across the codebase.

app/ante/evm/ante_test.go (7)

46-48: LGTM: Updated ChainID retrieval method

The change to retrieve the ChainID from config.GetChainConfig().ChainID is consistent with the PR objective of removing the unused ChainID from the EVM keeper. This update ensures that the ChainID is obtained from the global configuration, which is the correct approach after the recent refactor.


57-58: LGTM: Consistent ChainID update

The change to use config.GetChainConfig().ChainID for the ethTxParams struct is consistent with the previous update. This ensures that all test cases use the same method to retrieve the ChainID, maintaining consistency throughout the test suite.


170-171: LGTM: ChainID update in test case

The change to use config.GetChainConfig().ChainID in this specific test case maintains consistency with the earlier updates. This ensures that all parts of the test suite, including individual test cases, use the new method for ChainID retrieval.


189-190: LGTM: Comprehensive ChainID updates across test cases

The changes to use config.GetChainConfig().ChainID have been consistently applied across multiple test cases. This comprehensive update ensures that all scenarios in the test suite use the new method for ChainID retrieval, maintaining consistency and aligning with the PR's objectives.

Also applies to: 207-208, 225-226, 247-248


923-926: LGTM: ChainID updates in dynamic fee tests

The changes to use config.GetChainConfig().ChainID have been correctly applied to the TestAnteHandlerWithDynamicTxFee function. This ensures consistency across different types of tests, including those dealing with dynamic transaction fees.

Also applies to: 936-939


1087-1090: LGTM: Final ChainID updates and overall consistency

The changes to use config.GetChainConfig().ChainID in the TestAnteHandlerWithParams function complete the comprehensive update of the ChainID retrieval method throughout the test file. These final changes ensure that all test functions, including those testing specific parameters, use the new global configuration approach for obtaining the ChainID.

Overall, the updates in this file consistently implement the new ChainID retrieval method across all test cases and functions. This change aligns perfectly with the PR's objective of removing the unused ChainID from the EVM keeper and transitioning to a globally configured ChainID.

Also applies to: 1101-1104


Line range hint 1-1204: Summary: Comprehensive and consistent ChainID updates

This review has examined all changes made to the app/ante/evm/ante_test.go file. The modifications consistently update the method of retrieving the ChainID from using the EVM keeper to using the global configuration (config.GetChainConfig().ChainID). These changes have been applied across all test functions and cases, including:

  1. TestAnteHandler
  2. TestAnteHandlerWithDynamicTxFee
  3. TestAnteHandlerWithParams

The updates align perfectly with the PR's objective of removing the unused ChainID from the EVM keeper and transitioning to a globally configured ChainID. The changes are thorough, maintain consistency throughout the test suite, and do not introduce any apparent issues or potential problems.

Overall, these modifications successfully implement the intended changes and improve the codebase by centralizing the ChainID configuration.

CHANGELOG.md (22)

62-62: New EVM extension for ICS-20 transfer

This change introduces a wrapper for ICS-20 transfer to automatically convert ERC-20 tokens to native Cosmos coins. This is a significant improvement that enhances interoperability between EVM and Cosmos ecosystems.


Line range hint 66-67: API Breaking Changes: Renaming inflation module

The inflation module has been renamed to inflation/v1. This change may require updates to any code or scripts that interact with the inflation module.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 68-68: API Breaking Changes: Deprecating legacy EIP-712 ante handler

The legacy EIP-712 ante handler has been deprecated. Ensure that any systems relying on this handler are updated accordingly.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 72-73: Improvement: Addition of Golang dependency vulnerability checker

A new CI step has been added to check for vulnerabilities in Golang dependencies. This enhances the security of the project.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 74-75: Improvement: Default File store listener added

A default File store listener has been added for the application, implementing ADR38. This improves the application's ability to handle state changes.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 76-76: Documentation: Audits page added

An audits page has been added to the documentation, which improves transparency and security awareness for the project.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 77-78: Improvement: New message for updating vesting funder

A new MsgUpdateVestingFunder has been added to update the Funder field of a clawback vesting account. This provides more flexibility in managing vesting accounts.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 79-80: Improvement: IBC denom utility functions

New utility functions for IBC denoms have been added, which should simplify working with IBC denominations.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 81-81: Improvement: ERC-20 module utility functions

New utility functions (iterator and params) have been added for the ERC-20 module, enhancing its functionality.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 82-82: Improvement: Go version update

The project has been updated to use Go v1.19. Ensure all development environments are updated accordingly.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 83-83: Testing: Node upgrade end-to-end test suite

A new end-to-end test suite for node upgrades has been added, improving the robustness of upgrade processes.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 84-84: CLI Improvement: Google CLI Syntax

The CLI now uses Google CLI Syntax for required and optional args, improving usability and consistency.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 85-85: Performance: AnteHandlers re-ordered

AnteHandlers have been re-ordered for better performance. Monitor the system to ensure this change has the intended effect.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 88-88: Documentation: Ethereum tx indexer docs added

Documentation for the Ethereum transaction indexer has been added, which should help with understanding and using this feature.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 90-90: CLI Improvement: Prune command added

A new prune command has been added to the CLI, providing more control over data management.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 91-91: CLI Improvement: Ledger support added

Ledger CLI support has been added, enhancing security options for users.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 95-95: Bug Fix: Ledger supported algorithms

The Ledger supported algorithms have been updated to only consist of EthSecp256k1. Ensure this change doesn't break existing integrations.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 96-96: CLI Update: Default node snapshot interval

The default node snapshot interval has been updated to 5000. Monitor system performance to ensure this change is optimal.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 97-97: CLI Fix: Version command

The evmosd version command has been fixed to show either tag or last commit. This improves version tracking.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 98-98: CLI Fix: Snapshot configuration

The snapshot configuration has been fixed. Verify that snapshots are working as expected after this change.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 99-99: App Improvement: gRPC node service

The gRPC node service is now set up with the application, enhancing the application's API capabilities.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)


Line range hint 100-100: Metrics Fix: Unbound metrics and labels

Unbound metrics have been fixed and labels that keep increasing have been removed. This should improve the stability and usefulness of metrics.

Tools
Markdownlint

60-60: Expected: 120; Actual: 133
Line length

(MD013, line-length)

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 @0xstepit!!

Left one nit comment

@0xstepit 0xstepit enabled auto-merge (squash) September 24, 2024 07:13
@0xstepit 0xstepit merged commit 07b35b4 into main Sep 24, 2024
50 of 52 checks passed
@0xstepit 0xstepit deleted the stepit/evm-chain-id branch September 24, 2024 09:21
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.

3 participants