Skip to content

Commit

Permalink
rename sourceRouter => router
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanRHall committed Jul 31, 2024
1 parent 9859504 commit 02dc92a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
22 changes: 11 additions & 11 deletions contracts/src/v0.8/ccip/onRamp/EVM2EVMMultiOnRamp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ contract EVM2EVMMultiOnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCre
/// Ensures that 2 identical messages sent to 2 different lanes will have a distinct hash.
/// Must match the metadataHash used in computing leaf hashes offchain for the root committed in
/// the commitStore and i_metadataHash in the offRamp.
address sourceRouter; // This is the local router address that is allowed to send messages to the destination chain.
address router; // This is the local router address that is allowed to send messages to the destination chain.
// This is NOT the receiving router address on the destination chain.
}

Expand All @@ -82,7 +82,7 @@ contract EVM2EVMMultiOnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCre
//solhint-disable gas-struct-packing
struct DestChainConfigArgs {
uint64 destChainSelector; // Destination chain selector
address sourceRouter; // Source router address
address router; // Source router address
}

// STATIC CONFIG
Expand Down Expand Up @@ -144,13 +144,6 @@ contract EVM2EVMMultiOnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCre
return s_destChainConfigs[destChainSelector].sequenceNumber + 1;
}

/// @notice Gets the source router for a destination chain
/// @param destChainSelector The destination chain selector
/// @return sourceRouterAddress the source router address that is allowed to send messages to the destination chain
function getSourceRouterAddress(uint64 destChainSelector) external view returns (address) {
return s_destChainConfigs[destChainSelector].sourceRouter;
}

/// @inheritdoc IEVM2AnyOnRampClient
function forwardFromRouter(
uint64 destChainSelector,
Expand All @@ -162,7 +155,7 @@ contract EVM2EVMMultiOnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCre
// Validate message sender is set and allowed. Not validated in `getFee` since it is not user-driven.
if (originalSender == address(0)) revert RouterMustSetOriginalSender();
// Router address may be zero intentionally to pause.
if (msg.sender != s_destChainConfigs[destChainSelector].sourceRouter) revert MustBeCalledByRouter();
if (msg.sender != s_destChainConfigs[destChainSelector].router) revert MustBeCalledByRouter();

address messageValidator = s_dynamicConfig.messageValidator;
if (messageValidator != address(0)) {
Expand Down Expand Up @@ -317,6 +310,13 @@ contract EVM2EVMMultiOnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCre
);
}

/// @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) {
return s_destChainConfigs[destChainSelector];
}

