Skip to content

refactor(pkg/chains): add Avalanche, Arbitrum and World Chain in chain info#3379

Merged
lumtis merged 4 commits intodevelopfrom
feat/new-evm-chain-params
Jan 22, 2025
Merged

refactor(pkg/chains): add Avalanche, Arbitrum and World Chain in chain info#3379
lumtis merged 4 commits intodevelopfrom
feat/new-evm-chain-params

Conversation

@lumtis
Copy link
Contributor

@lumtis lumtis commented Jan 20, 2025

Description

Add new EVM chains considered from:
#3361
#3362
#3365

Summary by CodeRabbit

  • New Features

    • Added support for Avalanche, Arbitrum, and World Chain networks
    • Introduced new consensus algorithms: Snowman and Arbitrum Nitro
  • Documentation

    • Updated changelog to reflect new network and consensus additions
    • Updated OpenAPI specification with new network and consensus details
  • Refactor

    • Expanded chain definitions to include new mainnet and testnet chains
    • Updated protocol buffer definitions to support new networks and consensus types

@lumtis lumtis requested a review from a team as a code owner January 20, 2025 16:31
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2025

📝 Walkthrough

Walkthrough

This pull request introduces comprehensive support for three new blockchain networks: Avalanche, Arbitrum, and World Chain. The changes span multiple files across the Zeta Chain project, systematically updating protocol definitions, test cases, and documentation to incorporate these new networks. The modifications include expanding network and consensus enumerations, adding new chain configurations, and ensuring test coverage reflects the updated network landscape.

Changes

File Change Summary
changelog.md Added entry for new blockchain networks
docs/openapi/openapi.swagger.yaml Updated consensus algorithms and networks list
pkg/chains/chain_test.go Modified test cases for network and consensus validation
pkg/chains/chains.go Added new mainnet and testnet chain definitions
pkg/chains/chains_test.go Updated test cases to include new chains
proto/zetachain/zetacore/pkg/chains/chains.proto Extended Network and Consensus enumerations

Possibly related PRs

Suggested Labels

no-changelog, UPGRADE_LIGHT_TESTS

Suggested Reviewers

  • fbac
  • kingpinXD
  • skosito
  • gartnera
  • swift1337
  • brewmaster012
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@lumtis lumtis changed the title feat(pkg/chains): add new EVM chains feat(pkg/chains): add Avalanche, Arbitrum and World Chain in chain info Jan 20, 2025
@lumtis lumtis changed the title feat(pkg/chains): add Avalanche, Arbitrum and World Chain in chain info refactor(pkg/chains): add Avalanche, Arbitrum and World Chain in chain info Jan 20, 2025
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

🧹 Nitpick comments (2)
docs/openapi/openapi.swagger.yaml (1)

57080-57081: Fix indentation in description section.

The indentation of the snowman mapping is inconsistent with other entries.

    description: |-
      - catchain_consensus: ton
-       - snowman: avalanche
+      - snowman: avalanche
proto/zetachain/zetacore/pkg/chains/chains.proto (1)

Line range hint 1-150: Consider adding reserved ranges for future network and consensus types.

While the current additions maintain backward compatibility, it would be beneficial to reserve number ranges for different categories of networks (L1s, L2s, etc.) and consensus mechanisms. This would make the protocol more maintainable as new chains are added.

Example modification:

enum Network {
  option (gogoproto.goproto_enum_stringer) = true;
+ reserved 12 to 20; // Reserved for future L1 networks
+ reserved 21 to 30; // Reserved for future L2 networks
  eth = 0;
  // ... existing entries ...
  worldchain = 11;
}

enum Consensus {
  option (gogoproto.goproto_enum_stringer) = true;
+ reserved 8 to 15;  // Reserved for future L1 consensus mechanisms
+ reserved 16 to 25; // Reserved for future L2 consensus mechanisms
  ethereum = 0;
  // ... existing entries ...
  arbitrum_nitro = 7;
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 078dbef and 0aa46de.

⛔ Files ignored due to path filters (2)
  • pkg/chains/chains.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
  • typescript/zetachain/zetacore/pkg/chains/chains_pb.d.ts is excluded by !**/*_pb.d.ts
📒 Files selected for processing (6)
  • changelog.md (1 hunks)
  • docs/openapi/openapi.swagger.yaml (2 hunks)
  • pkg/chains/chain_test.go (2 hunks)
  • pkg/chains/chains.go (3 hunks)
  • pkg/chains/chains_test.go (5 hunks)
  • proto/zetachain/zetacore/pkg/chains/chains.proto (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • changelog.md
🧰 Additional context used
📓 Path-based instructions (4)
pkg/chains/chain_test.go (1)

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

pkg/chains/chains.go (1)

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

pkg/chains/chains_test.go (1)

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

proto/zetachain/zetacore/pkg/chains/chains.proto (1)

Pattern **/*.proto: Review the Protobuf definitions, point out issues relative to compatibility, and expressiveness.

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: start-e2e-test / e2e
🔇 Additional comments (17)
pkg/chains/chains.go (7)

101-111: LGTM! Avalanche C-Chain configuration is accurate.

The chain ID and consensus mechanism (Snowman) are correctly specified for the Avalanche C-Chain.


113-123: LGTM! Arbitrum One configuration is accurate.

The chain ID and consensus mechanism (Arbitrum Nitro) are correctly specified for Arbitrum One.


283-293: LGTM! Avalanche Fuji testnet configuration is accurate.

The chain ID and consensus mechanism match the Avalanche Fuji testnet specifications.


295-305: LGTM! Arbitrum Sepolia testnet configuration is accurate.

The chain ID and consensus mechanism match the Arbitrum Sepolia testnet specifications.


504-509: LGTM! Default chains list updated correctly.

The new chains are added in a consistent order, maintaining the pattern of mainnet chains followed by their testnet counterparts.


125-135: Verify World Chain configuration.

While the configuration follows the standard pattern, please verify the chain ID and consensus mechanism for World Chain, as it's a relatively new network.

✅ Verification successful

World Chain configuration verified.

The configuration is correct and follows the established pattern:

