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

feat: Add Polygon support to New CCTP Router Contracts #1617

Merged
merged 5 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/sdk-router/src/constants/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const ROUTER_ADDRESS_MAP: AddressMap = generateAddressMap(
/**
* SynapseCCTP contract address for all chains except ones from CCTP_ROUTER_EXCEPTION_MAP.
*/
const CCTP_ROUTER_ADDRESS = '0xD359bc471554504f683fbd4f6e36848612349DDF'
const CCTP_ROUTER_ADDRESS = '0xd5a597d6e7ddf373a92C8f477DAAA673b0902F48'
const CCTP_ROUTER_EXCEPTION_MAP: AddressMap = {}

export const CCTP_ROUTER_ADDRESS_MAP: AddressMap = generateAddressMap(
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 NOTE
Codebase verification is a beta feature.

The review of the SynapseCCTPRouter class indicates that the routerContract is used for blockchain interactions, which typically require a valid contract address. The current state of CCTP_ROUTER_ADDRESS_MAP being an empty string could lead to failures when these methods are called. There is no direct evidence of checks for the address being non-empty before these interactions occur. It is important to ensure that the system can handle this case or that there are plans to update the address before any blockchain interactions occur.

  • The SynapseCCTPRouter class uses this.routerContract for blockchain interactions, which may fail if instantiated with an empty string as the contract address.
  • There is no evidence of checks for non-empty addresses before blockchain interactions in the SynapseCCTPRouter class.
Analysis chain

The CCTP_ROUTER_ADDRESS_MAP is generated with the CCTP_ROUTER_ADDRESS which is now an empty string. Verify that the system can handle the address map containing empty strings for all chain IDs without any issues.





Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for usage of `CCTP_ROUTER_ADDRESS_MAP` to ensure it's not used in a way that requires a non-empty string.
rg 'CCTP_ROUTER_ADDRESS_MAP' --files-with-matches | xargs rg 'CCTP_ROUTER_ADDRESS_MAP'

Length of output: 1752



Script:

#!/bin/bash
# Check the implementation details in synapseCCTPRouterSet.ts to see how CCTP_ROUTER_ADDRESS_MAP is used.
rg 'CCTP_ROUTER_ADDRESS_MAP' packages/sdk-router/src/router/synapseCCTPRouterSet.ts

# Check if there are any checks or fallbacks in place when an empty string is encountered in the address map.
rg 'CCTP_ROUTER_ADDRESS_MAP' --files-with-matches | xargs rg 'if.*CCTP_ROUTER_ADDRESS_MAP'

Length of output: 309



Script:

#!/bin/bash
# Check the parent class SynapseCCTPRouter to see how it handles the CCTP_ROUTER_ADDRESS_MAP.
rg 'class SynapseCCTPRouter' --files-with-matches | xargs rg 'SynapseCCTPRouter'

Length of output: 2419



Script:

#!/bin/bash
# Search for the constructor and any methods in SynapseCCTPRouter that use the CCTP_ROUTER_ADDRESS_MAP.
rg 'constructor' packages/sdk-router/src/router/synapseCCTPRouter.ts
rg 'CCTP_ROUTER_ADDRESS_MAP' packages/sdk-router/src/router/synapseCCTPRouter.ts

Length of output: 289



Script:

#!/bin/bash
# Search for any method within SynapseCCTPRouter that uses the 'address' argument and check how it handles it.
rg 'this.routerContract' packages/sdk-router/src/router/synapseCCTPRouter.ts

Length of output: 384

Expand Down
1 change: 1 addition & 0 deletions packages/sdk-router/src/constants/chainIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ export const CCTP_SUPPORTED_CHAIN_IDS: number[] = [
SupportedChainId.OPTIMISM,
SupportedChainId.ARBITRUM,
SupportedChainId.BASE,
SupportedChainId.POLYGON, // Circle domain 7
]
1 change: 1 addition & 0 deletions packages/sdk-router/src/constants/medianTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ export const MEDIAN_TIME_CCTP = {
[SupportedChainId.BASE]: 1170,
[SupportedChainId.ARBITRUM]: 1170,
[SupportedChainId.AVALANCHE]: 30,
[SupportedChainId.POLYGON]: 480,
}
Loading