Skip to content

Commit

Permalink
Merge branch 'ccip-develop' into feature/ccip-2493
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkouv authored Jun 20, 2024
2 parents 8847297 + 62b7b60 commit a5c8720
Show file tree
Hide file tree
Showing 149 changed files with 4,740 additions and 3,233 deletions.
5 changes: 5 additions & 0 deletions .changeset/afraid-cups-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#added zkSync L1 GasPrice calculation
5 changes: 5 additions & 0 deletions .changeset/chilled-papayas-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ccip": patch
---

#updated Add TokenPricesReader implementation
5 changes: 5 additions & 0 deletions .changeset/quick-kangaroos-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ccip": minor
---

#removed nops and weights logic from multi onramp
5 changes: 5 additions & 0 deletions .changeset/smooth-starfishes-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ccip": minor
---

Move price observations from Commit plugin into a standalone job
2 changes: 1 addition & 1 deletion .github/workflows/solidity-wrappers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
uses: smartcontractkit/.github/actions/setup-github-token@ef78fa97bf3c77de6563db1175422703e9e6674f # [email protected]
id: get-gh-token
with:
aws-role-arn: ${{ secrets.AWS_OIDC_CHAINLINK_CI_AUTO_PR_TOKEN_ISSUER_ROLE_ARN }}
aws-role-arn: ${{ secrets.AWS_OIDC_CCIP_CI_AUTO_PR_TOKEN_ISSUER_ROLE_ARN }}
aws-lambda-url: ${{ secrets.AWS_INFRA_RELENG_TOKEN_ISSUER_LAMBDA_URL }}
aws-region: ${{ secrets.AWS_REGION }}

Expand Down
5 changes: 5 additions & 0 deletions contracts/.changeset/flat-bikes-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/contracts-ccip': patch
---

add LM event to receive() function
5 changes: 5 additions & 0 deletions contracts/.changeset/tall-toys-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@chainlink/contracts-ccip": minor
---

remove nops and weights logic from multi onramp
490 changes: 246 additions & 244 deletions contracts/gas-snapshots/ccip.gas-snapshot

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions contracts/gas-snapshots/liquiditymanager.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ LiquidityManager__report:test_EmptyReportReverts() (gas: 11159)
LiquidityManager_addLiquidity:test_addLiquiditySuccess() (gas: 279154)
LiquidityManager_rebalanceLiquidity:test_InsufficientLiquidityReverts() (gas: 19585)
LiquidityManager_rebalanceLiquidity:test_InvalidRemoteChainReverts() (gas: 190304)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPoolsSuccess() (gas: 8809026)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPoolsSuccess_AlreadyFinalized() (gas: 8731220)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPools_MultiStageFinalization() (gas: 8726428)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPools_NativeRewrap() (gas: 8653242)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPoolsSuccess() (gas: 8831482)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPoolsSuccess_AlreadyFinalized() (gas: 8742448)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPools_MultiStageFinalization() (gas: 8737656)
LiquidityManager_rebalanceLiquidity:test_rebalanceBetweenPools_NativeRewrap() (gas: 8665799)
LiquidityManager_rebalanceLiquidity:test_rebalanceLiquiditySuccess() (gas: 379308)
LiquidityManager_receive:test_receive_success() (gas: 21182)
LiquidityManager_removeLiquidity:test_InsufficientLiquidityReverts() (gas: 184481)
LiquidityManager_removeLiquidity:test_OnlyOwnerReverts() (gas: 10967)
LiquidityManager_removeLiquidity:test_removeLiquiditySuccess() (gas: 236047)
Expand Down
2 changes: 1 addition & 1 deletion contracts/scripts/native_solc_compile_all_ccip
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ echo " └───────────────────────

SOLC_VERSION="0.8.24"
OPTIMIZE_RUNS=26000
OPTIMIZE_RUNS_OFFRAMP=19500
OPTIMIZE_RUNS_OFFRAMP=18000
OPTIMIZE_RUNS_ONRAMP=3600


