Skip to content

Commit

Permalink
Merge branch 'ccip-develop' into feat/CCIP-2595
Browse files Browse the repository at this point in the history
  • Loading branch information
0xsuryansh authored Jul 10, 2024
2 parents 61d973a + c10a0f0 commit 6922b39
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 114 deletions.
139 changes: 69 additions & 70 deletions contracts/gas-snapshots/ccip.gas-snapshot

Large diffs are not rendered by default.

11 changes: 2 additions & 9 deletions contracts/src/v0.8/ccip/onRamp/EVM2EVMMultiOnRamp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ contract EVM2EVMMultiOnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCre

/// @dev Struct to hold the configs for a destination chain
struct DestChainConfig {
DestChainDynamicConfig dynamicConfig; // ──╮ Dynamic configs for a destination chain
address prevOnRamp; // ────────────────────╯ Address of previous-version OnRamp
DestChainDynamicConfig dynamicConfig; // Dynamic configs for a destination chain
uint64 sequenceNumber; // The last used sequence number. This is zero in the case where no messages has been sent yet.
// 0 is not a valid sequence number for any real transaction.
/// @dev metadataHash is a lane-specific prefix for a message hash preimage which ensures global uniqueness
Expand All @@ -157,14 +156,12 @@ contract EVM2EVMMultiOnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCre
bytes32 metadataHash;
}

/// @dev Struct to hold the dynamic configs, its destination chain selector and previous onRamp.
/// Same as DestChainConfig but with the destChainSelector and the prevOnRamp so that an array of these
/// @dev Struct to hold the dynamic configs, its destination chain selector. Same as DestChainConfig but with the destChainSelector so that an array of these
/// can be passed in the constructor and the applyDestChainConfigUpdates function
//solhint-disable gas-struct-packing
struct DestChainConfigArgs {
uint64 destChainSelector; // Destination chain selector
DestChainDynamicConfig dynamicConfig; // Struct to hold the configs for a destination chain
address prevOnRamp; // Address of previous-version OnRamp.
}

// STATIC CONFIG
Expand Down Expand Up @@ -761,11 +758,9 @@ contract EVM2EVMMultiOnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCre
}

DestChainConfig storage destChainConfig = s_destChainConfig[destChainSelector];
address prevOnRamp = destChainConfigArg.prevOnRamp;

DestChainConfig memory newDestChainConfig = DestChainConfig({
dynamicConfig: destChainConfigArg.dynamicConfig,
prevOnRamp: prevOnRamp,
sequenceNumber: destChainConfig.sequenceNumber,
metadataHash: destChainConfig.metadataHash
});
Expand All @@ -776,11 +771,9 @@ contract EVM2EVMMultiOnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCre
newDestChainConfig.metadataHash =
keccak256(abi.encode(Internal.EVM_2_ANY_MESSAGE_HASH, i_chainSelector, destChainSelector, address(this)));
destChainConfig.metadataHash = newDestChainConfig.metadataHash;
if (prevOnRamp != address(0)) destChainConfig.prevOnRamp = prevOnRamp;

