diff --git a/contracts/src/v0.8/ccip/libraries/Internal.sol b/contracts/src/v0.8/ccip/libraries/Internal.sol index cc71dedfb4..af1fc5e583 100644 --- a/contracts/src/v0.8/ccip/libraries/Internal.sol +++ b/contracts/src/v0.8/ccip/libraries/Internal.sol @@ -71,7 +71,7 @@ library Internal { /// @dev RMN depends on this struct, if changing, please notify the RMN maintainers. struct ExecutionReportSingleChain { uint64 sourceChainSelector; // Source chain selector for which the report is submitted - EVM2EVMMessage[] messages; + Any2EVMRampMessage[] messages; // Contains a bytes array for each message, each inner bytes array contains bytes per transferred token bytes[][] offchainTokenData; bytes32[] proofs; @@ -106,6 +106,7 @@ library Internal { bytes32 messageId; // a hash of the message data } + // TODO: create new const for EVM2AnyMessage /// @dev EVM2EVMMessage struct has 13 fields, including 3 variable arrays. /// Each variable array takes 1 more slot to store its length. /// When abi encoded, excluding array contents, @@ -113,6 +114,7 @@ library Internal { /// For structs that contain arrays, 1 more slot is added to the front, reaching a total of 17. uint256 public constant MESSAGE_FIXED_BYTES = 32 * 17; + // TODO: create new const for EVM2AnyMessage /// @dev Each token transfer adds 1 EVMTokenAmount and 1 bytes. /// When abiEncoded, each EVMTokenAmount takes 2 slots, each bytes takes 2 slots, excl bytes contents uint256 public constant MESSAGE_FIXED_BYTES_PER_TOKEN = 32 * 4; @@ -130,6 +132,19 @@ library Internal { }); } + function _toAny2EVMMessage( + Any2EVMRampMessage memory original, + Client.EVMTokenAmount[] memory destTokenAmounts + ) internal pure returns (Client.Any2EVMMessage memory message) { + return Client.Any2EVMMessage({ + messageId: original.header.messageId, + sourceChainSelector: original.header.sourceChainSelector, + sender: abi.encode(original.sender), + data: original.data, + destTokenAmounts: destTokenAmounts + }); + } + bytes32 internal constant EVM_2_EVM_MESSAGE_HASH = keccak256("EVM2EVMMessageHashV2"); function _hash(EVM2EVMMessage memory original, bytes32 metadataHash) internal pure returns (bytes32) { @@ -158,32 +173,25 @@ library Internal { ); } - // TODO: this function is incomplete and should not yet be used - it is intended for Any2EVM / EVM2Any messages - function _hash(EVM2EVMMessage memory original) internal pure returns (bytes32) { + function _hash(Any2EVMRampMessage memory original) internal pure returns (bytes32) { // Fixed-size message fields are included in nested hash to reduce stack pressure. // This hashing scheme is also used by RMN. If changing it, please notify the RMN maintainers. return keccak256( abi.encode( MerkleMultiProof.LEAF_DOMAIN_SEPARATOR, - // TODO: include prefix message hash - // TODO: include OnRamp address - // TODO: include destChainSelector + // Implicit metadata hash + keccak256( + // TODO: include prefix message hash + // TODO: include OnRamp address + abi.encode(original.header.sourceChainSelector, original.header.destChainSelector) + ), keccak256( abi.encode( - original.sourceChainSelector, - original.sender, - original.receiver, - original.sequenceNumber, - original.gasLimit, - original.strict, - original.nonce, - original.feeToken, - original.feeTokenAmount + original.sender, original.receiver, original.header.sequenceNumber, original.gasLimit, original.header.nonce ) ), keccak256(original.data), - keccak256(abi.encode(original.tokenAmounts)), - keccak256(abi.encode(original.sourceTokenData)) + keccak256(abi.encode(original.tokenAmounts)) ) ); } @@ -230,4 +238,25 @@ library Internal { Commit, Execution } + + /// @notice Family-agnostic header for OnRamp & OffRamp messages + struct RampMessageHeader { + bytes32 messageId; // Unique identifier for the message, with family-agnostic encoding (i.e. not necessarily abi.encoded) + uint64 sourceChainSelector; // ───────╮ the chain selector of the source chain, note: not chainId + uint64 destChainSelector; // | the chain selector of the destination chain, note: not chainId + uint64 sequenceNumber; // │ sequence number, not unique across lanes + uint64 nonce; // ─────────────────────╯ nonce for this lane for this sender, not unique across senders/lanes + } + + /// @notice Family-agnostic message routed to an OffRamp + struct Any2EVMRampMessage { + RampMessageHeader header; // Message header + bytes sender; // sender address on the source chain + bytes data; // arbitrary data payload supplied by the message sender + address receiver; // receiver address on the destination chain + uint256 gasLimit; // user supplied maximum gas amount available for dest chain execution + // TODO: revisit collapsing tokenAmounts + sourceTokenData into one struct array + Client.EVMTokenAmount[] tokenAmounts; // array of tokens and amounts to transfer + bytes[] sourceTokenData; // array of token data, one per token + } } diff --git a/contracts/src/v0.8/ccip/offRamp/EVM2EVMMultiOffRamp.sol b/contracts/src/v0.8/ccip/offRamp/EVM2EVMMultiOffRamp.sol index 62b19bb7ca..3a88528f61 100644 --- a/contracts/src/v0.8/ccip/offRamp/EVM2EVMMultiOffRamp.sol +++ b/contracts/src/v0.8/ccip/offRamp/EVM2EVMMultiOffRamp.sol @@ -3,7 +3,6 @@ pragma solidity 0.8.24; import {ITypeAndVersion} from "../../shared/interfaces/ITypeAndVersion.sol"; 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 {IPoolV1} from "../interfaces/IPool.sol"; @@ -30,7 +29,7 @@ import {ERC165Checker} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts /// @dev MultiOCR3Base is used to store multiple OCR configs for both the OffRamp and the CommitStore. /// The execution plugin type has to be configured without signature verification, and the commit /// plugin type with verification. -contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3Base { +contract EVM2EVMMultiOffRamp is ITypeAndVersion, MultiOCR3Base { using ERC165Checker for address; using EnumerableMapAddresses for EnumerableMapAddresses.AddressToAddressMap; @@ -64,8 +63,8 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3 /// @dev Atlas depends on this event, if changing, please notify Atlas. event StaticConfigSet(StaticConfig staticConfig); event DynamicConfigSet(DynamicConfig dynamicConfig); - event SkippedIncorrectNonce(uint64 sourceChainSelector, uint64 nonce, address sender); - event SkippedSenderWithPreviousRampMessageInflight(uint64 sourceChainSelector, uint64 nonce, address sender); + event SkippedIncorrectNonce(uint64 sourceChainSelector, uint64 nonce, bytes sender); + event SkippedSenderWithPreviousRampMessageInflight(uint64 sourceChainSelector, uint64 nonce, bytes sender); /// @dev RMN depends on this event, if changing, please notify the RMN maintainers. event ExecutionStateChanged( uint64 indexed sourceChainSelector, @@ -254,8 +253,7 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3 return s_executionStates[sourceChainSelector][sequenceNumber / 128]; } - /// @inheritdoc IAny2EVMMultiOffRamp - function getSenderNonce(uint64 sourceChainSelector, address sender) external view returns (uint64) { + function getSenderNonce(uint64 sourceChainSelector, bytes memory sender) external view returns (uint64) { (uint64 nonce,) = _getSenderNonce(sourceChainSelector, sender); return nonce; } @@ -267,16 +265,16 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3 /// @return isFromPrevRamp True if the nonce was retrieved from the prevOffRamps function _getSenderNonce( uint64 sourceChainSelector, - address sender + bytes memory sender ) internal view returns (uint64 nonce, bool isFromPrevRamp) { - uint64 senderNonce = s_senderNonce[sourceChainSelector][sender]; + uint64 senderNonce = s_senderNonce[sourceChainSelector][abi.decode(sender, (address))]; if (senderNonce == 0) { address prevOffRamp = s_sourceChainConfigs[sourceChainSelector].prevOffRamp; if (prevOffRamp != address(0)) { // If OffRamp was upgraded, check if sender has a nonce from the previous OffRamp. // NOTE: assuming prevOffRamp is always a lane-specific off ramp - return (IAny2EVMOffRamp(prevOffRamp).getSenderNonce(sender), true); + return (IAny2EVMOffRamp(prevOffRamp).getSenderNonce(abi.decode(sender, (address))), true); } } @@ -375,16 +373,17 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3 bytes32[] memory hashedLeaves = new bytes32[](numMsgs); for (uint256 i = 0; i < numMsgs; ++i) { - Internal.EVM2EVMMessage memory message = report.messages[i]; + Internal.Any2EVMRampMessage memory message = report.messages[i]; // We do this hash here instead of in _verifyMessages to avoid two separate loops // over the same data, which increases gas cost // TODO: verify message.onRamp == config.onRamp // TODO: verify message.destChainSelector == config.destChainSelector hashedLeaves[i] = Internal._hash(message); + // TODO: revisit this - is messageID independent of the leaf hash? // For EVM2EVM offramps, the messageID is the leaf hash. // Asserting that this is true ensures we don't accidentally commit and then execute // a message with an unexpected hash. - if (hashedLeaves[i] != message.messageId) revert InvalidMessageId(message.messageId); + if (hashedLeaves[i] != message.header.messageId) revert InvalidMessageId(message.header.messageId); } // SECURITY CRITICAL CHECK @@ -395,14 +394,15 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3 // Execute messages bool manualExecution = manualExecGasLimits.length != 0; for (uint256 i = 0; i < numMsgs; ++i) { - Internal.EVM2EVMMessage memory message = report.messages[i]; + Internal.Any2EVMRampMessage memory message = report.messages[i]; - Internal.MessageExecutionState originalState = getExecutionState(sourceChainSelector, message.sequenceNumber); + Internal.MessageExecutionState originalState = + getExecutionState(sourceChainSelector, message.header.sequenceNumber); if (originalState == Internal.MessageExecutionState.SUCCESS) { // If the message has already been executed, we skip it. We want to not revert on race conditions between // executing parties. This will allow us to open up manual exec while also attempting with the DON, without // reverting an entire DON batch when a user manually executes while the tx is inflight. - emit SkippedAlreadyExecutedMessage(sourceChainSelector, message.sequenceNumber); + emit SkippedAlreadyExecutedMessage(sourceChainSelector, message.header.sequenceNumber); continue; } // Two valid cases here, we either have never touched this message before, or we tried to execute @@ -413,7 +413,7 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3 originalState == Internal.MessageExecutionState.UNTOUCHED || originalState == Internal.MessageExecutionState.FAILURE ) - ) revert AlreadyExecuted(sourceChainSelector, message.sequenceNumber); + ) revert AlreadyExecuted(sourceChainSelector, message.header.sequenceNumber); if (manualExecution) { bool isOldCommitReport = @@ -432,36 +432,38 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3 // DON can only execute a message once // Acceptable state transitions: UNTOUCHED->SUCCESS, UNTOUCHED->FAILURE if (originalState != Internal.MessageExecutionState.UNTOUCHED) { - revert AlreadyAttempted(sourceChainSelector, message.sequenceNumber); + revert AlreadyAttempted(sourceChainSelector, message.header.sequenceNumber); } } - if (message.nonce > 0) { + if (message.header.nonce > 0) { // In the scenario where we upgrade offRamps, we still want to have sequential nonces. // Referencing the old offRamp to check the expected nonce if none is set for a // given sender allows us to skip the current message if it would not be the next according // to the old offRamp. This preserves sequencing between updates. + // TODO: remove after NonceManager changes (uint64 prevNonce, bool isFromPrevRamp) = _getSenderNonce(sourceChainSelector, message.sender); if (isFromPrevRamp) { - if (prevNonce + 1 != message.nonce) { + if (prevNonce + 1 != message.header.nonce) { // the starting v2 onramp nonce, i.e. the 1st message nonce v2 offramp is expected to receive, // is guaranteed to equal (largest v1 onramp nonce + 1). // if this message's nonce isn't (v1 offramp nonce + 1), then v1 offramp nonce != largest v1 onramp nonce, // it tells us there are still messages inflight for v1 offramp - emit SkippedSenderWithPreviousRampMessageInflight(sourceChainSelector, message.nonce, message.sender); + emit SkippedSenderWithPreviousRampMessageInflight(sourceChainSelector, message.header.nonce, message.sender); continue; } // Otherwise this nonce is indeed the "transitional nonce", that is // all messages sent to v1 ramp have been executed by the DON and the sequence can resume in V2. // Note if first time user in V2, then prevNonce will be 0, and message.nonce = 1, so this will be a no-op. - s_senderNonce[sourceChainSelector][message.sender] = prevNonce; + // TODO: remove after NonceManager changes + s_senderNonce[sourceChainSelector][abi.decode(message.sender, (address))] = prevNonce; } // UNTOUCHED messages MUST be executed in order always IF message.nonce > 0. if (originalState == Internal.MessageExecutionState.UNTOUCHED) { - if (prevNonce + 1 != message.nonce) { + if (prevNonce + 1 != message.header.nonce) { // We skip the message if the nonce is incorrect, since message.nonce > 0. - emit SkippedIncorrectNonce(sourceChainSelector, message.nonce, message.sender); + emit SkippedIncorrectNonce(sourceChainSelector, message.header.nonce, message.sender); continue; } } @@ -471,12 +473,12 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3 // when executing as a defense in depth measure. bytes[] memory offchainTokenData = report.offchainTokenData[i]; if (message.tokenAmounts.length != offchainTokenData.length) { - revert TokenDataMismatch(sourceChainSelector, message.sequenceNumber); + revert TokenDataMismatch(sourceChainSelector, message.header.sequenceNumber); } - _setExecutionState(sourceChainSelector, message.sequenceNumber, Internal.MessageExecutionState.IN_PROGRESS); + _setExecutionState(sourceChainSelector, message.header.sequenceNumber, Internal.MessageExecutionState.IN_PROGRESS); (Internal.MessageExecutionState newState, bytes memory returnData) = _trialExecute(message, offchainTokenData); - _setExecutionState(sourceChainSelector, message.sequenceNumber, newState); + _setExecutionState(sourceChainSelector, message.header.sequenceNumber, newState); // 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 @@ -487,13 +489,13 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3 ) { // 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); + revert ExecutionError(message.header.messageId, returnData); } // The only valid prior states are UNTOUCHED and FAILURE (checked above) // The only valid post states are FAILURE and SUCCESS (checked below) if (newState != Internal.MessageExecutionState.FAILURE && newState != Internal.MessageExecutionState.SUCCESS) { - revert InvalidNewState(sourceChainSelector, message.sequenceNumber, newState); + revert InvalidNewState(sourceChainSelector, message.header.sequenceNumber, newState); } // Nonce changes per state transition. @@ -502,21 +504,24 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3 // UNTOUCHED -> SUCCESS nonce bump // FAILURE -> FAILURE no nonce bump // FAILURE -> SUCCESS no nonce bump - if (message.nonce > 0 && originalState == Internal.MessageExecutionState.UNTOUCHED) { - s_senderNonce[sourceChainSelector][message.sender]++; + if (message.header.nonce > 0 && originalState == Internal.MessageExecutionState.UNTOUCHED) { + // TODO: remove after NonceManager changes + s_senderNonce[sourceChainSelector][abi.decode(message.sender, (address))]++; } - emit ExecutionStateChanged(sourceChainSelector, message.sequenceNumber, message.messageId, newState, returnData); + emit ExecutionStateChanged( + sourceChainSelector, message.header.sequenceNumber, message.header.messageId, newState, returnData + ); } } /// @notice Try executing a message. - /// @param message Internal.EVM2EVMMessage memory message. + /// @param message Internal.Any2EVMRampMessage memory message. /// @param offchainTokenData Data provided by the DON for token transfers. /// @return the new state of the message, being either SUCCESS or FAILURE. /// @return revert data in bytes if CCIP receiver reverted during execution. function _trialExecute( - Internal.EVM2EVMMessage memory message, + Internal.Any2EVMRampMessage memory message, bytes[] memory offchainTokenData ) internal returns (Internal.MessageExecutionState, bytes memory) { try this.executeSingleMessage(message, offchainTokenData) {} @@ -534,7 +539,7 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3 return (Internal.MessageExecutionState.FAILURE, err); } else { // If revert is not caused by CCIP receiver, it is unexpected, bubble up the revert. - revert ExecutionError(message.messageId, err); + revert ExecutionError(message.header.messageId, err); } } // If message execution succeeded, no CCIP receiver return data is expected, return with empty bytes. @@ -548,7 +553,7 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3 /// its execution and enforce atomicity among successful message processing and token transfer. /// @dev We use ERC-165 to check for the ccipReceive interface to permit sending tokens to contracts /// (for example smart contract wallets) without an associated message. - function executeSingleMessage(Internal.EVM2EVMMessage memory message, bytes[] memory offchainTokenData) external { + function executeSingleMessage(Internal.Any2EVMRampMessage memory message, bytes[] memory offchainTokenData) external { if (msg.sender != address(this)) revert CanOnlySelfCall(); Client.EVMTokenAmount[] memory destTokenAmounts = new Client.EVMTokenAmount[](0); if (message.tokenAmounts.length > 0) { @@ -556,7 +561,7 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3 message.tokenAmounts, abi.encode(message.sender), message.receiver, - message.sourceChainSelector, + message.header.sourceChainSelector, message.sourceTokenData, offchainTokenData ); @@ -912,9 +917,9 @@ contract EVM2EVMMultiOffRamp is IAny2EVMMultiOffRamp, ITypeAndVersion, MultiOCR3 return Client.EVMTokenAmount({token: localToken, amount: localAmount}); } + // TODO: add missing param comments /// @notice Uses pools to release or mint a number of different tokens to a receiver address. /// @param sourceTokenAmounts List of tokens and amount values to be released/minted. - /// @param encodedSourceTokenData Array of token data returned by token pools on the source chain. /// @param offchainTokenData Array of token data fetched offchain by the DON. /// @dev This function wrappes the token pool call in a try catch block to gracefully handle /// any non-rate limiting errors that may occur. If we encounter a rate limiting related error diff --git a/contracts/src/v0.8/ccip/test/e2e/MultiRampsEnd2End.sol b/contracts/src/v0.8/ccip/test/e2e/MultiRampsEnd2End.sol index e1a142e58f..f1c29077ba 100644 --- a/contracts/src/v0.8/ccip/test/e2e/MultiRampsEnd2End.sol +++ b/contracts/src/v0.8/ccip/test/e2e/MultiRampsEnd2End.sol @@ -14,7 +14,7 @@ import "../onRamp/EVM2EVMMultiOnRampSetup.t.sol"; /// 2. Commit multiple merkle roots (1 for each source chain). /// 3. Batch execute all the committed messages. contract MultiRampsE2E is EVM2EVMMultiOnRampSetup, EVM2EVMMultiOffRampSetup { - using Internal for Internal.EVM2EVMMessage; + using Internal for Internal.Any2EVMRampMessage; Router internal s_sourceRouter2; EVM2EVMMultiOnRampHelper internal s_onRamp2; @@ -111,10 +111,10 @@ contract MultiRampsE2E is EVM2EVMMultiOnRampSetup, EVM2EVMMultiOffRampSetup { uint256 balance1Pre = token1.balanceOf(OWNER); // Send messages - Internal.EVM2EVMMessage[] memory messages1 = new Internal.EVM2EVMMessage[](2); + Internal.Any2EVMRampMessage[] memory messages1 = new Internal.Any2EVMRampMessage[](2); messages1[0] = _sendRequest(1, SOURCE_CHAIN_SELECTOR, 1, s_metadataHash, s_sourceRouter, s_tokenAdminRegistry); messages1[1] = _sendRequest(2, SOURCE_CHAIN_SELECTOR, 2, s_metadataHash, s_sourceRouter, s_tokenAdminRegistry); - Internal.EVM2EVMMessage[] memory messages2 = new Internal.EVM2EVMMessage[](1); + Internal.Any2EVMRampMessage[] memory messages2 = new Internal.Any2EVMRampMessage[](1); messages2[0] = _sendRequest(1, SOURCE_CHAIN_SELECTOR + 1, 1, s_metadataHash2, s_sourceRouter2, s_tokenAdminRegistry2); @@ -128,12 +128,12 @@ contract MultiRampsE2E is EVM2EVMMultiOnRampSetup, EVM2EVMMultiOffRampSetup { // Commit bytes32[] memory hashedMessages1 = new bytes32[](2); hashedMessages1[0] = messages1[0]._hash(); - messages1[0].messageId = hashedMessages1[0]; + messages1[0].header.messageId = hashedMessages1[0]; hashedMessages1[1] = messages1[1]._hash(); - messages1[1].messageId = hashedMessages1[1]; + messages1[1].header.messageId = hashedMessages1[1]; bytes32[] memory hashedMessages2 = new bytes32[](1); hashedMessages2[0] = messages2[0]._hash(); - messages2[0].messageId = hashedMessages2[0]; + messages2[0].header.messageId = hashedMessages2[0]; bytes32[] memory merkleRoots = new bytes32[](2); merkleRoots[0] = MerkleHelper.getMerkleRoot(hashedMessages1); @@ -142,12 +142,12 @@ contract MultiRampsE2E is EVM2EVMMultiOnRampSetup, EVM2EVMMultiOffRampSetup { EVM2EVMMultiOffRamp.MerkleRoot[] memory roots = new EVM2EVMMultiOffRamp.MerkleRoot[](2); roots[0] = EVM2EVMMultiOffRamp.MerkleRoot({ sourceChainSelector: SOURCE_CHAIN_SELECTOR, - interval: EVM2EVMMultiOffRamp.Interval(messages1[0].sequenceNumber, messages1[1].sequenceNumber), + interval: EVM2EVMMultiOffRamp.Interval(messages1[0].header.sequenceNumber, messages1[1].header.sequenceNumber), merkleRoot: merkleRoots[0] }); roots[1] = EVM2EVMMultiOffRamp.MerkleRoot({ sourceChainSelector: SOURCE_CHAIN_SELECTOR + 1, - interval: EVM2EVMMultiOffRamp.Interval(messages2[0].sequenceNumber, messages2[0].sequenceNumber), + interval: EVM2EVMMultiOffRamp.Interval(messages2[0].header.sequenceNumber, messages2[0].header.sequenceNumber), merkleRoot: merkleRoots[1] }); @@ -176,8 +176,8 @@ contract MultiRampsE2E is EVM2EVMMultiOnRampSetup, EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR, - messages1[0].sequenceNumber, - messages1[0].messageId, + messages1[0].header.sequenceNumber, + messages1[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -185,8 +185,8 @@ contract MultiRampsE2E is EVM2EVMMultiOnRampSetup, EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR, - messages1[1].sequenceNumber, - messages1[1].messageId, + messages1[1].header.sequenceNumber, + messages1[1].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -194,8 +194,8 @@ contract MultiRampsE2E is EVM2EVMMultiOnRampSetup, EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR + 1, - messages2[0].sequenceNumber, - messages2[0].messageId, + messages2[0].header.sequenceNumber, + messages2[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -215,7 +215,7 @@ contract MultiRampsE2E is EVM2EVMMultiOnRampSetup, EVM2EVMMultiOffRampSetup { bytes32 metadataHash, Router router, TokenAdminRegistry tokenAdminRegistry - ) public returns (Internal.EVM2EVMMessage memory) { + ) public returns (Internal.Any2EVMRampMessage memory) { Client.EVM2AnyMessage memory message = _generateTokenMessage(); uint256 expectedFee = router.getFee(DEST_CHAIN_SELECTOR, message); @@ -242,6 +242,20 @@ contract MultiRampsE2E is EVM2EVMMultiOnRampSetup, EVM2EVMMultiOffRampSetup { router.ccipSend(DEST_CHAIN_SELECTOR, message); vm.pauseGasMetering(); - return msgEvent; + return Internal.Any2EVMRampMessage({ + header: Internal.RampMessageHeader({ + messageId: msgEvent.messageId, + sourceChainSelector: sourceChainSelector, + destChainSelector: DEST_CHAIN_SELECTOR, + sequenceNumber: msgEvent.sequenceNumber, + nonce: msgEvent.nonce + }), + sender: abi.encode(msgEvent.sender), + data: msgEvent.data, + receiver: msgEvent.receiver, + gasLimit: msgEvent.gasLimit, + tokenAmounts: msgEvent.tokenAmounts, + sourceTokenData: msgEvent.sourceTokenData + }); } } diff --git a/contracts/src/v0.8/ccip/test/helpers/EVM2EVMMultiOffRampHelper.sol b/contracts/src/v0.8/ccip/test/helpers/EVM2EVMMultiOffRampHelper.sol index cd4c467da4..0e2202869e 100644 --- a/contracts/src/v0.8/ccip/test/helpers/EVM2EVMMultiOffRampHelper.sol +++ b/contracts/src/v0.8/ccip/test/helpers/EVM2EVMMultiOffRampHelper.sol @@ -53,7 +53,7 @@ contract EVM2EVMMultiOffRampHelper is EVM2EVMMultiOffRamp, IgnoreContractSize { } function trialExecute( - Internal.EVM2EVMMessage memory message, + Internal.Any2EVMRampMessage memory message, bytes[] memory offchainTokenData ) external returns (Internal.MessageExecutionState, bytes memory) { return _trialExecute(message, offchainTokenData); diff --git a/contracts/src/v0.8/ccip/test/offRamp/EVM2EVMMultiOffRamp.t.sol b/contracts/src/v0.8/ccip/test/offRamp/EVM2EVMMultiOffRamp.t.sol index ea27bdd648..379d112086 100644 --- a/contracts/src/v0.8/ccip/test/offRamp/EVM2EVMMultiOffRamp.t.sol +++ b/contracts/src/v0.8/ccip/test/offRamp/EVM2EVMMultiOffRamp.t.sol @@ -327,27 +327,28 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { } function test_SingleMessageNoTokens_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages[0].sourceChainSelector, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sourceChainSelector, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); - messages[0].nonce++; - messages[0].sequenceNumber++; - messages[0].messageId = Internal._hash(messages[0]); + messages[0].header.nonce++; + messages[0].header.sequenceNumber++; + messages[0].header.messageId = Internal._hash(messages[0]); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages[0].sourceChainSelector, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sourceChainSelector, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -358,15 +359,16 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { } function test_SingleMessageNoTokensUnordered_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); - messages[0].nonce = 0; - messages[0].messageId = Internal._hash(messages[0]); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + messages[0].header.nonce = 0; + messages[0].header.messageId = Internal._hash(messages[0]); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages[0].sourceChainSelector, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sourceChainSelector, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -380,14 +382,14 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { "nonce must remain unchanged on unordered messages" ); - messages[0].sequenceNumber++; - messages[0].messageId = Internal._hash(messages[0]); + messages[0].header.sequenceNumber++; + messages[0].header.messageId = Internal._hash(messages[0]); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages[0].sourceChainSelector, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sourceChainSelector, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -403,7 +405,7 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { } function test_SingleMessageNoTokensOtherChain_Success() public { - Internal.EVM2EVMMessage[] memory messagesChain1 = + Internal.Any2EVMRampMessage[] memory messagesChain1 = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); s_offRamp.executeSingleReport( _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messagesChain1), new uint256[](0) @@ -412,7 +414,7 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { uint64 nonceChain1 = s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messagesChain1[0].sender); assertGt(nonceChain1, 0); - Internal.EVM2EVMMessage[] memory messagesChain2 = + Internal.Any2EVMRampMessage[] memory messagesChain2 = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_3, ON_RAMP_ADDRESS_3); assertEq(s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_3, messagesChain2[0].sender), 0); @@ -426,7 +428,8 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { } function test_ReceiverError_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); bytes memory realError1 = new bytes(2); realError1[0] = 0xbe; @@ -434,13 +437,13 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { s_reverting_receiver.setErr(realError1); messages[0].receiver = address(s_reverting_receiver); - messages[0].messageId = Internal._hash(messages[0]); + messages[0].header.messageId = Internal._hash(messages[0]); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages[0].sourceChainSelector, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sourceChainSelector, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.FAILURE, abi.encodeWithSelector( EVM2EVMMultiOffRamp.ReceiverError.selector, @@ -448,54 +451,59 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { ) ); // Nonce should increment on non-strict - assertEq(uint64(0), s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, address(OWNER))); + assertEq(uint64(0), s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, abi.encode(OWNER))); s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); - assertEq(uint64(1), s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, address(OWNER))); + assertEq(uint64(1), s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, abi.encode(OWNER))); } function test_SkippedIncorrectNonce_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); - messages[0].nonce++; - messages[0].messageId = Internal._hash(messages[0]); + messages[0].header.nonce++; + messages[0].header.messageId = Internal._hash(messages[0]); vm.expectEmit(); emit EVM2EVMMultiOffRamp.SkippedIncorrectNonce( - messages[0].sourceChainSelector, messages[0].nonce, messages[0].sender + messages[0].header.sourceChainSelector, messages[0].header.nonce, messages[0].sender ); s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); } function test_SkippedIncorrectNonceStillExecutes_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateMessagesWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateMessagesWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); - messages[1].nonce++; - messages[1].messageId = Internal._hash(messages[1]); + messages[1].header.nonce++; + messages[1].header.messageId = Internal._hash(messages[1]); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); vm.expectEmit(); - emit EVM2EVMMultiOffRamp.SkippedIncorrectNonce(SOURCE_CHAIN_SELECTOR_1, messages[1].nonce, messages[1].sender); + emit EVM2EVMMultiOffRamp.SkippedIncorrectNonce( + SOURCE_CHAIN_SELECTOR_1, messages[1].header.nonce, messages[1].sender + ); s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); } function test__execute_SkippedAlreadyExecutedMessage_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages[0].sourceChainSelector, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sourceChainSelector, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -503,21 +511,22 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); vm.expectEmit(); - emit EVM2EVMMultiOffRamp.SkippedAlreadyExecutedMessage(SOURCE_CHAIN_SELECTOR_1, messages[0].sequenceNumber); + emit EVM2EVMMultiOffRamp.SkippedAlreadyExecutedMessage(SOURCE_CHAIN_SELECTOR_1, messages[0].header.sequenceNumber); s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); } function test__execute_SkippedAlreadyExecutedMessageUnordered_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); - messages[0].nonce = 0; - messages[0].messageId = Internal._hash(messages[0]); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + messages[0].header.nonce = 0; + messages[0].header.messageId = Internal._hash(messages[0]); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages[0].sourceChainSelector, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sourceChainSelector, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -525,7 +534,7 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); vm.expectEmit(); - emit EVM2EVMMultiOffRamp.SkippedAlreadyExecutedMessage(SOURCE_CHAIN_SELECTOR_1, messages[0].sequenceNumber); + emit EVM2EVMMultiOffRamp.SkippedAlreadyExecutedMessage(SOURCE_CHAIN_SELECTOR_1, messages[0].header.sequenceNumber); s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); } @@ -533,16 +542,17 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { // Send a message to a contract that does not implement the CCIPReceiver interface // This should execute successfully. function test_SingleMessageToNonCCIPReceiver_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); MaybeRevertMessageReceiverNo165 newReceiver = new MaybeRevertMessageReceiverNo165(true); messages[0].receiver = address(newReceiver); - messages[0].messageId = Internal._hash(messages[0]); + messages[0].header.messageId = Internal._hash(messages[0]); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages[0].sourceChainSelector, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sourceChainSelector, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -552,13 +562,14 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { function test_SingleMessagesNoTokensSuccess_gas() public { vm.pauseGasMetering(); - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages[0].sourceChainSelector, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sourceChainSelector, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -571,16 +582,17 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { function test_TwoMessagesWithTokensSuccess_gas() public { vm.pauseGasMetering(); - Internal.EVM2EVMMessage[] memory messages = _generateMessagesWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateMessagesWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); // Set message 1 to use another receiver to simulate more fair gas costs messages[1].receiver = address(s_secondary_receiver); - messages[1].messageId = Internal._hash(messages[1]); + messages[1].header.messageId = Internal._hash(messages[1]); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -588,8 +600,8 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages[1].sequenceNumber, - messages[1].messageId, + messages[1].header.sequenceNumber, + messages[1].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -601,16 +613,17 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { } function test_TwoMessagesWithTokensAndGE_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateMessagesWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateMessagesWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); // Set message 1 to use another receiver to simulate more fair gas costs messages[1].receiver = address(s_secondary_receiver); - messages[1].messageId = Internal._hash(messages[1]); + messages[1].header.messageId = Internal._hash(messages[1]); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -618,21 +631,21 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages[1].sequenceNumber, - messages[1].messageId, + messages[1].header.sequenceNumber, + messages[1].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); - assertEq(uint64(0), s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, OWNER)); + assertEq(uint64(0), s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, abi.encode(OWNER))); s_offRamp.executeSingleReport( _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), _getGasLimitsFromMessages(messages) ); - assertEq(uint64(2), s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, OWNER)); + assertEq(uint64(2), s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, abi.encode(OWNER))); } function test_Fuzz_InterleavingOrderedAndUnorderedMessages_Success(bool[7] memory orderings) public { - Internal.EVM2EVMMessage[] memory messages = new Internal.EVM2EVMMessage[](orderings.length); + Internal.Any2EVMRampMessage[] memory messages = new Internal.Any2EVMRampMessage[](orderings.length); // number of tokens needs to be capped otherwise we hit UnsupportedNumberOfTokens. Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](3); for (uint256 i = 0; i < 3; ++i) { @@ -644,21 +657,21 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { messages[i] = _generateAny2EVMMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, uint64(i + 1), tokenAmounts, !orderings[i]); if (orderings[i]) { - messages[i].nonce = ++expectedNonce; + messages[i].header.nonce = ++expectedNonce; } - messages[i].messageId = Internal._hash(messages[i]); + messages[i].header.messageId = Internal._hash(messages[i]); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages[i].sequenceNumber, - messages[i].messageId, + messages[i].header.sequenceNumber, + messages[i].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); } - uint64 nonceBefore = s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, OWNER); + uint64 nonceBefore = s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, abi.encode(OWNER)); assertEq(uint64(0), nonceBefore, "nonce before exec should be 0"); s_offRamp.executeSingleReport( _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), _getGasLimitsFromMessages(messages) @@ -666,17 +679,18 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { // all executions should succeed. for (uint256 i = 0; i < orderings.length; ++i) { assertEq( - uint256(s_offRamp.getExecutionState(SOURCE_CHAIN_SELECTOR_1, messages[i].sequenceNumber)), + uint256(s_offRamp.getExecutionState(SOURCE_CHAIN_SELECTOR_1, messages[i].header.sequenceNumber)), uint256(Internal.MessageExecutionState.SUCCESS) ); } - assertEq(nonceBefore + expectedNonce, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, OWNER)); + assertEq(nonceBefore + expectedNonce, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, abi.encode(OWNER))); } function test_InvalidSourcePoolAddress_Success() public { address fakePoolAddress = address(0x0000000000333333); - Internal.EVM2EVMMessage[] memory messages = _generateMessagesWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateMessagesWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); messages[0].sourceTokenData[0] = abi.encode( Internal.SourceTokenData({ sourcePoolAddress: abi.encode(fakePoolAddress), @@ -685,14 +699,14 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { }) ); - messages[0].messageId = Internal._hash(messages[0]); - messages[1].messageId = Internal._hash(messages[1]); + messages[0].header.messageId = Internal._hash(messages[0]); + messages[1].header.messageId = Internal._hash(messages[1]); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.FAILURE, abi.encodeWithSelector( EVM2EVMMultiOffRamp.TokenHandlingError.selector, @@ -718,33 +732,35 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { // Reverts function test_InvalidMessageId_Revert() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); - messages[0].nonce++; + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + messages[0].header.nonce++; // MessageID no longer matches hash. Internal.ExecutionReportSingleChain memory executionReport = _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages); - vm.expectRevert(abi.encodeWithSelector(EVM2EVMMultiOffRamp.InvalidMessageId.selector, messages[0].messageId)); + vm.expectRevert(abi.encodeWithSelector(EVM2EVMMultiOffRamp.InvalidMessageId.selector, messages[0].header.messageId)); s_offRamp.executeSingleReport(executionReport, new uint256[](0)); } function test_MismatchingSourceChainSelector_Revert() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_3, ON_RAMP_ADDRESS_3); - messages[0].sourceChainSelector = SOURCE_CHAIN_SELECTOR_1; + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_3, ON_RAMP_ADDRESS_3); + messages[0].header.sourceChainSelector = SOURCE_CHAIN_SELECTOR_1; // MessageID no longer matches hash. Internal.ExecutionReportSingleChain memory executionReport = _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages); - vm.expectRevert(abi.encodeWithSelector(EVM2EVMMultiOffRamp.InvalidMessageId.selector, messages[0].messageId)); + vm.expectRevert(abi.encodeWithSelector(EVM2EVMMultiOffRamp.InvalidMessageId.selector, messages[0].header.messageId)); s_offRamp.executeSingleReport(executionReport, new uint256[](0)); } // TODO: re-implement for mismatching OnRamp // function test_MismatchingMetadataHash_Revert() public { - // Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); - // messages[0].messageId = Internal._hash(messages[0], METADATA_HASH_2); + // Internal.Any2EVMRampMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + // messages[0].header.messageId = Internal._hash(messages[0], METADATA_HASH_2); // // MessageID no longer matches hash. // Internal.ExecutionReportSingleChain memory executionReport = // _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages); - // vm.expectRevert(abi.encodeWithSelector(EVM2EVMMultiOffRamp.InvalidMessageId.selector, messages[0].messageId)); + // vm.expectRevert(abi.encodeWithSelector(EVM2EVMMultiOffRamp.InvalidMessageId.selector, messages[0].header.messageId)); // s_offRamp.executeSingleReport(executionReport, new uint256[](0)); // } @@ -809,7 +825,7 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { sourceChainSelector: SOURCE_CHAIN_SELECTOR_1, proofs: new bytes32[](0), proofFlagBits: 0, - messages: new Internal.EVM2EVMMessage[](0), + messages: new Internal.Any2EVMRampMessage[](0), offchainTokenData: new bytes[][](0) }), new uint256[](0) @@ -820,7 +836,8 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { s_offRamp.setVerifyOverrideResult(SOURCE_CHAIN_SELECTOR_1, 0); vm.expectRevert(abi.encodeWithSelector(EVM2EVMMultiOffRamp.RootNotCommitted.selector, SOURCE_CHAIN_SELECTOR_1)); - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); s_offRamp.executeSingleReport( _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), _getGasLimitsFromMessages(messages) ); @@ -833,7 +850,8 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { abi.encodeWithSelector(EVM2EVMMultiOffRamp.ManualExecutionNotYetEnabled.selector, SOURCE_CHAIN_SELECTOR_1) ); - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); s_offRamp.executeSingleReport( _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), _getGasLimitsFromMessages(messages) ); @@ -843,40 +861,43 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { uint64 newSourceChainSelector = SOURCE_CHAIN_SELECTOR_1 + 1; bytes memory newOnRamp = abi.encode(ON_RAMP_ADDRESS, 1); - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(newSourceChainSelector, newOnRamp); + Internal.Any2EVMRampMessage[] memory messages = _generateSingleBasicMessage(newSourceChainSelector, newOnRamp); vm.expectRevert(abi.encodeWithSelector(EVM2EVMMultiOffRamp.SourceChainNotEnabled.selector, newSourceChainSelector)); s_offRamp.executeSingleReport(_generateReportFromMessages(newSourceChainSelector, messages), new uint256[](0)); } function test_DisabledSourceChain_Revert() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_2, ON_RAMP_ADDRESS_2); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_2, ON_RAMP_ADDRESS_2); vm.expectRevert(abi.encodeWithSelector(EVM2EVMMultiOffRamp.SourceChainNotEnabled.selector, SOURCE_CHAIN_SELECTOR_2)); s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_2, messages), new uint256[](0)); } function test_TokenDataMismatch_Revert() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); Internal.ExecutionReportSingleChain memory report = _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages); report.offchainTokenData[0] = new bytes[](messages[0].tokenAmounts.length + 1); vm.expectRevert( abi.encodeWithSelector( - EVM2EVMMultiOffRamp.TokenDataMismatch.selector, SOURCE_CHAIN_SELECTOR_1, messages[0].sequenceNumber + EVM2EVMMultiOffRamp.TokenDataMismatch.selector, SOURCE_CHAIN_SELECTOR_1, messages[0].header.sequenceNumber ) ); s_offRamp.executeSingleReport(report, new uint256[](0)); } function test_RouterYULCall_Revert() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); // gas limit too high, Router's external call should revert messages[0].gasLimit = 1e36; messages[0].receiver = address(new ConformingReceiver(address(s_destRouter), s_destFeeToken)); - messages[0].messageId = Internal._hash(messages[0]); + messages[0].header.messageId = Internal._hash(messages[0]); Internal.ExecutionReportSingleChain memory executionReport = _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages); @@ -884,7 +905,7 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { vm.expectRevert( abi.encodeWithSelector( EVM2EVMMultiOffRamp.ExecutionError.selector, - messages[0].messageId, + messages[0].header.messageId, abi.encodeWithSelector(CallWithExactGas.NotEnoughGasForCall.selector) ) ); @@ -892,7 +913,8 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { } function test_RetryFailedMessageWithoutManualExecution_Revert() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); bytes memory realError1 = new bytes(2); realError1[0] = 0xbe; @@ -900,13 +922,13 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { s_reverting_receiver.setErr(realError1); messages[0].receiver = address(s_reverting_receiver); - messages[0].messageId = Internal._hash(messages[0]); + messages[0].header.messageId = Internal._hash(messages[0]); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages[0].sourceChainSelector, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sourceChainSelector, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.FAILURE, abi.encodeWithSelector( EVM2EVMMultiOffRamp.ReceiverError.selector, @@ -917,283 +939,284 @@ contract EVM2EVMMultiOffRamp_executeSingleReport is EVM2EVMMultiOffRampSetup { vm.expectRevert( abi.encodeWithSelector( - EVM2EVMMultiOffRamp.AlreadyAttempted.selector, SOURCE_CHAIN_SELECTOR_1, messages[0].sequenceNumber + EVM2EVMMultiOffRamp.AlreadyAttempted.selector, SOURCE_CHAIN_SELECTOR_1, messages[0].header.sequenceNumber ) ); s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); } } -contract EVM2EVMMultiOffRamp_execute_upgrade is EVM2EVMMultiOffRampSetup { - EVM2EVMOffRampHelper internal s_prevOffRamp; - EVM2EVMOffRampHelper[] internal s_nestedPrevOffRamps; - - function setUp() public virtual override { - super.setUp(); - - ICommitStore mockPrevCommitStore = new MockCommitStore(); - s_prevOffRamp = _deploySingleLaneOffRamp( - mockPrevCommitStore, s_destRouter, address(0), SOURCE_CHAIN_SELECTOR_1, address(bytes20(ON_RAMP_ADDRESS_1)) - ); - - s_nestedPrevOffRamps = new EVM2EVMOffRampHelper[](2); - s_nestedPrevOffRamps[0] = _deploySingleLaneOffRamp( - mockPrevCommitStore, s_destRouter, address(0), SOURCE_CHAIN_SELECTOR_2, address(bytes20(ON_RAMP_ADDRESS_2)) - ); - s_nestedPrevOffRamps[1] = _deploySingleLaneOffRamp( - mockPrevCommitStore, - s_destRouter, - address(s_nestedPrevOffRamps[0]), - SOURCE_CHAIN_SELECTOR_2, - address(bytes20(ON_RAMP_ADDRESS_2)) - ); - - EVM2EVMMultiOffRamp.SourceChainConfigArgs[] memory sourceChainConfigs = - new EVM2EVMMultiOffRamp.SourceChainConfigArgs[](3); - sourceChainConfigs[0] = EVM2EVMMultiOffRamp.SourceChainConfigArgs({ - sourceChainSelector: SOURCE_CHAIN_SELECTOR_1, - onRamp: ON_RAMP_ADDRESS_1, - isEnabled: true, - prevOffRamp: address(s_prevOffRamp) - }); - sourceChainConfigs[1] = EVM2EVMMultiOffRamp.SourceChainConfigArgs({ - sourceChainSelector: SOURCE_CHAIN_SELECTOR_2, - onRamp: ON_RAMP_ADDRESS_2, - isEnabled: true, - prevOffRamp: address(s_nestedPrevOffRamps[1]) - }); - sourceChainConfigs[2] = EVM2EVMMultiOffRamp.SourceChainConfigArgs({ - sourceChainSelector: SOURCE_CHAIN_SELECTOR_3, - onRamp: ON_RAMP_ADDRESS_3, - isEnabled: true, - prevOffRamp: address(0) - }); - - _setupMultipleOffRampsFromConfigs(sourceChainConfigs); - - s_offRamp.setVerifyOverrideResult(SOURCE_CHAIN_SELECTOR_1, 1); - s_offRamp.setVerifyOverrideResult(SOURCE_CHAIN_SELECTOR_3, 1); - } - - function test_Upgraded_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); - vm.expectEmit(); - emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, - Internal.MessageExecutionState.SUCCESS, - "" - ); - - s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); - } - - function test_NoPrevOffRampForChain_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); - messages[0].messageId = Internal._hash(messages[0], s_prevOffRamp.metadataHash()); - uint64 startNonceChain3 = s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_3, messages[0].sender); - s_prevOffRamp.execute(_generateSingleRampReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); - - // Nonce unchanged for chain 3 - assertEq(startNonceChain3, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_3, messages[0].sender)); - - Internal.EVM2EVMMessage[] memory messagesChain3 = - _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_3, ON_RAMP_ADDRESS_3); - vm.expectEmit(); - emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - SOURCE_CHAIN_SELECTOR_3, - messagesChain3[0].sequenceNumber, - messagesChain3[0].messageId, - Internal.MessageExecutionState.SUCCESS, - "" - ); - - s_offRamp.executeSingleReport( - _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_3, messagesChain3), new uint256[](0) - ); - assertEq(startNonceChain3 + 1, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_3, messagesChain3[0].sender)); - } - - function test_UpgradedSenderNoncesReadsPreviousRamp_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); - messages[0].messageId = Internal._hash(messages[0], s_prevOffRamp.metadataHash()); - uint64 startNonce = s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender); - - for (uint64 i = 1; i < 4; ++i) { - s_prevOffRamp.execute(_generateSingleRampReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); - - // messages contains a single message - update for the next execution - messages[0].nonce++; - messages[0].sequenceNumber++; - messages[0].messageId = Internal._hash(messages[0], s_prevOffRamp.metadataHash()); - - assertEq(startNonce + i, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); - } - } - - function test_UpgradedSenderNoncesReadsPreviousRampTransitive_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_2, ON_RAMP_ADDRESS_2); - messages[0].messageId = Internal._hash(messages[0], s_nestedPrevOffRamps[0].metadataHash()); - uint64 startNonce = s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_2, messages[0].sender); - - for (uint64 i = 1; i < 4; ++i) { - s_nestedPrevOffRamps[0].execute( - _generateSingleRampReportFromMessages(SOURCE_CHAIN_SELECTOR_2, messages), new uint256[](0) - ); - - // messages contains a single message - update for the next execution - messages[0].nonce++; - messages[0].sequenceNumber++; - messages[0].messageId = Internal._hash(messages[0], s_nestedPrevOffRamps[0].metadataHash()); - - // Read through prev sender nonce through prevOffRamp -> prevPrevOffRamp - assertEq(startNonce + i, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_2, messages[0].sender)); - } - } - - function test_UpgradedNonceStartsAtV1Nonce_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); - messages[0].messageId = Internal._hash(messages[0], s_prevOffRamp.metadataHash()); - - uint64 startNonce = s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender); - s_prevOffRamp.execute(_generateSingleRampReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); - - assertEq(startNonce + 1, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); - - messages[0].nonce++; - messages[0].messageId = Internal._hash(messages[0]); - - vm.expectEmit(); - emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, - Internal.MessageExecutionState.SUCCESS, - "" - ); - - s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); - assertEq(startNonce + 2, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); - - messages[0].nonce++; - messages[0].sequenceNumber++; - messages[0].messageId = Internal._hash(messages[0]); - - vm.expectEmit(); - emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, - Internal.MessageExecutionState.SUCCESS, - "" - ); - - s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); - assertEq(startNonce + 3, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); - } - - function test_UpgradedNonceNewSenderStartsAtZero_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); - messages[0].messageId = Internal._hash(messages[0], s_prevOffRamp.metadataHash()); - - s_prevOffRamp.execute(_generateSingleRampReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); - - address newSender = address(1234567); - messages[0].sender = newSender; - messages[0].messageId = Internal._hash(messages[0]); - - vm.expectEmit(); - emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, - Internal.MessageExecutionState.SUCCESS, - "" - ); - - // new sender nonce in new offramp should go from 0 -> 1 - assertEq(s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, newSender), 0); - s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); - assertEq(s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, newSender), 1); - } - - function test_UpgradedOffRampNonceSkipsIfMsgInFlight_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); - - address newSender = address(1234567); - messages[0].sender = newSender; - messages[0].nonce = 2; - messages[0].messageId = Internal._hash(messages[0]); - - uint64 startNonce = s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender); - - // new offramp sees msg nonce higher than senderNonce - // it waits for previous offramp to execute - vm.expectEmit(); - emit EVM2EVMMultiOffRamp.SkippedSenderWithPreviousRampMessageInflight( - SOURCE_CHAIN_SELECTOR_1, messages[0].nonce, newSender - ); - s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); - assertEq(startNonce, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); - - messages[0].nonce = 1; - messages[0].messageId = Internal._hash(messages[0]); - - // previous offramp executes msg and increases nonce - messages[0].messageId = Internal._hash(messages[0], s_prevOffRamp.metadataHash()); - s_prevOffRamp.execute(_generateSingleRampReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); - assertEq(startNonce + 1, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); - - messages[0].nonce = 2; - messages[0].messageId = Internal._hash(messages[0]); - - // new offramp is able to execute - vm.expectEmit(); - emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, - Internal.MessageExecutionState.SUCCESS, - "" - ); - - s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); - assertEq(startNonce + 2, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); - } - - function test_UpgradedWithMultiRamp_Revert() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); - vm.expectEmit(); - emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, - Internal.MessageExecutionState.SUCCESS, - "" - ); - s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); - - address prevOffRamp = address(s_offRamp); - _deployOffRamp(s_destRouter, s_mockRMN); - - EVM2EVMMultiOffRamp.SourceChainConfigArgs[] memory sourceChainConfigs = - new EVM2EVMMultiOffRamp.SourceChainConfigArgs[](1); - sourceChainConfigs[0] = EVM2EVMMultiOffRamp.SourceChainConfigArgs({ - sourceChainSelector: SOURCE_CHAIN_SELECTOR_1, - onRamp: ON_RAMP_ADDRESS_1, - isEnabled: true, - prevOffRamp: address(prevOffRamp) - }); - _setupMultipleOffRampsFromConfigs(sourceChainConfigs); - - vm.expectRevert(); - s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender); - - vm.expectRevert(); - s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); - } -} +// TODO: revisit after NonceManager merge +// contract EVM2EVMMultiOffRamp_execute_upgrade is EVM2EVMMultiOffRampSetup { +// EVM2EVMOffRampHelper internal s_prevOffRamp; +// EVM2EVMOffRampHelper[] internal s_nestedPrevOffRamps; + +// function setUp() public virtual override { +// super.setUp(); + +// ICommitStore mockPrevCommitStore = new MockCommitStore(); +// s_prevOffRamp = _deploySingleLaneOffRamp( +// mockPrevCommitStore, s_destRouter, address(0), SOURCE_CHAIN_SELECTOR_1, address(bytes20(ON_RAMP_ADDRESS_1)) +// ); + +// s_nestedPrevOffRamps = new EVM2EVMOffRampHelper[](2); +// s_nestedPrevOffRamps[0] = _deploySingleLaneOffRamp( +// mockPrevCommitStore, s_destRouter, address(0), SOURCE_CHAIN_SELECTOR_2, address(bytes20(ON_RAMP_ADDRESS_2)) +// ); +// s_nestedPrevOffRamps[1] = _deploySingleLaneOffRamp( +// mockPrevCommitStore, +// s_destRouter, +// address(s_nestedPrevOffRamps[0]), +// SOURCE_CHAIN_SELECTOR_2, +// address(bytes20(ON_RAMP_ADDRESS_2)) +// ); + +// EVM2EVMMultiOffRamp.SourceChainConfigArgs[] memory sourceChainConfigs = +// new EVM2EVMMultiOffRamp.SourceChainConfigArgs[](3); +// sourceChainConfigs[0] = EVM2EVMMultiOffRamp.SourceChainConfigArgs({ +// sourceChainSelector: SOURCE_CHAIN_SELECTOR_1, +// onRamp: ON_RAMP_ADDRESS_1, +// isEnabled: true, +// prevOffRamp: address(s_prevOffRamp) +// }); +// sourceChainConfigs[1] = EVM2EVMMultiOffRamp.SourceChainConfigArgs({ +// sourceChainSelector: SOURCE_CHAIN_SELECTOR_2, +// onRamp: ON_RAMP_ADDRESS_2, +// isEnabled: true, +// prevOffRamp: address(s_nestedPrevOffRamps[1]) +// }); +// sourceChainConfigs[2] = EVM2EVMMultiOffRamp.SourceChainConfigArgs({ +// sourceChainSelector: SOURCE_CHAIN_SELECTOR_3, +// onRamp: ON_RAMP_ADDRESS_3, +// isEnabled: true, +// prevOffRamp: address(0) +// }); + +// _setupMultipleOffRampsFromConfigs(sourceChainConfigs); + +// s_offRamp.setVerifyOverrideResult(SOURCE_CHAIN_SELECTOR_1, 1); +// s_offRamp.setVerifyOverrideResult(SOURCE_CHAIN_SELECTOR_3, 1); +// } + +// function test_Upgraded_Success() public { +// Internal.Any2EVMRampMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); +// vm.expectEmit(); +// emit EVM2EVMMultiOffRamp.ExecutionStateChanged( +// SOURCE_CHAIN_SELECTOR_1, +// messages[0].header.sequenceNumber, +// messages[0].header.messageId, +// Internal.MessageExecutionState.SUCCESS, +// "" +// ); + +// s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); +// } + +// function test_NoPrevOffRampForChain_Success() public { +// Internal.Any2EVMRampMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); +// messages[0].header.messageId = Internal._hash(messages[0], s_prevOffRamp.metadataHash()); +// uint64 startNonceChain3 = s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_3, messages[0].sender); +// s_prevOffRamp.execute(_generateSingleRampReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); + +// // Nonce unchanged for chain 3 +// assertEq(startNonceChain3, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_3, messages[0].sender)); + +// Internal.Any2EVMRampMessage[] memory messagesChain3 = +// _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_3, ON_RAMP_ADDRESS_3); +// vm.expectEmit(); +// emit EVM2EVMMultiOffRamp.ExecutionStateChanged( +// SOURCE_CHAIN_SELECTOR_3, +// messagesChain3[0].sequenceNumber, +// messagesChain3[0].messageId, +// Internal.MessageExecutionState.SUCCESS, +// "" +// ); + +// s_offRamp.executeSingleReport( +// _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_3, messagesChain3), new uint256[](0) +// ); +// assertEq(startNonceChain3 + 1, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_3, messagesChain3[0].sender)); +// } + +// function test_UpgradedSenderNoncesReadsPreviousRamp_Success() public { +// Internal.Any2EVMRampMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); +// messages[0].header.messageId = Internal._hash(messages[0], s_prevOffRamp.metadataHash()); +// uint64 startNonce = s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender); + +// for (uint64 i = 1; i < 4; ++i) { +// s_prevOffRamp.execute(_generateSingleRampReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); + +// // messages contains a single message - update for the next execution +// messages[0].header.nonce++; +// messages[0].header.sequenceNumber++; +// messages[0].header.messageId = Internal._hash(messages[0], s_prevOffRamp.metadataHash()); + +// assertEq(startNonce + i, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); +// } +// } + +// function test_UpgradedSenderNoncesReadsPreviousRampTransitive_Success() public { +// Internal.Any2EVMRampMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_2, ON_RAMP_ADDRESS_2); +// messages[0].header.messageId = Internal._hash(messages[0], s_nestedPrevOffRamps[0].metadataHash()); +// uint64 startNonce = s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_2, messages[0].sender); + +// for (uint64 i = 1; i < 4; ++i) { +// s_nestedPrevOffRamps[0].execute( +// _generateSingleRampReportFromMessages(SOURCE_CHAIN_SELECTOR_2, messages), new uint256[](0) +// ); + +// // messages contains a single message - update for the next execution +// messages[0].header.nonce++; +// messages[0].header.sequenceNumber++; +// messages[0].header.messageId = Internal._hash(messages[0], s_nestedPrevOffRamps[0].metadataHash()); + +// // Read through prev sender nonce through prevOffRamp -> prevPrevOffRamp +// assertEq(startNonce + i, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_2, messages[0].sender)); +// } +// } + +// function test_UpgradedNonceStartsAtV1Nonce_Success() public { +// Internal.Any2EVMRampMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); +// messages[0].header.messageId = Internal._hash(messages[0], s_prevOffRamp.metadataHash()); + +// uint64 startNonce = s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender); +// s_prevOffRamp.execute(_generateSingleRampReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); + +// assertEq(startNonce + 1, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); + +// messages[0].header.nonce++; +// messages[0].header.messageId = Internal._hash(messages[0]); + +// vm.expectEmit(); +// emit EVM2EVMMultiOffRamp.ExecutionStateChanged( +// SOURCE_CHAIN_SELECTOR_1, +// messages[0].header.sequenceNumber, +// messages[0].header.messageId, +// Internal.MessageExecutionState.SUCCESS, +// "" +// ); + +// s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); +// assertEq(startNonce + 2, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); + +// messages[0].header.nonce++; +// messages[0].header.sequenceNumber++; +// messages[0].header.messageId = Internal._hash(messages[0]); + +// vm.expectEmit(); +// emit EVM2EVMMultiOffRamp.ExecutionStateChanged( +// SOURCE_CHAIN_SELECTOR_1, +// messages[0].header.sequenceNumber, +// messages[0].header.messageId, +// Internal.MessageExecutionState.SUCCESS, +// "" +// ); + +// s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); +// assertEq(startNonce + 3, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); +// } + +// function test_UpgradedNonceNewSenderStartsAtZero_Success() public { +// Internal.Any2EVMRampMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); +// messages[0].header.messageId = Internal._hash(messages[0], s_prevOffRamp.metadataHash()); + +// s_prevOffRamp.execute(_generateSingleRampReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); + +// address newSender = address(1234567); +// messages[0].sender = newSender; +// messages[0].header.messageId = Internal._hash(messages[0]); + +// vm.expectEmit(); +// emit EVM2EVMMultiOffRamp.ExecutionStateChanged( +// SOURCE_CHAIN_SELECTOR_1, +// messages[0].header.sequenceNumber, +// messages[0].header.messageId, +// Internal.MessageExecutionState.SUCCESS, +// "" +// ); + +// // new sender nonce in new offramp should go from 0 -> 1 +// assertEq(s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, newSender), 0); +// s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); +// assertEq(s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, newSender), 1); +// } + +// function test_UpgradedOffRampNonceSkipsIfMsgInFlight_Success() public { +// Internal.Any2EVMRampMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + +// address newSender = address(1234567); +// messages[0].sender = newSender; +// messages[0].header.nonce = 2; +// messages[0].header.messageId = Internal._hash(messages[0]); + +// uint64 startNonce = s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender); + +// // new offramp sees msg nonce higher than senderNonce +// // it waits for previous offramp to execute +// vm.expectEmit(); +// emit EVM2EVMMultiOffRamp.SkippedSenderWithPreviousRampMessageInflight( +// SOURCE_CHAIN_SELECTOR_1, messages[0].header.nonce, newSender +// ); +// s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); +// assertEq(startNonce, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); + +// messages[0].header.nonce = 1; +// messages[0].header.messageId = Internal._hash(messages[0]); + +// // previous offramp executes msg and increases nonce +// messages[0].header.messageId = Internal._hash(messages[0], s_prevOffRamp.metadataHash()); +// s_prevOffRamp.execute(_generateSingleRampReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); +// assertEq(startNonce + 1, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); + +// messages[0].header.nonce = 2; +// messages[0].header.messageId = Internal._hash(messages[0]); + +// // new offramp is able to execute +// vm.expectEmit(); +// emit EVM2EVMMultiOffRamp.ExecutionStateChanged( +// SOURCE_CHAIN_SELECTOR_1, +// messages[0].header.sequenceNumber, +// messages[0].header.messageId, +// Internal.MessageExecutionState.SUCCESS, +// "" +// ); + +// s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); +// assertEq(startNonce + 2, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); +// } + +// function test_UpgradedWithMultiRamp_Revert() public { +// Internal.Any2EVMRampMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); +// vm.expectEmit(); +// emit EVM2EVMMultiOffRamp.ExecutionStateChanged( +// SOURCE_CHAIN_SELECTOR_1, +// messages[0].header.sequenceNumber, +// messages[0].header.messageId, +// Internal.MessageExecutionState.SUCCESS, +// "" +// ); +// s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); + +// address prevOffRamp = address(s_offRamp); +// _deployOffRamp(s_destRouter, s_mockRMN); + +// EVM2EVMMultiOffRamp.SourceChainConfigArgs[] memory sourceChainConfigs = +// new EVM2EVMMultiOffRamp.SourceChainConfigArgs[](1); +// sourceChainConfigs[0] = EVM2EVMMultiOffRamp.SourceChainConfigArgs({ +// sourceChainSelector: SOURCE_CHAIN_SELECTOR_1, +// onRamp: ON_RAMP_ADDRESS_1, +// isEnabled: true, +// prevOffRamp: address(prevOffRamp) +// }); +// _setupMultipleOffRampsFromConfigs(sourceChainConfigs); + +// vm.expectRevert(); +// s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender); + +// vm.expectRevert(); +// s_offRamp.executeSingleReport(_generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[](0)); +// } +// } contract EVM2EVMMultiOffRamp_executeSingleMessage is EVM2EVMMultiOffRampSetup { function setUp() public virtual override { @@ -1203,13 +1226,14 @@ contract EVM2EVMMultiOffRamp_executeSingleMessage is EVM2EVMMultiOffRampSetup { } function test_executeSingleMessage_NoTokens_Success() public { - Internal.EVM2EVMMessage memory message = + Internal.Any2EVMRampMessage memory message = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1); s_offRamp.executeSingleMessage(message, new bytes[](message.tokenAmounts.length)); } function test_executeSingleMessage_WithTokens_Success() public { - Internal.EVM2EVMMessage memory message = _generateMessagesWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1)[0]; + Internal.Any2EVMRampMessage memory message = + _generateMessagesWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1)[0]; bytes[] memory offchainTokenData = new bytes[](message.tokenAmounts.length); Internal.SourceTokenData memory sourceTokenData = abi.decode(message.sourceTokenData[0], (Internal.SourceTokenData)); @@ -1238,13 +1262,13 @@ contract EVM2EVMMultiOffRamp_executeSingleMessage is EVM2EVMMultiOffRampSetup { vm.startPrank(OWNER); _enableInboundMessageValidator(); vm.startPrank(address(s_offRamp)); - Internal.EVM2EVMMessage memory message = + Internal.Any2EVMRampMessage memory message = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1); s_offRamp.executeSingleMessage(message, new bytes[](message.tokenAmounts.length)); } function test_NonContract_Success() public { - Internal.EVM2EVMMessage memory message = + Internal.Any2EVMRampMessage memory message = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1); message.receiver = STRANGER; s_offRamp.executeSingleMessage(message, new bytes[](message.tokenAmounts.length)); @@ -1258,7 +1282,7 @@ contract EVM2EVMMultiOffRamp_executeSingleMessage is EVM2EVMMultiOffRampSetup { emit TokenPool.Released(address(s_offRamp), STRANGER, amounts[0]); vm.expectEmit(); emit TokenPool.Minted(address(s_offRamp), STRANGER, amounts[1]); - Internal.EVM2EVMMessage memory message = + Internal.Any2EVMRampMessage memory message = _generateAny2EVMMessageWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1, amounts); message.receiver = STRANGER; s_offRamp.executeSingleMessage(message, new bytes[](message.tokenAmounts.length)); @@ -1273,7 +1297,7 @@ contract EVM2EVMMultiOffRamp_executeSingleMessage is EVM2EVMMultiOffRampSetup { bytes memory errorMessage = "Random token pool issue"; - Internal.EVM2EVMMessage memory message = + Internal.Any2EVMRampMessage memory message = _generateAny2EVMMessageWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1, amounts); s_maybeRevertingPool.setShouldRevert(errorMessage); @@ -1283,7 +1307,7 @@ contract EVM2EVMMultiOffRamp_executeSingleMessage is EVM2EVMMultiOffRampSetup { } function test_ZeroGasDONExecution_Revert() public { - Internal.EVM2EVMMessage memory message = + Internal.Any2EVMRampMessage memory message = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1); message.gasLimit = 0; @@ -1294,7 +1318,7 @@ contract EVM2EVMMultiOffRamp_executeSingleMessage is EVM2EVMMultiOffRampSetup { function test_MessageSender_Revert() public { vm.stopPrank(); - Internal.EVM2EVMMessage memory message = + Internal.Any2EVMRampMessage memory message = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1); vm.expectRevert(EVM2EVMMultiOffRamp.CanOnlySelfCall.selector); s_offRamp.executeSingleMessage(message, new bytes[](message.tokenAmounts.length)); @@ -1305,9 +1329,9 @@ contract EVM2EVMMultiOffRamp_executeSingleMessage is EVM2EVMMultiOffRampSetup { vm.startPrank(OWNER); _enableInboundMessageValidator(); vm.startPrank(address(s_offRamp)); - Internal.EVM2EVMMessage memory message = + Internal.Any2EVMRampMessage memory message = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1); - s_inboundMessageValidator.setMessageIdValidationState(message.messageId, true); + s_inboundMessageValidator.setMessageIdValidationState(message.header.messageId, true); vm.expectRevert( abi.encodeWithSelector( IMessageInterceptor.MessageValidationError.selector, @@ -1323,15 +1347,15 @@ contract EVM2EVMMultiOffRamp_executeSingleMessage is EVM2EVMMultiOffRampSetup { _enableInboundMessageValidator(); vm.startPrank(address(s_offRamp)); - Internal.EVM2EVMMessage memory message = + Internal.Any2EVMRampMessage memory message = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1); // Setup the receiver to a non-CCIP Receiver, which will skip the Router call (but should still perform the validation) MaybeRevertMessageReceiverNo165 newReceiver = new MaybeRevertMessageReceiverNo165(true); message.receiver = address(newReceiver); - message.messageId = Internal._hash(message); + message.header.messageId = Internal._hash(message); - s_inboundMessageValidator.setMessageIdValidationState(message.messageId, true); + s_inboundMessageValidator.setMessageIdValidationState(message.header.messageId, true); vm.expectRevert( abi.encodeWithSelector( IMessageInterceptor.MessageValidationError.selector, @@ -1351,12 +1375,13 @@ contract EVM2EVMMultiOffRamp_batchExecute is EVM2EVMMultiOffRampSetup { } function test_SingleReport_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages[0].sourceChainSelector, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sourceChainSelector, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -1368,8 +1393,8 @@ contract EVM2EVMMultiOffRamp_batchExecute is EVM2EVMMultiOffRampSetup { } function test_MultipleReportsSameChain_Success() public { - Internal.EVM2EVMMessage[] memory messages1 = new Internal.EVM2EVMMessage[](2); - Internal.EVM2EVMMessage[] memory messages2 = new Internal.EVM2EVMMessage[](1); + Internal.Any2EVMRampMessage[] memory messages1 = new Internal.Any2EVMRampMessage[](2); + Internal.Any2EVMRampMessage[] memory messages2 = new Internal.Any2EVMRampMessage[](1); messages1[0] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1); messages1[1] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 2); @@ -1381,27 +1406,27 @@ contract EVM2EVMMultiOffRamp_batchExecute is EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages1[0].sourceChainSelector, - messages1[0].sequenceNumber, - messages1[0].messageId, + messages1[0].header.sourceChainSelector, + messages1[0].header.sequenceNumber, + messages1[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages1[1].sourceChainSelector, - messages1[1].sequenceNumber, - messages1[1].messageId, + messages1[1].header.sourceChainSelector, + messages1[1].header.sequenceNumber, + messages1[1].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages2[0].sourceChainSelector, - messages2[0].sequenceNumber, - messages2[0].messageId, + messages2[0].header.sourceChainSelector, + messages2[0].header.sequenceNumber, + messages2[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -1412,8 +1437,8 @@ contract EVM2EVMMultiOffRamp_batchExecute is EVM2EVMMultiOffRampSetup { } function test_MultipleReportsDifferentChains_Success() public { - Internal.EVM2EVMMessage[] memory messages1 = new Internal.EVM2EVMMessage[](2); - Internal.EVM2EVMMessage[] memory messages2 = new Internal.EVM2EVMMessage[](1); + Internal.Any2EVMRampMessage[] memory messages1 = new Internal.Any2EVMRampMessage[](2); + Internal.Any2EVMRampMessage[] memory messages2 = new Internal.Any2EVMRampMessage[](1); messages1[0] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1); messages1[1] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 2); @@ -1425,27 +1450,27 @@ contract EVM2EVMMultiOffRamp_batchExecute is EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages1[0].sourceChainSelector, - messages1[0].sequenceNumber, - messages1[0].messageId, + messages1[0].header.sourceChainSelector, + messages1[0].header.sequenceNumber, + messages1[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages1[1].sourceChainSelector, - messages1[1].sequenceNumber, - messages1[1].messageId, + messages1[1].header.sourceChainSelector, + messages1[1].header.sequenceNumber, + messages1[1].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages2[0].sourceChainSelector, - messages2[0].sequenceNumber, - messages2[0].messageId, + messages2[0].header.sourceChainSelector, + messages2[0].header.sequenceNumber, + messages2[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -1461,7 +1486,8 @@ contract EVM2EVMMultiOffRamp_batchExecute is EVM2EVMMultiOffRampSetup { } function test_MultipleReportsSkipDuplicate_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); Internal.ExecutionReportSingleChain[] memory reports = new Internal.ExecutionReportSingleChain[](2); reports[0] = _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages); @@ -1469,15 +1495,15 @@ contract EVM2EVMMultiOffRamp_batchExecute is EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages[0].sourceChainSelector, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sourceChainSelector, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); vm.expectEmit(); - emit EVM2EVMMultiOffRamp.SkippedAlreadyExecutedMessage(SOURCE_CHAIN_SELECTOR_1, messages[0].sequenceNumber); + emit EVM2EVMMultiOffRamp.SkippedAlreadyExecutedMessage(SOURCE_CHAIN_SELECTOR_1, messages[0].header.sequenceNumber); s_offRamp.batchExecute(reports, new uint256[][](2)); } @@ -1510,8 +1536,8 @@ contract EVM2EVMMultiOffRamp_batchExecute is EVM2EVMMultiOffRampSetup { } function test_OutOfBoundsGasLimitsAccess_Revert() public { - Internal.EVM2EVMMessage[] memory messages1 = new Internal.EVM2EVMMessage[](2); - Internal.EVM2EVMMessage[] memory messages2 = new Internal.EVM2EVMMessage[](1); + Internal.Any2EVMRampMessage[] memory messages1 = new Internal.Any2EVMRampMessage[](2); + Internal.Any2EVMRampMessage[] memory messages2 = new Internal.Any2EVMRampMessage[](1); messages1[0] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1); messages1[1] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 2); @@ -1536,9 +1562,10 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { } function test_manuallyExecute_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); messages[0].receiver = address(s_reverting_receiver); - messages[0].messageId = Internal._hash(messages[0]); + messages[0].header.messageId = Internal._hash(messages[0]); s_offRamp.batchExecute(_generateBatchReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[][](1)); s_reverting_receiver.setRevert(false); @@ -1546,8 +1573,8 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -1558,9 +1585,10 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { } function test_manuallyExecute_WithGasOverride_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); messages[0].receiver = address(s_reverting_receiver); - messages[0].messageId = Internal._hash(messages[0]); + messages[0].header.messageId = Internal._hash(messages[0]); s_offRamp.batchExecute(_generateBatchReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[][](1)); s_reverting_receiver.setRevert(false); @@ -1568,8 +1596,8 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -1582,19 +1610,20 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { } function test_manuallyExecute_DoesNotRevertIfUntouched_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); messages[0].receiver = address(s_reverting_receiver); - messages[0].messageId = Internal._hash(messages[0]); + messages[0].header.messageId = Internal._hash(messages[0]); - assertEq(messages[0].nonce - 1, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); + assertEq(messages[0].header.nonce - 1, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); s_reverting_receiver.setRevert(true); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.FAILURE, abi.encodeWithSelector( EVM2EVMMultiOffRamp.ReceiverError.selector, @@ -1607,23 +1636,23 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { s_offRamp.manuallyExecute(_generateBatchReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), gasLimitOverrides); - assertEq(messages[0].nonce, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); + assertEq(messages[0].header.nonce, s_offRamp.getSenderNonce(SOURCE_CHAIN_SELECTOR_1, messages[0].sender)); } function test_manuallyExecute_WithMultiReportGasOverride_Success() public { - Internal.EVM2EVMMessage[] memory messages1 = new Internal.EVM2EVMMessage[](3); - Internal.EVM2EVMMessage[] memory messages2 = new Internal.EVM2EVMMessage[](2); + Internal.Any2EVMRampMessage[] memory messages1 = new Internal.Any2EVMRampMessage[](3); + Internal.Any2EVMRampMessage[] memory messages2 = new Internal.Any2EVMRampMessage[](2); for (uint64 i = 0; i < 3; ++i) { messages1[i] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, i + 1); messages1[i].receiver = address(s_reverting_receiver); - messages1[i].messageId = Internal._hash(messages1[i]); + messages1[i].header.messageId = Internal._hash(messages1[i]); } for (uint64 i = 0; i < 2; ++i) { messages2[i] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_3, ON_RAMP_ADDRESS_3, i + 1); messages2[i].receiver = address(s_reverting_receiver); - messages2[i].messageId = Internal._hash(messages2[i]); + messages2[i].header.messageId = Internal._hash(messages2[i]); } Internal.ExecutionReportSingleChain[] memory reports = new Internal.ExecutionReportSingleChain[](2); @@ -1642,8 +1671,8 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages1[i].sequenceNumber, - messages1[i].messageId, + messages1[i].header.sequenceNumber, + messages1[i].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -1655,8 +1684,8 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_3, - messages2[i].sequenceNumber, - messages2[i].messageId, + messages2[i].header.sequenceNumber, + messages2[i].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -1668,19 +1697,19 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { } function test_manuallyExecute_WithPartialMessages_Success() public { - Internal.EVM2EVMMessage[] memory messages = new Internal.EVM2EVMMessage[](3); + Internal.Any2EVMRampMessage[] memory messages = new Internal.Any2EVMRampMessage[](3); for (uint64 i = 0; i < 3; ++i) { messages[i] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, i + 1); } messages[1].receiver = address(s_reverting_receiver); - messages[1].messageId = Internal._hash(messages[1]); + messages[1].header.messageId = Internal._hash(messages[1]); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -1688,8 +1717,8 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages[1].sequenceNumber, - messages[1].messageId, + messages[1].header.sequenceNumber, + messages[1].header.messageId, Internal.MessageExecutionState.FAILURE, abi.encodeWithSelector( EVM2EVMMultiOffRamp.ReceiverError.selector, @@ -1700,8 +1729,8 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages[2].sequenceNumber, - messages[2].messageId, + messages[2].header.sequenceNumber, + messages[2].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -1711,7 +1740,7 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { s_reverting_receiver.setRevert(false); // Only the 2nd message reverted - Internal.EVM2EVMMessage[] memory newMessages = new Internal.EVM2EVMMessage[](1); + Internal.Any2EVMRampMessage[] memory newMessages = new Internal.Any2EVMRampMessage[](1); newMessages[0] = messages[1]; uint256[][] memory gasLimitOverrides = new uint256[][](1); @@ -1721,8 +1750,8 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - newMessages[0].sequenceNumber, - newMessages[0].messageId, + newMessages[0].header.sequenceNumber, + newMessages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -1731,16 +1760,17 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { } function test_manuallyExecute_LowGasLimit_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); messages[0].gasLimit = 1; messages[0].receiver = address(new ConformingReceiver(address(s_destRouter), s_destFeeToken)); - messages[0].messageId = Internal._hash(messages[0]); + messages[0].header.messageId = Internal._hash(messages[0]); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.FAILURE, abi.encodeWithSelector(EVM2EVMMultiOffRamp.ReceiverError.selector, "") ); @@ -1756,8 +1786,8 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -1767,7 +1797,8 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { // Reverts function test_manuallyExecute_ForkedChain_Revert() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); Internal.ExecutionReportSingleChain[] memory reports = _generateBatchReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages); @@ -1783,7 +1814,7 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { } function test_ManualExecGasLimitMismatchSingleReport_Revert() public { - Internal.EVM2EVMMessage[] memory messages = new Internal.EVM2EVMMessage[](2); + Internal.Any2EVMRampMessage[] memory messages = new Internal.Any2EVMRampMessage[](2); messages[0] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1); messages[1] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 2); @@ -1814,8 +1845,8 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { } function test_manuallyExecute_GasLimitMismatchMultipleReports_Revert() public { - Internal.EVM2EVMMessage[] memory messages1 = new Internal.EVM2EVMMessage[](2); - Internal.EVM2EVMMessage[] memory messages2 = new Internal.EVM2EVMMessage[](1); + Internal.Any2EVMRampMessage[] memory messages1 = new Internal.Any2EVMRampMessage[](2); + Internal.Any2EVMRampMessage[] memory messages2 = new Internal.Any2EVMRampMessage[](1); messages1[0] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1); messages1[1] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 2); @@ -1857,7 +1888,8 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { } function test_ManualExecInvalidGasLimit_Revert() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); uint256[][] memory gasLimitOverrides = new uint256[][](1); gasLimitOverrides[0] = _getGasLimitsFromMessages(messages); @@ -1872,10 +1904,11 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { } function test_manuallyExecute_FailedTx_Revert() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); messages[0].receiver = address(s_reverting_receiver); - messages[0].messageId = Internal._hash(messages[0]); + messages[0].header.messageId = Internal._hash(messages[0]); s_offRamp.batchExecute(_generateBatchReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages), new uint256[][](1)); @@ -1887,7 +1920,7 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { vm.expectRevert( abi.encodeWithSelector( EVM2EVMMultiOffRamp.ExecutionError.selector, - messages[0].messageId, + messages[0].header.messageId, abi.encodeWithSelector( EVM2EVMMultiOffRamp.ReceiverError.selector, abi.encodeWithSelector(MaybeRevertMessageReceiver.CustomError.selector, bytes("")) @@ -1909,10 +1942,10 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { // For this test any message will be flagged as correct by the // commitStore. In a real scenario the abuser would have to actually // send the message that they want to replay. - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); messages[0].tokenAmounts = new Client.EVMTokenAmount[](1); messages[0].tokenAmounts[0] = Client.EVMTokenAmount({token: s_sourceFeeToken, amount: tokenAmount}); - messages[0].receiver = address(receiver); messages[0].sourceTokenData = new bytes[](1); messages[0].sourceTokenData[0] = abi.encode( Internal.SourceTokenData({ @@ -1922,7 +1955,9 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { }) ); - messages[0].messageId = Internal._hash(messages[0]); + messages[0].receiver = address(receiver); + + messages[0].header.messageId = Internal._hash(messages[0]); Internal.ExecutionReportSingleChain memory report = _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages); @@ -1937,14 +1972,16 @@ contract EVM2EVMMultiOffRamp_manuallyExecute is EVM2EVMMultiOffRampSetup { // This means the first tx is marked `FAILURE` with the error message of the second tx. vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages[0].sourceChainSelector, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sourceChainSelector, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.FAILURE, abi.encodeWithSelector( EVM2EVMMultiOffRamp.ReceiverError.selector, abi.encodeWithSelector( - EVM2EVMMultiOffRamp.AlreadyExecuted.selector, messages[0].sourceChainSelector, messages[0].sequenceNumber + EVM2EVMMultiOffRamp.AlreadyExecuted.selector, + messages[0].header.sourceChainSelector, + messages[0].header.sequenceNumber ) ) ); @@ -1965,15 +2002,16 @@ contract EVM2EVMMultiOffRamp_execute is EVM2EVMMultiOffRampSetup { // Asserts that execute completes function test_SingleReport_Success() public { - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); Internal.ExecutionReportSingleChain[] memory reports = _generateBatchReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( SOURCE_CHAIN_SELECTOR_1, - messages[0].sequenceNumber, - messages[0].messageId, + messages[0].header.sequenceNumber, + messages[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -1987,8 +2025,8 @@ contract EVM2EVMMultiOffRamp_execute is EVM2EVMMultiOffRampSetup { } function test_MultipleReports_Success() public { - Internal.EVM2EVMMessage[] memory messages1 = new Internal.EVM2EVMMessage[](2); - Internal.EVM2EVMMessage[] memory messages2 = new Internal.EVM2EVMMessage[](1); + Internal.Any2EVMRampMessage[] memory messages1 = new Internal.Any2EVMRampMessage[](2); + Internal.Any2EVMRampMessage[] memory messages2 = new Internal.Any2EVMRampMessage[](1); messages1[0] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1); messages1[1] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 2); @@ -2000,27 +2038,27 @@ contract EVM2EVMMultiOffRamp_execute is EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages1[0].sourceChainSelector, - messages1[0].sequenceNumber, - messages1[0].messageId, + messages1[0].header.sourceChainSelector, + messages1[0].header.sequenceNumber, + messages1[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages1[1].sourceChainSelector, - messages1[1].sequenceNumber, - messages1[1].messageId, + messages1[1].header.sourceChainSelector, + messages1[1].header.sequenceNumber, + messages1[1].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages2[0].sourceChainSelector, - messages2[0].sequenceNumber, - messages2[0].messageId, + messages2[0].header.sourceChainSelector, + messages2[0].header.sequenceNumber, + messages2[0].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -2036,7 +2074,7 @@ contract EVM2EVMMultiOffRamp_execute is EVM2EVMMultiOffRampSetup { function test_LargeBatch_Success() public { Internal.ExecutionReportSingleChain[] memory reports = new Internal.ExecutionReportSingleChain[](10); for (uint64 i = 0; i < reports.length; ++i) { - Internal.EVM2EVMMessage[] memory messages = new Internal.EVM2EVMMessage[](3); + Internal.Any2EVMRampMessage[] memory messages = new Internal.Any2EVMRampMessage[](3); messages[0] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1 + i * 3); messages[1] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 2 + i * 3); messages[2] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 3 + i * 3); @@ -2048,9 +2086,9 @@ contract EVM2EVMMultiOffRamp_execute is EVM2EVMMultiOffRampSetup { for (uint64 j = 0; j < reports[i].messages.length; ++j) { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - reports[i].messages[j].sourceChainSelector, - reports[i].messages[j].sequenceNumber, - reports[i].messages[j].messageId, + reports[i].messages[j].header.sourceChainSelector, + reports[i].messages[j].header.sequenceNumber, + reports[i].messages[j].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); @@ -2068,8 +2106,8 @@ contract EVM2EVMMultiOffRamp_execute is EVM2EVMMultiOffRampSetup { function test_MultipleReportsWithPartialValidationFailures_Success() public { _enableInboundMessageValidator(); - Internal.EVM2EVMMessage[] memory messages1 = new Internal.EVM2EVMMessage[](2); - Internal.EVM2EVMMessage[] memory messages2 = new Internal.EVM2EVMMessage[](1); + Internal.Any2EVMRampMessage[] memory messages1 = new Internal.Any2EVMRampMessage[](2); + Internal.Any2EVMRampMessage[] memory messages2 = new Internal.Any2EVMRampMessage[](1); messages1[0] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1); messages1[1] = _generateAny2EVMMessageNoTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 2); @@ -2079,14 +2117,14 @@ contract EVM2EVMMultiOffRamp_execute is EVM2EVMMultiOffRampSetup { reports[0] = _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages1); reports[1] = _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages2); - s_inboundMessageValidator.setMessageIdValidationState(messages1[0].messageId, true); - s_inboundMessageValidator.setMessageIdValidationState(messages2[0].messageId, true); + s_inboundMessageValidator.setMessageIdValidationState(messages1[0].header.messageId, true); + s_inboundMessageValidator.setMessageIdValidationState(messages2[0].header.messageId, true); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages1[0].sourceChainSelector, - messages1[0].sequenceNumber, - messages1[0].messageId, + messages1[0].header.sourceChainSelector, + messages1[0].header.sequenceNumber, + messages1[0].header.messageId, Internal.MessageExecutionState.FAILURE, abi.encodeWithSelector( IMessageInterceptor.MessageValidationError.selector, @@ -2096,18 +2134,18 @@ contract EVM2EVMMultiOffRamp_execute is EVM2EVMMultiOffRampSetup { vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages1[1].sourceChainSelector, - messages1[1].sequenceNumber, - messages1[1].messageId, + messages1[1].header.sourceChainSelector, + messages1[1].header.sequenceNumber, + messages1[1].header.messageId, Internal.MessageExecutionState.SUCCESS, "" ); vm.expectEmit(); emit EVM2EVMMultiOffRamp.ExecutionStateChanged( - messages2[0].sourceChainSelector, - messages2[0].sequenceNumber, - messages2[0].messageId, + messages2[0].header.sourceChainSelector, + messages2[0].header.sequenceNumber, + messages2[0].header.messageId, Internal.MessageExecutionState.FAILURE, abi.encodeWithSelector( IMessageInterceptor.MessageValidationError.selector, @@ -2128,7 +2166,8 @@ contract EVM2EVMMultiOffRamp_execute is EVM2EVMMultiOffRampSetup { function test_UnauthorizedTransmitter_Revert() public { bytes32[3] memory reportContext = [s_configDigestExec, s_configDigestExec, s_configDigestExec]; - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); Internal.ExecutionReportSingleChain[] memory reports = _generateBatchReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages); @@ -2140,7 +2179,8 @@ contract EVM2EVMMultiOffRamp_execute is EVM2EVMMultiOffRampSetup { _redeployOffRampWithNoOCRConfigs(); s_offRamp.setVerifyOverrideResult(SOURCE_CHAIN_SELECTOR_1, 1); - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); Internal.ExecutionReportSingleChain[] memory reports = _generateBatchReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages); @@ -2166,7 +2206,8 @@ contract EVM2EVMMultiOffRamp_execute is EVM2EVMMultiOffRampSetup { }); s_offRamp.setOCR3Configs(ocrConfigs); - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); Internal.ExecutionReportSingleChain[] memory reports = _generateBatchReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages); @@ -2194,7 +2235,8 @@ contract EVM2EVMMultiOffRamp_execute is EVM2EVMMultiOffRampSetup { }); s_offRamp.setOCR3Configs(ocrConfigs); - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); Internal.ExecutionReportSingleChain[] memory reports = _generateBatchReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages); @@ -2223,7 +2265,8 @@ contract EVM2EVMMultiOffRamp_execute is EVM2EVMMultiOffRampSetup { function test_NonArray_Revert() public { bytes32[3] memory reportContext = [s_configDigestExec, s_configDigestExec, s_configDigestExec]; - Internal.EVM2EVMMessage[] memory messages = _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); + Internal.Any2EVMRampMessage[] memory messages = + _generateSingleBasicMessage(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1); Internal.ExecutionReportSingleChain memory report = _generateReportFromMessages(SOURCE_CHAIN_SELECTOR_1, messages); vm.startPrank(s_validTransmitters[0]); @@ -2395,7 +2438,7 @@ contract EVM2EVMMultiOffRamp_trialExecute is EVM2EVMMultiOffRampSetup { amounts[0] = 1000; amounts[1] = 50; - Internal.EVM2EVMMessage memory message = + Internal.Any2EVMRampMessage memory message = _generateAny2EVMMessageWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1, amounts); IERC20 dstToken0 = IERC20(s_destTokens[0]); uint256 startingBalance = dstToken0.balanceOf(message.receiver); @@ -2419,7 +2462,7 @@ contract EVM2EVMMultiOffRamp_trialExecute is EVM2EVMMultiOffRampSetup { bytes memory errorMessage = "Random token pool issue"; - Internal.EVM2EVMMessage memory message = + Internal.Any2EVMRampMessage memory message = _generateAny2EVMMessageWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1, amounts); s_maybeRevertingPool.setShouldRevert(errorMessage); @@ -2439,7 +2482,7 @@ contract EVM2EVMMultiOffRamp_trialExecute is EVM2EVMMultiOffRampSetup { bytes memory errorMessage = abi.encodeWithSelector(RateLimiter.BucketOverfilled.selector); - Internal.EVM2EVMMessage memory message = + Internal.Any2EVMRampMessage memory message = _generateAny2EVMMessageWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1, amounts); s_maybeRevertingPool.setShouldRevert(errorMessage); @@ -2453,7 +2496,7 @@ contract EVM2EVMMultiOffRamp_trialExecute is EVM2EVMMultiOffRampSetup { function test_TokenPoolIsNotAContract_Success() public { uint256[] memory amounts = new uint256[](2); amounts[0] = 10000; - Internal.EVM2EVMMessage memory message = + Internal.Any2EVMRampMessage memory message = _generateAny2EVMMessageWithTokens(SOURCE_CHAIN_SELECTOR_1, ON_RAMP_ADDRESS_1, 1, amounts); // Happy path, pool is correct @@ -2473,12 +2516,7 @@ contract EVM2EVMMultiOffRamp_trialExecute is EVM2EVMMultiOffRampSetup { }) ); - message.messageId = Internal._hash( - message, - keccak256( - abi.encode(Internal.EVM_2_EVM_MESSAGE_HASH, SOURCE_CHAIN_SELECTOR_1, DEST_CHAIN_SELECTOR, ON_RAMP_ADDRESS_1) - ) - ); + message.header.messageId = Internal._hash(message); // Unhappy path, no revert but marked as failed. (newState, err) = s_offRamp.trialExecute(message, new bytes[](message.tokenAmounts.length)); @@ -2496,12 +2534,7 @@ contract EVM2EVMMultiOffRamp_trialExecute is EVM2EVMMultiOffRampSetup { }) ); - message.messageId = Internal._hash( - message, - keccak256( - abi.encode(Internal.EVM_2_EVM_MESSAGE_HASH, SOURCE_CHAIN_SELECTOR_1, DEST_CHAIN_SELECTOR, ON_RAMP_ADDRESS_1) - ) - ); + message.header.messageId = Internal._hash(message); (newState, err) = s_offRamp.trialExecute(message, new bytes[](message.tokenAmounts.length)); diff --git a/contracts/src/v0.8/ccip/test/offRamp/EVM2EVMMultiOffRampSetup.t.sol b/contracts/src/v0.8/ccip/test/offRamp/EVM2EVMMultiOffRampSetup.t.sol index 2ffdf2f054..68be3a7f2b 100644 --- a/contracts/src/v0.8/ccip/test/offRamp/EVM2EVMMultiOffRampSetup.t.sol +++ b/contracts/src/v0.8/ccip/test/offRamp/EVM2EVMMultiOffRampSetup.t.sol @@ -234,7 +234,7 @@ contract EVM2EVMMultiOffRampSetup is TokenSetup, PriceRegistrySetup, MultiOCR3Ba }); } - function _convertToGeneralMessage(Internal.EVM2EVMMessage memory original) + function _convertToGeneralMessage(Internal.Any2EVMRampMessage memory original) internal view returns (Client.Any2EVMMessage memory message) @@ -253,8 +253,8 @@ contract EVM2EVMMultiOffRampSetup is TokenSetup, PriceRegistrySetup, MultiOCR3Ba } return Client.Any2EVMMessage({ - messageId: original.messageId, - sourceChainSelector: original.sourceChainSelector, + messageId: original.header.messageId, + sourceChainSelector: original.header.sourceChainSelector, sender: abi.encode(original.sender), data: original.data, destTokenAmounts: destTokenAmounts @@ -265,7 +265,7 @@ contract EVM2EVMMultiOffRampSetup is TokenSetup, PriceRegistrySetup, MultiOCR3Ba uint64 sourceChainSelector, bytes memory onRamp, uint64 sequenceNumber - ) internal view returns (Internal.EVM2EVMMessage memory) { + ) internal view returns (Internal.Any2EVMRampMessage memory) { return _generateAny2EVMMessage(sourceChainSelector, onRamp, sequenceNumber, new Client.EVMTokenAmount[](0), false); } @@ -274,7 +274,7 @@ contract EVM2EVMMultiOffRampSetup is TokenSetup, PriceRegistrySetup, MultiOCR3Ba bytes memory onRamp, uint64 sequenceNumber, uint256[] memory amounts - ) internal view returns (Internal.EVM2EVMMessage memory) { + ) internal view returns (Internal.Any2EVMRampMessage memory) { Client.EVMTokenAmount[] memory tokenAmounts = getCastedSourceEVMTokenAmountsWithZeroAmounts(); for (uint256 i = 0; i < tokenAmounts.length; ++i) { tokenAmounts[i].amount = amounts[i]; @@ -289,22 +289,22 @@ contract EVM2EVMMultiOffRampSetup is TokenSetup, PriceRegistrySetup, MultiOCR3Ba uint64 sequenceNumber, Client.EVMTokenAmount[] memory tokenAmounts, bool allowOutOfOrderExecution - ) internal view returns (Internal.EVM2EVMMessage memory) { + ) internal view returns (Internal.Any2EVMRampMessage memory) { bytes memory data = abi.encode(0); - Internal.EVM2EVMMessage memory message = Internal.EVM2EVMMessage({ - sequenceNumber: sequenceNumber, - sender: OWNER, - nonce: allowOutOfOrderExecution ? 0 : sequenceNumber, - gasLimit: GAS_LIMIT, - strict: false, - sourceChainSelector: sourceChainSelector, - receiver: address(s_receiver), + Internal.Any2EVMRampMessage memory message = Internal.Any2EVMRampMessage({ + header: Internal.RampMessageHeader({ + messageId: "", + sourceChainSelector: sourceChainSelector, + destChainSelector: DEST_CHAIN_SELECTOR, + sequenceNumber: sequenceNumber, + nonce: allowOutOfOrderExecution ? 0 : sequenceNumber + }), + sender: abi.encode(OWNER), data: data, + receiver: address(s_receiver), tokenAmounts: tokenAmounts, sourceTokenData: new bytes[](tokenAmounts.length), - feeToken: s_destFeeToken, - feeTokenAmount: uint256(0), - messageId: "" + gasLimit: GAS_LIMIT }); // Correctly set the TokenDataPayload for each token. Tokens have to be set up in the TokenSetup. @@ -318,7 +318,7 @@ contract EVM2EVMMultiOffRampSetup is TokenSetup, PriceRegistrySetup, MultiOCR3Ba ); } - message.messageId = Internal._hash(message); + message.header.messageId = Internal._hash(message); return message; } @@ -326,8 +326,8 @@ contract EVM2EVMMultiOffRampSetup is TokenSetup, PriceRegistrySetup, MultiOCR3Ba function _generateSingleBasicMessage( uint64 sourceChainSelector, bytes memory onRamp - ) internal view returns (Internal.EVM2EVMMessage[] memory) { - Internal.EVM2EVMMessage[] memory messages = new Internal.EVM2EVMMessage[](1); + ) internal view returns (Internal.Any2EVMRampMessage[] memory) { + Internal.Any2EVMRampMessage[] memory messages = new Internal.Any2EVMRampMessage[](1); messages[0] = _generateAny2EVMMessageNoTokens(sourceChainSelector, onRamp, 1); return messages; } @@ -335,8 +335,8 @@ contract EVM2EVMMultiOffRampSetup is TokenSetup, PriceRegistrySetup, MultiOCR3Ba function _generateMessagesWithTokens( uint64 sourceChainSelector, bytes memory onRamp - ) internal view returns (Internal.EVM2EVMMessage[] memory) { - Internal.EVM2EVMMessage[] memory messages = new Internal.EVM2EVMMessage[](2); + ) internal view returns (Internal.Any2EVMRampMessage[] memory) { + Internal.Any2EVMRampMessage[] memory messages = new Internal.Any2EVMRampMessage[](2); Client.EVMTokenAmount[] memory tokenAmounts = getCastedSourceEVMTokenAmountsWithZeroAmounts(); tokenAmounts[0].amount = 1e18; tokenAmounts[1].amount = 5e18; @@ -346,24 +346,25 @@ contract EVM2EVMMultiOffRampSetup is TokenSetup, PriceRegistrySetup, MultiOCR3Ba return messages; } - function _generateSingleRampReportFromMessages( - uint64 sourceChainSelector, - Internal.EVM2EVMMessage[] memory messages - ) internal pure returns (Internal.ExecutionReport memory) { - Internal.ExecutionReportSingleChain memory singleChainReport = - _generateReportFromMessages(sourceChainSelector, messages); - - return Internal.ExecutionReport({ - proofs: singleChainReport.proofs, - proofFlagBits: singleChainReport.proofFlagBits, - messages: singleChainReport.messages, - offchainTokenData: singleChainReport.offchainTokenData - }); - } + // TODO: revisit after merging in NonceManager + // function _generateSingleRampReportFromMessages( + // uint64 sourceChainSelector, + // Internal.Any2EVMRampMessage[] memory messages + // ) internal pure returns (Internal.ExecutionReport memory) { + // Internal.ExecutionReportSingleChain memory singleChainReport = + // _generateReportFromMessages(sourceChainSelector, messages); + + // return Internal.ExecutionReport({ + // proofs: singleChainReport.proofs, + // proofFlagBits: singleChainReport.proofFlagBits, + // messages: singleChainReport.messages, + // offchainTokenData: singleChainReport.offchainTokenData + // }); + // } function _generateReportFromMessages( uint64 sourceChainSelector, - Internal.EVM2EVMMessage[] memory messages + Internal.Any2EVMRampMessage[] memory messages ) internal pure returns (Internal.ExecutionReportSingleChain memory) { bytes[][] memory offchainTokenData = new bytes[][](messages.length); @@ -382,14 +383,14 @@ contract EVM2EVMMultiOffRampSetup is TokenSetup, PriceRegistrySetup, MultiOCR3Ba function _generateBatchReportFromMessages( uint64 sourceChainSelector, - Internal.EVM2EVMMessage[] memory messages + Internal.Any2EVMRampMessage[] memory messages ) internal pure returns (Internal.ExecutionReportSingleChain[] memory) { Internal.ExecutionReportSingleChain[] memory reports = new Internal.ExecutionReportSingleChain[](1); reports[0] = _generateReportFromMessages(sourceChainSelector, messages); return reports; } - function _getGasLimitsFromMessages(Internal.EVM2EVMMessage[] memory messages) + function _getGasLimitsFromMessages(Internal.Any2EVMRampMessage[] memory messages) internal pure returns (uint256[] memory)