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
…CCIP-2455-off-chain-blessing-off-ramp-contract-changes
  • Loading branch information
RyanRHall committed Sep 4, 2024
2 parents 522d0e1 + 17ce920 commit 796523a
Show file tree
Hide file tree
Showing 12 changed files with 496 additions and 192 deletions.
194 changes: 98 additions & 96 deletions contracts/gas-snapshots/ccip.gas-snapshot

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions contracts/src/v0.8/ccip/offRamp/OffRamp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base {
/// @dev RMN depends on this event, if changing, please notify the RMN maintainers.
event CommitReportAccepted(CommitReport report);
event RootRemoved(bytes32 root);
event SkippedReportExecution(uint64 sourceChainSelector);

/// @notice Struct that contains the static configuration
/// @dev RMN depends on this struct, if changing, please notify the RMN maintainers.
Expand Down Expand Up @@ -325,7 +326,16 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base {
uint256[] memory manualExecGasLimits
) internal {
uint64 sourceChainSelector = report.sourceChainSelector;
_whenNotCursed(sourceChainSelector);
bool manualExecution = manualExecGasLimits.length != 0;
if (i_rmnRemote.isCursed(bytes16(uint128(sourceChainSelector)))) {
if (manualExecution) {
// For manual execution we don't want to silently fail so we revert
revert CursedByRMN(sourceChainSelector);
}
// For DON execution we do not revert as a single lane curse can revert the entire batch
emit SkippedReportExecution(sourceChainSelector);
return;
}

bytes memory onRamp = _getEnabledSourceChainConfig(sourceChainSelector).onRamp;

Expand Down Expand Up @@ -357,7 +367,6 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base {
if (timestampCommitted == 0) revert RootNotCommitted(sourceChainSelector);

// Execute messages
bool manualExecution = manualExecGasLimits.length != 0;
for (uint256 i = 0; i < numMsgs; ++i) {
uint256 gasStart = gasleft();
Internal.Any2EVMRampMessage memory message = report.messages[i];
Expand Down Expand Up @@ -595,7 +604,10 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base {
Internal.MerkleRoot memory root = commitReport.merkleRoots[i];
uint64 sourceChainSelector = root.sourceChainSelector;

_whenNotCursed(sourceChainSelector);
if (i_rmnRemote.isCursed(bytes16(uint128(sourceChainSelector)))) {
revert CursedByRMN(sourceChainSelector);
}

SourceChainConfig storage sourceChainConfig = _getEnabledSourceChainConfig(sourceChainSelector);

if (sourceChainConfig.minSeqNr != root.minSeqNr || root.minSeqNr > root.maxSeqNr) {
Expand Down Expand Up @@ -920,12 +932,4 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base {
// solhint-disable-next-line
revert();
}

/// @notice Validates that the source chain -> this chain lane, and reverts if it is cursed
/// @param sourceChainSelector Source chain selector to check for cursing
function _whenNotCursed(uint64 sourceChainSelector) internal view {
if (i_rmnRemote.isCursed(bytes16(uint128(sourceChainSelector)))) {
revert CursedByRMN(sourceChainSelector);
}
}
}
4 changes: 2 additions & 2 deletions contracts/src/v0.8/ccip/onRamp/OnRamp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract OnRamp is IEVM2AnyOnRampClient, ITypeAndVersion, OwnerIsCreator {
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 CCIPSendRequested(uint64 indexed destChainSelector, Internal.EVM2AnyRampMessage message);
event CCIPMessageSent(uint64 indexed destChainSelector, Internal.EVM2AnyRampMessage message);
event AllowListAdminSet(address indexed allowListAdmin);
event AllowListSendersAdded(uint64 indexed destChainSelector, address[] senders);
event AllowListSendersRemoved(uint64 indexed destChainSelector, address[] senders);
Expand Down Expand Up @@ -243,7 +243,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 CCIPSendRequested(destChainSelector, newMessage);
emit CCIPMessageSent(destChainSelector, newMessage);
return newMessage.header.messageId;
}

Expand Down
8 changes: 4 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.CCIPSendRequested(DEST_CHAIN_SELECTOR, _messageToEvent(message, 1, 1, FEE_AMOUNT, OWNER));
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, 1, 1, FEE_AMOUNT, OWNER));
s_onRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, FEE_AMOUNT, OWNER);
}

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

// new onramp nonce should start from 2, while sequence number start from 1
vm.expectEmit();
emit OnRamp.CCIPSendRequested(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));
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.CCIPSendRequested(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));
s_onRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, FEE_AMOUNT, OWNER);

assertEq(startNonce + 3, s_outboundNonceManager.getOutboundNonce(DEST_CHAIN_SELECTOR, OWNER));
Expand All @@ -314,7 +314,7 @@ contract NonceManager_OnRampUpgrade is OnRampSetup {
address newSender = address(1234567);
// new onramp nonce should start from 1 for new sender
vm.expectEmit();
emit OnRamp.CCIPSendRequested(DEST_CHAIN_SELECTOR, _messageToEvent(message, 1, 1, FEE_AMOUNT, newSender));
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, _messageToEvent(message, 1, 1, FEE_AMOUNT, newSender));
s_onRamp.forwardFromRouter(DEST_CHAIN_SELECTOR, message, FEE_AMOUNT, newSender);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ contract MultiOnRampTokenPoolReentrancy is OnRampSetup {
Internal.EVM2AnyRampMessage memory msgEvent2 = _messageToEvent(message2, 2, 2, expectedFee, address(s_facadeClient));

vm.expectEmit();
emit OnRamp.CCIPSendRequested(DEST_CHAIN_SELECTOR, msgEvent2);
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, msgEvent2);
vm.expectEmit();
emit OnRamp.CCIPSendRequested(DEST_CHAIN_SELECTOR, msgEvent1);
emit OnRamp.CCIPMessageSent(DEST_CHAIN_SELECTOR, msgEvent1);

s_facadeClient.send(amount);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/ccip/test/e2e/MultiRampsEnd2End.sol
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ contract MultiRampsE2E is OnRampSetup, OffRampSetup {
);

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

vm.resumeGasMetering();
router.ccipSend(DEST_CHAIN_SELECTOR, message);
Expand Down
Loading

0 comments on commit 796523a

Please sign in to comment.