emit DestChainAdded(destChainSelector, destChainConfig);
} else {
if (destChainConfig.prevOnRamp != prevOnRamp) revert InvalidDestChainConfig(destChainSelector);
if (destChainConfigArg.dynamicConfig.defaultTokenDestBytesOverhead < Pool.CCIP_LOCK_OR_BURN_V1_RET_BYTES) {
revert InvalidDestBytesOverhead(address(0), destChainConfigArg.dynamicConfig.defaultTokenDestBytesOverhead);
}
Expand Down
1 change: 0 additions & 1 deletion contracts/src/v0.8/ccip/test/NonceManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ contract NonceManager_OnRampUpgrade is EVM2EVMMultiOnRampSetup {
s_outboundNonceManager.applyPreviousRampsUpdates(previousRamps);

EVM2EVMMultiOnRamp.DestChainConfigArgs[] memory destChainConfigArgs = _generateDestChainConfigArgs();
destChainConfigArgs[0].prevOnRamp = address(s_prevOnRamp);

(s_onRamp, s_metadataHash) = _deployOnRamp(
SOURCE_CHAIN_SELECTOR, address(s_sourceRouter), address(s_outboundNonceManager), address(s_tokenAdminRegistry)
Expand Down
28 changes: 3 additions & 25 deletions contracts/src/v0.8/ccip/test/onRamp/EVM2EVMMultiOnRamp.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ contract EVM2EVMMultiOnRamp_constructor is EVM2EVMMultiOnRampSetup {
DEST_CHAIN_SELECTOR,
EVM2EVMMultiOnRamp.DestChainConfig({
dynamicConfig: destChainConfigArg.dynamicConfig,
prevOnRamp: address(0),
sequenceNumber: 0,
metadataHash: ""
})
Expand All @@ -61,7 +60,6 @@ contract EVM2EVMMultiOnRamp_constructor is EVM2EVMMultiOnRampSetup {

EVM2EVMMultiOnRamp.DestChainConfig memory expectedDestChainConfig = EVM2EVMMultiOnRamp.DestChainConfig({
dynamicConfig: destChainConfigArg.dynamicConfig,
prevOnRamp: address(0),
sequenceNumber: 0,
metadataHash: keccak256(
abi.encode(
Expand Down Expand Up @@ -197,18 +195,13 @@ contract EVM2EVMMultiOnRamp_applyDestChainConfigUpdates is EVM2EVMMultiOnRampSet
);
destChainConfigArgs.dynamicConfig.chainFamilySelector = Internal.CHAIN_FAMILY_SELECTOR_EVM;

bool isNewChain = true;
bool isNewChain = destChainConfigArgs.destChainSelector != DEST_CHAIN_SELECTOR;

if (destChainConfigArgs.destChainSelector == DEST_CHAIN_SELECTOR) {
destChainConfigArgs.prevOnRamp = address(0);
isNewChain = false;
}
EVM2EVMMultiOnRamp.DestChainConfigArgs[] memory newDestChainConfigArgs =
new EVM2EVMMultiOnRamp.DestChainConfigArgs[](1);
newDestChainConfigArgs[0] = destChainConfigArgs;
EVM2EVMMultiOnRamp.DestChainConfig memory expectedDestChainConfig = EVM2EVMMultiOnRamp.DestChainConfig({
dynamicConfig: destChainConfigArgs.dynamicConfig,
prevOnRamp: destChainConfigArgs.prevOnRamp,
sequenceNumber: 0,
metadataHash: keccak256(
abi.encode(
Expand Down Expand Up @@ -244,7 +237,6 @@ contract EVM2EVMMultiOnRamp_applyDestChainConfigUpdates is EVM2EVMMultiOnRampSet

EVM2EVMMultiOnRamp.DestChainConfig memory expectedDestChainConfig0 = EVM2EVMMultiOnRamp.DestChainConfig({
dynamicConfig: destChainConfigArgs[0].dynamicConfig,
prevOnRamp: address(0),
sequenceNumber: 0,
metadataHash: keccak256(
abi.encode(
Expand All @@ -258,7 +250,6 @@ contract EVM2EVMMultiOnRamp_applyDestChainConfigUpdates is EVM2EVMMultiOnRampSet

EVM2EVMMultiOnRamp.DestChainConfig memory expectedDestChainConfig1 = EVM2EVMMultiOnRamp.DestChainConfig({
dynamicConfig: destChainConfigArgs[1].dynamicConfig,
prevOnRamp: address(0),
sequenceNumber: 0,
metadataHash: keccak256(
abi.encode(
Expand Down Expand Up @@ -320,17 +311,6 @@ contract EVM2EVMMultiOnRamp_applyDestChainConfigUpdates is EVM2EVMMultiOnRampSet
s_onRamp.applyDestChainConfigUpdates(destChainConfigArgs);
}

function test_InvalidDestChainConfigNewPrevOnRampOnExistingChain_Revert() public {
EVM2EVMMultiOnRamp.DestChainConfigArgs[] memory destChainConfigArgs = _generateDestChainConfigArgs();
EVM2EVMMultiOnRamp.DestChainConfigArgs memory destChainConfigArg = destChainConfigArgs[0];

destChainConfigArg.prevOnRamp = address(1);
vm.expectRevert(
abi.encodeWithSelector(EVM2EVMMultiOnRamp.InvalidDestChainConfig.selector, destChainConfigArg.destChainSelector)
);
s_onRamp.applyDestChainConfigUpdates(destChainConfigArgs);
}

function test_InvalidDestBytesOverhead_Revert() public {
EVM2EVMMultiOnRamp.DestChainConfigArgs[] memory destChainConfigArgs = _generateDestChainConfigArgs();
EVM2EVMMultiOnRamp.DestChainConfigArgs memory destChainConfigArg = destChainConfigArgs[0];
Expand Down Expand Up @@ -1100,8 +1080,7 @@ contract EVM2EVMMultiOnRamp_getDataAvailabilityCost is EVM2EVMMultiOnRamp_getFee
EVM2EVMMultiOnRamp.DestChainConfig memory destChainConfig = s_onRamp.getDestChainConfig(destChainSelector);
destChainConfigArgs[0] = EVM2EVMMultiOnRamp.DestChainConfigArgs({
destChainSelector: destChainSelector,
dynamicConfig: destChainConfig.dynamicConfig,
prevOnRamp: destChainConfig.prevOnRamp
dynamicConfig: destChainConfig.dynamicConfig
});
destChainConfigArgs[0].dynamicConfig.destDataAvailabilityOverheadGas = destDataAvailabilityOverheadGas;
destChainConfigArgs[0].dynamicConfig.destGasPerDataAvailabilityByte = destGasPerDataAvailabilityByte;
Expand Down Expand Up @@ -1173,8 +1152,7 @@ contract EVM2EVMMultiOnRamp_getFee is EVM2EVMMultiOnRamp_getFeeSetup {
EVM2EVMMultiOnRamp.DestChainConfig memory destChainConfig = s_onRamp.getDestChainConfig(DEST_CHAIN_SELECTOR);
destChainConfigArgs[0] = EVM2EVMMultiOnRamp.DestChainConfigArgs({
destChainSelector: DEST_CHAIN_SELECTOR,
dynamicConfig: destChainConfig.dynamicConfig,
prevOnRamp: destChainConfig.prevOnRamp
dynamicConfig: destChainConfig.dynamicConfig
});
destChainConfigArgs[0].dynamicConfig.destDataAvailabilityMultiplierBps = 0;
s_onRamp.applyDestChainConfigUpdates(destChainConfigArgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@ contract EVM2EVMMultiOnRampSetup is TokenSetup, PriceRegistrySetup {
networkFeeUSDCents: 1_00,
enforceOutOfOrder: false,
chainFamilySelector: Internal.CHAIN_FAMILY_SELECTOR_EVM
}),
prevOnRamp: address(0)
})
});
return destChainConfigs;
}
Expand Down Expand Up @@ -367,7 +366,6 @@ contract EVM2EVMMultiOnRampSetup is TokenSetup, PriceRegistrySetup {
assertEq(a.dynamicConfig.defaultTokenDestGasOverhead, b.dynamicConfig.defaultTokenDestGasOverhead);
assertEq(a.dynamicConfig.defaultTokenDestBytesOverhead, b.dynamicConfig.defaultTokenDestBytesOverhead);
assertEq(a.dynamicConfig.defaultTxGasLimit, b.dynamicConfig.defaultTxGasLimit);
assertEq(a.prevOnRamp, b.prevOnRamp);
assertEq(a.sequenceNumber, b.sequenceNumber);
assertEq(a.metadataHash, b.metadataHash);
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ commit_store: ../../../contracts/solc/v0.8.24/CommitStore/CommitStore.abi ../../
commit_store_helper: ../../../contracts/solc/v0.8.24/CommitStoreHelper/CommitStoreHelper.abi ../../../contracts/solc/v0.8.24/CommitStoreHelper/CommitStoreHelper.bin ebd8aac686fa28a71d4212bcd25a28f8f640d50dce5e50498b2f6b8534890b69
ether_sender_receiver: ../../../contracts/solc/v0.8.24/EtherSenderReceiver/EtherSenderReceiver.abi ../../../contracts/solc/v0.8.24/EtherSenderReceiver/EtherSenderReceiver.bin 09510a3f773f108a3c231e8d202835c845ded862d071ec54c4f89c12d868b8de
evm_2_evm_multi_offramp: ../../../contracts/solc/v0.8.24/EVM2EVMMultiOffRamp/EVM2EVMMultiOffRamp.abi ../../../contracts/solc/v0.8.24/EVM2EVMMultiOffRamp/EVM2EVMMultiOffRamp.bin 2ab5cd4acb0c0b7087397d0c99e928119ef9e174bfd55628e6b2daf14f2da1fe
evm_2_evm_multi_onramp: ../../../contracts/solc/v0.8.24/EVM2EVMMultiOnRamp/EVM2EVMMultiOnRamp.abi ../../../contracts/solc/v0.8.24/EVM2EVMMultiOnRamp/EVM2EVMMultiOnRamp.bin e304765672aeab78529edc35f6ee44779c098643fe3a7b4f3c0f33a9493016ac
evm_2_evm_multi_onramp: ../../../contracts/solc/v0.8.24/EVM2EVMMultiOnRamp/EVM2EVMMultiOnRamp.abi ../../../contracts/solc/v0.8.24/EVM2EVMMultiOnRamp/EVM2EVMMultiOnRamp.bin 85698e5c4c6cb10f4f969cc1740b9ff094c469530e0a763670cf388311f00619
evm_2_evm_offramp: ../../../contracts/solc/v0.8.24/EVM2EVMOffRamp/EVM2EVMOffRamp.abi ../../../contracts/solc/v0.8.24/EVM2EVMOffRamp/EVM2EVMOffRamp.bin b6132cb22370d62b1b20174bbe832ec87df61f6ab65f7fe2515733bdd10a30f5
evm_2_evm_onramp: ../../../contracts/solc/v0.8.24/EVM2EVMOnRamp/EVM2EVMOnRamp.abi ../../../contracts/solc/v0.8.24/EVM2EVMOnRamp/EVM2EVMOnRamp.bin 383e9930fbc1b7fbb6554cc8857229d207fd6742e87c7fb1a37002347e8de8e2
lock_release_token_pool: ../../../contracts/solc/v0.8.24/LockReleaseTokenPool/LockReleaseTokenPool.abi ../../../contracts/solc/v0.8.24/LockReleaseTokenPool/LockReleaseTokenPool.bin c65c226e1e4d38414bd4a1b76fc8aca3cb3dd98df61268424c44564f455d3752
Expand Down

0 comments on commit 6922b39

Please sign in to comment.