diff --git a/ethereum/contracts/coreRelayer/CoreRelayer.sol b/ethereum/contracts/coreRelayer/CoreRelayer.sol index 78730ec..eaa7c61 100644 --- a/ethereum/contracts/coreRelayer/CoreRelayer.sol +++ b/ethereum/contracts/coreRelayer/CoreRelayer.sol @@ -265,19 +265,19 @@ contract CoreRelayer is CoreRelayerDelivery { // For each 'Send' request, // calculate how much gas the relay provider can pay for on 'request.targetChain' using 'request.newTransactionFee', // and calculate how much value the relay provider will pass into 'request.targetAddress' - DeliveryInstructionsContainer memory container = + DeliveryInstructionsContainer memory instructionsContainer = convertMultichainSendToDeliveryInstructionsContainer(sendContainer); // For each 'Send' request, // Check that the total amount of value the relay provider needs to use for this send is <= the relayProvider's maximum budget for 'targetChain' // and check that the calculated gas is greater than 0 - checkInstructions(container, IRelayProvider(sendContainer.relayProviderAddress)); + checkInstructions(instructionsContainer, IRelayProvider(sendContainer.relayProviderAddress)); // Save information about the forward in state, so it can be processed after the execution of 'receiveWormholeMessages', // because we will then know how much of the 'maxTransactionFee' of the current delivery is still available for use in this forward setForwardInstruction( ForwardInstruction({ - container: container, + container: instructionsContainer, nonce: nonce, msgValue: msg.value, totalFee: totalFee, diff --git a/ethereum/contracts/coreRelayer/CoreRelayerMessages.sol b/ethereum/contracts/coreRelayer/CoreRelayerMessages.sol index 7d94c52..a0a0439 100644 --- a/ethereum/contracts/coreRelayer/CoreRelayerMessages.sol +++ b/ethereum/contracts/coreRelayer/CoreRelayerMessages.sol @@ -85,6 +85,10 @@ contract CoreRelayerMessages is CoreRelayerStructs, CoreRelayerGetters { instruction.targetChain = send.targetChain; instruction.targetAddress = send.targetAddress; instruction.refundAddress = send.refundAddress; + bytes32 deliveryAddress = relayProvider.getDeliveryAddress(send.targetChain); + if (deliveryAddress == bytes32(0x0)) { + revert IWormholeRelayer.RelayProviderDoesNotSupportTargetChain(); + } instruction.maximumRefundTarget = calculateTargetDeliveryMaximumRefund(send.targetChain, send.maxTransactionFee, relayProvider); instruction.receiverValueTarget = @@ -92,7 +96,7 @@ contract CoreRelayerMessages is CoreRelayerStructs, CoreRelayerGetters { instruction.executionParameters = ExecutionParameters({ version: 1, gasLimit: calculateTargetGasDeliveryAmount(send.targetChain, send.maxTransactionFee, relayProvider), - providerDeliveryAddress: relayProvider.getDeliveryAddress(send.targetChain) + providerDeliveryAddress: deliveryAddress }); } diff --git a/ethereum/forge-test/CoreRelayer.t.sol b/ethereum/forge-test/CoreRelayer.t.sol index 94610af..6808a41 100644 --- a/ethereum/forge-test/CoreRelayer.t.sol +++ b/ethereum/forge-test/CoreRelayer.t.sol @@ -1314,6 +1314,36 @@ contract TestCoreRelayer is Test { ); } + function testRevertTargetNotSupported( + GasParameters memory gasParams, + FeeParameters memory feeParams, + bytes memory message + ) public { + StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1000000); + + vm.recordLogs(); + + // estimate the cost based on the intialized values + uint256 maxTransactionFee = setup.source.coreRelayer.quoteGas( + setup.targetChainId, gasParams.targetGasLimit, address(setup.source.relayProvider) + ); + + uint256 wormholeFee = setup.source.wormhole.messageFee(); + + vm.expectRevert(abi.encodeWithSignature("RelayProviderDoesNotSupportTargetChain()")); + setup.source.integration.sendMessageWithRefundAddress{value: maxTransactionFee + uint256(3) * wormholeFee}( + message, 32, address(setup.target.integration), address(setup.target.refundAddress) + ); + + setup.source.relayProvider.updateDeliveryAddress( + setup.targetChainId, setup.source.relayProvider.getDeliveryAddress(32) + ); + vm.expectRevert(abi.encodeWithSignature("RelayProviderDoesNotSupportTargetChain()")); + setup.source.integration.sendMessageWithRefundAddress{value: maxTransactionFee + uint256(3) * wormholeFee}( + message, setup.targetChainId, address(setup.target.integration), address(setup.target.refundAddress) + ); + } + /** * *