Skip to content

Commit

Permalink
Merge branch 'ccip-develop' of github.com:smartcontractkit/ccip into …
Browse files Browse the repository at this point in the history
…test-matrix-m
  • Loading branch information
b-gopalswami committed Sep 24, 2024
2 parents 22fee2e + ebc7094 commit 3c59361
Show file tree
Hide file tree
Showing 24 changed files with 822 additions and 219 deletions.
7 changes: 6 additions & 1 deletion .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ packages:
filename: optimism_portal2_interface.go
outpkg: mock_optimism_portal_2
interfaces:
OptimismPortal2Interface:
OptimismPortal2Interface:
github.com/smartcontractkit/chainlink/v2/core/gethwrappers/liquiditymanager/generated/optimism_dispute_game_factory:
config:
dir: core/gethwrappers/liquiditymanager/mocks/mock_optimism_dispute_game_factory/
Expand Down Expand Up @@ -503,6 +503,11 @@ packages:
USDCReader:
config:
filename: usdc_reader_mock.go
github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/estimatorconfig:
interfaces:
GasPriceInterceptor:
config:
filename: gas_price_interceptor_mock.go
github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/batchreader:
config:
filename: token_pool_batched_reader_mock.go
Expand Down
94 changes: 47 additions & 47 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@ MultiOCR3Base_transmit:test_UnAuthorizedTransmitter_Revert() (gas: 24234)
MultiOCR3Base_transmit:test_UnauthorizedSigner_Revert() (gas: 61275)
MultiOCR3Base_transmit:test_UnconfiguredPlugin_Revert() (gas: 39933)
MultiOCR3Base_transmit:test_ZeroSignatures_Revert() (gas: 33049)
MultiOnRampTokenPoolReentrancy:test_OnRampTokenPoolReentrancy_Success() (gas: 233778)
MultiRampsE2E:test_E2E_3MessagesMMultiOffRampSuccess_gas() (gas: 1504663)
MultiOnRampTokenPoolReentrancy:test_OnRampTokenPoolReentrancy_Success() (gas: 233701)
MultiRampsE2E:test_E2E_3MessagesMMultiOffRampSuccess_gas() (gas: 1500580)
NonceManager_NonceIncrementation:test_getIncrementedOutboundNonce_Success() (gas: 37934)
NonceManager_NonceIncrementation:test_incrementInboundNonce_Skip() (gas: 23706)
NonceManager_NonceIncrementation:test_incrementInboundNonce_Success() (gas: 38778)
Expand All @@ -585,15 +585,15 @@ NonceManager_OffRampUpgrade:test_UpgradedOffRampNonceSkipsIfMsgInFlight_Success(
NonceManager_OffRampUpgrade:test_UpgradedSenderNoncesReadsPreviousRampTransitive_Success() (gas: 249120)
NonceManager_OffRampUpgrade:test_UpgradedSenderNoncesReadsPreviousRamp_Success() (gas: 237027)
NonceManager_OffRampUpgrade:test_Upgraded_Success() (gas: 153748)
NonceManager_OnRampUpgrade:test_UpgradeNonceNewSenderStartsAtZero_Success() (gas: 168959)
NonceManager_OnRampUpgrade:test_UpgradeNonceStartsAtV1Nonce_Success() (gas: 221148)
NonceManager_OnRampUpgrade:test_UpgradeSenderNoncesReadsPreviousRamp_Success() (gas: 126861)
NonceManager_OnRampUpgrade:test_Upgrade_Success() (gas: 107723)
NonceManager_applyPreviousRampsUpdates:test_MultipleRampsUpdates() (gas: 123207)
NonceManager_OnRampUpgrade:test_UpgradeNonceNewSenderStartsAtZero_Success() (gas: 168256)
NonceManager_OnRampUpgrade:test_UpgradeNonceStartsAtV1Nonce_Success() (gas: 219631)
NonceManager_OnRampUpgrade:test_UpgradeSenderNoncesReadsPreviousRamp_Success() (gas: 126745)
NonceManager_OnRampUpgrade:test_Upgrade_Success() (gas: 106975)
NonceManager_applyPreviousRampsUpdates:test_MultipleRampsUpdates() (gas: 123102)
NonceManager_applyPreviousRampsUpdates:test_PreviousRampAlreadySetOffRamp_Revert() (gas: 43079)
NonceManager_applyPreviousRampsUpdates:test_PreviousRampAlreadySetOnRampAndOffRamp_Revert() (gas: 64408)
NonceManager_applyPreviousRampsUpdates:test_PreviousRampAlreadySetOnRamp_Revert() (gas: 42943)
NonceManager_applyPreviousRampsUpdates:test_SingleRampUpdate() (gas: 66696)
NonceManager_applyPreviousRampsUpdates:test_SingleRampUpdate() (gas: 66666)
NonceManager_applyPreviousRampsUpdates:test_ZeroInput() (gas: 12070)
NonceManager_typeAndVersion:test_typeAndVersion() (gas: 9705)
OCR2BaseNoChecks_setOCR2Config:test_FMustBePositive_Revert() (gas: 12210)
Expand Down Expand Up @@ -758,51 +758,51 @@ OffRamp_trialExecute:test_trialExecute_Success() (gas: 277894)
OnRampTokenPoolReentrancy:test_OnRampTokenPoolReentrancy_Success() (gas: 390842)
OnRamp_applyAllowListUpdates:test_applyAllowListUpdates_InvalidAllowListRequestDisabledAllowListWithAdds() (gas: 18030)
OnRamp_applyAllowListUpdates:test_applyAllowListUpdates_Revert() (gas: 67426)
OnRamp_applyAllowListUpdates:test_applyAllowListUpdates_Success() (gas: 325124)
OnRamp_applyDestChainConfigUpdates:test_ApplyDestChainConfigUpdates_Success() (gas: 65227)
OnRamp_applyDestChainConfigUpdates:test_ApplyDestChainConfigUpdates_WithInvalidChainSelector_Revert() (gas: 13446)
OnRamp_constructor:test_Constructor_InvalidConfigChainSelectorEqZero_Revert() (gas: 95048)
OnRamp_constructor:test_Constructor_InvalidConfigNonceManagerEqAddressZero_Revert() (gas: 92990)
OnRamp_constructor:test_Constructor_InvalidConfigRMNProxyEqAddressZero_Revert() (gas: 98023)
OnRamp_constructor:test_Constructor_InvalidConfigTokenAdminRegistryEqAddressZero_Revert() (gas: 93046)
OnRamp_constructor:test_Constructor_Success() (gas: 2750875)
OnRamp_forwardFromRouter:test_ForwardFromRouterExtraArgsV2AllowOutOfOrderTrue_Success() (gas: 115146)
OnRamp_forwardFromRouter:test_ForwardFromRouterExtraArgsV2_Success() (gas: 145969)
OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessCustomExtraArgs() (gas: 145545)
OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessEmptyExtraArgs() (gas: 143772)
OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessLegacyExtraArgs() (gas: 145763)
OnRamp_forwardFromRouter:test_ForwardFromRouter_Success() (gas: 145139)
OnRamp_forwardFromRouter:test_ForwardFromRouter_Success_ConfigurableSourceRouter() (gas: 145974)
OnRamp_forwardFromRouter:test_InvalidExtraArgsTag_Revert() (gas: 38593)
OnRamp_forwardFromRouter:test_MessageInterceptionError_Revert() (gas: 143056)
OnRamp_forwardFromRouter:test_MesssageFeeTooHigh_Revert() (gas: 36706)
OnRamp_forwardFromRouter:test_MultiCannotSendZeroTokens_Revert() (gas: 36509)
OnRamp_applyAllowListUpdates:test_applyAllowListUpdates_Success() (gas: 325083)
OnRamp_applyDestChainConfigUpdates:test_ApplyDestChainConfigUpdates_Success() (gas: 65095)
OnRamp_applyDestChainConfigUpdates:test_ApplyDestChainConfigUpdates_WithInvalidChainSelector_Revert() (gas: 13422)
OnRamp_constructor:test_Constructor_InvalidConfigChainSelectorEqZero_Revert() (gas: 94996)
OnRamp_constructor:test_Constructor_InvalidConfigNonceManagerEqAddressZero_Revert() (gas: 92938)
OnRamp_constructor:test_Constructor_InvalidConfigRMNProxyEqAddressZero_Revert() (gas: 97971)
OnRamp_constructor:test_Constructor_InvalidConfigTokenAdminRegistryEqAddressZero_Revert() (gas: 92972)
OnRamp_constructor:test_Constructor_Success() (gas: 2734391)
OnRamp_forwardFromRouter:test_ForwardFromRouterExtraArgsV2AllowOutOfOrderTrue_Success() (gas: 114527)
OnRamp_forwardFromRouter:test_ForwardFromRouterExtraArgsV2_Success() (gas: 145328)
OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessCustomExtraArgs() (gas: 144925)
OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessEmptyExtraArgs() (gas: 143086)
OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessLegacyExtraArgs() (gas: 145122)
OnRamp_forwardFromRouter:test_ForwardFromRouter_Success() (gas: 144520)
OnRamp_forwardFromRouter:test_ForwardFromRouter_Success_ConfigurableSourceRouter() (gas: 144604)
OnRamp_forwardFromRouter:test_InvalidExtraArgsTag_Revert() (gas: 38554)
OnRamp_forwardFromRouter:test_MessageInterceptionError_Revert() (gas: 143051)
OnRamp_forwardFromRouter:test_MesssageFeeTooHigh_Revert() (gas: 36596)
OnRamp_forwardFromRouter:test_MultiCannotSendZeroTokens_Revert() (gas: 36527)
OnRamp_forwardFromRouter:test_OriginalSender_Revert() (gas: 18291)
OnRamp_forwardFromRouter:test_Paused_Revert() (gas: 38454)
OnRamp_forwardFromRouter:test_Permissions_Revert() (gas: 23663)
OnRamp_forwardFromRouter:test_ShouldIncrementNonceOnlyOnOrdered_Success() (gas: 186202)
OnRamp_forwardFromRouter:test_ShouldIncrementSeqNumAndNonce_Success() (gas: 212587)
OnRamp_forwardFromRouter:test_ShouldStoreLinkFees() (gas: 125127)
OnRamp_forwardFromRouter:test_ShouldStoreNonLinkFees() (gas: 141767)
OnRamp_forwardFromRouter:test_SourceTokenDataTooLarge_Revert() (gas: 3618195)
OnRamp_forwardFromRouter:test_Paused_Revert() (gas: 38431)
OnRamp_forwardFromRouter:test_Permissions_Revert() (gas: 23640)
OnRamp_forwardFromRouter:test_ShouldIncrementNonceOnlyOnOrdered_Success() (gas: 183954)
OnRamp_forwardFromRouter:test_ShouldIncrementSeqNumAndNonce_Success() (gas: 210338)
OnRamp_forwardFromRouter:test_ShouldStoreLinkFees() (gas: 146154)
OnRamp_forwardFromRouter:test_ShouldStoreNonLinkFees() (gas: 160259)
OnRamp_forwardFromRouter:test_SourceTokenDataTooLarge_Revert() (gas: 3613942)
OnRamp_forwardFromRouter:test_UnAllowedOriginalSender_Revert() (gas: 24010)
OnRamp_forwardFromRouter:test_UnsupportedToken_Revert() (gas: 75826)
OnRamp_forwardFromRouter:test_forwardFromRouter_UnsupportedToken_Revert() (gas: 38559)
OnRamp_forwardFromRouter:test_forwardFromRouter_WithInterception_Success() (gas: 280050)
OnRamp_getFee:test_EmptyMessage_Success() (gas: 98757)
OnRamp_getFee:test_EnforceOutOfOrder_Revert() (gas: 64779)
OnRamp_getFee:test_GetFeeOfZeroForTokenMessage_Success() (gas: 86359)
OnRamp_getFee:test_NotAFeeTokenButPricedToken_Revert() (gas: 35185)
OnRamp_getFee:test_SingleTokenMessage_Success() (gas: 113916)
OnRamp_getFee:test_Unhealthy_Revert() (gas: 17171)
OnRamp_getSupportedTokens:test_GetSupportedTokens_Revert() (gas: 10510)
OnRamp_getTokenPool:test_GetTokenPool_Success() (gas: 35372)
OnRamp_setDynamicConfig:test_setDynamicConfig_InvalidConfigFeeAggregatorEqAddressZero_Revert() (gas: 11581)
OnRamp_forwardFromRouter:test_UnsupportedToken_Revert() (gas: 75866)
OnRamp_forwardFromRouter:test_forwardFromRouter_UnsupportedToken_Revert() (gas: 38599)
OnRamp_forwardFromRouter:test_forwardFromRouter_WithInterception_Success() (gas: 279390)
OnRamp_getFee:test_EmptyMessage_Success() (gas: 98513)
OnRamp_getFee:test_EnforceOutOfOrder_Revert() (gas: 64645)
OnRamp_getFee:test_GetFeeOfZeroForTokenMessage_Success() (gas: 86177)
OnRamp_getFee:test_NotAFeeTokenButPricedToken_Revert() (gas: 35097)
OnRamp_getFee:test_SingleTokenMessage_Success() (gas: 113639)
OnRamp_getFee:test_Unhealthy_Revert() (gas: 17061)
OnRamp_getSupportedTokens:test_GetSupportedTokens_Revert() (gas: 10474)
OnRamp_getTokenPool:test_GetTokenPool_Success() (gas: 35348)
OnRamp_setDynamicConfig:test_setDynamicConfig_InvalidConfigFeeAggregatorEqAddressZero_Revert() (gas: 11536)
OnRamp_setDynamicConfig:test_setDynamicConfig_InvalidConfigFeeQuoterEqAddressZero_Revert() (gas: 13195)
OnRamp_setDynamicConfig:test_setDynamicConfig_InvalidConfigInvalidConfig_Revert() (gas: 11522)
OnRamp_setDynamicConfig:test_setDynamicConfig_InvalidConfigOnlyOwner_Revert() (gas: 16850)
OnRamp_setDynamicConfig:test_setDynamicConfig_InvalidConfigReentrancyGuardEnteredEqTrue_Revert() (gas: 13265)
OnRamp_setDynamicConfig:test_setDynamicConfig_Success() (gas: 56460)
OnRamp_setDynamicConfig:test_setDynamicConfig_Success() (gas: 56369)
OnRamp_withdrawFeeTokens:test_WithdrawFeeTokens_Success() (gas: 97302)
PingPong_ccipReceive:test_CcipReceive_Success() (gas: 151349)
PingPong_plumbing:test_OutOfOrderExecution_Success() (gas: 20310)
Expand Down
1 change: 1 addition & 0 deletions contracts/src/v0.8/ccip/libraries/Internal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ library Internal {
bytes extraArgs; // destination-chain specific extra args, such as the gasLimit for EVM chains
address feeToken; // fee token
uint256 feeTokenAmount; // fee token amount
uint256 feeValueJuels; // fee amount in Juels
EVM2AnyTokenTransfer[] tokenAmounts; // array of tokens and amounts to transfer
}

Expand Down
16 changes: 7 additions & 9 deletions contracts/src/v0.8/ccip/onRamp/OnRamp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ contract OnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCreator {
event DestChainConfigSet(
uint64 indexed destChainSelector, uint64 sequenceNumber, IRouter router, bool allowListEnabled
);
event FeePaid(address indexed feeToken, uint256 feeValueJuels);
event FeeTokenWithdrawn(address indexed feeAggregator, address indexed feeToken, uint256 amount);
/// RMN depends on this event, if changing, please notify the RMN maintainers.
event CCIPMessageSent(uint64 indexed destChainSelector, Internal.EVM2AnyRampMessage message);
Expand Down Expand Up @@ -211,6 +210,7 @@ contract OnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCreator {
receiver: message.receiver,
feeToken: message.feeToken,
feeTokenAmount: feeTokenAmount,
feeValueJuels: 0, // calculated later
// Should be populated via lock / burn pool calls
tokenAmounts: new Internal.EVM2AnyTokenTransfer[](message.tokenAmounts.length)
});
Expand All @@ -224,17 +224,15 @@ contract OnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCreator {

// Convert message fee to juels and retrieve converted args
// Validate pool return data after it is populated (view function - no state changes)
(
uint256 msgFeeJuels,
bool isOutOfOrderExecution,
bytes memory convertedExtraArgs,
bytes[] memory destExecDataPerToken
) = IFeeQuoter(s_dynamicConfig.feeQuoter).processMessageArgs(
bool isOutOfOrderExecution;
bytes memory convertedExtraArgs;
bytes[] memory destExecDataPerToken;
(newMessage.feeValueJuels, isOutOfOrderExecution, convertedExtraArgs, destExecDataPerToken) = IFeeQuoter(
s_dynamicConfig.feeQuoter
).processMessageArgs(
destChainSelector, message.feeToken, feeTokenAmount, message.extraArgs, newMessage.tokenAmounts, tokenAmounts
);

emit FeePaid(message.feeToken, msgFeeJuels);

newMessage.header.nonce = isOutOfOrderExecution
? 0
: INonceManager(i_nonceManager).getIncrementedOutboundNonce(destChainSelector, originalSender);
Expand Down
5 changes: 4 additions & 1 deletion contracts/src/v0.8/ccip/test/e2e/MultiRampsEnd2End.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,17 @@ contract MultiRampsE2E is OnRampSetup, OffRampSetup {
IERC20(s_sourceTokens[0]).approve(address(router), i_tokenAmount0 + router.getFee(DEST_CHAIN_SELECTOR, message));
IERC20(s_sourceTokens[1]).approve(address(router), i_tokenAmount1);

uint256 feeAmount = router.getFee(DEST_CHAIN_SELECTOR, message);

message.receiver = abi.encode(address(s_receiver));
Internal.EVM2AnyRampMessage memory msgEvent = _messageToEvent(
message,
sourceChainSelector,
DEST_CHAIN_SELECTOR,
expectedSeqNum,
nonce,
router.getFee(DEST_CHAIN_SELECTOR, message),
feeAmount,
feeAmount,
OWNER,
metadataHash,
tokenAdminRegistry
Expand Down
2 changes: 2 additions & 0 deletions contracts/src/v0.8/ccip/test/feeQuoter/FeeQuoterSetup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ contract FeeQuoterFeeSetup is FeeQuoterSetup {
uint64 seqNum,
uint64 nonce,
uint256 feeTokenAmount,
uint256 feeValueJuels,
address originalSender,
bytes32 metadataHash,
TokenAdminRegistry tokenAdminRegistry
Expand All @@ -388,6 +389,7 @@ contract FeeQuoterFeeSetup is FeeQuoterSetup {
extraArgs: Client._argsToBytes(extraArgs),
feeToken: message.feeToken,
feeTokenAmount: feeTokenAmount,
feeValueJuels: feeValueJuels,
tokenAmounts: new Internal.EVM2AnyTokenTransfer[](message.tokenAmounts.length)
});

Expand Down
8 changes: 4 additions & 4 deletions contracts/src/v0.8/ccip/test/onRamp/OnRamp.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ contract OnRamp_forwardFromRouter is OnRampSetup {
IERC20(s_sourceFeeToken).transferFrom(OWNER, address(s_onRamp), feeAmount);

vm.expectEmit();
emit OnRamp.FeePaid(s_sourceFeeToken, feeAmount);
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, 1, 1, feeAmount, OWNER));

s_onRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, feeAmount, OWNER);

assertEq(IERC20(s_sourceFeeToken).balanceOf(address(s_onRamp)), feeAmount);
Expand All @@ -307,7 +308,8 @@ contract OnRamp_forwardFromRouter is OnRampSetup {
uint256 expectedJuels = (feeAmount * conversionRate) / 1e18;

vm.expectEmit();
emit OnRamp.FeePaid(s_sourceTokens[1], expectedJuels);
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, 1, 1, feeAmount, expectedJuels, OWNER));

s_onRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, feeAmount, OWNER);

assertEq(IERC20(s_sourceTokens[1]).balanceOf(address(s_onRamp)), feeAmount);
Expand Down Expand Up @@ -352,8 +354,6 @@ contract OnRamp_forwardFromRouter is OnRampSetup {
Internal.EVM2AnyRampMessage memory expectedEvent = _messageToEvent(message, 1, 1, feeTokenAmount, originalSender);

vm.expectEmit();
emit OnRamp.FeePaid(s_sourceFeeToken, feeTokenAmount);
vm.expectEmit(false, false, false, true);
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, expectedEvent);

// Assert the message Id is correct
Expand Down
23 changes: 22 additions & 1 deletion contracts/src/v0.8/ccip/test/onRamp/OnRampSetup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,41 @@ contract OnRampSetup is FeeQuoterFeeSetup {
});
}

/// @dev a helper function to compose EVM2AnyRampMessage messages
/// @dev it is assummed that LINK is the payment token because feeTokenAmount == feeValueJuels
function _messageToEvent(
Client.EVM2AnyMessage memory message,
uint64 seqNum,
uint64 nonce,
uint256 feeTokenAmount,
address originalSender
) public view returns (Internal.EVM2AnyRampMessage memory) {
) internal view returns (Internal.EVM2AnyRampMessage memory) {
return _messageToEvent(
message,
seqNum,
nonce,
feeTokenAmount, // fee paid
feeTokenAmount, // converstion to jules is the same
originalSender
);
}

function _messageToEvent(
Client.EVM2AnyMessage memory message,
uint64 seqNum,
uint64 nonce,
uint256 feeTokenAmount,
uint256 feeValueJuels,
address originalSender
) internal view returns (Internal.EVM2AnyRampMessage memory) {
return _messageToEvent(
message,
SOURCE_CHAIN_SELECTOR,
DEST_CHAIN_SELECTOR,
seqNum,
nonce,
feeTokenAmount,
feeValueJuels,
originalSender,
s_metadataHash,
s_tokenAdminRegistry
Expand Down
Loading

0 comments on commit 3c59361

Please sign in to comment.