diff --git a/evm/src/NttManager/ManagerBase.sol b/evm/src/NttManager/ManagerBase.sol index 895208a90..3e6228df6 100644 --- a/evm/src/NttManager/ManagerBase.sol +++ b/evm/src/NttManager/ManagerBase.sol @@ -104,9 +104,10 @@ abstract contract ManagerBase is /// @inheritdoc IManagerBase function quoteDeliveryPrice( - uint16 recipientChain + uint16 recipientChain, + bytes memory transceiverInstructions ) public view returns (uint256) { - return endpoint.quoteDeliveryPrice(recipientChain); // TODO: Add in executor delivery price. + return endpoint.quoteDeliveryPrice(recipientChain, transceiverInstructions); } // =============== Internal Logic =========================================================== diff --git a/evm/src/NttManager/NttManager.sol b/evm/src/NttManager/NttManager.sol index 68a73a516..d978f24f1 100644 --- a/evm/src/NttManager/NttManager.sol +++ b/evm/src/NttManager/NttManager.sol @@ -185,10 +185,19 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { uint256 amount, uint16 recipientChain, bytes32 recipient, - bytes calldata executorQuote + bytes calldata executorQuote, + bytes calldata relayInstructions, + bytes calldata transceiverInstructions ) external payable nonReentrant whenNotPaused returns (uint64) { return _transferEntryPoint( - amount, recipientChain, recipient, recipient, false, executorQuote, new bytes(0) + amount, + recipientChain, + recipient, + recipient, + false, + executorQuote, + relayInstructions, + transceiverInstructions ); } @@ -200,7 +209,8 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { bytes32 refundAddress, bool shouldQueue, bytes calldata executorQuote, - bytes memory relayInstructions + bytes calldata relayInstructions, + bytes calldata transceiverInstructions ) external payable nonReentrant whenNotPaused returns (uint64) { return _transferEntryPoint( amount, @@ -209,7 +219,8 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { refundAddress, shouldQueue, executorQuote, - relayInstructions + relayInstructions, + transceiverInstructions ); } @@ -387,7 +398,8 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { queuedTransfer.refundAddress, queuedTransfer.sender, queuedTransfer.executorQuote, - queuedTransfer.relayInstructions + queuedTransfer.relayInstructions, + queuedTransfer.transceiverInstructions ); } @@ -424,7 +436,8 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { bytes32 refundAddress, bool shouldQueue, bytes memory executorQuote, - bytes memory relayInstructions + bytes memory relayInstructions, + bytes memory transceiverInstructions ) internal returns (uint64) { if (amount == 0) { revert ZeroAmount(); @@ -490,6 +503,7 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { shouldQueue, executorQuote, relayInstructions, + transceiverInstructions, trimmedAmount, sequence ); @@ -506,7 +520,8 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { refundAddress, msg.sender, executorQuote, - relayInstructions + relayInstructions, + transceiverInstructions ); } @@ -518,6 +533,7 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { bool shouldQueue, bytes memory executorQuote, bytes memory relayInstructions, + bytes memory transceiverInstructions, TrimmedAmount trimmedAmount, uint64 sequence ) internal virtual returns (bool enqueued) { @@ -546,13 +562,14 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { refundAddress, msg.sender, executorQuote, - relayInstructions + relayInstructions, + transceiverInstructions ); // refund price quote back to sender _refundToSender(msg.value); - // return that the transfer has been enqued + // return that the transfer has been enqueued return true; } @@ -572,100 +589,123 @@ contract NttManager is INttManager, RateLimiter, ManagerBase { bytes32 refundAddress, address sender, bytes memory executorQuote, - bytes memory relayInstructions + bytes memory relayInstructions, + bytes memory transceiverInstructions ) internal returns (uint64 msgSequence) { // verify chain has not forked checkFork(evmChainId); // Compute the quote price and refund user excess value from msg.value - uint256 epTotalPriceQuote = quoteAndRefund(recipientChain); + uint256 epTotalPriceQuote = quoteAndRefund(recipientChain, transceiverInstructions); - // push it on the stack again to avoid a stack too deep error - uint64 seq = sequence; - TrimmedAmount amt = amount; - bytes32 recip = recipient; - bytes32 refundAddr = refundAddress; + return _transfer( + _TransferArgs({ + sequence: sequence, + amount: amount, + recipientChain: recipientChain, + recipient: recipient, + refundAddress: refundAddress, + sender: sender, + executorQuote: executorQuote, + relayInstructions: relayInstructions, + transceiverInstructions: transceiverInstructions, + epTotalPriceQuote: epTotalPriceQuote + }) + ); + } - bytes memory encodedNttManagerPayload = - buildEncodedPayload(amt, recip, recipientChain, seq, sender, refundAddr); + /// @dev Used to get around "stack too deep. + struct _TransferArgs { + uint64 sequence; + TrimmedAmount amount; + uint16 recipientChain; + bytes32 recipient; + bytes32 refundAddress; + address sender; + bytes executorQuote; + bytes relayInstructions; + bytes transceiverInstructions; + uint256 epTotalPriceQuote; + } - // push onto the stack again to avoid stack too deep error - uint16 destinationChain = recipientChain; + function _transfer( + _TransferArgs memory args + ) internal returns (uint64 msgSequence) { + bytes memory encodedNttManagerPayload = buildEncodedPayload(args); // send the message bytes32 payloadHash = keccak256(encodedNttManagerPayload); - endpoint.sendMessage{value: epTotalPriceQuote}( - destinationChain, - UniversalAddressLibrary.fromBytes32(_getPeersStorage()[destinationChain].peerAddress), + endpoint.sendMessage{value: args.epTotalPriceQuote}( + args.recipientChain, + UniversalAddressLibrary.fromBytes32(_getPeersStorage()[args.recipientChain].peerAddress), payloadHash, - UniversalAddressLibrary.toAddress(UniversalAddressLibrary.fromBytes32(refundAddr)) + UniversalAddressLibrary.toAddress( + UniversalAddressLibrary.fromBytes32(args.refundAddress) + ), + args.transceiverInstructions ); emit TransferSent( - recip, - refundAddr, - amt.untrim(tokenDecimals()), - epTotalPriceQuote, - destinationChain, - seq, + args.recipient, + args.refundAddress, + args.amount.untrim(tokenDecimals()), + args.epTotalPriceQuote, + args.recipientChain, + args.sequence, payloadHash ); - bytes memory execQuote = executorQuote; - - uint128 gasLimit = _getPeersStorage()[destinationChain].gasLimit; + uint128 gasLimit = _getPeersStorage()[args.recipientChain].gasLimit; if (gasLimit == 0) { - revert InvalidGasLimitZero(destinationChain); + revert InvalidGasLimitZero(args.recipientChain); } - bytes memory ri = RelayInstructions.encodeGas(gasLimit, 0); - if (relayInstructions.length != 0) { - ri = abi.encodePacked(ri, relayInstructions); + bytes memory relayInstructions = RelayInstructions.encodeGas(gasLimit, 0); + if (args.relayInstructions.length != 0) { + relayInstructions = abi.encodePacked(relayInstructions, args.relayInstructions); } executor.requestExecution( - destinationChain, - recip, - UniversalAddressLibrary.fromBytes32(refundAddr).toAddress(), - execQuote, + args.recipientChain, + args.recipient, + UniversalAddressLibrary.fromBytes32(args.refundAddress).toAddress(), + args.executorQuote, encodedNttManagerPayload, - ri + relayInstructions ); // return the sequence number - return seq; + return args.sequence; } function quoteAndRefund( - uint16 recipientChain + uint16 recipientChain, + bytes memory transceiverInstructions ) internal returns (uint256 epTotalPriceQuote) { - // refund user excess value from msg.value - epTotalPriceQuote = quoteDeliveryPrice(recipientChain); - // Check for negative value. - { - uint256 excessValue = msg.value - epTotalPriceQuote; - if (excessValue > 0) { - _refundToSender(excessValue); - } + epTotalPriceQuote = quoteDeliveryPrice(recipientChain, transceiverInstructions); + uint256 excessValue = msg.value - epTotalPriceQuote; + if (excessValue > 0) { + _refundToSender(excessValue); } } function buildEncodedPayload( - TrimmedAmount amount, - bytes32 recipient, - uint16 recipientChain, - uint64 seq, - address sender, - bytes32 refundAddr + _TransferArgs memory args ) internal returns (bytes memory encodedNttManagerPayload) { - TransceiverStructs.NativeTokenTransfer memory ntt = - _prepareNativeTokenTransfer(amount, recipient, recipientChain, seq, sender, refundAddr); + TransceiverStructs.NativeTokenTransfer memory ntt = _prepareNativeTokenTransfer( + args.amount, + args.recipient, + args.recipientChain, + args.sequence, + args.sender, + args.refundAddress + ); // construct the NttManagerMessage payload encodedNttManagerPayload = TransceiverStructs.encodeNttManagerMessage( TransceiverStructs.NttManagerMessage( - bytes32(uint256(seq)), - toWormholeFormat(sender), + bytes32(uint256(args.sequence)), + toWormholeFormat(args.sender), TransceiverStructs.encodeNativeTokenTransfer(ntt) ) ); diff --git a/evm/src/NttManager/NttManagerNoRateLimiting.sol b/evm/src/NttManager/NttManagerNoRateLimiting.sol index 0632d251b..1e9e8aae0 100644 --- a/evm/src/NttManager/NttManagerNoRateLimiting.sol +++ b/evm/src/NttManager/NttManagerNoRateLimiting.sol @@ -99,6 +99,7 @@ contract NttManagerNoRateLimiting is NttManager { bool, // shouldQueue bytes memory, // executorQuote bytes memory, // relayInstructions + bytes memory, // transceiverInstructions TrimmedAmount, // trimmedAmount uint64 // sequence ) internal pure override returns (bool) { diff --git a/evm/src/interfaces/IManagerBase.sol b/evm/src/interfaces/IManagerBase.sol index 40cbbc71e..706200397 100644 --- a/evm/src/interfaces/IManagerBase.sol +++ b/evm/src/interfaces/IManagerBase.sol @@ -98,9 +98,11 @@ interface IManagerBase { /// @notice Fetch the delivery price for a given recipient chain transfer. /// @param recipientChain The Wormhole chain ID of the transfer destination. + /// @param transceiverInstructions The encoded adapter instructions to be passed to the endpoint. /// @return - The delivery prices associated with each enabled endpoint and the total price. function quoteDeliveryPrice( - uint16 recipientChain + uint16 recipientChain, + bytes memory transceiverInstructions ) external view returns (uint256); /// @notice Sets the threshold for the number of attestations required for a message diff --git a/evm/src/interfaces/INttManager.sol b/evm/src/interfaces/INttManager.sol index 4265550bd..57e67f37a 100644 --- a/evm/src/interfaces/INttManager.sol +++ b/evm/src/interfaces/INttManager.sol @@ -166,12 +166,17 @@ interface INttManager is IManagerBase { /// @param amount The amount to transfer. /// @param recipientChain The Wormhole chain ID for the destination. /// @param recipient The recipient address. + /// @param executorQuote The signed quote to be passed to the executor. + /// @param relayInstructions The relay instructions to be passed to the executor. + /// @param transceiverInstructions The adapter instructions to be passed to the endpoint. /// @return msgId The resulting message ID of the transfer function transfer( uint256 amount, uint16 recipientChain, bytes32 recipient, - bytes calldata executorQuote + bytes calldata executorQuote, + bytes calldata relayInstructions, + bytes calldata transceiverInstructions ) external payable returns (uint64 msgId); /// @notice Transfer a given amount to a recipient on a given chain. This function is called @@ -182,9 +187,11 @@ interface INttManager is IManagerBase { /// @param amount The amount to transfer. /// @param recipientChain The Wormhole chain ID for the destination. /// @param recipient The recipient address. - /// @param refundAddress The address to which a refund for unussed gas is issued on the recipient chain. + /// @param refundAddress The address to which a refund for unused gas is issued on the recipient chain. /// @param shouldQueue Whether the transfer should be queued if the outbound limit is hit. - /// @param encodedInstructions Additional instructions to be forwarded to the recipient chain. + /// @param executorQuote The signed quote to be passed to the executor. + /// @param relayInstructions The relay instructions to be passed to the executor. + /// @param transceiverInstructions The adapter instructions to be passed to the endpoint. /// @return msgId The resulting message ID of the transfer function transfer( uint256 amount, @@ -193,7 +200,8 @@ interface INttManager is IManagerBase { bytes32 refundAddress, bool shouldQueue, bytes calldata executorQuote, - bytes memory encodedInstructions + bytes calldata relayInstructions, + bytes calldata transceiverInstructions ) external payable returns (uint64 msgId); /// @notice Complete an outbound transfer that's been queued. diff --git a/evm/src/interfaces/IRateLimiter.sol b/evm/src/interfaces/IRateLimiter.sol index 90f7c605d..c3555945d 100644 --- a/evm/src/interfaces/IRateLimiter.sol +++ b/evm/src/interfaces/IRateLimiter.sol @@ -63,6 +63,7 @@ interface IRateLimiter { /// - recipientChain: the chain of the recipient. /// - sender: the sender of the transfer. /// - relayInstructions: additional instructions to be forwarded to the relayer. + /// - transceiverInstructions: instructions to be passed into the adapters. struct OutboundQueuedTransfer { bytes32 recipient; bytes32 refundAddress; @@ -72,6 +73,7 @@ interface IRateLimiter { address sender; bytes executorQuote; bytes relayInstructions; + bytes transceiverInstructions; } /// @notice Parameters for an inbound queued transfer. diff --git a/evm/src/libraries/RateLimiter.sol b/evm/src/libraries/RateLimiter.sol index 26e124358..8bee4396d 100644 --- a/evm/src/libraries/RateLimiter.sol +++ b/evm/src/libraries/RateLimiter.sol @@ -70,8 +70,8 @@ abstract contract RateLimiter is IRateLimiter, IRateLimiterEvents { constructor(uint64 _rateLimitDuration, bool _skipRateLimiting) { if ( - _rateLimitDuration == 0 && !_skipRateLimiting - || _rateLimitDuration != 0 && _skipRateLimiting + (_rateLimitDuration == 0 && !_skipRateLimiting) + || (_rateLimitDuration != 0 && _skipRateLimiting) ) { revert UndefinedRateLimiting(); } @@ -303,7 +303,8 @@ abstract contract RateLimiter is IRateLimiter, IRateLimiterEvents { bytes32 refundAddress, address senderAddress, bytes memory executorQuote, - bytes memory relayInstructions + bytes memory relayInstructions, + bytes memory transceiverInstructions ) internal { _getOutboundQueueStorage()[sequence] = OutboundQueuedTransfer({ amount: amount, @@ -313,7 +314,8 @@ abstract contract RateLimiter is IRateLimiter, IRateLimiterEvents { txTimestamp: uint64(block.timestamp), sender: senderAddress, executorQuote: executorQuote, - relayInstructions: relayInstructions + relayInstructions: relayInstructions, + transceiverInstructions: transceiverInstructions }); emit OutboundTransferQueued(sequence); diff --git a/evm/test/IntegrationAdditionalTransfer.t.sol b/evm/test/IntegrationAdditionalTransfer.t.sol index e7933e74f..965bed964 100755 --- a/evm/test/IntegrationAdditionalTransfer.t.sol +++ b/evm/test/IntegrationAdditionalTransfer.t.sol @@ -170,7 +170,9 @@ contract TestAdditionalPayload is Test { sendingAmount, chainId2, bytes32(uint256(uint160(userB))), - executorChain1.createSignedQuote(executorChain2.chainId()) + executorChain1.createSignedQuote(executorChain2.chainId()), + executorChain1.createRelayInstructions(), + endpointChain1.createAdapterInstructions() ); // Balance check on funds going in and out working as expected @@ -262,7 +264,8 @@ contract TestAdditionalPayload is Test { toWormholeFormat(userC), false, executorChain2.createSignedQuote(executorChain1.chainId()), - new bytes(0) + executorChain2.createRelayInstructions(), + endpointChain2.createAdapterInstructions() ); uint256 supplyAfter = token2.totalSupply(); diff --git a/evm/test/IntegrationStandalone.t.sol b/evm/test/IntegrationStandalone.t.sol index 096471e61..e9d329018 100755 --- a/evm/test/IntegrationStandalone.t.sol +++ b/evm/test/IntegrationStandalone.t.sol @@ -173,7 +173,9 @@ contract TestEndToEndBase is Test, IRateLimiterEvents { sendingAmount, chainId2, bytes32(uint256(uint160(userB))), - executorChain1.createSignedQuote(executorChain2.chainId()) + executorChain1.createSignedQuote(executorChain2.chainId()), + executorChain1.createRelayInstructions(), + endpointChain1.createAdapterInstructions() ); // Balance check on funds going in and out working as expected @@ -247,7 +249,8 @@ contract TestEndToEndBase is Test, IRateLimiterEvents { toWormholeFormat(userC), false, executorChain2.createSignedQuote(executorChain1.chainId()), - new bytes(0) + executorChain2.createRelayInstructions(), + endpointChain2.createAdapterInstructions() ); uint256 supplyAfter = token2.totalSupply(); @@ -318,7 +321,8 @@ contract TestEndToEndBase is Test, IRateLimiterEvents { toWormholeFormat(userA), true, executorChain1.createSignedQuote(executorChain2.chainId()), - new bytes(0) + executorChain1.createRelayInstructions(), + endpointChain1.createAdapterInstructions() ); // Balance check on funds going in and out working as expected @@ -394,7 +398,8 @@ contract TestEndToEndBase is Test, IRateLimiterEvents { toWormholeFormat(userC), true, executorChain2.createSignedQuote(executorChain1.chainId(), 2 days), // We are going to warp the time below. - new bytes(0) + executorChain2.createRelayInstructions(), + endpointChain2.createAdapterInstructions() ); // Test timing on the queues @@ -531,7 +536,8 @@ contract TestEndToEndBase is Test, IRateLimiterEvents { toWormholeFormat(userA), false, executorChain1.createSignedQuote(executorChain2.chainId()), - new bytes(0) + executorChain1.createRelayInstructions(), + endpointChain1.createAdapterInstructions() ); } @@ -590,7 +596,8 @@ contract TestEndToEndBase is Test, IRateLimiterEvents { toWormholeFormat(userB), false, executorChain2.createSignedQuote(executorChain1.chainId()), - new bytes(0) + executorChain2.createRelayInstructions(), + endpointChain2.createAdapterInstructions() ); uint256 nttManagerBalanceAfter = token1.balanceOf(address(nttManagerChain2)); uint256 userBalanceAfter = token1.balanceOf(address(userB)); diff --git a/evm/test/IntegrationWithoutRateLimiting.t.sol b/evm/test/IntegrationWithoutRateLimiting.t.sol index 4d7c81bf8..4b58b54f6 100755 --- a/evm/test/IntegrationWithoutRateLimiting.t.sol +++ b/evm/test/IntegrationWithoutRateLimiting.t.sol @@ -168,7 +168,9 @@ contract TestNoRateLimitingEndToEndBase is Test, IRateLimiterEvents { sendingAmount, chainId2, bytes32(uint256(uint160(userB))), - executorChain1.createSignedQuote(executorChain2.chainId()) + executorChain1.createSignedQuote(executorChain2.chainId()), + executorChain1.createRelayInstructions(), + endpointChain1.createAdapterInstructions() ); // Balance check on funds going in and out working as expected @@ -242,7 +244,8 @@ contract TestNoRateLimitingEndToEndBase is Test, IRateLimiterEvents { toWormholeFormat(userC), false, executorChain2.createSignedQuote(executorChain1.chainId()), - new bytes(0) + executorChain2.createRelayInstructions(), + endpointChain2.createAdapterInstructions() ); uint256 supplyAfter = token2.totalSupply(); @@ -378,7 +381,8 @@ contract TestNoRateLimitingEndToEndBase is Test, IRateLimiterEvents { toWormholeFormat(userA), true, executorChain1.createSignedQuote(executorChain2.chainId()), - new bytes(0) + executorChain1.createRelayInstructions(), + endpointChain1.createAdapterInstructions() ); // Balance check on funds going in and out working as expected @@ -455,7 +459,8 @@ contract TestNoRateLimitingEndToEndBase is Test, IRateLimiterEvents { toWormholeFormat(userC), true, executorChain2.createSignedQuote(executorChain1.chainId()), - new bytes(0) + executorChain2.createRelayInstructions(), + endpointChain2.createAdapterInstructions() ); uint256 supplyAfter = token2.totalSupply(); @@ -546,7 +551,8 @@ contract TestNoRateLimitingEndToEndBase is Test, IRateLimiterEvents { toWormholeFormat(userA), false, executorChain1.createSignedQuote(executorChain2.chainId()), - new bytes(0) + executorChain1.createRelayInstructions(), + endpointChain1.createAdapterInstructions() ); } @@ -606,7 +612,8 @@ contract TestNoRateLimitingEndToEndBase is Test, IRateLimiterEvents { toWormholeFormat(userB), false, executorChain2.createSignedQuote(executorChain1.chainId()), - new bytes(0) + executorChain2.createRelayInstructions(), + endpointChain2.createAdapterInstructions() ); uint256 nttManagerBalanceAfter = token1.balanceOf(address(nttManagerChain2)); uint256 userBalanceAfter = token1.balanceOf(address(userB)); diff --git a/evm/test/NttManager.t.sol b/evm/test/NttManager.t.sol index ee085184e..ef1765b90 100644 --- a/evm/test/NttManager.t.sol +++ b/evm/test/NttManager.t.sol @@ -216,19 +216,25 @@ contract TestNttManager is Test, IRateLimiterEvents { 1 * 10 ** decimals, chainId2, toWormholeFormat(user_B), - executor.createSignedQuote(executorOther.chainId()) + executor.createSignedQuote(executorOther.chainId()), + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); uint64 s2 = nttManagerZeroRateLimiter.transfer( 1 * 10 ** decimals, chainId2, toWormholeFormat(user_B), - executor.createSignedQuote(executorOther.chainId()) + executor.createSignedQuote(executorOther.chainId()), + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); uint64 s3 = nttManagerZeroRateLimiter.transfer( 1 * 10 ** decimals, chainId2, toWormholeFormat(user_B), - executor.createSignedQuote(executorOther.chainId()) + executor.createSignedQuote(executorOther.chainId()), + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); @@ -286,13 +292,17 @@ contract TestNttManager is Test, IRateLimiterEvents { assertEq(nttManager.isPaused(), true); bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); // When the NttManager is paused, initiating transfers, completing queued transfers on both source and destination chains, // executing transfers and attesting to transfers should all revert vm.expectRevert( abi.encodeWithSelector(PausableUpgradeable.RequireContractIsNotPaused.selector) ); - nttManager.transfer(0, 0, bytes32(0), executorSignedQuote); + nttManager.transfer( + 0, 0, bytes32(0), executorSignedQuote, executorRelayInstructions, adapterInstructions + ); vm.expectRevert( abi.encodeWithSelector(PausableUpgradeable.RequireContractIsNotPaused.selector) @@ -368,9 +378,13 @@ contract TestNttManager is Test, IRateLimiterEvents { newNttManager.initialize(); bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); vm.expectRevert(abi.encodeWithSelector(INttManager.StaticcallFailed.selector)); - newNttManager.transfer(1, 1, bytes32("1"), executorSignedQuote); + newNttManager.transfer( + 1, 1, bytes32("1"), executorSignedQuote, executorRelayInstructions, adapterInstructions + ); } // === transceiver registration @@ -466,6 +480,8 @@ contract TestNttManager is Test, IRateLimiterEvents { token.approve(address(newNttManager), 3 * 10 ** decimals); bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); vm.expectRevert(abi.encodeWithSelector(Endpoint.AdapterNotEnabled.selector)); newNttManager.transfer( @@ -475,7 +491,8 @@ contract TestNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executorSignedQuote, - new bytes(0) + executorRelayInstructions, + adapterInstructions ); } @@ -529,7 +546,8 @@ contract TestNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), true, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); @@ -567,7 +585,8 @@ contract TestNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), true, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); assertEq(s2, s1 + 1); @@ -733,7 +752,8 @@ contract TestNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); uint64 s2 = nttManager.transfer( 1 * 10 ** decimals, @@ -742,7 +762,8 @@ contract TestNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); uint64 s3 = nttManager.transfer( 1 * 10 ** decimals, @@ -751,7 +772,8 @@ contract TestNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); assertEq(s1, 0); @@ -785,6 +807,8 @@ contract TestNttManager is Test, IRateLimiterEvents { uint256 amount = type(uint64).max * 10 ** (decimals - 6); bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); vm.expectRevert("SafeCast: value doesn't fit in 64 bits"); nttManager.transfer( @@ -794,7 +818,8 @@ contract TestNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executorSignedQuote, - new bytes(0) + executorRelayInstructions, + adapterInstructions ); // A (slightly) more sensible amount should work normally @@ -805,8 +830,9 @@ contract TestNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_B), toWormholeFormat(user_A), false, - executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executorSignedQuote, + executorRelayInstructions, + adapterInstructions ); } @@ -857,7 +883,8 @@ contract TestNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), true, // Should queue executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); // We should have enqueued message zero and not have sent anything out. @@ -877,6 +904,8 @@ contract TestNttManager is Test, IRateLimiterEvents { nttManager.cancelOutboundQueuedTransfer(sequence); bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); // Outbound transfers fail when queued vm.expectRevert(abi.encodeWithSelector(InvalidFork.selector, evmChainId, chainId)); @@ -887,7 +916,8 @@ contract TestNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), true, // Should queue executorSignedQuote, - new bytes(0) + executorRelayInstructions, + adapterInstructions ); vm.stopPrank(); @@ -902,7 +932,8 @@ contract TestNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executorSignedQuote, - new bytes(0) + executorRelayInstructions, + adapterInstructions ); // INBOUND @@ -1025,16 +1056,22 @@ contract TestNttManager is Test, IRateLimiterEvents { vm.startPrank(from); - uint256 transferAmount = 3 * 10 ** decimals; - assertEq( - transferAmount < maxAmount - 500, true, "Transferring more tokens than what exists" - ); - - uint256 dustAmount = 500; - uint256 amountWithDust = transferAmount + dustAmount; // An amount with 19 digits, which will result in dust due to 18 decimals - token.approve(address(nttManager), amountWithDust); + uint256 amountWithDust; + uint256 dustAmount; + { + uint256 transferAmount = 3 * 10 ** decimals; + assertEq( + transferAmount < maxAmount - 500, true, "Transferring more tokens than what exists" + ); + + dustAmount = 500; + amountWithDust = transferAmount + dustAmount; // An amount with 19 digits, which will result in dust due to 18 decimals + token.approve(address(nttManager), amountWithDust); + } bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); vm.expectRevert( abi.encodeWithSelector( @@ -1048,7 +1085,8 @@ contract TestNttManager is Test, IRateLimiterEvents { toWormholeFormat(from), false, executorSignedQuote, - new bytes(0) + executorRelayInstructions, + adapterInstructions ); vm.stopPrank(); @@ -1167,7 +1205,8 @@ contract TestNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); @@ -1220,7 +1259,8 @@ contract TestNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); @@ -1243,6 +1283,8 @@ contract TestNttManager is Test, IRateLimiterEvents { t.upgrade(address(dummy3)); bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); vm.startPrank(user_A); vm.expectRevert(abi.encodeWithSelector(NumberOfDecimalsNotEqual.selector, 8, 7)); @@ -1253,7 +1295,8 @@ contract TestNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executorSignedQuote, - new bytes(0) + executorRelayInstructions, + adapterInstructions ); vm.stopPrank(); @@ -1307,9 +1350,18 @@ contract TestNttManager is Test, IRateLimiterEvents { token.approve(address(nttManager), amount); bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); vm.expectRevert(abi.encodeWithSelector(INttManager.InvalidGasLimitZero.selector, chainId2)); - nttManager.transfer(amount, chainId2, toWormholeFormat(user_B), executorSignedQuote); + nttManager.transfer( + amount, + chainId2, + toWormholeFormat(user_B), + executorSignedQuote, + executorRelayInstructions, + adapterInstructions + ); } function checkAttestationOnly( diff --git a/evm/test/NttManagerNoRateLimiting.t.sol b/evm/test/NttManagerNoRateLimiting.t.sol index fdd3a3947..a5525547d 100644 --- a/evm/test/NttManagerNoRateLimiting.t.sol +++ b/evm/test/NttManagerNoRateLimiting.t.sol @@ -149,13 +149,17 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { assertEq(nttManager.isPaused(), true); bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); // When the NttManagerNoRateLimiting is paused, initiating transfers, completing queued transfers on both source and destination chains, // executing transfers and attesting to transfers should all revert vm.expectRevert( abi.encodeWithSelector(PausableUpgradeable.RequireContractIsNotPaused.selector) ); - nttManager.transfer(0, 0, bytes32(0), executorSignedQuote); + nttManager.transfer( + 0, 0, bytes32(0), executorSignedQuote, executorRelayInstructions, adapterInstructions + ); vm.expectRevert( abi.encodeWithSelector(PausableUpgradeable.RequireContractIsNotPaused.selector) @@ -226,9 +230,13 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { newNttManagerNoRateLimiting.initialize(); bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); vm.expectRevert(abi.encodeWithSelector(INttManager.StaticcallFailed.selector)); - newNttManagerNoRateLimiting.transfer(1, 1, bytes32("1"), executorSignedQuote); + newNttManagerNoRateLimiting.transfer( + 1, 1, bytes32("1"), executorSignedQuote, executorRelayInstructions, adapterInstructions + ); } // === transceiver registration @@ -324,6 +332,8 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { token.approve(address(newNttManagerNoRateLimiting), 3 * 10 ** decimals); bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); vm.expectRevert(abi.encodeWithSelector(Endpoint.AdapterNotEnabled.selector)); newNttManagerNoRateLimiting.transfer( @@ -333,7 +343,8 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executorSignedQuote, - new bytes(0) + executorRelayInstructions, + adapterInstructions ); } @@ -476,7 +487,8 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); uint64 s2 = nttManager.transfer( 1 * 10 ** decimals, @@ -485,7 +497,8 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); uint64 s3 = nttManager.transfer( 1 * 10 ** decimals, @@ -494,7 +507,8 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); assertEq(s1, 0); @@ -521,6 +535,10 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { vm.startPrank(user_A); token.approve(address(nttManager), type(uint256).max); + bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); + // When transferring to a chain with 6 decimals the amount will get trimmed to 6 decimals. // Without rate limiting, this won't be scaled back up to 8 for local accounting. uint256 amount = type(uint64).max * 10 ** (decimals - 6); @@ -530,12 +548,11 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_B), toWormholeFormat(user_A), false, - executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executorSignedQuote, + executorRelayInstructions, + adapterInstructions ); - bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); - // However, attempting to transfer an amount higher than the destination chain can handle will revert. amount = type(uint64).max * 10 ** (decimals - 4); vm.expectRevert("SafeCast: value doesn't fit in 64 bits"); @@ -546,7 +563,8 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executorSignedQuote, - new bytes(0) + executorRelayInstructions, + adapterInstructions ); // A (slightly) more sensible amount should work normally @@ -557,8 +575,9 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_B), toWormholeFormat(user_A), false, - executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executorSignedQuote, + executorRelayInstructions, + adapterInstructions ); } @@ -609,7 +628,8 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), true, // Should queue executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); // We should have sent out message zero. @@ -629,6 +649,8 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { nttManager.cancelOutboundQueuedTransfer(sequence); bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); // Outbound transfers fail when queued vm.expectRevert(abi.encodeWithSelector(InvalidFork.selector, evmChainId, chainId)); @@ -639,7 +661,8 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), true, // Should queue executorSignedQuote, - new bytes(0) + executorRelayInstructions, + adapterInstructions ); vm.stopPrank(); @@ -654,7 +677,8 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executorSignedQuote, - new bytes(0) + executorRelayInstructions, + adapterInstructions ); // INBOUND @@ -765,16 +789,22 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { vm.startPrank(from); - uint256 transferAmount = 3 * 10 ** decimals; - assertEq( - transferAmount < maxAmount - 500, true, "Transferring more tokens than what exists" - ); - - uint256 dustAmount = 500; - uint256 amountWithDust = transferAmount + dustAmount; // An amount with 19 digits, which will result in dust due to 18 decimals - token.approve(address(nttManager), amountWithDust); + uint256 amountWithDust; + uint256 dustAmount; + { + uint256 transferAmount = 3 * 10 ** decimals; + assertEq( + transferAmount < maxAmount - 500, true, "Transferring more tokens than what exists" + ); + + dustAmount = 500; + amountWithDust = transferAmount + dustAmount; // An amount with 19 digits, which will result in dust due to 18 decimals + token.approve(address(nttManager), amountWithDust); + } bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); vm.expectRevert( abi.encodeWithSelector( @@ -788,7 +818,8 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { toWormholeFormat(from), false, executorSignedQuote, - new bytes(0) + executorRelayInstructions, + adapterInstructions ); vm.stopPrank(); @@ -970,7 +1001,8 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); @@ -1025,7 +1057,8 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); @@ -1057,7 +1090,8 @@ contract TestNoRateLimitingNttManager is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); diff --git a/evm/test/RateLimit.t.sol b/evm/test/RateLimit.t.sol index 8268270f6..7c67dc54c 100644 --- a/evm/test/RateLimit.t.sol +++ b/evm/test/RateLimit.t.sol @@ -154,7 +154,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); @@ -199,7 +200,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); @@ -244,7 +246,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); @@ -284,7 +287,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); @@ -338,7 +342,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); @@ -386,7 +391,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); @@ -434,6 +440,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { token.approve(address(nttManager), transferAmount); bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); vm.expectRevert( abi.encodeWithSelector( @@ -447,7 +455,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executorSignedQuote, - new bytes(0) + executorRelayInstructions, + adapterInstructions ); } @@ -471,7 +480,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); // assert that first transfer went through @@ -487,6 +497,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { token.approve(address(nttManager), badTransferAmount); bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); vm.expectRevert( abi.encodeWithSelector( @@ -502,7 +514,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executorSignedQuote, - new bytes(0) + executorRelayInstructions, + adapterInstructions ); } @@ -533,7 +546,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { toWormholeFormat(user_A), true, executor.createSignedQuote(executorOther.chainId(), 2 days), // We are going to warp the time below. - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); // assert that the transfer got queued up @@ -705,7 +719,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); @@ -783,7 +798,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { toWormholeFormat(userA), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); @@ -880,6 +896,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { // revert if amount to be transferred is 0 if (transferAmount.getAmount() == 0) { bytes memory executorSignedQuote = executor.createSignedQuote(executorOther.chainId()); + bytes memory executorRelayInstructions = executor.createRelayInstructions(); + bytes memory adapterInstructions = endpoint.createAdapterInstructions(); vm.expectRevert(abi.encodeWithSelector(INttManager.ZeroAmount.selector)); nttManager.transfer( @@ -889,7 +907,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executorSignedQuote, - new bytes(0) + executorRelayInstructions, + adapterInstructions ); return; @@ -903,7 +922,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); @@ -973,7 +993,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { toWormholeFormat(user_A), false, executor.createSignedQuote(executorOther.chainId()), - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); vm.stopPrank(); @@ -1032,7 +1053,8 @@ contract TestRateLimit is Test, IRateLimiterEvents { toWormholeFormat(user_A), true, executor.createSignedQuote(executorOther.chainId(), 2 days), // We are going to warp the time below. - new bytes(0) + executor.createRelayInstructions(), + endpoint.createAdapterInstructions() ); // assert that the transfer got queued up diff --git a/evm/test/interfaces/ITransceiverReceiver.sol b/evm/test/interfaces/ITransceiverReceiver.sol index 5d3307524..68e71bfb7 100644 --- a/evm/test/interfaces/ITransceiverReceiver.sol +++ b/evm/test/interfaces/ITransceiverReceiver.sol @@ -2,5 +2,7 @@ pragma solidity >=0.8.8 <0.9.0; interface IAdapterReceiver { - function receiveMessage(bytes memory encodedMessage) external; + function receiveMessage( + bytes memory encodedMessage + ) external; } diff --git a/evm/test/mocks/DummyTransceiver.sol b/evm/test/mocks/DummyTransceiver.sol index 96b044c14..24ea1a194 100644 --- a/evm/test/mocks/DummyTransceiver.sol +++ b/evm/test/mocks/DummyTransceiver.sol @@ -22,7 +22,8 @@ contract DummyTransceiver is IAdapter { } function quoteDeliveryPrice( - uint16 /* recipientChain */ + uint16, /* recipientChain */ + bytes calldata /* adapterInstructions */ ) external pure returns (uint256) { return 0; } @@ -49,7 +50,8 @@ contract DummyTransceiver is IAdapter { uint16 dstChain, UniversalAddress dstAddr, bytes32 payloadHash, - address refundAddr + address refundAddr, + bytes calldata // adapterInstructions ) external payable { Message memory m = Message({ srcChain: chainId, diff --git a/evm/test/mocks/MockEndpoint.sol b/evm/test/mocks/MockEndpoint.sol index 8ad310c18..b19b03feb 100644 --- a/evm/test/mocks/MockEndpoint.sol +++ b/evm/test/mocks/MockEndpoint.sol @@ -2,9 +2,15 @@ pragma solidity ^0.8.19; import "example-messaging-endpoint/evm/src/Endpoint.sol"; +import "example-messaging-endpoint/evm/src/libraries/AdapterInstructions.sol"; contract MockEndpoint is Endpoint { constructor( uint16 _chainId ) Endpoint(_chainId) {} + + function createAdapterInstructions() public pure returns (bytes memory encoded) { + AdapterInstructions.Instruction[] memory insts = new AdapterInstructions.Instruction[](0); + encoded = AdapterInstructions.encodeInstructions(insts); + } } diff --git a/evm/test/mocks/MockExecutor.sol b/evm/test/mocks/MockExecutor.sol index 604380879..213033fd0 100644 --- a/evm/test/mocks/MockExecutor.sol +++ b/evm/test/mocks/MockExecutor.sol @@ -47,6 +47,10 @@ contract MockExecutor is Executor { return encodeSignedQuoteHeader(signedQuote); } + function createRelayInstructions() public pure returns (bytes memory) { + return new bytes(0); + } + function msgValue() public pure returns (uint256) { return 0; }