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

Add all CCTP supported chains to domain map #2399

Merged
merged 1 commit into from
Mar 29, 2024
Merged

Conversation

dwasse
Copy link
Collaborator

@dwasse dwasse commented Mar 29, 2024

Summary by CodeRabbit

  • New Features
    • Added support for Avalanche, Base, and Polygon networks in both mainnet and testnet configurations.

@dwasse dwasse requested a review from trajan0x as a code owner March 29, 2024 21:46
Copy link
Contributor

coderabbitai bot commented Mar 29, 2024

Walkthrough

The update introduces support for additional blockchain networks by including new chain IDs for the Avalanche, Base, and Polygon platforms. This enhancement is applied to both mainnet and testnet environments, ensuring broader compatibility and integration capabilities. The modifications are neatly encapsulated in the domain mapping configurations, facilitating seamless interactions across diverse blockchain landscapes.

Changes

Files Summary
services/.../relayer/chains.go Added new chain IDs for Avalanche, Base, and Polygon networks in mainnet and testnet configurations; updated domain maps.

🐇✨
In the realm of code, where the data hops and plays,
New chains join the warren, in the blockchain's maze.
Avalanche, Base, Polygon, in main and testnet guise,
A rabbit's work, through digital skies.
🌐🔗
To connect them all, a task so bright,
In the burrow of bytes, we leap with 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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@github-actions github-actions bot added go Pull requests that update Go code size/xs labels Mar 29, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 9bec538 and 4a38a26.
Files selected for processing (1)
  • services/cctp-relayer/relayer/chains.go (1 hunks)
Additional Context Used
Additional comments not posted (5)
services/cctp-relayer/relayer/chains.go (5)

9-13: The addition of new chain IDs for Avalanche (43114), Base (8453), and Polygon (137) networks in the mainnet configurations is correct and aligns with the PR objectives. Ensure these IDs are accurate and up-to-date with the respective blockchain documentation.


17-21: The addition of new chain IDs for Avalanche Fuji (43113), Base Sepolia (84532), and Polygon Amoy (80002) networks in the testnet configurations is correct and aligns with the PR objectives. Ensure these IDs are accurate and up-to-date with the respective blockchain documentation.


26-30: The addition of new mappings in the mainnetDomainMap for Avalanche, Base, and Polygon networks is correct. However, ensure that the domain numbers (e.g., 1, 6, 7) are correctly assigned and do not conflict with existing mappings or future expansions.


36-40: The addition of new mappings in the testnetDomainMap for Avalanche Fuji, Base Sepolia, and Polygon Amoy networks is correct. Similar to the mainnet mappings, ensure that the domain numbers (e.g., 1, 6, 7) are correctly assigned and do not conflict with existing mappings or future expansions.


6-43: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [47-107]

Overall, the functions related to domain and chain ID mappings (IsTestnetChainID, CircleDomainToChainID, ChainIDToCircleDomain, initReverseMaps) are implemented correctly and follow logical patterns consistent with the objectives of the PR. However, ensure that the initialization of testnetChainIDMap and mainnetChainIDMap in initReverseMaps is thread-safe if concurrent access is expected. Consider using a sync.Once or similar mechanism to guarantee that the initialization is performed exactly once in a thread-safe manner.

Comment on lines 6 to 43

// Mainnet chain IDs.
const ethereumChainID = 1
const avalancheChainID = 43114
const optimismChainID = 10
const arbitrumChainID = 42161
const baseChainID = 8453
const polygonChainID = 137

// Testnet chain IDs.
const sepoliaChainID = 11155111
const avalancheFujiChainID = 43113
const opSepoliaChainID = 11155420
const arbitrumSepoliaChainID = 421614
const baseSepoliaChainID = 84532
const polygonAmoyChainID = 80002

// see https://developers.circle.com/stablecoins/docs/evm-smart-contracts#mainnet-contract-addresses
var mainnetDomainMap = map[uint32]uint32{
0: ethereumChainID,
1: avalancheChainID,
2: optimismChainID,
3: arbitrumChainID,
6: baseChainID,
7: polygonChainID,
}

// see https://developers.circle.com/stablecoins/docs/evm-smart-contracts#testnet-contract-addresses
var testnetDomainMap = map[uint32]uint32{
0: sepoliaChainID,
1: avalancheFujiChainID,
2: opSepoliaChainID,
3: arbitrumSepoliaChainID,
6: baseSepoliaChainID,
7: polygonAmoyChainID,
}

var testnetChainIDMap map[uint32]uint32 // Maps chainID to domain for testnet
Copy link
Contributor

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [5-5]

The TODO comment suggests moving this file to a common location. Consider addressing this as part of a broader refactoring effort to improve code organization and maintainability. It might be beneficial to create a dedicated package for chain-related constants and utilities if there are multiple relayers or services that could benefit from shared access to this information.

Would you like me to open a GitHub issue to track this potential refactoring task?

Copy link

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4a38a26
Status: ✅  Deploy successful!
Preview URL: https://cd7b239c.sanguine-fe.pages.dev
Branch Preview URL: https://feat-cctp-domains.sanguine-fe.pages.dev

View logs

Copy link

codecov bot commented Mar 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 46.75013%. Comparing base (0425595) to head (4a38a26).
Report is 1 commits behind head on master.

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #2399         +/-   ##
===================================================
- Coverage   46.89062%   46.75013%   -0.14049%     
===================================================
  Files            383         395         +12     
  Lines          29202       30432       +1230     
  Branches          83          83                 
===================================================
+ Hits           13693       14227        +534     
- Misses         14049       14678        +629     
- Partials        1460        1527         +67     
Flag Coverage Δ
cctp-relayer 43.41463% <ø> (?)
rfq 29.09708% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dwasse dwasse merged commit 597f11d into master Mar 29, 2024
31 checks passed
@dwasse dwasse deleted the feat/cctp-domains branch March 29, 2024 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code size/xs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant