Skip to content

Commit

Permalink
Multi-OffRamp - per-chain configs (#761)
Browse files Browse the repository at this point in the history
## Motivation
Implements per-chain source configs in the MultiOffRamp, which allows an
OffRamp to support more than one source configuration

## Solution
Modifies the MultiOffRamp configs to be per-chain, along with getters
and setters. Puts TODOs for execution and other functional parts

**Focus**: The focus of the PR are the source config state, event,
set/get and constructor changes

**Out of scope for this PR:**
* State changes to be per-chain
* Per-chain ARL
* Full test coverage for non-config setters / getters
  • Loading branch information
elatoskinas committed May 8, 2024
1 parent 828be93 commit 499bfa7
Show file tree
Hide file tree
Showing 12 changed files with 3,831 additions and 61 deletions.
5 changes: 5 additions & 0 deletions .changeset/poor-trains-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ccip": minor
---

Per-chain configs for MultiOffRamp
5 changes: 5 additions & 0 deletions contracts/.changeset/heavy-pets-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@chainlink/contracts-ccip": minor
---

Per-chain configs for MultiOffRamp
26 changes: 24 additions & 2 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,28 @@ CommitStore_verify:test_TooManyLeaves_Revert() (gas: 36807)
DefensiveExampleTest:test_HappyPath_Success() (gas: 207522)
DefensiveExampleTest:test_Recovery() (gas: 431757)
E2E:test_E2E_3MessagesSuccess_gas() (gas: 1048339)
EVM2EVMMultiOffRamp__releaseOrMintTokens:test_PriceNotFoundForToken_Reverts() (gas: 136936)
EVM2EVMMultiOffRamp__releaseOrMintTokens:test_TokenHandlingError_Reverts() (gas: 160550)
EVM2EVMMultiOffRamp__releaseOrMintTokens:test__releaseOrMintTokens_PoolIsNotAContract_Reverts() (gas: 32043)
EVM2EVMMultiOffRamp__releaseOrMintTokens:test__releaseOrMintTokens_PoolIsNotAPool_Reverts() (gas: 28406)
EVM2EVMMultiOffRamp__releaseOrMintTokens:test_releaseOrMintTokens_InvalidDataLengthReturnData_Revert() (gas: 65185)
EVM2EVMMultiOffRamp__releaseOrMintTokens:test_releaseOrMintTokens_InvalidEVMAddress_Revert() (gas: 51234)
EVM2EVMMultiOffRamp__releaseOrMintTokens:test_releaseOrMintTokens_Success() (gas: 193489)
EVM2EVMMultiOffRamp__releaseOrMintTokens:test_releaseOrMintTokens_destDenominatedDecimals_Success() (gas: 148437)
EVM2EVMMultiOffRamp_applySourceChainConfigUpdates:test_AddMultipleChains_Success() (gas: 261297)
EVM2EVMMultiOffRamp_applySourceChainConfigUpdates:test_AddNewChain_Success() (gas: 94782)
EVM2EVMMultiOffRamp_applySourceChainConfigUpdates:test_ApplyZeroUpdates_Success() (gas: 12333)
EVM2EVMMultiOffRamp_applySourceChainConfigUpdates:test_ReplaceExistingChain_Success() (gas: 103314)
EVM2EVMMultiOffRamp_applySourceChainConfigUpdates:test_ZeroOnRampAddress_Revert() (gas: 14511)
EVM2EVMMultiOffRamp_constructor:test_Constructor_Success() (gas: 5497432)
EVM2EVMMultiOffRamp_constructor:test_ZeroOnRampAddress_Revert() (gas: 143610)
EVM2EVMMultiOffRamp_metadataHash:test_MetadataHashChangesOnOnRampAddress_Success() (gas: 10983)
EVM2EVMMultiOffRamp_metadataHash:test_MetadataHashChangesOnSourceChain_Success() (gas: 11036)
EVM2EVMMultiOffRamp_metadataHash:test_MetadataHash_Success() (gas: 9146)
EVM2EVMMultiOffRamp_metadataHash:test_fuzz__MetadataHash_NoCollisions(uint64,uint64,uint64,address,address) (runs: 10001, μ: 4944907, ~: 4944907)
EVM2EVMMultiOffRamp_setDynamicConfig:test_NonOwner_Revert() (gas: 40344)
EVM2EVMMultiOffRamp_setDynamicConfig:test_RouterZeroAddress_Revert() (gas: 38530)
EVM2EVMMultiOffRamp_setDynamicConfig:test_SetDynamicConfig_Success() (gas: 142159)
EVM2EVMOffRamp__releaseOrMintTokens:test_OverValueWithARLOff_Success() (gas: 340275)
EVM2EVMOffRamp__releaseOrMintTokens:test_PriceNotFoundForToken_Reverts() (gas: 130288)
EVM2EVMOffRamp__releaseOrMintTokens:test_RateLimitErrors_Reverts() (gas: 675788)
Expand Down Expand Up @@ -484,8 +506,8 @@ TokenAdminRegistry_transferAdminRole:test_transferAdminRole_OnlyAdministrator_Re
TokenAdminRegistry_transferAdminRole:test_transferAdminRole_Success() (gas: 50342)
TokenPoolAndProxy:test_lockOrBurn_burnMint_Success() (gas: 5926354)
TokenPoolAndProxy:test_lockOrBurn_lockRelease_Success() (gas: 6310837)
TokenPoolAndProxyMigration:test_tokenPoolMigration_Success_1_2() (gas: 6727032)
TokenPoolAndProxyMigration:test_tokenPoolMigration_Success_1_4() (gas: 6900022)
TokenPoolAndProxyMigration:test_tokenPoolMigration_Success_1_2() (gas: 6730241)
TokenPoolAndProxyMigration:test_tokenPoolMigration_Success_1_4() (gas: 6903231)
TokenPoolWithAllowList_applyAllowListUpdates:test_AllowListNotEnabled_Revert() (gas: 2184772)
TokenPoolWithAllowList_applyAllowListUpdates:test_OnlyOwner_Revert() (gas: 12111)
TokenPoolWithAllowList_applyAllowListUpdates:test_SetAllowListSkipsZero_Success() (gas: 23412)
Expand Down
1 change: 1 addition & 0 deletions contracts/scripts/native_solc_compile_all_ccip
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ compileContractLowOpts () {
# Solc produces and overwrites intermediary contracts.
# Contracts should be ordered in reverse-import-complexity-order to minimize overwrite risks.
compileContract ccip/offRamp/EVM2EVMOffRamp.sol
compileContract ccip/offRamp/EVM2EVMMultiOffRamp.sol
compileContract ccip/applications/PingPongDemo.sol
compileContract ccip/applications/SelfFundedPingPong.sol
compileContract ccip/applications/EtherSenderReceiver.sol
Expand Down
186 changes: 127 additions & 59 deletions contracts/src/v0.8/ccip/offRamp/EVM2EVMMultiOffRamp.sol

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions contracts/src/v0.8/ccip/test/StructFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {ARM} from "../ARM.sol";
import {PriceRegistry} from "../PriceRegistry.sol";
import {Internal} from "../libraries/Internal.sol";
import {RateLimiter} from "../libraries/RateLimiter.sol";

import {EVM2EVMMultiOffRamp} from "../offRamp/EVM2EVMMultiOffRamp.sol";
import {EVM2EVMOffRamp} from "../offRamp/EVM2EVMOffRamp.sol";
import {EVM2EVMOnRamp} from "../onRamp/EVM2EVMOnRamp.sol";

Expand Down Expand Up @@ -141,6 +143,20 @@ contract StructFactory {
});
}

