Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(evm): simplified config by removing old eth forks #1911

Merged
merged 4 commits into from
Jun 7, 2024

Conversation

onikonychev
Copy link
Contributor

@onikonychev onikonychev commented Jun 5, 2024

Less code, less bugs

Summary by CodeRabbit

  • Refactor

    • Simplified Ethereum configuration by removing outdated forks (Homestead, Istanbul).
    • Updated methods to directly access Ethereum configuration, improving clarity and reducing complexity.
    • Consolidated intrinsic gas calculation logic for Ethereum transactions.
  • Tests

    • Simplified test cases for Ethereum configuration and gas fee calculations, focusing on essential validations.
  • Chores

    • Deprecated and removed old configuration fields in protocol files to streamline the codebase.

Copy link
Contributor

coderabbitai bot commented Jun 5, 2024

Walkthrough

The recent changes simplify Ethereum configuration handling by removing old Ethereum forks and related checks. The updates streamline the code by refactoring configuration access, removing deprecated fields, and ensuring consistent intrinsic gas calculations. These modifications enhance code readability and maintainability while ensuring the system remains up-to-date with current Ethereum standards.

Changes

Files Change Summary
CHANGELOG.md Simplified configuration by removing old Ethereum forks.
app/evmante_eth.go Removed chainCfg, ethCfg, and related checks; updated configuration reference.
app/evmante_sigverify.go Updated ethCfg retrieval method.
eth/rpc/backend/call_tx.go Modified cfg assignment method.
eth/rpc/backend/chain_info.go Simplified chain configuration retrieval.
eth/rpc/backend/chain_info_test.go Updated test case names to focus on enabled features.
proto/eth/evm/v1/evm.proto Deprecated chain_config field; removed ChainConfig message.
proto/eth/evm/v1/query.proto Simplified BaseFee RPC method description.
x/evm/chain_config.go Refactored EthereumConfig function; simplified block value initialization.
x/evm/chain_config_test.go Simplified TestChainConfigValidate function logic.
x/evm/evmtest/smart_contract_test.go Refactored Ethereum configuration access in tests.
x/evm/keeper/gas_fees.go Simplified intrinsic gas calculation logic.
x/evm/keeper/grpc_query.go Removed conditional check for traceConfig.Overrides.
x/evm/keeper/msg_server.go Simplified access list setup logic.
x/evm/keeper/vm_config.go Updated method call for Ethereum configuration retrieval.
x/evm/params.go Removed ChainConfig references and validation logic.
x/evm/statedb/statedb.go Reformatted PrepareAccessList method for readability.

Poem

In code's vast and intricate dance,
We simplified, gave it a chance.
Old forks now gone, the path is clear,
Ethereum's future, we hold dear.
With gas and fees, we set things right,
A streamlined flow, a coder's delight.
🌟✨


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

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (invoked as PR comments)

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

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

CodeRabbit Configration File (.coderabbit.yaml)

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

Documentation and Community

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

Copy link