/// @notice Updates the destination chain specific config.
/// @param destChainConfigArgs Array of source chain specific configs.
function applyDestChainConfigUpdates(DestChainConfigArgs[] memory destChainConfigArgs) external onlyOwner {
Expand All @@ -335,7 +335,7 @@ contract EVM2EVMMultiOnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCre

DestChainConfig memory newDestChainConfig = DestChainConfig({
sequenceNumber: s_destChainConfigs[destChainSelector].sequenceNumber,
sourceRouter: destChainConfigArg.sourceRouter
router: destChainConfigArg.router
});
s_destChainConfigs[destChainSelector] = newDestChainConfig;

Expand Down
16 changes: 7 additions & 9 deletions contracts/src/v0.8/ccip/test/onRamp/EVM2EVMMultiOnRamp.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract EVM2EVMMultiOnRamp_constructor is EVM2EVMMultiOnRampSetup {
assertEq("EVM2EVMMultiOnRamp 1.6.0-dev", s_onRamp.typeAndVersion());
assertEq(OWNER, s_onRamp.owner());
assertEq(1, s_onRamp.getExpectedNextSequenceNumber(DEST_CHAIN_SELECTOR));
assertEq(address(s_sourceRouter), s_onRamp.getSourceRouterAddress(DEST_CHAIN_SELECTOR));
assertEq(address(s_sourceRouter), s_onRamp.getDestChainConfig(DEST_CHAIN_SELECTOR).router);
}

function test_Constructor_InvalidConfigChainSelectorEqZero_Revert() public {
Expand Down Expand Up @@ -750,21 +750,19 @@ contract EVM2EVMMultiOnRamp_applyDestChainConfigUpdates is EVM2EVMMultiOnRampSet
vm.expectEmit();
emit EVM2EVMMultiOnRamp.DestChainConfigSet(DEST_CHAIN_SELECTOR, EVM2EVMMultiOnRamp.DestChainConfig(0, address(0)));
s_onRamp.applyDestChainConfigUpdates(configArgs);
assertEq(address(0), s_onRamp.getSourceRouterAddress(DEST_CHAIN_SELECTOR));
assertEq(address(0), s_onRamp.getDestChainConfig(DEST_CHAIN_SELECTOR).router);
// supports updating and adding lanes simultaneously
configArgs = new EVM2EVMMultiOnRamp.DestChainConfigArgs[](2);
configArgs[0] = EVM2EVMMultiOnRamp.DestChainConfigArgs({
destChainSelector: DEST_CHAIN_SELECTOR,
sourceRouter: address(s_sourceRouter)
});
configArgs[1] = EVM2EVMMultiOnRamp.DestChainConfigArgs({destChainSelector: 9999, sourceRouter: address(9999)});
configArgs[0] =
EVM2EVMMultiOnRamp.DestChainConfigArgs({destChainSelector: DEST_CHAIN_SELECTOR, router: address(s_sourceRouter)});
configArgs[1] = EVM2EVMMultiOnRamp.DestChainConfigArgs({destChainSelector: 9999, router: address(9999)});
vm.expectEmit();
emit EVM2EVMMultiOnRamp.DestChainConfigSet(
DEST_CHAIN_SELECTOR, EVM2EVMMultiOnRamp.DestChainConfig(0, address(s_sourceRouter))
);
emit EVM2EVMMultiOnRamp.DestChainConfigSet(9999, EVM2EVMMultiOnRamp.DestChainConfig(0, address(9999)));
s_onRamp.applyDestChainConfigUpdates(configArgs);
assertEq(address(s_sourceRouter), s_onRamp.getSourceRouterAddress(DEST_CHAIN_SELECTOR));
assertEq(address(9999), s_onRamp.getSourceRouterAddress(9999));
assertEq(address(s_sourceRouter), s_onRamp.getDestChainConfig(DEST_CHAIN_SELECTOR).router);
assertEq(address(9999), s_onRamp.getDestChainConfig(9999).router);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,20 @@ contract EVM2EVMMultiOnRampSetup is TokenSetup, PriceRegistryFeeSetup {
return result;
}

function _generateDestChainConfigArgs(address sourceRouter)
function _generateDestChainConfigArgs(address router)
internal
pure
returns (EVM2EVMMultiOnRamp.DestChainConfigArgs[] memory)
{
EVM2EVMMultiOnRamp.DestChainConfigArgs[] memory destChainConfigs = new EVM2EVMMultiOnRamp.DestChainConfigArgs[](1);
destChainConfigs[0] =
EVM2EVMMultiOnRamp.DestChainConfigArgs({destChainSelector: DEST_CHAIN_SELECTOR, sourceRouter: sourceRouter});
EVM2EVMMultiOnRamp.DestChainConfigArgs({destChainSelector: DEST_CHAIN_SELECTOR, router: router});
return destChainConfigs;
}

function _deployOnRamp(
uint64 sourceChainSelector,
address sourceRouter,
address router,
address nonceManager,
address tokenAdminRegistry
) internal returns (EVM2EVMMultiOnRampHelper, bytes32 metadataHash) {
Expand All @@ -136,7 +136,7 @@ contract EVM2EVMMultiOnRampSetup is TokenSetup, PriceRegistryFeeSetup {
tokenAdminRegistry: tokenAdminRegistry
}),
_generateDynamicMultiOnRampConfig(address(s_priceRegistry)),
_generateDestChainConfigArgs(sourceRouter)
_generateDestChainConfigArgs(router)
);

address[] memory authorizedCallers = new address[](1);
Expand Down

0 comments on commit 02dc92a

Please sign in to comment.