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

Merge FeePaid event into CCIPMessageSent #1452

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ 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)
MultiRampsE2E:test_E2E_3MessagesMMultiOffRampSuccess_gas() (gas: 1500631)
NonceManager_NonceIncrementation:test_getIncrementedOutboundNonce_Success() (gas: 37934)
NonceManager_NonceIncrementation:test_incrementInboundNonce_Skip() (gas: 23706)
NonceManager_NonceIncrementation:test_incrementInboundNonce_Success() (gas: 38778)
Expand All @@ -585,10 +585,10 @@ 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_UpgradeNonceNewSenderStartsAtZero_Success() (gas: 167894)
NonceManager_OnRampUpgrade:test_UpgradeNonceStartsAtV1Nonce_Success() (gas: 219014)
NonceManager_OnRampUpgrade:test_UpgradeSenderNoncesReadsPreviousRamp_Success() (gas: 126861)
NonceManager_OnRampUpgrade:test_Upgrade_Success() (gas: 107723)
NonceManager_OnRampUpgrade:test_Upgrade_Success() (gas: 106657)
NonceManager_applyPreviousRampsUpdates:test_MultipleRampsUpdates() (gas: 123207)
NonceManager_applyPreviousRampsUpdates:test_PreviousRampAlreadySetOffRamp_Revert() (gas: 43079)
NonceManager_applyPreviousRampsUpdates:test_PreviousRampAlreadySetOnRampAndOffRamp_Revert() (gas: 64408)
Expand Down Expand Up @@ -761,34 +761,34 @@ 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_constructor:test_Constructor_InvalidConfigChainSelectorEqZero_Revert() (gas: 95032)
OnRamp_constructor:test_Constructor_InvalidConfigNonceManagerEqAddressZero_Revert() (gas: 92974)
OnRamp_constructor:test_Constructor_InvalidConfigRMNProxyEqAddressZero_Revert() (gas: 98007)
OnRamp_constructor:test_Constructor_InvalidConfigTokenAdminRegistryEqAddressZero_Revert() (gas: 93030)
OnRamp_constructor:test_Constructor_Success() (gas: 2736236)
OnRamp_forwardFromRouter:test_ForwardFromRouterExtraArgsV2AllowOutOfOrderTrue_Success() (gas: 114080)
OnRamp_forwardFromRouter:test_ForwardFromRouterExtraArgsV2_Success() (gas: 144904)
OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessCustomExtraArgs() (gas: 144479)
OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessEmptyExtraArgs() (gas: 142706)
OnRamp_forwardFromRouter:test_ForwardFromRouterSuccessLegacyExtraArgs() (gas: 144698)
OnRamp_forwardFromRouter:test_ForwardFromRouter_Success() (gas: 144074)
OnRamp_forwardFromRouter:test_ForwardFromRouter_Success_ConfigurableSourceRouter() (gas: 144630)
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_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_ShouldIncrementNonceOnlyOnOrdered_Success() (gas: 182996)
OnRamp_forwardFromRouter:test_ShouldIncrementSeqNumAndNonce_Success() (gas: 209384)
OnRamp_forwardFromRouter:test_ShouldStoreLinkFees() (gas: 145730)
OnRamp_forwardFromRouter:test_ShouldStoreNonLinkFees() (gas: 160185)
OnRamp_forwardFromRouter:test_SourceTokenDataTooLarge_Revert() (gas: 3614162)
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_forwardFromRouter:test_forwardFromRouter_WithInterception_Success() (gas: 278985)
OnRamp_getFee:test_EmptyMessage_Success() (gas: 98757)
OnRamp_getFee:test_EnforceOutOfOrder_Revert() (gas: 64779)
OnRamp_getFee:test_GetFeeOfZeroForTokenMessage_Success() (gas: 86359)
Expand Down
7 changes: 2 additions & 5 deletions contracts/src/v0.8/ccip/onRamp/OnRamp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ 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);
event CCIPMessageSent(uint64 indexed destChainSelector, Internal.EVM2AnyRampMessage message, uint256 feeValueJuels);
event AllowListAdminSet(address indexed allowListAdmin);
event AllowListSendersAdded(uint64 indexed destChainSelector, address[] senders);
event AllowListSendersRemoved(uint64 indexed destChainSelector, address[] senders);
Expand Down Expand Up @@ -233,8 +232,6 @@ contract OnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCreator {
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 All @@ -255,7 +252,7 @@ contract OnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCreator {
// Emit message request
// This must happen after any pool events as some tokens (e.g. USDC) emit events that we expect to precede this
// event in the offchain code.
emit CCIPMessageSent(destChainSelector, newMessage);
emit CCIPMessageSent(destChainSelector, newMessage, msgFeeJuels);

s_dynamicConfig.reentrancyGuardEntered = false;

Expand Down
12 changes: 8 additions & 4 deletions contracts/src/v0.8/ccip/test/NonceManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ contract NonceManager_OnRampUpgrade is OnRampSetup {
Client.EVM2AnyMessage memory message = _generateEmptyMessage();

vm.expectEmit();
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, 1, 1, FEE_AMOUNT, OWNER));
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, 1, 1, FEE_AMOUNT, OWNER), FEE_AMOUNT);
s_onRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, FEE_AMOUNT, OWNER);
}

