Skip to content

Commit

Permalink
replace getOffRamps and isOffRamp
Browse files Browse the repository at this point in the history
  • Loading branch information
RensR committed Oct 19, 2023
1 parent 020cc0b commit 56d439a
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 119 deletions.
120 changes: 60 additions & 60 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ BurnMintERC677_burn:testPoolBurnRevertNotHealthyReverts() (gas: 58172)
BurnMintERC677_burn:testPoolBurnSuccess() (gas: 197691)
BurnMintERC677_mint:testPoolMintNotHealthyReverts() (gas: 55341)
BurnMintERC677_mint:testPoolMintSuccess() (gas: 93632)
CCIPClientExample_sanity:testExamples() (gas: 2215511)
CCIPClientExample_sanity:testExamples() (gas: 2215733)
CallWithExactGas_callWithExactGas:test_CallWithExactGasSuccess() (gas: 22382)
CallWithExactGas_callWithExactGas:test_NoContractReverts() (gas: 10456)
CallWithExactGas_callWithExactGas:test_NoGasForCallExactCheckReverts() (gas: 14030)
Expand Down Expand Up @@ -91,15 +91,15 @@ CommitStore_verify:testPausedReverts() (gas: 18438)
CommitStore_verify:testTooManyLeavesReverts() (gas: 36830)
DefensiveExampleTest:testHappyPathSuccess() (gas: 174828)
DefensiveExampleTest:testRecovery() (gas: 399728)
E2E:testE2E_3MessagesSuccess_gas() (gas: 881285)
E2E:testE2E_3MessagesSuccess_gas() (gas: 881720)
EVM2EVMOffRamp__releaseOrMintTokens:testRateLimitErrorsReverts() (gas: 442138)
EVM2EVMOffRamp__releaseOrMintTokens:testTokenHandlingErrorReverts() (gas: 103096)
EVM2EVMOffRamp__releaseOrMintTokens:testUnsupportedTokenReverts() (gas: 18133)
EVM2EVMOffRamp__releaseOrMintTokens:test_releaseOrMintTokensSuccess() (gas: 140162)
EVM2EVMOffRamp__report:testReportSuccess() (gas: 126678)
EVM2EVMOffRamp__report:testReportSuccess() (gas: 126703)
EVM2EVMOffRamp__trialExecute:testRateLimitErrorSuccess() (gas: 174387)
EVM2EVMOffRamp__trialExecute:testTokenHandlingErrorIsCaughtSuccess() (gas: 182709)
EVM2EVMOffRamp__trialExecute:test_trialExecuteSuccess() (gas: 235747)
EVM2EVMOffRamp__trialExecute:test_trialExecuteSuccess() (gas: 235772)
EVM2EVMOffRamp_applyPoolUpdates:testApplyPoolUpdatesSuccess() (gas: 2562444)
EVM2EVMOffRamp_applyPoolUpdates:testInvalidTokenPoolConfigReverts() (gas: 17337)
EVM2EVMOffRamp_applyPoolUpdates:testOnlyCallableByOwnerReverts() (gas: 16000)
Expand All @@ -111,53 +111,53 @@ EVM2EVMOffRamp_constructor:testCommitStoreAlreadyInUseReverts() (gas: 169257)
EVM2EVMOffRamp_constructor:testConstructorSuccess() (gas: 6007540)
EVM2EVMOffRamp_constructor:testTokenConfigMismatchReverts() (gas: 145623)
EVM2EVMOffRamp_constructor:testZeroOnRampAddressReverts() (gas: 2666128)
EVM2EVMOffRamp_execute:testAlreadyExecutedReverts() (gas: 136613)
EVM2EVMOffRamp_execute:testAlreadyExecutedReverts() (gas: 136638)
EVM2EVMOffRamp_execute:testEmptyReportReverts() (gas: 18992)
EVM2EVMOffRamp_execute:testInvalidMessageIdReverts() (gas: 33964)
EVM2EVMOffRamp_execute:testInvalidSourceChainReverts() (gas: 49188)
EVM2EVMOffRamp_execute:testManualExecutionNotYetEnabledReverts() (gas: 43978)
EVM2EVMOffRamp_execute:testMessageTooLargeReverts() (gas: 149952)
EVM2EVMOffRamp_execute:testPausedReverts() (gas: 74597)
EVM2EVMOffRamp_execute:testReceiverErrorSuccess() (gas: 162994)
EVM2EVMOffRamp_execute:testReceiverErrorSuccess() (gas: 163019)
EVM2EVMOffRamp_execute:testRootNotCommittedReverts() (gas: 38854)
EVM2EVMOffRamp_execute:testRouterYULCallReverts() (gas: 413160)
EVM2EVMOffRamp_execute:testSingleMessageNoTokensSuccess() (gas: 172298)
EVM2EVMOffRamp_execute:testRouterYULCallReverts() (gas: 413187)
EVM2EVMOffRamp_execute:testSingleMessageNoTokensSuccess() (gas: 172348)
EVM2EVMOffRamp_execute:testSingleMessageToNonCCIPReceiverSuccess() (gas: 245967)
EVM2EVMOffRamp_execute:testSingleMessagesNoTokensSuccess_gas() (gas: 114080)
EVM2EVMOffRamp_execute:testSkippedIncorrectNonceStillExecutesSuccess() (gas: 322708)
EVM2EVMOffRamp_execute:testSingleMessagesNoTokensSuccess_gas() (gas: 114105)
EVM2EVMOffRamp_execute:testSkippedIncorrectNonceStillExecutesSuccess() (gas: 322733)
EVM2EVMOffRamp_execute:testSkippedIncorrectNonceSuccess() (gas: 51709)
EVM2EVMOffRamp_execute:testStrictUntouchedToSuccessSuccess() (gas: 130221)
EVM2EVMOffRamp_execute:testStrictUntouchedToSuccessSuccess() (gas: 130246)
EVM2EVMOffRamp_execute:testTokenDataMismatchReverts() (gas: 49549)
EVM2EVMOffRamp_execute:testTwoMessagesWithTokensAndGESuccess() (gas: 440941)
EVM2EVMOffRamp_execute:testTwoMessagesWithTokensSuccess_gas() (gas: 400214)
EVM2EVMOffRamp_execute:testTwoMessagesWithTokensAndGESuccess() (gas: 440991)
EVM2EVMOffRamp_execute:testTwoMessagesWithTokensSuccess_gas() (gas: 400264)
EVM2EVMOffRamp_execute:testUnexpectedTokenDataReverts() (gas: 32945)
EVM2EVMOffRamp_execute:testUnhealthyReverts() (gas: 417371)
EVM2EVMOffRamp_execute:testUnhealthyReverts() (gas: 417421)
EVM2EVMOffRamp_execute:testUnsupportedNumberOfTokensReverts() (gas: 61077)
EVM2EVMOffRamp_execute:testUnsupportedTokenReverts() (gas: 129738)
EVM2EVMOffRamp_executeSingleMessage:testMessageSenderReverts() (gas: 20494)
EVM2EVMOffRamp_executeSingleMessage:testNoTokensSuccess() (gas: 47661)
EVM2EVMOffRamp_executeSingleMessage:testNoTokensSuccess() (gas: 47686)
EVM2EVMOffRamp_executeSingleMessage:testNonContractSuccess() (gas: 20042)
EVM2EVMOffRamp_executeSingleMessage:testNonContractWithTokensSuccess() (gas: 204618)
EVM2EVMOffRamp_executeSingleMessage:testTokenHandlingErrorReverts() (gas: 139650)
EVM2EVMOffRamp_executeSingleMessage:testTokensSuccess() (gas: 233197)
EVM2EVMOffRamp_executeSingleMessage:testZeroGasDONExecutionReverts() (gas: 48206)
EVM2EVMOffRamp_execute_upgrade:testV2NonceNewSenderStartsAtZeroSuccess() (gas: 230728)
EVM2EVMOffRamp_execute_upgrade:testV2NonceStartsAtV1NonceSuccess() (gas: 277971)
EVM2EVMOffRamp_execute_upgrade:testV2OffRampNonceSkipsIfMsgInFlightSuccess() (gas: 259420)
EVM2EVMOffRamp_execute_upgrade:testV2SenderNoncesReadsPreviousRampSuccess() (gas: 223213)
EVM2EVMOffRamp_execute_upgrade:testV2Success() (gas: 130748)
EVM2EVMOffRamp_executeSingleMessage:testTokensSuccess() (gas: 233222)
EVM2EVMOffRamp_executeSingleMessage:testZeroGasDONExecutionReverts() (gas: 48231)
EVM2EVMOffRamp_execute_upgrade:testV2NonceNewSenderStartsAtZeroSuccess() (gas: 230778)
EVM2EVMOffRamp_execute_upgrade:testV2NonceStartsAtV1NonceSuccess() (gas: 278046)
EVM2EVMOffRamp_execute_upgrade:testV2OffRampNonceSkipsIfMsgInFlightSuccess() (gas: 259470)
EVM2EVMOffRamp_execute_upgrade:testV2SenderNoncesReadsPreviousRampSuccess() (gas: 223288)
EVM2EVMOffRamp_execute_upgrade:testV2Success() (gas: 130773)
EVM2EVMOffRamp_getDestinationToken:testGetDestinationTokenSuccess() (gas: 32642)
EVM2EVMOffRamp_getDestinationToken:testUnsupportedTokenReverts() (gas: 13727)
EVM2EVMOffRamp_getDestinationTokens:testGetDestinationTokensSuccess() (gas: 26043)
EVM2EVMOffRamp_getExecutionState:testFillExecutionStateSuccess() (gas: 3047472)
EVM2EVMOffRamp_getExecutionState:test_GetExecutionStateSuccess() (gas: 76354)
EVM2EVMOffRamp_manuallyExecute:testLowGasLimitManualExecSuccess() (gas: 495769)
EVM2EVMOffRamp_manuallyExecute:testLowGasLimitManualExecSuccess() (gas: 495819)
EVM2EVMOffRamp_manuallyExecute:testManualExecForkedChainReverts() (gas: 25902)
EVM2EVMOffRamp_manuallyExecute:testManualExecGasLimitMismatchReverts() (gas: 43405)
EVM2EVMOffRamp_manuallyExecute:testManualExecInvalidGasLimitReverts() (gas: 25940)
EVM2EVMOffRamp_manuallyExecute:testManualExecSuccess() (gas: 188449)
EVM2EVMOffRamp_manuallyExecute:testManualExecWithGasOverrideSuccess() (gas: 189073)
EVM2EVMOffRamp_manuallyExecute:testReentrancyManualExecuteFAILS() (gas: 1891166)
EVM2EVMOffRamp_manuallyExecute:testManualExecSuccess() (gas: 188499)
EVM2EVMOffRamp_manuallyExecute:testManualExecWithGasOverrideSuccess() (gas: 189123)
EVM2EVMOffRamp_manuallyExecute:testReentrancyManualExecuteFAILS() (gas: 1891191)
EVM2EVMOffRamp_metadataHash:testMetadataHashSuccess() (gas: 6074)
EVM2EVMOffRamp_setDynamicConfig:testNonOwnerReverts() (gas: 44413)
EVM2EVMOffRamp_setDynamicConfig:testRouterZeroAddressReverts() (gas: 38425)
Expand Down Expand Up @@ -296,10 +296,10 @@ OCR2Base_transmit:testTransmit2SignersSuccess_gas() (gas: 51741)
OCR2Base_transmit:testUnAuthorizedTransmitterReverts() (gas: 23441)
OCR2Base_transmit:testUnauthorizedSignerReverts() (gas: 43661)
OCR2Base_transmit:testWrongNumberOfSignaturesReverts() (gas: 20507)
OnRampTokenPoolReentrancy:testSuccess() (gas: 333114)
PingPong_ccipReceive:testCcipReceiveSuccess() (gas: 146279)
OnRampTokenPoolReentrancy:testSuccess() (gas: 333256)
PingPong_ccipReceive:testCcipReceiveSuccess() (gas: 146319)
PingPong_plumbing:testPausingSuccess() (gas: 14471)
PingPong_startPingPong:testStartPingPongSuccess() (gas: 171430)
PingPong_startPingPong:testStartPingPongSuccess() (gas: 171452)
PriceRegistry_applyFeeTokensUpdates:testApplyFeeTokensUpdatesSuccess() (gas: 77463)
PriceRegistry_applyFeeTokensUpdates:testOnlyCallableByOwnerReverts() (gas: 16532)
PriceRegistry_applyPriceUpdatersUpdates:testApplyPriceUpdaterUpdatesSuccess() (gas: 80844)
Expand Down Expand Up @@ -337,41 +337,41 @@ RateLimiter_consume:testTokenRateLimitReachedReverts() (gas: 24382)
RateLimiter_currentTokenBucketState:testCurrentTokenBucketStateSuccess() (gas: 32403)
RateLimiter_currentTokenBucketState:testRefillSuccess() (gas: 41673)
RateLimiter_setTokenBucketConfig:testSetRateLimiterConfigSuccess() (gas: 35459)
Router_applyRampUpdates:testOffRampDisable() (gas: 194086)
Router_applyRampUpdates:testOffRampDisable() (gas: 158016)
Router_applyRampUpdates:testOffRampMismatchReverts() (gas: 89043)
Router_applyRampUpdates:testOnRampDisable() (gas: 52147)
Router_applyRampUpdates:testOnlyOwnerReverts() (gas: 12224)
Router_ccipSend:testCCIPSendLinkFeeNoTokenSuccess_gas() (gas: 110420)
Router_ccipSend:testCCIPSendLinkFeeOneTokenSuccess_gas() (gas: 188963)
Router_ccipSend:testCCIPSendNativeFeeNoTokenSuccess_gas() (gas: 122471)
Router_ccipSend:testCCIPSendNativeFeeOneTokenSuccess_gas() (gas: 201016)
Router_ccipSend:testFeeTokenAmountTooLowReverts() (gas: 61405)
Router_ccipSend:testCCIPSendLinkFeeNoTokenSuccess_gas() (gas: 110460)
Router_ccipSend:testCCIPSendLinkFeeOneTokenSuccess_gas() (gas: 189043)
Router_ccipSend:testCCIPSendNativeFeeNoTokenSuccess_gas() (gas: 122511)
Router_ccipSend:testCCIPSendNativeFeeOneTokenSuccess_gas() (gas: 201096)
Router_ccipSend:testFeeTokenAmountTooLowReverts() (gas: 61445)
Router_ccipSend:testInvalidMsgValue() (gas: 31860)
Router_ccipSend:testNativeFeeTokenInsufficientValue() (gas: 63938)
Router_ccipSend:testNativeFeeTokenOverpaySuccess() (gas: 162178)
Router_ccipSend:testNativeFeeTokenSuccess() (gas: 161519)
Router_ccipSend:testNativeFeeTokenOverpaySuccess() (gas: 162200)
Router_ccipSend:testNativeFeeTokenSuccess() (gas: 161541)
Router_ccipSend:testNativeFeeTokenZeroValue() (gas: 51295)
Router_ccipSend:testNonLinkFeeTokenSuccess() (gas: 232331)
Router_ccipSend:testNonLinkFeeTokenSuccess() (gas: 232371)
Router_ccipSend:testUnsupportedDestinationChainReverts() (gas: 24624)
Router_ccipSend:testWhenNotHealthyReverts() (gas: 44650)
Router_ccipSend:testWrappedNativeFeeTokenSuccess() (gas: 163618)
Router_ccipSend:testZeroFeeAndGasPriceSuccess() (gas: 229287)
Router_constructor:testConstructorSuccess() (gas: 9929)
Router_getFee:testGetFeeSupportedChainSuccess() (gas: 38939)
Router_getFee:testUnsupportedDestinationChainReverts() (gas: 17079)
Router_ccipSend:testWrappedNativeFeeTokenSuccess() (gas: 163640)
Router_ccipSend:testZeroFeeAndGasPriceSuccess() (gas: 229309)
Router_constructor:testConstructorSuccess() (gas: 9995)
Router_getFee:testGetFeeSupportedChainSuccess() (gas: 38921)
Router_getFee:testUnsupportedDestinationChainReverts() (gas: 17057)
Router_getSupportedTokens:testGetSupportedTokensSuccess() (gas: 33604)
Router_getSupportedTokens:testUnknownChainSuccess() (gas: 8542)
Router_recoverTokens:testRecoverTokensInvalidRecipientReverts() (gas: 11211)
Router_recoverTokens:testRecoverTokensNoFundsReverts() (gas: 17675)
Router_recoverTokens:testRecoverTokensNonOwnerReverts() (gas: 15283)
Router_recoverTokens:testRecoverTokensSuccess() (gas: 48429)
Router_recoverTokens:testRecoverTokensValueReceiverReverts() (gas: 444668)
Router_routeMessage:testAutoExecSuccess() (gas: 38981)
Router_routeMessage:testExecutionEventSuccess() (gas: 208891)
Router_routeMessage:testManualExecSuccess() (gas: 31226)
Router_routeMessage:testOnlyOffRampReverts() (gas: 27135)
Router_routeMessage:testWhenNotHealthyReverts() (gas: 42985)
Router_setWrappedNative:testOnlyOwnerReverts() (gas: 10976)
ThirdPartyBurnMintTokenPool_applyRampUpdates:testInvalidOffRampReverts() (gas: 20839)
Router_getSupportedTokens:testUnknownChainSuccess() (gas: 8565)
Router_recoverTokens:testRecoverTokensInvalidRecipientReverts() (gas: 11234)
Router_recoverTokens:testRecoverTokensNoFundsReverts() (gas: 17698)
Router_recoverTokens:testRecoverTokensNonOwnerReverts() (gas: 15306)
Router_recoverTokens:testRecoverTokensSuccess() (gas: 48498)
Router_recoverTokens:testRecoverTokensValueReceiverReverts() (gas: 444691)
Router_routeMessage:testAutoExecSuccess() (gas: 39031)
Router_routeMessage:testExecutionEventSuccess() (gas: 208966)
Router_routeMessage:testManualExecSuccess() (gas: 31251)
Router_routeMessage:testOnlyOffRampReverts() (gas: 27162)
Router_routeMessage:testWhenNotHealthyReverts() (gas: 42963)
Router_setWrappedNative:testOnlyOwnerReverts() (gas: 10954)
ThirdPartyBurnMintTokenPool_lockOrBurn:testLockOrBurnWithAllowListReverts() (gas: 21762)
ThirdPartyBurnMintTokenPool_lockOrBurn:testLockOrBurnWithAllowListSuccess() (gas: 100009)
TokenPoolWithAllowList_applyAllowListUpdates:testOnlyOwnerReverts() (gas: 12072)
Expand All @@ -387,16 +387,16 @@ TokenPool_setOffRampRateLimiterConfig:testOnlyOwnerReverts() (gas: 17975)
TokenPool_setOnRampRateLimiterConfig:testNonExistentRampReverts() (gas: 14143)
TokenPool_setOnRampRateLimiterConfig:testOnlyOwnerReverts() (gas: 17999)
TokenProxy_ccipSend:testCcipSendGasShouldBeZeroReverts() (gas: 17053)
TokenProxy_ccipSend:testCcipSendInsufficientAllowanceReverts() (gas: 127612)
TokenProxy_ccipSend:testCcipSendInsufficientAllowanceReverts() (gas: 127594)
TokenProxy_ccipSend:testCcipSendInvalidTokenReverts() (gas: 15839)
TokenProxy_ccipSend:testCcipSendNativeSuccess() (gas: 229975)
TokenProxy_ccipSend:testCcipSendNativeSuccess() (gas: 230055)
TokenProxy_ccipSend:testCcipSendNoDataAllowedReverts() (gas: 16167)
TokenProxy_ccipSend:testCcipSendSuccess() (gas: 249960)
TokenProxy_ccipSend:testCcipSendSuccess() (gas: 250009)
TokenProxy_constructor:testConstructor() (gas: 10651)
TokenProxy_getFee:testGetFeeGasShouldBeZeroReverts() (gas: 16734)
TokenProxy_getFee:testGetFeeInvalidTokenReverts() (gas: 12616)
TokenProxy_getFee:testGetFeeNoDataAllowedReverts() (gas: 15763)
TokenProxy_getFee:testGetFeeSuccess() (gas: 74267)
TokenProxy_getFee:testGetFeeSuccess() (gas: 74231)
USDCTokenPool__validateMessage:testValidateInvalidMessageReverts() (gas: 25239)
USDCTokenPool_lockOrBurn:testLockOrBurnWithAllowListReverts() (gas: 21848)
USDCTokenPool_lockOrBurn:testPermissionsErrorReverts() (gas: 12450)
Expand Down
62 changes: 34 additions & 28 deletions contracts/src/v0.8/ccip/Router.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ import {IERC20} from "../vendor/openzeppelin-solidity/v4.8.0/contracts/token/ERC
contract Router is IRouter, IRouterClient, ITypeAndVersion, OwnerIsCreator {
using SafeERC20 for IERC20;
using EnumerableSet for EnumerableSet.AddressSet;
using EnumerableSet for EnumerableSet.UintSet;

error FailedToSendValue();
error InvalidRecipientAddress(address to);
error OffRampMismatch(uint64 chainSelector, address offRamp);
error BadARMSignal();

event OnRampSet(uint64 indexed destChainSelector, address onRamp);
Expand Down Expand Up @@ -58,11 +60,9 @@ contract Router is IRouter, IRouterClient, ITypeAndVersion, OwnerIsCreator {
address private s_wrappedNative;
// destChainSelector => onRamp address
mapping(uint256 destChainSelector => address onRamp) private s_onRamps;
// A collection of offramp addresses.
EnumerableSet.AddressSet private s_offRamps;
// Mapping of [sourceChainSelector, offRamp] to a flag indicating whether it is valid.
// The mapping key is sourceChainSelector << 160 + offramp address.
mapping(uint256 sourceSelectorAndOffRamp => bool isOffRamp) private s_offRampIndexes;
// Stores [sourceChainSelector << 160 + offramp] as a pair to allow for
// lookups for specific chain/offramp pairs.
EnumerableSet.UintSet private s_chainSelectorAndOffRamps;

constructor(address wrappedNative, address armProxy) {
// Zero address indicates unsupported auto-wrapping, therefore, unsupported
Expand Down Expand Up @@ -157,9 +157,10 @@ contract Router is IRouter, IRouterClient, ITypeAndVersion, OwnerIsCreator {
uint256 gasLimit,
address receiver
) external override whenHealthy returns (bool success, bytes memory retData) {
// We only permit offRamps to call this function.
uint256 rampIndex = (uint256(message.sourceChainSelector) << 160) + uint160(msg.sender);
if (!s_offRampIndexes[rampIndex]) revert OnlyOffRamp();
// We only permit offRamps to call this function. We have to encode the sourceChainSelector
// and msg.sender into a uint256 to use as a key in the set.
if (!s_chainSelectorAndOffRamps.contains((uint256(message.sourceChainSelector) << 160) + uint160(msg.sender)))
revert OnlyOffRamp();

// We encode here instead of the offRamps to constrain specifically what functions
// can be called from the router.
Expand Down Expand Up @@ -206,15 +207,21 @@ contract Router is IRouter, IRouterClient, ITypeAndVersion, OwnerIsCreator {
return s_onRamps[destChainSelector];
}

/// @notice Return a full list of configured offRamps.
function getOffRamps() external view returns (address[] memory) {
return s_offRamps.values();
function getOffRamps() external view returns (OffRamp[] memory) {
uint256[] memory encodedOffRamps = s_chainSelectorAndOffRamps.values();
OffRamp[] memory offRamps = new OffRamp[](encodedOffRamps.length);
for (uint256 i = 0; i < encodedOffRamps.length; ++i) {
uint256 encodedOffRamp = encodedOffRamps[i];
offRamps[i] = OffRamp({
sourceChainSelector: uint64(encodedOffRamp >> 160),
offRamp: address(uint160(encodedOffRamp))
});
}
return offRamps;
}

/// @notice Returns true if the given address is a permissioned offRamp
/// and sourceChainSelector if so.
function isOffRamp(address offRamp) external view returns (bool) {
return s_offRamps.contains(offRamp);
function isOffRamp(address offRamp, uint64 sourceChainSelector) external view returns (bool) {
return s_chainSelectorAndOffRamps.contains((uint256(sourceChainSelector) << 160) + uint160(offRamp));
}

/// @notice applyRampUpdates applies a set of ramp changes which provides
Expand All @@ -231,26 +238,25 @@ contract Router is IRouter, IRouterClient, ITypeAndVersion, OwnerIsCreator {
s_onRamps[onRampUpdate.destChainSelector] = onRampUpdate.onRamp;
emit OnRampSet(onRampUpdate.destChainSelector, onRampUpdate.onRamp);
}

// Apply ingress updates.
// We permit an empty list as a way to disable ingress.
for (uint256 i = 0; i < offRampRemoves.length; ++i) {
uint64 rampSelector = offRampRemoves[i].sourceChainSelector;
address rampAddress = offRampRemoves[i].offRamp;
uint64 sourceChainSelector = offRampRemoves[i].sourceChainSelector;
address offRampAddress = offRampRemoves[i].offRamp;

s_offRampIndexes[(uint256(rampSelector) << 160) + uint160(rampAddress)] = false;
// If the selector-offRamp pair does not exist, revert.
if (!s_chainSelectorAndOffRamps.remove((uint256(sourceChainSelector) << 160) + uint160(offRampAddress)))
revert OffRampMismatch(sourceChainSelector, offRampAddress);

if (s_offRamps.remove(rampAddress)) {
emit OffRampRemoved(rampSelector, rampAddress);
}
emit OffRampRemoved(sourceChainSelector, offRampAddress);
}
for (uint256 i = 0; i < offRampAdds.length; ++i) {
uint64 rampSelector = offRampAdds[i].sourceChainSelector;
address rampAddress = offRampAdds[i].offRamp;

s_offRampIndexes[(uint256(rampSelector) << 160) + uint160(rampAddress)] = true;
for (uint256 i = 0; i < offRampAdds.length; ++i) {
uint64 sourceChainSelector = offRampAdds[i].sourceChainSelector;
address offRampAddress = offRampAdds[i].offRamp;

if (s_offRamps.add(rampAddress)) {
emit OffRampAdded(rampSelector, rampAddress);
if (s_chainSelectorAndOffRamps.add((uint256(sourceChainSelector) << 160) + uint160(offRampAddress))) {
emit OffRampAdded(sourceChainSelector, offRampAddress);
}
}
}
Expand Down
Loading

0 comments on commit 56d439a

Please sign in to comment.