diff --git a/ethereum/contracts/coreRelayer/CoreRelayer.sol b/ethereum/contracts/coreRelayer/CoreRelayer.sol index 4079cb4..68c4ecd 100644 --- a/ethereum/contracts/coreRelayer/CoreRelayer.sol +++ b/ethereum/contracts/coreRelayer/CoreRelayer.sol @@ -26,19 +26,36 @@ contract CoreRelayer is CoreRelayerGovernance { DeliveryStatus status ); + function send( + uint16 targetChain, + bytes32 targetAddress, + bytes32 refundAddress, + uint256 maxTransactionFee, + uint256 receiverValue, + uint32 nonce + ) external payable returns (uint64 sequence) { + sequence = send( + IWormholeRelayer.Send( + targetChain, targetAddress, refundAddress, maxTransactionFee, receiverValue, getDefaultRelayParams() + ), + nonce, + getDefaultRelayProvider() + ); + } + function send(IWormholeRelayer.Send memory request, uint32 nonce, address relayProvider) public payable returns (uint64 sequence) { - return multichainSend(multichainSendContainer(request, relayProvider), nonce); + sequence = multichainSend(multichainSendContainer(request, relayProvider), nonce); } function forward(IWormholeRelayer.Send memory request, uint32 nonce, address relayProvider) public payable { - return multichainForward(multichainSendContainer(request, relayProvider), nonce); + multichainForward(multichainSendContainer(request, relayProvider), nonce); } - function resend(IWormholeRelayer.ResendByTx memory request, uint32 nonce, address relayProvider) + function resend(IWormholeRelayer.ResendByTx memory request, address relayProvider) public payable returns (uint64 sequence) @@ -54,7 +71,7 @@ contract CoreRelayer is CoreRelayerGovernance { checkRedeliveryInstruction(instruction, provider); sequence = wormhole().publishMessage{value: wormholeMessageFee()}( - nonce, encodeRedeliveryInstruction(instruction), provider.getConsistencyLevel() + 0, encodeRedeliveryInstruction(instruction), provider.getConsistencyLevel() ); //Send the delivery fees to the specified address of the provider. @@ -283,7 +300,7 @@ contract CoreRelayer is CoreRelayerGovernance { return registeredCoreRelayerContract(vm.emitterChainId) == vm.emitterAddress; } - function getDefaultRelayProvider() public view returns (IRelayProvider) { + function getDefaultRelayProvider() public view returns (address) { return defaultRelayProvider(); } diff --git a/ethereum/contracts/coreRelayer/CoreRelayerGetters.sol b/ethereum/contracts/coreRelayer/CoreRelayerGetters.sol index e1e3189..b26a79e 100644 --- a/ethereum/contracts/coreRelayer/CoreRelayerGetters.sol +++ b/ethereum/contracts/coreRelayer/CoreRelayerGetters.sol @@ -53,8 +53,8 @@ contract CoreRelayerGetters is CoreRelayerState { return _state.registeredCoreRelayerContract[chain]; } - function defaultRelayProvider() internal view returns (IRelayProvider) { - return IRelayProvider(_state.defaultRelayProvider); + function defaultRelayProvider() internal view returns (address) { + return _state.defaultRelayProvider; } function getForwardInstruction() internal view returns (CoreRelayerStructs.ForwardInstruction memory) { diff --git a/ethereum/contracts/interfaces/IWormholeRelayer.sol b/ethereum/contracts/interfaces/IWormholeRelayer.sol index 6498f18..5aca3a8 100644 --- a/ethereum/contracts/interfaces/IWormholeRelayer.sol +++ b/ethereum/contracts/interfaces/IWormholeRelayer.sol @@ -23,7 +23,7 @@ interface IWormholeRelayer { * This contract must implement the IWormholeReceiver interface, which simply requires a 'receiveWormholeMessage(bytes[] memory vaas, bytes[] memory additionalData)' endpoint * @param refundAddress The address (in Wormhole 32-byte format) on chain 'targetChain' to which any leftover funds (that weren't used for target chain gas or passed into targetAddress as value) should be sent * @param maxTransactionFee The maximum amount (denominated in source chain (this chain) currency) that you wish to spend on funding gas for the target chain. - * If more gas is needed on the target chain than is paid for, there will be a DeliveryFailure. + * If more gas is needed on the target chain than is paid for, there will be a Receiver Failure. * Any unused value out of this fee will be refunded to 'refundAddress' * If maxTransactionFee >= quoteGas(targetChain, gasLimit, getDefaultRelayProvider()), then as long as 'targetAddress''s receiveWormholeMessage function uses at most 'gasLimit' units of gas (and doesn't revert), the delivery will succeed * @param receiverValue The amount (denominated in source chain currency) that will be converted to target chain currency and passed into the receiveWormholeMessage endpoint as value. @@ -52,7 +52,7 @@ interface IWormholeRelayer { * This contract must implement the IWormholeReceiver interface, which simply requires a 'receiveWormholeMessage(bytes[] memory vaas, bytes[] memory additionalData)' endpoint * @custom:member refundAddress The address (in Wormhole 32-byte format) on chain 'targetChain' to which any leftover funds (that weren't used for target chain gas or passed into targetAddress as value) should be sent * @custom:member maxTransactionFee The maximum amount (denominated in source chain (this chain) currency) that you wish to spend on funding gas for the target chain. - * If more gas is needed on the target chain than is paid for, there will be a DeliveryFailure. + * If more gas is needed on the target chain than is paid for, there will be a Receiver Failure. * Any unused value out of this fee will be refunded to 'refundAddress' * @custom:member receiverValue The amount (denominated in source chain currency) that will be converted to target chain currency and passed into the receiveWormholeMessage endpoint as value. * @custom:member relayParameters This should be 'getDefaultRelayParameters()' @@ -118,7 +118,7 @@ interface IWormholeRelayer { * This contract must implement the IWormholeReceiver interface, which simply requires a 'receiveWormholeMessage(bytes[] memory vaas, bytes[] memory additionalData)' endpoint * @param refundAddress The address (in Wormhole 32-byte format) on chain 'targetChain' to which any leftover funds (that weren't used for target chain gas or passed into targetAddress as value) should be sent * @param maxTransactionFee The maximum amount (denominated in source chain (this chain) currency) that you wish to spend on funding gas for the target chain. - * If more gas is needed on the target chain than is paid for, there will be a DeliveryFailure. + * If more gas is needed on the target chain than is paid for, there will be a Receiver Failure. * Any unused value out of this fee will be refunded to 'refundAddress' * If maxTransactionFee >= quoteGas(targetChain, gasLimit, getDefaultRelayProvider()), then as long as 'targetAddress''s receiveWormholeMessage function uses at most 'gasLimit' units of gas (and doesn't revert), the delivery will succeed * @param receiverValue The amount (denominated in source chain currency) that will be converted to target chain currency and passed into the receiveWormholeMessage endpoint as value. @@ -187,7 +187,7 @@ interface IWormholeRelayer { * @custom:member multisendIndex If the 'send' (or forward) function was used in the original transaction, this should be 0. Otherwise if the multichainSend (or multichainForward) function was used, * then this should be the index of the specific Send request in the requests array that you wish to be redelivered * @custom:member newMaxTransactionFee The new maximum amount (denominated in source chain (this chain) currency) that you wish to spend on funding gas for the target chain. - * If more gas is needed on the target chain than is paid for, there will be a DeliveryFailure. + * If more gas is needed on the target chain than is paid for, there will be a Receiver Failure. * Any unused value out of this fee will be refunded to 'refundAddress' * This must be greater than or equal to the original maxTransactionFee paid in the original request * @custom:member receiverValue The amount (denominated in source chain currency) that will be converted to target chain currency and passed into the receiveWormholeMessage endpoint as value. @@ -213,17 +213,13 @@ interface IWormholeRelayer { * then the user can request a redelivery of these wormhole messages any time in the future through a call to 'resend' using this struct * * @param request Information about the resend request, including the source chain and source transaction hash, - * @param nonce This should be 0 * @param relayProvider The address of (the relay provider you wish to deliver the messages)'s contract on this source chain. This must be a contract that implements IRelayProvider. * If the targetAddress's receiveWormholeMessage function uses 'gasLimit' units of gas, then we must have newMaxTransactionFee >= quoteGasResend(targetChain, gasLimit, relayProvider) * * @return sequence The sequence number for the emitted wormhole message, which contains encoded delivery instructions meant for your specified relay provider. * The relay provider will listen for these messages, and then execute the redelivery as described */ - function resend(ResendByTx memory request, uint32 nonce, address relayProvider) - external - payable - returns (uint64 sequence); + function resend(ResendByTx memory request, address relayProvider) external payable returns (uint64 sequence); /** * @notice This 'MultichainSend' struct represents a collection of send requests 'requests' and a specified relay provider 'relayProviderAddress' diff --git a/ethereum/forge-test/CoreRelayer.t.sol b/ethereum/forge-test/CoreRelayer.t.sol index de7c73c..33793bc 100644 --- a/ethereum/forge-test/CoreRelayer.t.sol +++ b/ethereum/forge-test/CoreRelayer.t.sol @@ -604,7 +604,7 @@ contract TestCoreRelayer is Test { vm.deal(address(this), payment + newMaxTransactionFeeFee); setup.source.coreRelayer.resend{value: payment + newMaxTransactionFeeFee}( - redeliveryRequest, 1, address(setup.source.relayProvider) + redeliveryRequest, address(setup.source.relayProvider) ); genericRelayer(setup.sourceChainId, 1); @@ -663,7 +663,7 @@ contract TestCoreRelayer is Test { vm.deal(address(this), payment + newMaxTransactionFeeFee); setup.source.coreRelayer.resend{value: payment + newMaxTransactionFeeFee}( - redeliveryRequest, 1, address(setup.source.relayProvider) + redeliveryRequest, address(setup.source.relayProvider) ); genericRelayer(setup.sourceChainId, 1); @@ -689,7 +689,7 @@ contract TestCoreRelayer is Test { vm.deal(address(this), payment + newMaxTransactionFeeFee - 1); setup.source.coreRelayer.resend{value: payment + newMaxTransactionFeeFee - 1}( - redeliveryRequest, 1, address(setup.source.relayProvider) + redeliveryRequest, address(setup.source.relayProvider) ); genericRelayer(setup.sourceChainId, 1); @@ -855,11 +855,11 @@ contract TestCoreRelayer is Test { vm.deal(address(this), stack.payment); vm.expectRevert(abi.encodeWithSignature("MsgValueTooLow()")); setup.source.coreRelayer.resend{value: stack.payment - 1}( - stack.redeliveryRequest, 1, address(setup.source.relayProvider) + stack.redeliveryRequest, address(setup.source.relayProvider) ); setup.source.coreRelayer.resend{value: stack.payment}( - stack.redeliveryRequest, 1, address(setup.source.relayProvider) + stack.redeliveryRequest, address(setup.source.relayProvider) ); stack.entries = vm.getRecordedLogs(); @@ -934,7 +934,7 @@ contract TestCoreRelayer is Test { vm.deal(address(this), stack.payment); vm.getRecordedLogs(); setup.source.coreRelayer.resend{value: stack.payment}( - stack.redeliveryRequest, 1, address(setup.source.relayProvider) + stack.redeliveryRequest, address(setup.source.relayProvider) ); stack.entries = vm.getRecordedLogs(); setup.source.relayProvider.updateDeliveryAddress( @@ -1002,7 +1002,7 @@ contract TestCoreRelayer is Test { vm.deal(address(this), stack.payment); vm.getRecordedLogs(); setup.source.coreRelayer.resend{value: stack.payment}( - stack.redeliveryRequest, 1, address(setup.source.relayProvider) + stack.redeliveryRequest, address(setup.source.relayProvider) ); stack.entries = vm.getRecordedLogs(); setup.source.relayProvider.updateDeliveryAddress( diff --git a/ethereum/ts-scripts/mockIntegration/redeliveryTest.ts b/ethereum/ts-scripts/mockIntegration/redeliveryTest.ts index 94d26ad..b5a8b28 100644 --- a/ethereum/ts-scripts/mockIntegration/redeliveryTest.ts +++ b/ethereum/ts-scripts/mockIntegration/redeliveryTest.ts @@ -49,7 +49,6 @@ async function run( newReceiverValue: BigNumber.from(0), newRelayParameters: new Uint8Array(), }, - nonce, relayProvider, { value: relayQuote, gasLimit: 1000000 } )