Expand All @@ -292,14 +292,18 @@ contract NonceManager_OnRampUpgrade is OnRampSetup {

// new onramp nonce should start from 2, while sequence number start from 1
vm.expectEmit();
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, 1, startNonce + 2, FEE_AMOUNT, OWNER));
emit OnRamp.CCIPMessageSent(
DEST_CHAIN_SELECTOR, _messageToEvent(message, 1, startNonce + 2, FEE_AMOUNT, OWNER), FEE_AMOUNT
);
s_onRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, FEE_AMOUNT, OWNER);

assertEq(startNonce + 2, s_outboundNonceManager.getOutboundNonce(DEST_CHAIN_SELECTOR, OWNER));

// after another send, nonce should be 3, and sequence number be 2
vm.expectEmit();
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, 2, startNonce + 3, FEE_AMOUNT, OWNER));
emit OnRamp.CCIPMessageSent(
DEST_CHAIN_SELECTOR, _messageToEvent(message, 2, startNonce + 3, FEE_AMOUNT, OWNER), FEE_AMOUNT
);
s_onRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, FEE_AMOUNT, OWNER);

assertEq(startNonce + 3, s_outboundNonceManager.getOutboundNonce(DEST_CHAIN_SELECTOR, OWNER));
Expand All @@ -314,7 +318,7 @@ contract NonceManager_OnRampUpgrade is OnRampSetup {
address newSender = address(1234567);
// new onramp nonce should start from 1 for new sender
vm.expectEmit();
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, 1, 1, FEE_AMOUNT, newSender));
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, 1, 1, FEE_AMOUNT, newSender), FEE_AMOUNT);
s_onRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, FEE_AMOUNT, newSender);
}
}
Expand Down
6 changes: 4 additions & 2 deletions contracts/src/v0.8/ccip/test/e2e/MultiRampsEnd2End.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -251,21 +251,23 @@ 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,
OWNER,
metadataHash,
tokenAdminRegistry
);

vm.expectEmit();
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, msgEvent);
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, msgEvent, feeAmount);

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

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

s_onRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, feeAmount, OWNER);
}
Expand Down Expand Up @@ -181,7 +181,7 @@ contract OnRamp_forwardFromRouter is OnRampSetup {

vm.expectEmit();
// We expect the message to be emitted with strict = false.
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, 1, 1, feeAmount, OWNER));
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, 1, 1, feeAmount, OWNER), feeAmount);

s_onRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, feeAmount, OWNER);
}
Expand All @@ -194,7 +194,7 @@ contract OnRamp_forwardFromRouter is OnRampSetup {

vm.expectEmit();
// We expect the message to be emitted with strict = false.
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, 1, 1, feeAmount, OWNER));
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, 1, 1, feeAmount, OWNER), feeAmount);

s_onRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, feeAmount, OWNER);
}
Expand All @@ -206,7 +206,7 @@ contract OnRamp_forwardFromRouter is OnRampSetup {
IERC20(s_sourceFeeToken).transferFrom(OWNER, address(s_onRamp), feeAmount);

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

s_onRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, feeAmount, OWNER);
}
Expand All @@ -220,7 +220,7 @@ contract OnRamp_forwardFromRouter is OnRampSetup {
IERC20(s_sourceFeeToken).transferFrom(OWNER, address(s_onRamp), feeAmount);

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

s_onRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, feeAmount, OWNER);
}
Expand All @@ -234,7 +234,7 @@ contract OnRamp_forwardFromRouter is OnRampSetup {
IERC20(s_sourceFeeToken).transferFrom(OWNER, address(s_onRamp), feeAmount);

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

s_onRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, feeAmount, OWNER);
}
Expand All @@ -247,7 +247,7 @@ contract OnRamp_forwardFromRouter is OnRampSetup {
uint64 sequenceNumberBefore = s_onRamp.getExpectedNextSequenceNumber(DEST_CHAIN_SELECTOR) - 1;

vm.expectEmit();
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, i, i, 0, OWNER));
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, i, i, 0, OWNER), 0);

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

Expand All @@ -269,7 +269,7 @@ contract OnRamp_forwardFromRouter is OnRampSetup {
uint64 sequenceNumberBefore = s_onRamp.getExpectedNextSequenceNumber(DEST_CHAIN_SELECTOR) - 1;

vm.expectEmit();
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, i, i, 0, OWNER));
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, i, i, 0, OWNER), 0);

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

Expand All @@ -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), feeAmount);

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, OWNER), expectedJuels);

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

assertEq(IERC20(s_sourceTokens[1]).balanceOf(address(s_onRamp)), feeAmount);
Expand Down Expand Up @@ -352,9 +354,7 @@ 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);
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, expectedEvent, feeTokenAmount);

// Assert the message Id is correct
assertEq(
Expand All @@ -376,7 +376,7 @@ contract OnRamp_forwardFromRouter is OnRampSetup {
s_outboundmessageInterceptor.setMessageIdValidationState(keccak256(abi.encode(message)), false);

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

s_onRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, feeAmount, OWNER);
}
Expand Down
Loading
Loading