Forward uses same refund chain id and refund address (#3034)
* WIP * Fixes * Forward uses same refund chain id and refund address * Updated interfaces
This commit is contained in:
parent
9d47614047
commit
6c19fea9b0
|
@ -260,8 +260,7 @@ interface IWormholeRelayerSend is IWormholeRelayerBase {
|
|||
*
|
||||
* The difference between the two sides of the above inequality will be added to `paymentForExtraReceiverValue` of the first forward requested
|
||||
*
|
||||
* Any refunds (from leftover gas) will be paid to the delivery provider. In order to receive the refunds, use the 'forwardToEvm' function
|
||||
* with `refundChain` and `refundAddress` as parameters
|
||||
* Any refunds (from leftover gas) from this forward will be paid to the same refundChain and refundAddress specified for the current delivery.
|
||||
*
|
||||
* @param targetChain in Wormhole Chain ID format
|
||||
* @param targetAddress address to call on targetChain (that implements IWormholeReceiver), in Wormhole bytes32 format
|
||||
|
@ -296,8 +295,7 @@ interface IWormholeRelayerSend is IWormholeRelayerBase {
|
|||
*
|
||||
* The difference between the two sides of the above inequality will be added to `paymentForExtraReceiverValue` of the first forward requested
|
||||
*
|
||||
* Any refunds (from leftover gas) will be paid to the delivery provider. In order to receive the refunds, use the 'forwardToEvm' function
|
||||
* with `refundChain` and `refundAddress` as parameters
|
||||
* Any refunds (from leftover gas) from this forward will be paid to the same refundChain and refundAddress specified for the current delivery.
|
||||
*
|
||||
* @param targetChain in Wormhole Chain ID format
|
||||
* @param targetAddress address to call on targetChain (that implements IWormholeReceiver), in Wormhole bytes32 format
|
||||
|
|
|
@ -262,8 +262,7 @@ interface IWormholeRelayerSend is IWormholeRelayerBase {
|
|||
*
|
||||
* The difference between the two sides of the above inequality will be added to `paymentForExtraReceiverValue` of the first forward requested
|
||||
*
|
||||
* Any refunds (from leftover gas) will be paid to the delivery provider. In order to receive the refunds, use the 'forwardToEvm' function
|
||||
* with `refundChain` and `refundAddress` as parameters
|
||||
* Any refunds (from leftover gas) from this forward will be paid to the same refundChain and refundAddress specified for the current delivery.
|
||||
*
|
||||
* @param targetChain in Wormhole Chain ID format
|
||||
* @param targetAddress address to call on targetChain (that implements IWormholeReceiver), in Wormhole bytes32 format
|
||||
|
@ -298,8 +297,7 @@ interface IWormholeRelayerSend is IWormholeRelayerBase {
|
|||
*
|
||||
* The difference between the two sides of the above inequality will be added to `paymentForExtraReceiverValue` of the first forward requested
|
||||
*
|
||||
* Any refunds (from leftover gas) will be paid to the delivery provider. In order to receive the refunds, use the 'forwardToEvm' function
|
||||
* with `refundChain` and `refundAddress` as parameters
|
||||
* Any refunds (from leftover gas) from this forward will be paid to the same refundChain and refundAddress specified for the current delivery.
|
||||
*
|
||||
* @param targetChain in Wormhole Chain ID format
|
||||
* @param targetAddress address to call on targetChain (that implements IWormholeReceiver), in Wormhole bytes32 format
|
||||
|
|
|
@ -101,7 +101,7 @@ abstract contract WormholeRelayerBase is IWormholeRelayerBase {
|
|||
|
||||
// ----------------------- delivery transaction temorary storage functions -----------------------
|
||||
|
||||
function startDelivery(address targetAddress, address deliveryProvider) internal {
|
||||
function startDelivery(address targetAddress, address deliveryProvider, uint16 refundChain, bytes32 refundAddress) internal {
|
||||
DeliveryTmpState storage state = getDeliveryTmpState();
|
||||
if (state.deliveryInProgress) {
|
||||
revert ReentrantDelivery(msg.sender, state.deliveryTarget);
|
||||
|
@ -110,6 +110,8 @@ abstract contract WormholeRelayerBase is IWormholeRelayerBase {
|
|||
state.deliveryInProgress = true;
|
||||
state.deliveryTarget = targetAddress;
|
||||
state.deliveryProvider = deliveryProvider;
|
||||
state.refundChain = refundChain;
|
||||
state.refundAddress = refundAddress;
|
||||
}
|
||||
|
||||
function finishDelivery() internal {
|
||||
|
@ -117,6 +119,8 @@ abstract contract WormholeRelayerBase is IWormholeRelayerBase {
|
|||
state.deliveryInProgress = false;
|
||||
state.deliveryTarget = address(0);
|
||||
state.deliveryProvider = address(0);
|
||||
state.refundChain = 0;
|
||||
state.refundAddress = bytes32(0);
|
||||
delete state.forwardInstructions;
|
||||
}
|
||||
|
||||
|
@ -132,6 +136,14 @@ abstract contract WormholeRelayerBase is IWormholeRelayerBase {
|
|||
return getDeliveryTmpState().deliveryProvider;
|
||||
}
|
||||
|
||||
function getCurrentRefundChain() internal view returns (uint16) {
|
||||
return getDeliveryTmpState().refundChain;
|
||||
}
|
||||
|
||||
function getCurrentRefundAddress() internal view returns (bytes32) {
|
||||
return getDeliveryTmpState().refundAddress;
|
||||
}
|
||||
|
||||
function checkMsgSenderInDelivery() internal view {
|
||||
DeliveryTmpState storage state = getDeliveryTmpState();
|
||||
if (!state.deliveryInProgress) {
|
||||
|
|
|
@ -71,7 +71,9 @@ abstract contract WormholeRelayerDelivery is WormholeRelayerBase, IWormholeRelay
|
|||
// cost of the happy path.
|
||||
startDelivery(
|
||||
fromWormholeFormat(instruction.targetAddress),
|
||||
fromWormholeFormat(instruction.refundDeliveryProvider)
|
||||
fromWormholeFormat(instruction.refundDeliveryProvider),
|
||||
instruction.refundChain,
|
||||
instruction.refundAddress
|
||||
);
|
||||
|
||||
DeliveryVAAInfo memory deliveryVaaInfo = DeliveryVAAInfo({
|
||||
|
|
|
@ -162,17 +162,17 @@ abstract contract WormholeRelayerSend is WormholeRelayerBase, IWormholeRelayerSe
|
|||
TargetNative receiverValue,
|
||||
Gas gasLimit
|
||||
) external payable {
|
||||
(address deliveryProvider, address deliveryProviderOnTarget) =
|
||||
(address deliveryProvider,) =
|
||||
getOriginalOrDefaultDeliveryProvider(targetChain);
|
||||
forwardToEvm(
|
||||
forward(
|
||||
targetChain,
|
||||
targetAddress,
|
||||
toWormholeFormat(targetAddress),
|
||||
payload,
|
||||
receiverValue,
|
||||
LocalNative.wrap(0),
|
||||
gasLimit,
|
||||
targetChain,
|
||||
deliveryProviderOnTarget,
|
||||
encodeEvmExecutionParamsV1(EvmExecutionParamsV1(gasLimit)),
|
||||
getCurrentRefundChain(),
|
||||
getCurrentRefundAddress(),
|
||||
deliveryProvider,
|
||||
new VaaKey[](0),
|
||||
CONSISTENCY_LEVEL_FINALIZED
|
||||
|
@ -187,17 +187,17 @@ abstract contract WormholeRelayerSend is WormholeRelayerBase, IWormholeRelayerSe
|
|||
Gas gasLimit,
|
||||
VaaKey[] memory vaaKeys
|
||||
) external payable {
|
||||
(address deliveryProvider, address deliveryProviderOnTarget) =
|
||||
(address deliveryProvider,) =
|
||||
getOriginalOrDefaultDeliveryProvider(targetChain);
|
||||
forwardToEvm(
|
||||
forward(
|
||||
targetChain,
|
||||
targetAddress,
|
||||
toWormholeFormat(targetAddress),
|
||||
payload,
|
||||
receiverValue,
|
||||
LocalNative.wrap(0),
|
||||
gasLimit,
|
||||
targetChain,
|
||||
deliveryProviderOnTarget,
|
||||
encodeEvmExecutionParamsV1(EvmExecutionParamsV1(gasLimit)),
|
||||
getCurrentRefundChain(),
|
||||
getCurrentRefundAddress(),
|
||||
deliveryProvider,
|
||||
vaaKeys,
|
||||
CONSISTENCY_LEVEL_FINALIZED
|
||||
|
|
|
@ -82,6 +82,10 @@ struct DeliveryTmpState {
|
|||
address deliveryTarget;
|
||||
// the target relay provider address for the in-progress delivery
|
||||
address deliveryProvider;
|
||||
// the refund chain for the in-progress delivery
|
||||
uint16 refundChain;
|
||||
// the refund address for the in-progress delivery
|
||||
bytes32 refundAddress;
|
||||
// Requests which will be forwarded from the current delivery.
|
||||
ForwardInstruction[] forwardInstructions;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue