Skip to content

Commit

Permalink
Merge 231e2cf into 2bb582b
Browse files Browse the repository at this point in the history
  • Loading branch information
elatoskinas authored Jul 11, 2024
2 parents 2bb582b + 231e2cf commit 1919dbe
Show file tree
Hide file tree
Showing 15 changed files with 4,894 additions and 3,800 deletions.
570 changes: 272 additions & 298 deletions contracts/gas-snapshots/ccip.gas-snapshot

Large diffs are not rendered by default.

590 changes: 577 additions & 13 deletions contracts/src/v0.8/ccip/PriceRegistry.sol

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions contracts/src/v0.8/ccip/interfaces/IPriceRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Client} from "../libraries/Client.sol";
import {Internal} from "../libraries/Internal.sol";

interface IPriceRegistry {
Expand Down Expand Up @@ -71,4 +72,24 @@ interface IPriceRegistry {
/// @notice Get the list of fee tokens.
/// @return The tokens set as fee tokens.
function getFeeTokens() external view returns (address[] memory);

/// @notice Validates the ccip message & returns the fee
/// @param destChainSelector The destination chain selector.
/// @param message The message to get quote for.
/// @return feeTokenAmount The amount of fee token needed for the fee, in smallest denomination of the fee token.
function getValidatedFee(
uint64 destChainSelector,
Client.EVM2AnyMessage calldata message
) external view returns (uint256 feeTokenAmount);

/// @notice Validates the message that is emitted from an OnRamp, and returns the converted message fee in juels
/// @param message OnRamp message to validate
/// @param sourceTokenAmounts Source token amounts that match the message tokenAmounts
/// @return msgFeeJuels message fee in juels
/// @return isOutOfOrderExecution true if the message should be executed out of order
/// @return convertedExtraArgs extra args converted to the latest family-specific args version
function getValidatedRampMessageParams(
Internal.EVM2AnyRampMessage memory message,
Client.EVMTokenAmount[] memory sourceTokenAmounts
) external view returns (uint256 msgFeeJuels, bool isOutOfOrderExecution, bytes memory convertedExtraArgs);
}
700 changes: 83 additions & 617 deletions contracts/src/v0.8/ccip/onRamp/EVM2EVMMultiOnRamp.sol

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions contracts/src/v0.8/ccip/test/NonceManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,6 @@ contract NonceManager_OnRampUpgrade is EVM2EVMMultiOnRampSetup {
NonceManager.PreviousRampsArgs(DEST_CHAIN_SELECTOR, NonceManager.PreviousRamps(address(s_prevOnRamp), address(0)));
s_outboundNonceManager.applyPreviousRampsUpdates(previousRamps);

EVM2EVMMultiOnRamp.DestChainConfigArgs[] memory destChainConfigArgs = _generateDestChainConfigArgs();

(s_onRamp, s_metadataHash) = _deployOnRamp(
SOURCE_CHAIN_SELECTOR, address(s_sourceRouter), address(s_outboundNonceManager), address(s_tokenAdminRegistry)
);
Expand Down
54 changes: 2 additions & 52 deletions contracts/src/v0.8/ccip/test/helpers/EVM2EVMMultiOnRampHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,6 @@ import {IgnoreContractSize} from "./IgnoreContractSize.sol";
contract EVM2EVMMultiOnRampHelper is EVM2EVMMultiOnRamp, IgnoreContractSize {
constructor(
StaticConfig memory staticConfig,
DynamicConfig memory dynamicConfig,
DestChainConfigArgs[] memory destChainConfigs,
PremiumMultiplierWeiPerEthArgs[] memory premiumMultiplierWeiPerEthArgs,
TokenTransferFeeConfigArgs[] memory tokenTransferFeeConfigArgs
)
EVM2EVMMultiOnRamp(
staticConfig,
dynamicConfig,
destChainConfigs,
premiumMultiplierWeiPerEthArgs,
tokenTransferFeeConfigArgs
)
{}

function getDataAvailabilityCost(
uint64 destChainSelector,
uint112 dataAvailabilityGasPrice,
uint256 messageDataLength,
uint256 numberOfTokens,
uint32 tokenTransferBytesOverhead
) external view returns (uint256) {
return _getDataAvailabilityCost(
destChainSelector, dataAvailabilityGasPrice, messageDataLength, numberOfTokens, tokenTransferBytesOverhead
);
}

function getTokenTransferCost(
uint64 destChainSelector,
address feeToken,
uint224 feeTokenPrice,
Client.EVMTokenAmount[] calldata tokenAmounts
) external view returns (uint256, uint32, uint32) {
return _getTokenTransferCost(destChainSelector, feeToken, feeTokenPrice, tokenAmounts);
}

function parseEVMExtraArgsFromBytes(
bytes calldata extraArgs,
uint64 destChainSelector
) external view returns (Client.EVMExtraArgsV2 memory) {
return _parseEVMExtraArgsFromBytes(extraArgs, s_destChainConfig[destChainSelector].dynamicConfig);
}

function validateDestFamilyAddress(bytes4 chainFamilySelector, bytes memory destAddress) external pure {
_validateDestFamilyAddress(chainFamilySelector, destAddress);
}

function convertParsedExtraArgs(
bytes calldata extraArgs,
DestChainDynamicConfig memory destChainDynamicConfig
) external pure returns (bytes memory encodedExtraArgs) {
return _convertParsedExtraArgs(extraArgs, destChainDynamicConfig);
}
DynamicConfig memory dynamicConfig
) EVM2EVMMultiOnRamp(staticConfig, dynamicConfig) {}
}
72 changes: 72 additions & 0 deletions contracts/src/v0.8/ccip/test/helpers/PriceRegistryHelper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.24;

import {PriceRegistry} from "../../PriceRegistry.sol";
import {Client} from "../../libraries/Client.sol";

contract PriceRegistryHelper is PriceRegistry {
constructor(
StaticConfig memory staticConfig,
address[] memory priceUpdaters,
address[] memory feeTokens,
TokenPriceFeedUpdate[] memory tokenPriceFeeds,
TokenTransferFeeConfigArgs[] memory tokenTransferFeeConfigArgs,
PremiumMultiplierWeiPerEthArgs[] memory premiumMultiplierWeiPerEthArgs,
DestChainDynamicConfigArgs[] memory destChainConfigArgs
)
PriceRegistry(
staticConfig,
priceUpdaters,
feeTokens,
tokenPriceFeeds,
tokenTransferFeeConfigArgs,
premiumMultiplierWeiPerEthArgs,
destChainConfigArgs
)
{}

function getDataAvailabilityCost(
uint64 destChainSelector,
uint112 dataAvailabilityGasPrice,
uint256 messageDataLength,
uint256 numberOfTokens,
uint32 tokenTransferBytesOverhead
) external view returns (uint256) {
return _getDataAvailabilityCost(
s_destChainDynamicConfigs[destChainSelector],
dataAvailabilityGasPrice,
messageDataLength,
numberOfTokens,
tokenTransferBytesOverhead
);
}

function getTokenTransferCost(
uint64 destChainSelector,
address feeToken,
uint224 feeTokenPrice,
Client.EVMTokenAmount[] calldata tokenAmounts
) external view returns (uint256, uint32, uint32) {
return _getTokenTransferCost(
s_destChainDynamicConfigs[destChainSelector], destChainSelector, feeToken, feeTokenPrice, tokenAmounts
);
}

function parseEVMExtraArgsFromBytes(
bytes calldata extraArgs,
uint64 destChainSelector
) external view returns (Client.EVMExtraArgsV2 memory) {
return _parseEVMExtraArgsFromBytes(extraArgs, s_destChainDynamicConfigs[destChainSelector]);
}

function parseEVMExtraArgsFromBytes(
bytes calldata extraArgs,
DestChainDynamicConfig memory destChainDynamicConfig
) external pure returns (Client.EVMExtraArgsV2 memory) {
return _parseEVMExtraArgsFromBytes(extraArgs, destChainDynamicConfig);
}

function validateDestFamilyAddress(bytes4 chainFamilySelector, bytes memory destAddress) external pure {
_validateDestFamilyAddress(chainFamilySelector, destAddress);
}
}
Loading

0 comments on commit 1919dbe

Please sign in to comment.