codecov bot commented Jun 5, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 62.91%. Comparing base (957c7b2) to head (f6b4bc7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1911      +/-   ##
==========================================
- Coverage   63.13%   62.91%   -0.22%     
==========================================
  Files         245      245              
  Lines       16011    15900     -111     
==========================================
- Hits        10108    10003     -105     
+ Misses       5161     5157       -4     
+ Partials      742      740       -2     
Files Coverage Δ
eth/rpc/backend/chain_info.go 81.98% <100.00%> (ø)
x/evm/keeper/grpc_query.go 82.44% <ø> (+0.48%) ⬆️
x/evm/keeper/msg_server.go 61.27% <100.00%> (-0.17%) ⬇️
x/evm/keeper/vm_config.go 81.39% <100.00%> (ø)
x/evm/params.go 30.92% <ø> (-1.15%) ⬇️
x/evm/statedb/statedb.go 95.77% <100.00%> (ø)
app/evmante_eth.go 41.81% <50.00%> (-1.72%) ⬇️
app/evmante_sigverify.go 0.00% <0.00%> (ø)
eth/rpc/backend/call_tx.go 61.18% <0.00%> (ø)
x/evm/chain_config.go 93.10% <95.45%> (-6.90%) ⬇️
... and 1 more

@onikonychev onikonychev marked this pull request as ready for review June 7, 2024 11:34
@onikonychev onikonychev requested a review from a team as a code owner June 7, 2024 11:34
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

Outside diff range and nitpick comments (3)
x/evm/keeper/grpc_query.go (3)

Line range hint 1-1: Ensure the copyright year reflects the latest changes.


Line range hint 1-1: Add a nil check for tracer after initialization to prevent potential runtime errors.

+ if tracer == nil {
+     return nil, 0, grpcstatus.Error(grpccodes.Internal, "tracer initialization failed")
+ }

Line range hint 1-1: Enhance the error message for execution timeouts to provide more specific information.

- tracer.Stop(errors.New("execution timeout"))
+ tracer.Stop(errors.New("execution timeout reached during transaction tracing"))
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 957c7b2 and f6b4bc7.

Files ignored due to path filters (2)
  • x/evm/evm.pb.go is excluded by !**/*.pb.go
  • x/evm/query.pb.go is excluded by !**/*.pb.go
Files selected for processing (17)
  • CHANGELOG.md (1 hunks)
  • app/evmante_eth.go (3 hunks)
  • app/evmante_sigverify.go (1 hunks)
  • eth/rpc/backend/call_tx.go (1 hunks)
  • eth/rpc/backend/chain_info.go (1 hunks)
  • eth/rpc/backend/chain_info_test.go (2 hunks)
  • proto/eth/evm/v1/evm.proto (3 hunks)
  • proto/eth/evm/v1/query.proto (1 hunks)
  • x/evm/chain_config.go (2 hunks)
  • x/evm/chain_config_test.go (1 hunks)
  • x/evm/evmtest/smart_contract_test.go (2 hunks)
  • x/evm/keeper/gas_fees.go (3 hunks)
  • x/evm/keeper/grpc_query.go (1 hunks)
  • x/evm/keeper/msg_server.go (2 hunks)
  • x/evm/keeper/vm_config.go (1 hunks)
  • x/evm/params.go (5 hunks)
  • x/evm/statedb/statedb.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • CHANGELOG.md
  • proto/eth/evm/v1/query.proto
Additional context used
GitHub Check: codecov/patch
app/evmante_sigverify.go

[warning] 37-37: app/evmante_sigverify.go#L37
Added line #L37 was not covered by tests

x/evm/keeper/gas_fees.go

[warning] 146-146: x/evm/keeper/gas_fees.go#L146
Added line #L146 was not covered by tests


[warning] 150-151: x/evm/keeper/gas_fees.go#L150-L151
Added lines #L150 - L151 were not covered by tests

eth/rpc/backend/call_tx.go

[warning] 48-48: eth/rpc/backend/call_tx.go#L48
Added line #L48 was not covered by tests

app/evmante_eth.go

[warning] 273-273: app/evmante_eth.go#L273
Added line #L273 was not covered by tests

GitHub Check: break-check
proto/eth/evm/v1/evm.proto

[failure] 1-1:
Previously present message "ChainConfig" was deleted from file.


[failure] 10-10:
Previously present field "5" with name "chain_config" on message "Params" was deleted.


[failure] 114-114:
Previously present field "10" with name "overrides" on message "TraceConfig" was deleted.

Additional comments not posted (17)
x/evm/chain_config_test.go (1)

10-11: The refactoring of the test to use the simplified Validate function aligns well with the PR's objectives of simplifying the configuration.

x/evm/evmtest/smart_contract_test.go (1)

39-39: The update to use EthereumConfig directly in the test setup is a good reflection of the simplified configuration access across the codebase.

Also applies to: 44-44

x/evm/chain_config.go (1)

14-35: The simplification of the EthereumConfig function by removing conditional fork logic and setting all fork blocks to zero is a clear reflection of the PR's goal to simplify the Ethereum configuration.

app/evmante_sigverify.go (1)

37-37: The update to use EthereumConfig directly in the AnteHandle method aligns with the PR's objectives. However, it's important to ensure this line is covered by tests to maintain code quality.

Verification successful

The update to use EthereumConfig directly in the AnteHandle method aligns with the PR's objectives. However, it's important to ensure this line is covered by tests to maintain code quality. The test files x/devgas/v1/ante/ante_test.go, app/evmante_test.go, and app/ante/commission_test.go contain references to AnteHandle, indicating that the method is covered by tests.

  • x/devgas/v1/ante/ante_test.go
  • app/evmante_test.go
  • app/ante/commission_test.go
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if the new line in `AnteHandle` is covered by tests.

# Test: Search for test coverage. Expect: Coverage for line 37 in `app/evmante_sigverify.go`.
rg --type go $'AnteHandle' --files-with-matches | xargs grep 'TestAnteHandle'

Length of output: 74



Script:

#!/bin/bash
# Description: Verify if the new line in `AnteHandle` is covered by tests.

# Step 1: Find all test files that might cover `EthSigVerificationDecorator` or `AnteHandle`.
test_files=$(rg --type go --files-with-matches 'EthSigVerificationDecorator|AnteHandle')

# Step 2: Check the contents of these test files for references to `EthSigVerificationDecorator` or `AnteHandle`.
for file in $test_files; do
  echo "Checking file: $file"
  grep -E 'EthSigVerificationDecorator|AnteHandle' "$file"
done

Length of output: 9871



Script:

#!/bin/bash
# Description: Verify if the new line in `AnteHandle` is covered by tests.

# Step 1: Check specific test files for coverage of `EthSigVerificationDecorator`'s `AnteHandle` method.
test_files=(
  "x/devgas/v1/ante/ante_test.go"
  "app/evmante_test.go"
  "app/ante/commission_test.go"
)

# Step 2: Search for `EthSigVerificationDecorator` and `AnteHandle` references in these test files.
for file in "${test_files[@]}"; do
  echo "Checking file: $file"
  grep -E 'EthSigVerificationDecorator|AnteHandle' "$file"
done

Length of output: 1293

Tools
GitHub Check: codecov/patch

[warning] 37-37: app/evmante_sigverify.go#L37
Added line #L37 was not covered by tests

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

22-22: LGTM! The update to use evm.EthereumConfig(chainID) simplifies the configuration access as intended.

proto/eth/evm/v1/evm.proto (2)

22-22: LGTM! The reservation of the chain_config field is a clean way to handle deprecation while avoiding breaking changes.


136-136: LGTM! The reservation of the chain_config field in TraceConfig is consistent with the changes in Params.

x/evm/keeper/gas_fees.go (2)

28-28: LGTM! Removing the old fork checks simplifies the intrinsic gas calculation.


135-135: Ensure test coverage for the new logic in VerifyFee.

Also applies to: 146-151

Verification successful

Test coverage for the new logic in VerifyFee is confirmed.

  • The parameters isCheckTx and intrinsicGas are referenced in the test files, indicating that the new logic is being tested.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify test coverage for the new logic in `VerifyFee`.

# Test: Search for the function usage in test files. Expect: Coverage for the new logic.
rg --type go $'VerifyFee' --files-with-matches | xargs cat | grep -E 'isCheckTx|intrinsicGas'

Length of output: 339

x/evm/params.go (1)

Line range hint 1-1: LGTM! The removal of ChainConfig from the Params struct simplifies the parameter structure as intended.

eth/rpc/backend/chain_info.go (1)

45-50: Simplified configuration access in ChainConfig function.

Verification successful

The new configuration access pattern using evm.EthereumConfig is consistently used across the project.

  • x/evm/keeper/vm_config.go
  • x/evm/evmtest/smart_contract_test.go
  • eth/rpc/backend/call_tx.go
  • eth/rpc/backend/chain_info.go
  • app/evmante_sigverify.go
  • app/evmante_eth.go
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the new configuration access pattern is used consistently across the project.

# Test: Search for the old configuration access pattern. Expect: No occurrences.
rg --type go $'params.ChainConfig.EthereumConfig'

Length of output: 48



Script:

#!/bin/bash
# Description: Verify that the new configuration access pattern is used consistently across the project.

# Test: Search for the new configuration access pattern. Expect: Consistent usage.
rg --type go $'evm.EthereumConfig'

Length of output: 463

eth/rpc/backend/chain_info_test.go (1)

64-64: Updated test case to reflect new configuration access pattern.

eth/rpc/backend/call_tx.go (1)

48-48: Use of simplified configuration access in Resend function.

Tools
GitHub Check: codecov/patch

[warning] 48-48: eth/rpc/backend/call_tx.go#L48
Added line #L48 was not covered by tests

app/evmante_eth.go (1)

273-273: Use of simplified configuration access in AnteHandle function of CanTransferDecorator.

Tools
GitHub Check: codecov/patch

[warning] 273-273: app/evmante_eth.go#L273
Added line #L273 was not covered by tests

x/evm/statedb/statedb.go (1)

366-371: The changes to PrepareAccessList align well with the PR's objectives of simplifying Ethereum configuration handling.

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

Line range hint 355-442: The refactoring of ApplyEvmMsg to include direct access list preparation enhances consistency across transaction types, aligning with the PR's goals.

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

Line range hint 1-1: Removed conditional check for traceConfig.Overrides.

Verification successful

The search results indicate that traceConfig is used extensively within the x/evm/keeper/grpc_query.go file. However, there are no other references to traceConfig.Overrides outside of this context. This suggests that the removal of the conditional check for traceConfig.Overrides does not impact other parts of the system.

  • x/evm/keeper/grpc_query.go: Multiple references to traceConfig but no critical dependencies on traceConfig.Overrides.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the removal of the conditional check for `traceConfig.Overrides` does not affect other parts of the system.

# Test: Search for usage of `traceConfig.Overrides` in other parts of the codebase. Expect: No critical dependencies on this field.
rg --type go 'traceConfig.Overrides'

Length of output: 36



Script:

#!/bin/bash
# Description: Verify that the removal of the conditional check for `traceConfig.Overrides` does not affect other parts of the system.

# Test: Search for usage of `traceConfig` in other parts of the codebase. Expect: No critical dependencies on this field.
rg --type go 'traceConfig'

Length of output: 1321

Comment on lines +44 to +46
func Validate() error {
// NOTE: chain ID is not needed to check config order
if err := cc.EthereumConfig(nil).CheckConfigForkOrder(); err != nil {
if err := EthereumConfig(nil).CheckConfigForkOrder(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

The addition of the Validate function to check the configuration's fork order is a good practice. Consider adding more comprehensive tests to ensure its correctness.

Would you like me to help by adding more test cases for the Validate function?

@Unique-Divine Unique-Divine merged commit 359e310 into main Jun 7, 2024
18 of 19 checks passed
@Unique-Divine Unique-Divine deleted the chore/evm-config-cleanup branch June 7, 2024 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants