Miscellaneous fixes (#104)

* resend doesn't take nonce as parameter

* Replace 'delivery failure' with 'receiver failure' in specs

* helper send method

* Fix interface to match not having nonce for resend

* Fix forge tests to not have nonce as a parameter

* fix redeliveryTest

* fix build error

* forge fmt

* fix interface of getdefaultrelayprovider
This commit is contained in:
derpy-duck 2023-02-27 18:49:38 -05:00 committed by GitHub
parent 24d682bca4
commit 7416880825
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 24 deletions

View File

@ -26,19 +26,36 @@ contract CoreRelayer is CoreRelayerGovernance {
DeliveryStatus status 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) function send(IWormholeRelayer.Send memory request, uint32 nonce, address relayProvider)
public public
payable payable
returns (uint64 sequence) 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 { 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 public
payable payable
returns (uint64 sequence) returns (uint64 sequence)
@ -54,7 +71,7 @@ contract CoreRelayer is CoreRelayerGovernance {
checkRedeliveryInstruction(instruction, provider); checkRedeliveryInstruction(instruction, provider);
sequence = wormhole().publishMessage{value: wormholeMessageFee()}( 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. //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; return registeredCoreRelayerContract(vm.emitterChainId) == vm.emitterAddress;
} }
function getDefaultRelayProvider() public view returns (IRelayProvider) { function getDefaultRelayProvider() public view returns (address) {
return defaultRelayProvider(); return defaultRelayProvider();
} }

View File

@ -53,8 +53,8 @@ contract CoreRelayerGetters is CoreRelayerState {
return _state.registeredCoreRelayerContract[chain]; return _state.registeredCoreRelayerContract[chain];
} }
function defaultRelayProvider() internal view returns (IRelayProvider) { function defaultRelayProvider() internal view returns (address) {
return IRelayProvider(_state.defaultRelayProvider); return _state.defaultRelayProvider;
} }
function getForwardInstruction() internal view returns (CoreRelayerStructs.ForwardInstruction memory) { function getForwardInstruction() internal view returns (CoreRelayerStructs.ForwardInstruction memory) {

View File

@ -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 * 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 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. * @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' * 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 * 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. * @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 * 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 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. * @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' * 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 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()' * @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 * 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 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. * @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' * 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 * 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. * @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, * @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 * 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. * @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' * 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 * 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. * @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 * 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 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. * @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) * 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. * @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 * The relay provider will listen for these messages, and then execute the redelivery as described
*/ */
function resend(ResendByTx memory request, uint32 nonce, address relayProvider) function resend(ResendByTx memory request, address relayProvider) external payable returns (uint64 sequence);
external
payable
returns (uint64 sequence);
/** /**
* @notice This 'MultichainSend' struct represents a collection of send requests 'requests' and a specified relay provider 'relayProviderAddress' * @notice This 'MultichainSend' struct represents a collection of send requests 'requests' and a specified relay provider 'relayProviderAddress'

View File

@ -604,7 +604,7 @@ contract TestCoreRelayer is Test {
vm.deal(address(this), payment + newMaxTransactionFeeFee); vm.deal(address(this), payment + newMaxTransactionFeeFee);
setup.source.coreRelayer.resend{value: payment + newMaxTransactionFeeFee}( setup.source.coreRelayer.resend{value: payment + newMaxTransactionFeeFee}(
redeliveryRequest, 1, address(setup.source.relayProvider) redeliveryRequest, address(setup.source.relayProvider)
); );
genericRelayer(setup.sourceChainId, 1); genericRelayer(setup.sourceChainId, 1);
@ -663,7 +663,7 @@ contract TestCoreRelayer is Test {
vm.deal(address(this), payment + newMaxTransactionFeeFee); vm.deal(address(this), payment + newMaxTransactionFeeFee);
setup.source.coreRelayer.resend{value: payment + newMaxTransactionFeeFee}( setup.source.coreRelayer.resend{value: payment + newMaxTransactionFeeFee}(
redeliveryRequest, 1, address(setup.source.relayProvider) redeliveryRequest, address(setup.source.relayProvider)
); );
genericRelayer(setup.sourceChainId, 1); genericRelayer(setup.sourceChainId, 1);
@ -689,7 +689,7 @@ contract TestCoreRelayer is Test {
vm.deal(address(this), payment + newMaxTransactionFeeFee - 1); vm.deal(address(this), payment + newMaxTransactionFeeFee - 1);
setup.source.coreRelayer.resend{value: 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); genericRelayer(setup.sourceChainId, 1);
@ -855,11 +855,11 @@ contract TestCoreRelayer is Test {
vm.deal(address(this), stack.payment); vm.deal(address(this), stack.payment);
vm.expectRevert(abi.encodeWithSignature("MsgValueTooLow()")); vm.expectRevert(abi.encodeWithSignature("MsgValueTooLow()"));
setup.source.coreRelayer.resend{value: stack.payment - 1}( 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}( setup.source.coreRelayer.resend{value: stack.payment}(
stack.redeliveryRequest, 1, address(setup.source.relayProvider) stack.redeliveryRequest, address(setup.source.relayProvider)
); );
stack.entries = vm.getRecordedLogs(); stack.entries = vm.getRecordedLogs();
@ -934,7 +934,7 @@ contract TestCoreRelayer is Test {
vm.deal(address(this), stack.payment); vm.deal(address(this), stack.payment);
vm.getRecordedLogs(); vm.getRecordedLogs();
setup.source.coreRelayer.resend{value: stack.payment}( setup.source.coreRelayer.resend{value: stack.payment}(
stack.redeliveryRequest, 1, address(setup.source.relayProvider) stack.redeliveryRequest, address(setup.source.relayProvider)
); );
stack.entries = vm.getRecordedLogs(); stack.entries = vm.getRecordedLogs();
setup.source.relayProvider.updateDeliveryAddress( setup.source.relayProvider.updateDeliveryAddress(
@ -1002,7 +1002,7 @@ contract TestCoreRelayer is Test {
vm.deal(address(this), stack.payment); vm.deal(address(this), stack.payment);
vm.getRecordedLogs(); vm.getRecordedLogs();
setup.source.coreRelayer.resend{value: stack.payment}( setup.source.coreRelayer.resend{value: stack.payment}(
stack.redeliveryRequest, 1, address(setup.source.relayProvider) stack.redeliveryRequest, address(setup.source.relayProvider)
); );
stack.entries = vm.getRecordedLogs(); stack.entries = vm.getRecordedLogs();
setup.source.relayProvider.updateDeliveryAddress( setup.source.relayProvider.updateDeliveryAddress(

View File

@ -49,7 +49,6 @@ async function run(
newReceiverValue: BigNumber.from(0), newReceiverValue: BigNumber.from(0),
newRelayParameters: new Uint8Array(), newRelayParameters: new Uint8Array(),
}, },
nonce,
relayProvider, relayProvider,
{ value: relayQuote, gasLimit: 1000000 } { value: relayQuote, gasLimit: 1000000 }
) )