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

Make router destination/source chain specific #1242

Conversation

RyanRHall
Copy link
Contributor

Motivation

We want the ability to test new lanes using custom, test routers. Therefore, we need a one-to-many relationship b/t routers and lanes, rather than a singleton.

Solution

Make routers configurable per lane, rather than per contract

Copy link
Contributor

github-actions bot commented Jul 31, 2024

LCOV of commit 603f269 during Solidity Foundry #7016

Summary coverage rate:
  lines......: 98.7% (1845 of 1869 lines)
  functions..: 96.4% (345 of 358 functions)
  branches...: 90.7% (778 of 858 branches)

Files changed coverage rate: n/a

@RyanRHall RyanRHall force-pushed the CCIP-2837-multi-on-ramp-make-router-destination-chain-specific-2 branch from 041611f to 46f5117 Compare July 31, 2024 20:38
@RyanRHall RyanRHall force-pushed the CCIP-2837-multi-on-ramp-make-router-destination-chain-specific-2 branch from 267a5c8 to d4bb04d Compare July 31, 2024 20:58
contracts/src/v0.8/ccip/onRamp/EVM2EVMMultiOnRamp.sol Outdated Show resolved Hide resolved
contracts/src/v0.8/ccip/onRamp/EVM2EVMMultiOnRamp.sol Outdated Show resolved Hide resolved
contracts/src/v0.8/ccip/onRamp/EVM2EVMMultiOnRamp.sol Outdated Show resolved Hide resolved
/// @notice Gets the source router for a destination chain
/// @param destChainSelector The destination chain selector
/// @return destChainConfig the config for the provided destination chain
function getDestChainConfig(uint64 destChainSelector) external view returns (DestChainConfig memory) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: there is already a function to fetch the sequence number. I think we should do 1 of the 2 options:

  1. Remove getExpectedNextSequenceNumber function
  2. Replace this function to only return the router

Personally I'm in favour of 1, I think there is also a benefit off-chain to know which router it is in the same flow. This would require some off-chain rework though

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also in favour of 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have some follow up Qs here - personally I'm usually in favor of "individual getters, monolithic setters" - ex setDestChainConfig(..), getRouter(destChain) and getSequenceNum(destChain). Especially if there is an offchain component here that might need to know about the router or seq num. The reason is for ease in upgrading. If we return all those fields in a single getConfig() function and then add something to the config, it's going to break the read function for offchain components, and those components will have to become version aware. Basically, I think individial getters make it easier for us to make patch or minor version upgrades.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you guys have an opinion on getExpectedNextSequenceNumber() vs getSequenceNumber()???

Copy link
Collaborator

Choose a reason for hiding this comment

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

Personally in favour of getSequenceNumber() as the increment can always be done off-chain (and on-chain we do not use this function). However, this might break some code in chainlink-ccip

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm also pro getSequenceNumber() - I'll save this for a follow up and we'll see if it's easy to coordinate with the other repo.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I also prefer getSequenceNumber() but we should confirm with off-chain first.

@RyanRHall RyanRHall force-pushed the CCIP-2837-multi-on-ramp-make-router-destination-chain-specific-2 branch from a46e289 to 1eeb738 Compare August 1, 2024 20:46
@@ -58,12 +61,29 @@ contract EVM2EVMMultiOnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCre
/// @dev Struct to contains the dynamic configuration
// solhint-disable-next-line gas-struct-packing
struct DynamicConfig {
address router; // Router address
address priceRegistry; // Price registry address
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: since we're using specific types (IRouter) - should we create a new ticket to convert these to specific types across all contracts? E.g. for dynamic config:

struct DynamicConfig {
  IPriceRegistry priceRegistry;
  IMessageValidator messageValidator;
  address feeAggregator;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 I'll create the ticket

contracts/src/v0.8/ccip/onRamp/EVM2EVMMultiOnRamp.sol Outdated Show resolved Hide resolved
assertEq(address(s_sourceRouter), address(s_onRamp.getRouter(DEST_CHAIN_SELECTOR)));
assertEq(address(9999), address(s_onRamp.getRouter(9999)));

// handles empty list
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: would be cleaner to split this into a separate test case

continue
}
onrampSourceChainConfigArgs = append(onrampSourceChainConfigArgs, evm_2_evm_multi_onramp.EVM2EVMMultiOnRampDestChainConfigArgs{
DestChainSelector: getSelector(remoteChainID), // for each destination chain, add a source chain config
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be some copy-pasta here but this comment seems misleading, either remove or replace it with something more useful, e.g:

// Setup a router for each destination chain

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, poor technique in my copy-pasta. good catch!

@@ -704,6 +723,7 @@ func wireOffRamp(t *testing.T, uni onchainUniverse, universes map[uint64]onchain
offrampSourceChainConfigArgs = append(offrampSourceChainConfigArgs, evm_2_evm_multi_offramp.EVM2EVMMultiOffRampSourceChainConfigArgs{
SourceChainSelector: getSelector(remoteChainID), // for each destination chain, add a source chain config
Copy link
Contributor

Choose a reason for hiding this comment

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

Also misleading comment, maybe:

Suggested change
SourceChainSelector: getSelector(remoteChainID), // for each destination chain, add a source chain config
SourceChainSelector: getSelector(remoteChainID), // for each source chain, add a source chain config

Though seems kinda redundant so I'd say just remove it

@RyanRHall RyanRHall merged commit 69a3a85 into ccip-develop Aug 6, 2024
103 checks passed
@RyanRHall RyanRHall deleted the CCIP-2837-multi-on-ramp-make-router-destination-chain-specific-2 branch August 6, 2024 13:27
dhaidashenko pushed a commit that referenced this pull request Sep 2, 2024
## Motivation
We want the ability to test new lanes using custom, test routers.
Therefore, we need a one-to-many relationship b/t routers and lanes,
rather than a singleton.

## Solution
Make routers configurable per lane, rather than per contract
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.

4 participants