function generateDynamicMultiOffRampConfig(
address router,
address priceRegistry
) internal pure returns (EVM2EVMMultiOffRamp.DynamicConfig memory) {
return EVM2EVMMultiOffRamp.DynamicConfig({
permissionLessExecutionThresholdSeconds: PERMISSION_LESS_EXECUTION_THRESHOLD_SECONDS,
router: router,
priceRegistry: priceRegistry,
maxNumberOfTokensPerMsg: MAX_TOKENS_LENGTH,
maxDataBytes: MAX_DATA_SIZE,
maxPoolReleaseOrMintGas: MAX_TOKEN_POOL_RELEASE_OR_MINT_GAS
});
}

function generateDynamicOnRampConfig(
address router,
address priceRegistry,
Expand Down
29 changes: 29 additions & 0 deletions contracts/src/v0.8/ccip/test/helpers/EVM2EVMMultiOffRampHelper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;

import {Client} from "../../libraries/Client.sol";
import {Internal} from "../../libraries/Internal.sol";
import {RateLimiter} from "../../libraries/RateLimiter.sol";
import {EVM2EVMMultiOffRamp} from "../../offRamp/EVM2EVMMultiOffRamp.sol";
import {IgnoreContractSize} from "./IgnoreContractSize.sol";

contract EVM2EVMMultiOffRampHelper is EVM2EVMMultiOffRamp, IgnoreContractSize {
constructor(
StaticConfig memory staticConfig,
SourceChainConfigArgs[] memory sourceChainConfigs,
RateLimiter.Config memory rateLimiterConfig
) EVM2EVMMultiOffRamp(staticConfig, sourceChainConfigs, rateLimiterConfig) {}

function metadataHash(uint64 sourceChainSelector, address onRamp) external view returns (bytes32) {
return _metadataHash(sourceChainSelector, onRamp, Internal.EVM_2_EVM_MESSAGE_HASH);
}

function releaseOrMintTokens(
Client.EVMTokenAmount[] memory sourceTokenAmounts,
EVM2EVMMultiOffRamp.Any2EVMMessageRoute memory messageRoute,
bytes[] calldata sourceTokenData,
bytes[] calldata offchainTokenData
) external returns (Client.EVMTokenAmount[] memory) {
return _releaseOrMintTokens(sourceTokenAmounts, messageRoute, sourceTokenData, offchainTokenData);
}
}

0 comments on commit 499bfa7

Please sign in to comment.