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

Multi-OffRamp - per-chain configs #761

Merged
merged 20 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
223632f
chore: create multi chain copies for ARL and offramp
elatoskinas Apr 19, 2024
5cb8014
chore: create multi chain copy for multi ARL tests
elatoskinas Apr 23, 2024
16278f0
feat: implement multi-chain source config for offramp
elatoskinas Apr 25, 2024
a282597
test: helpers and setup for multiofframp
elatoskinas Apr 25, 2024
d45250f
test: base test setup with metadatahash tests
elatoskinas Apr 25, 2024
9b9b0dd
test: release or mint tests
elatoskinas Apr 25, 2024
9707007
test: apply source chain updates tests
elatoskinas Apr 26, 2024
2e78cac
style: apply formatting
elatoskinas Apr 26, 2024
f861c71
chore: generate snapshots and wrappers
elatoskinas Apr 26, 2024
2f2a57f
feat: implement multi-offramp constructor
elatoskinas Apr 26, 2024
72f1170
refactor: convert source config update to struct args
elatoskinas Apr 29, 2024
f24383a
test: add fuzz test for metadata hash collisions
elatoskinas Apr 29, 2024
2318faa
refactor: remove source chain selectors getter and add additional todos
elatoskinas May 1, 2024
cadf65f
Merge branch 'ccip-develop' into feat/multi-offramp-source-config
elatoskinas May 3, 2024
498249e
chore: fix warnings and add todo for isEnabled
elatoskinas May 7, 2024
d1bbaa4
Merge branch 'ccip-develop' into feat/multi-offramp-source-config
elatoskinas May 7, 2024
c51dab9
docs: add changeset
elatoskinas May 7, 2024
3dafce4
chore: fix formatting
elatoskinas May 7, 2024
8556b4f
style: rename source chain config structs and functions
elatoskinas May 7, 2024
31e765b
chore: update gas snapshots and wrappers
elatoskinas May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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_applySoureConfigUpdates:test_AddMultipleChains_Success() (gas: 261297)
EVM2EVMMultiOffRamp_applySoureConfigUpdates:test_AddNewChain_Success() (gas: 94782)
EVM2EVMMultiOffRamp_applySoureConfigUpdates:test_ApplyZeroUpdates_Success() (gas: 12333)
EVM2EVMMultiOffRamp_applySoureConfigUpdates:test_ReplaceExistingChain_Success() (gas: 103314)
EVM2EVMMultiOffRamp_applySoureConfigUpdates:test_ZeroOnRampAddress_Revert() (gas: 14511)
EVM2EVMMultiOffRamp_constructor:test_Constructor_Success() (gas: 5497454)
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: 142181)
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
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,
SourceChainConfigUpdateArgs[] 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);
}
}