  • Chain ID 480 (mainnet) and 4801 (testnet) are properly configured
  • Uses OP Stack consensus mechanism, consistent with other L2 chains
  • Recently added through PR #3379 alongside Avalanche and Arbitrum
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any references to World Chain's configuration
rg -i "world.*chain.*480" 

Length of output: 27


Script:

#!/bin/bash
# Search for World Chain references
echo "=== World Chain references ==="
rg -i "world.*chain" -A 5 -B 5

echo -e "\n=== Chain ID 480 references ==="
rg "480" -A 5 -B 5

echo -e "\n=== OP Stack consensus references ==="
rg "op_stack" -A 5 -B 5

echo -e "\n=== Documentation files mentioning World Chain ==="
fd -e md -e txt | xargs rg -i "world.*chain" -l

Length of output: 85532


307-317: Verify World Chain testnet configuration.

While the configuration follows the standard pattern, please verify the chain ID and consensus mechanism for World Chain testnet.

✅ Verification successful

World Chain testnet configuration verified successfully.

The configuration is correct with chain ID 4801 and OP Stack consensus mechanism. This follows the established pattern for testnet configurations and aligns with the chain's architecture.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any references to World Chain testnet's configuration
rg -i "world.*testnet.*4801"

Length of output: 30


Script:

#!/bin/bash
# Search for World Chain references
echo "=== World Chain References ==="
rg -i "world.*chain" -A 2 -B 2

echo -e "\n=== Chain ID 4801 References ==="
rg "4801"

echo -e "\n=== Documentation Files with World Chain ==="
fd -e md -e txt | xargs rg -i "world.*chain" || true

echo -e "\n=== OP Stack Consensus References ==="
rg "op_stack|op stack" -i

Length of output: 107210

pkg/chains/chain_test.go (2)

76-76: LGTM! Invalid network test case updated correctly.

The test case now uses the new upper bound (Network_worldchain + 1) for testing invalid networks.


118-118: LGTM! Invalid consensus test case updated correctly.

The test case now uses the new upper bound (Consensus_arbitrum_nitro + 1) for testing invalid consensus mechanisms.

pkg/chains/chains_test.go (4)

40-42: LGTM! TestChainListByNetworkType updated correctly.

The test cases for both mainnet and testnet chains are updated to include the new chains in the correct order.

Also applies to: 62-64


188-193: LGTM! TestDefaultChainList updated correctly.

The test case is updated to include all new chains in the same order as defined in DefaultChainsList.


231-236: LGTM! TestChainListByGateway updated correctly.

The observers gateway test case is updated to include all new chains.


283-288: LGTM! TestExternalChainList updated correctly.

The test case is updated to include all new external chains.

docs/openapi/openapi.swagger.yaml (2)

57098-57100: LGTM! Network additions are well-structured.

The new network entries are consistent with the existing naming pattern and align with the PR objectives of adding new EVM chains.


57076-57081: 🛠️ Refactor suggestion

Add mapping for arbitrum_nitro in the description.

The description section maps consensus algorithms to their respective chains, but the mapping for arbitrum_nitro is missing. Please add it to maintain documentation completeness.

    description: |-
      - catchain_consensus: ton
       - snowman: avalanche
+      - arbitrum_nitro: arbitrum

Likely invalid or redundant comment.

proto/zetachain/zetacore/pkg/chains/chains.proto (2)

67-69: Network enum additions follow best practices.

The new network values are correctly added with sequential numbering, maintaining backward compatibility. The naming convention is consistent with existing entries.


103-104: Consensus enum additions are well-documented.

The new consensus values are properly added with sequential numbering and include helpful comments explaining their purpose (e.g., "snowman" for Avalanche).

@codecov
Copy link

codecov bot commented Jan 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.23%. Comparing base (078dbef) to head (0aa46de).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3379   +/-   ##
========================================
  Coverage    63.22%   63.23%           
========================================
  Files          436      436           
  Lines        30639    30645    +6     
========================================
+ Hits         19372    19378    +6     
  Misses       10432    10432           
  Partials       835      835           
Files with missing lines Coverage Δ
pkg/chains/chains.go 100.00% <100.00%> (ø)

@lumtis lumtis added this pull request to the merge queue Jan 22, 2025
Merged via the queue into develop with commit aabb271 Jan 22, 2025
41 checks passed
@lumtis lumtis deleted the feat/new-evm-chain-params branch January 22, 2025 09:08
@coderabbitai coderabbitai bot mentioned this pull request Feb 6, 2025
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