Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(pkg/chains): check if VM is EVM for IsEVMChain check #2801

Merged
merged 2 commits into from
Aug 30, 2024

Conversation

lumtis
Copy link
Member

@lumtis lumtis commented Aug 30, 2024

Description

IsEVMChain used to check if the chain consensus is Ethereum, which is invalid, the components using IsEVMChain don't perform logic that relies on consensus used by Ethereum.

Example: Base doesn't use Ethereum consensus as a L2 but comply with logic using isEVMChain.

This PR change the check.

All EVM chains so far had the value ConsensusEthereum except Base where we made a patch in the chain info. Therefore changing this check in theory doesn't bring any change in the workflow

Close: #2752

Summary by CodeRabbit

  • New Features

    • Enhanced identification of EVM chains by broadening criteria from consensus mechanism to virtual machine type.
    • Improved error handling in the IsEVMChain function for better reliability.
  • Bug Fixes

    • Updated test cases to correctly classify "Zeta Mainnet" as an EVM chain.
  • Tests

    • Modified tests to use dynamic values for SenderChainId in cross-chain transactions, improving accuracy.

Copy link
Contributor

coderabbitai bot commented Aug 30, 2024

Walkthrough

Walkthrough

The changes involve modifications to the IsEVMChain method in the Chain struct to check the virtual machine type instead of the consensus mechanism. Additionally, the logic in the standalone IsEVMChain function has been enhanced for better error handling. Test cases for the "Zeta Mainnet" have been updated to reflect its classification as an EVM chain. Lastly, a test case for refund functionality has been improved by dynamically assigning the SenderChainId.

Changes

File Path Change Summary
pkg/chains/chain.go Modified IsEVMChain method to check VM type instead of consensus; enhanced logic in standalone IsEVMChain function.
pkg/chains/chain_test.go Updated test cases for "Zeta Mainnet" to return true for EVM classification.
x/crosschain/keeper/refund_test.go Changed hardcoded SenderChainId to use a dynamically obtained value from getValidBtcChainID().

Assessment against linked issues

Objective Addressed Explanation
IsEVMChain should check that the VM is EVM (#2752)

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

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 Aug 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.62%. Comparing base (7b34d1d) to head (d857bc7).
Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2801      +/-   ##
===========================================
- Coverage    66.65%   66.62%   -0.04%     
===========================================
  Files          370      370              
  Lines        20680    20735      +55     
===========================================
+ Hits         13784    13814      +30     
- Misses        6261     6283      +22     
- Partials       635      638       +3     
Files with missing lines Coverage Δ
pkg/chains/chain.go 94.17% <100.00%> (+0.17%) ⬆️

... and 6 files with indirect coverage changes

@lumtis lumtis marked this pull request as ready for review August 30, 2024 12:53
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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 47a0609 and d857bc7.

Files selected for processing (3)
  • pkg/chains/chain.go (2 hunks)
  • pkg/chains/chain_test.go (2 hunks)
  • x/crosschain/keeper/refund_test.go (1 hunks)
Additional context used
Path-based instructions (3)
pkg/chains/chain.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

pkg/chains/chain_test.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

x/crosschain/keeper/refund_test.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

Additional comments not posted (5)
pkg/chains/chain.go (2)

89-89: Refactor IsEVMChain method to check VM type.

The change from checking the consensus mechanism to checking the VM type (Vm_evm) aligns with the PR objectives to more accurately determine EVM compatibility. This is a crucial update for the functionality of systems that rely on the VM type rather than the consensus mechanism.


112-120: Enhanced error handling in IsEVMChain function.

The update to first retrieve the chain using GetChainFromChainID and then check if it's an EVM chain using the updated IsEVMChain method improves the robustness of this function. This ensures that the function operates on a valid chain object, enhancing error handling by returning false if the chain is not found.

pkg/chains/chain_test.go (2)

225-225: Updated test case for Zeta Mainnet.

The test case update for "Zeta Mainnet" to return true for IsEVMChain reflects the updated logic in the main codebase. This ensures that the test is aligned with the new classification of "Zeta Mainnet" as an EVM chain.


334-334: Consistency in test cases for IsEVMChain.

The addition of "Zeta Mainnet" with a return value of true in the standalone IsEVMChain function test case maintains consistency with the method test case and the updated logic in the main codebase.

x/crosschain/keeper/refund_test.go (1)

219-224: Dynamic assignment of SenderChainId in test case.

The update to dynamically assign the SenderChainId using getValidBtcChainID() enhances the flexibility and accuracy of the test case. This ensures that the SenderChainId reflects a valid chain ID, improving the relevance of the test scenario.

Copy link
Contributor

@swift1337 swift1337 left a comment

Choose a reason for hiding this comment

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

Can you explain why we need to distinguish EVM from let's say OP Stack? Any difference from Zeta's point of view?

Copy link
Contributor

@kingpinXD kingpinXD left a comment

Choose a reason for hiding this comment

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

lgtm ,
While reviewing the usages of IsEVMChain function , I released that some logic in would be refactored to use network instead . Created an issue and will work on it
#2803.

Does not need any changes on this pr though

@lumtis lumtis added this pull request to the merge queue Aug 30, 2024
Merged via the queue into develop with commit 046344a Aug 30, 2024
32 checks passed
@lumtis lumtis deleted the fix/isevmchain branch August 30, 2024 16:31
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.

IsEVMChain should check that the VM is EVM
3 participants