Expand Down
12 changes: 11 additions & 1 deletion contracts/src/v0.8/ccip/CommitStore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ contract CommitStore is ICommitStore, ITypeAndVersion, OCR2Base {
event ReportAccepted(CommitReport report);
event ConfigSet(StaticConfig staticConfig, DynamicConfig dynamicConfig);
event RootRemoved(bytes32 root);
event SequenceNumberSet(uint64 oldSeqNum, uint64 newSeqNum);
event LatestPriceEpochAndRoundSet(uint40 oldEpochAndRound, uint40 newEpochAndRound);

/// @notice Static commit store config
/// @dev RMN depends on this struct, if changing, please notify the RMN maintainers.
Expand Down Expand Up @@ -112,19 +114,27 @@ contract CommitStore is ICommitStore, ITypeAndVersion, OCR2Base {
/// @notice Sets the minimum sequence number.
/// @param minSeqNr The new minimum sequence number.
function setMinSeqNr(uint64 minSeqNr) external onlyOwner {
uint64 oldSeqNum = s_minSeqNr;

s_minSeqNr = minSeqNr;

emit SequenceNumberSet(oldSeqNum, minSeqNr);
}

/// @notice Returns the epoch and round of the last price update.
/// @return the latest price epoch and round.
function getLatestPriceEpochAndRound() public view returns (uint64) {
function getLatestPriceEpochAndRound() external view returns (uint64) {
return s_latestPriceEpochAndRound;
}

/// @notice Sets the latest epoch and round for price update.
/// @param latestPriceEpochAndRound The new epoch and round for prices.
function setLatestPriceEpochAndRound(uint40 latestPriceEpochAndRound) external onlyOwner {
uint40 oldEpochAndRound = s_latestPriceEpochAndRound;

s_latestPriceEpochAndRound = latestPriceEpochAndRound;

emit LatestPriceEpochAndRoundSet(oldEpochAndRound, latestPriceEpochAndRound);
}

/// @notice Returns the timestamp of a potentially previously committed merkle root.
Expand Down
1 change: 0 additions & 1 deletion contracts/src/v0.8/ccip/MultiAggregateRateLimiter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ contract MultiAggregateRateLimiter is IMessageInterceptor, OwnerIsCreator {

error UnauthorizedCaller(address caller);
error PriceNotFoundForToken(address token);
error UpdateLengthMismatch();
error ZeroAddressNotAllowed();
error ZeroChainSelectorNotAllowed();

Expand Down
3 changes: 1 addition & 2 deletions contracts/src/v0.8/ccip/PriceRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ contract PriceRegistry is IPriceRegistry, OwnerIsCreator, ITypeAndVersion {
// │ Fee tokens │
// ================================================================

/// @notice Get the list of fee tokens.
/// @return The tokens set as fee tokens.
/// @inheritdoc IPriceRegistry
function getFeeTokens() external view returns (address[] memory) {
return s_feeTokens.values();
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/ccip/Router.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ contract Router is IRouter, IRouterClient, ITypeAndVersion, OwnerIsCreator {
return IEVM2AnyOnRamp(onRamp).getFee(destinationChainSelector, message);
}

/// @inheritdoc IRouterClient
/// @notice This functionality has been removed and will revert when called.
function getSupportedTokens(uint64 chainSelector) external view returns (address[] memory) {
if (!isChainSupported(chainSelector)) {
return new address[](0);
Expand Down
3 changes: 1 addition & 2 deletions contracts/src/v0.8/ccip/applications/CCIPClientExample.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import {IERC20} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/
// change if you introduce upgradeability. An immutable dapp building on top of CCIP
// like the example below will inherit the trust properties of CCIP (i.e. the oracle network).
// @dev The receiver's are encoded offchain and passed as direct arguments to permit supporting
// new chain family receivers (e.g. a solana encoded receiver address) without upgrading.
// new chain family receivers (e.g. a Solana encoded receiver address) without upgrading.
contract CCIPClientExample is CCIPReceiver, OwnerIsCreator {
error InvalidConfig();
error InvalidChain(uint64 chainSelector);

event MessageSent(bytes32 messageId);
Expand Down
3 changes: 0 additions & 3 deletions contracts/src/v0.8/ccip/applications/EtherSenderReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ contract EtherSenderReceiver is CCIPReceiver, ITypeAndVersion {
error InvalidTokenAmounts(uint256 gotAmounts);
error InvalidToken(address gotToken, address expectedToken);
error TokenAmountNotEqualToMsgValue(uint256 gotAmount, uint256 msgValue);
error InsufficientMsgValue(uint256 gotAmount, uint256 msgValue);
error InsufficientFee(uint256 gotFee, uint256 fee);
error GasLimitTooLow(uint256 minLimit, uint256 gotLimit);

string public constant override typeAndVersion = "EtherSenderReceiver 1.5.0";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ contract SelfFundedPingPong is PingPongDemo {
return s_countIncrBeforeFunding;
}

function setCountIncrBeforeFunding(uint8 countIncrBeforeFunding) public onlyOwner {
function setCountIncrBeforeFunding(uint8 countIncrBeforeFunding) external onlyOwner {
s_countIncrBeforeFunding = countIncrBeforeFunding;
emit CountIncrBeforeFundingSet(countIncrBeforeFunding);
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/v0.8/ccip/interfaces/IEVM2AnyOnRampClient.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IPool} from "./IPool.sol";
import {IPoolV1} from "./IPool.sol";

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

Expand All @@ -18,7 +18,7 @@ interface IEVM2AnyOnRampClient {
/// @param destChainSelector The destination chain selector
/// @param sourceToken The source chain token to get the pool for
/// @return pool Token pool
function getPoolBySourceToken(uint64 destChainSelector, IERC20 sourceToken) external view returns (IPool);
function getPoolBySourceToken(uint64 destChainSelector, IERC20 sourceToken) external view returns (IPoolV1);

/// @notice Gets a list of all supported source chain tokens.
/// @param destChainSelector The destination chain selector
Expand Down
12 changes: 6 additions & 6 deletions contracts/src/v0.8/ccip/interfaces/IPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {Pool} from "../libraries/Pool.sol";

import {IERC165} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/utils/introspection/IERC165.sol";

// Shared public interface for multiple pool types.
// Each pool type handles a different child token model (lock/unlock, mint/burn.)
interface IPool is IERC165 {
/// @notice Shared public interface for multiple V1 pool types.
/// Each pool type handles a different child token model (lock/unlock, mint/burn.)
interface IPoolV1 is IERC165 {
/// @notice Lock tokens into the pool or burn the tokens.
/// @param lockOrBurnIn Encoded data fields for the processing of tokens on the source chain.
/// @return lockOrBurnOut Encoded data fields for the processing of tokens on the destination chain.
Expand All @@ -16,9 +16,9 @@ interface IPool is IERC165 {
returns (Pool.LockOrBurnOutV1 memory lockOrBurnOut);

/// @notice Releases or mints tokens to the receiver address.
/// * localToken The address of the local token.
/// * destinationAmount The amount of tokens released or minted on the destination chain,
/// denominated in the local token's decimals.
/// @param releaseOrMintIn All data required to release or mint tokens.
/// @return releaseOrMintOut The amount of tokens released or minted on the local chain, denominated
/// in the local token's decimals.
function releaseOrMint(Pool.ReleaseOrMintInV1 calldata releaseOrMintIn)
external
returns (Pool.ReleaseOrMintOutV1 memory);
Expand Down
4 changes: 4 additions & 0 deletions contracts/src/v0.8/ccip/interfaces/IPriceRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,8 @@ interface IPriceRegistry {
uint256 fromTokenAmount,
address toToken
) external view returns (uint256 toTokenAmount);

/// @notice Get the list of fee tokens.
/// @return The tokens set as fee tokens.
function getFeeTokens() external view returns (address[] memory);
}
7 changes: 0 additions & 7 deletions contracts/src/v0.8/ccip/interfaces/IRouterClient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ interface IRouterClient {
/// @return supported is true if it is supported, false if not.
function isChainSupported(uint64 destChainSelector) external view returns (bool supported);

/// @notice Gets a list of all tokens that have been configured through permissioned methods
/// for the local chain. Do note that this list may not be exhaustive as some tokens may be
/// supported permissionlessly. The list does not take the destChainSelector into account.
/// @param destChainSelector No longer used.
/// @return tokens The addresses of the tokens that are supported.
function getSupportedTokens(uint64 destChainSelector) external view returns (address[] memory tokens);

/// @param destinationChainSelector The destination chainSelector
/// @param message The cross-chain CCIP message including data and/or tokens
/// @return fee returns execution fee for the message
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/v0.8/ccip/interfaces/ITokenAdminRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ interface ITokenAdminRegistry {
/// @notice Returns the pool for the given token.
function getPool(address token) external view returns (address);

/// @notice Registers an administrator for the given token.
/// @notice Proposes an administrator for the given token as pending administrator.
/// @param localToken The token to register the administrator for.
/// @param administrator The administrator to register.
function registerAdministrator(address localToken, address administrator) external;
function proposeAdministrator(address localToken, address administrator) external;
}
4 changes: 2 additions & 2 deletions contracts/src/v0.8/ccip/libraries/Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ library Pool {
}

struct ReleaseOrMintOutV1 {
// The number of tokens released or minted on the destination chain, denominated in the local token's decimals.
// The number of tokens released or minted on the destination chain, denominated in the local token's decimals.
// This value is expected to be equal to the ReleaseOrMintInV1.amount in the case where the source and destination
// chain have the same number of decimals
// chain have the same number of decimals.
uint256 destinationAmount;
}
}
2 changes: 1 addition & 1 deletion contracts/src/v0.8/ccip/ocr/MultiOCR3Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ abstract contract MultiOCR3Base is ITypeAndVersion, OwnerIsCreator {

/// @notice Hook that is called after a plugin's OCR3 config changes
/// @param ocrPluginType Plugin type for which the config changed
function _afterOCR3ConfigSet(uint8 ocrPluginType) internal virtual {}
function _afterOCR3ConfigSet(uint8 ocrPluginType) internal virtual;

/// @notice Clears oracle roles for the provided oracle addresses
/// @param ocrPluginType OCR plugin type to clear roles for
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/ccip/ocr/OCR2Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ abstract contract OCR2Base is OwnerIsCreator, OCR2Abstract {

/// @dev Hook that is run from setOCR2Config() right after validating configuration.
/// Empty by default, please provide an implementation in a child contract if you need additional configuration processing
function _beforeSetConfig(bytes memory _onchainConfig) internal virtual {}
function _beforeSetConfig(bytes memory _onchainConfig) internal virtual;

/// @return list of addresses permitted to transmit reports to this contract
/// @dev The list will match the order used to specify the transmitter during setConfig
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/ccip/ocr/OCR2BaseNoChecks.sol
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ abstract contract OCR2BaseNoChecks is OwnerIsCreator, OCR2Abstract {

/// @dev Hook that is run from setOCR2Config() right after validating configuration.
/// Empty by default, please provide an implementation in a child contract if you need additional configuration processing
function _beforeSetConfig(bytes memory _onchainConfig) internal virtual {}
function _beforeSetConfig(bytes memory _onchainConfig) internal virtual;

/// @return list of addresses permitted to transmit reports to this contract
/// @dev The list will match the order used to specify the transmitter during setConfig
Expand Down
21 changes: 15 additions & 6 deletions contracts/src/v0.8/ccip/offRamp/EVM2EVMMultiOffRamp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {IAny2EVMMessageReceiver} from "../interfaces/IAny2EVMMessageReceiver.sol
import {IAny2EVMMultiOffRamp} from "../interfaces/IAny2EVMMultiOffRamp.sol";
import {IAny2EVMOffRamp} from "../interfaces/IAny2EVMOffRamp.sol";
import {IMessageInterceptor} from "../interfaces/IMessageInterceptor.sol";
import {IPool} from "../interfaces/IPool.sol";
import {IPoolV1} from "../interfaces/IPool.sol";
import {IPriceRegistry} from "../interfaces/IPriceRegistry.sol";
import {IRMN} from "../interfaces/IRMN.sol";
import {IRouter} from "../interfaces/IRouter.sol";
Expand Down Expand Up @@ -84,6 +84,7 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3
/// @dev RMN depends on this event, if changing, please notify the RMN maintainers.
event CommitReportAccepted(CommitReport report);
event RootRemoved(bytes32 root);
event LatestPriceEpochAndRoundSet(uint40 oldEpochAndRound, uint40 newEpochAndRound);

/// @notice Static offRamp config
/// @dev RMN depends on this struct, if changing, please notify the RMN maintainers.
Expand All @@ -97,7 +98,7 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3
struct SourceChainConfig {
bool isEnabled; // ─────────╮ Flag whether the source chain is enabled or not
uint64 minSeqNr; // | The min sequence number expected for future messages
address prevOffRamp; // ────╯ Address of previous-version per-lane OffRamp. Used to be able to provide seequencing continuity during a zero downtime upgrade.
address prevOffRamp; // ────╯ Address of previous-version per-lane OffRamp. Used to be able to provide sequencing continuity during a zero downtime upgrade.
address onRamp; // OnRamp address on the source chain
/// @dev Ensures that 2 identical messages sent to 2 different lanes will have a distinct hash.
/// Must match the metadataHash used in computing leaf hashes offchain for the root committed in
Expand Down Expand Up @@ -500,8 +501,12 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3
// Since it's hard to estimate whether manual execution will succeed, we
// revert the entire transaction if it fails. This will show the user if
// their manual exec will fail before they submit it.
if (manualExecution && newState == Internal.MessageExecutionState.FAILURE) {
// If manual execution fails, we revert the entire transaction.
if (
manualExecution && newState == Internal.MessageExecutionState.FAILURE
&& originalState != Internal.MessageExecutionState.UNTOUCHED
) {
// If manual execution fails, we revert the entire transaction, unless the originalState is UNTOUCHED as we
// would still be making progress by changing the state from UNTOUCHED to FAILURE.
revert ExecutionError(message.messageId, returnData);
}

Expand Down Expand Up @@ -723,14 +728,18 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3

/// @notice Returns the epoch and round of the last price update.
/// @return the latest price epoch and round.
function getLatestPriceEpochAndRound() public view returns (uint64) {
function getLatestPriceEpochAndRound() external view returns (uint64) {
return s_latestPriceEpochAndRound;
}

/// @notice Sets the latest epoch and round for price update.
/// @param latestPriceEpochAndRound The new epoch and round for prices.
function setLatestPriceEpochAndRound(uint40 latestPriceEpochAndRound) external onlyOwner {
uint40 oldEpochAndRound = s_latestPriceEpochAndRound;

s_latestPriceEpochAndRound = latestPriceEpochAndRound;

emit LatestPriceEpochAndRoundSet(oldEpochAndRound, latestPriceEpochAndRound);
}

/// @notice Returns the timestamp of a potentially previously committed merkle root.
Expand Down Expand Up @@ -922,7 +931,7 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3
// We protects against return data bombs by capping the return data size at MAX_RET_BYTES.
(bool success, bytes memory returnData,) = CallWithExactGas._callWithExactGasSafeReturnData(
abi.encodeWithSelector(
IPool.releaseOrMint.selector,
IPoolV1.releaseOrMint.selector,
Pool.ReleaseOrMintInV1({
originalSender: messageRoute.sender,
receiver: messageRoute.receiver,
Expand Down
Loading

0 comments on commit a5c8720

Please sign in to comment.