Skip to content

Commit

Permalink
AutoRelayer: v1.1 Release (wormhole-foundation#3313)
Browse files Browse the repository at this point in the history
* AutoRelayer: remove forwards

* AutoRelayer: reentrancy guard

* AutoRelayer: remove forwards from sdk

* AutoRelayer: VaaKey -> MessageKey internals

* AutoRelayer: check delivery provider supports keyType

* AutoRelayer: VaaKey backcompat wire format

* AutoRelayer: sdk fix

* AutoRelayer: Add supported keys to delivery provider

* AutoRelayer: reintroduce reentrancy guard, revert when replay protection triggered

* AutoRelayer: fix manual delivery test

* AutoRelayer: review flups

* AutoRelayer: move libraries within relayer folder

* AutoRelayer: fix delivery provider config script

Also fix delivery provider revert bug

* AutoRelayer: Andreas code review flups

* AutoRelayer: js sdk includes MessageKey serde

* AutoRelayer: update sdk to use message key

* AutoRelayer: Simplify executeInstruction to internal call (wormhole-foundation#3352)

* refund instead of revert for replay protection (wormhole-foundation#3371)

* refund instead of revert for replay protection

* Remove mention of forward from IWormholeReceiver

* AutoRelayer: 1.1 reintroduce forwards (wormhole-foundation#3385)

* forward fallback WIP

* forward fallback no tmp storage

* Re-introduce testing of 'forward'

* Reintroduce forwards with original or default behavior for refund info + delivery provider info

* Reintroduce reentrant, only store refund information

---------

Co-authored-by: Joe Howarth <josephehowarth@gmail.com>
Co-authored-by: Joe Howarth <jhowarth@jumptrading.com>
  • Loading branch information
3 people authored Sep 22, 2023
1 parent 8872bf7 commit faa397c
Show file tree
Hide file tree
Showing 37 changed files with 1,586 additions and 2,021 deletions.
46 changes: 45 additions & 1 deletion ethereum/contracts/interfaces/relayer/IDeliveryProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,33 @@
pragma solidity ^0.8.0;

interface IDeliveryProvider {

/**
* @notice This function returns
*
* 1) nativePriceQuote: the price of a delivery (by this delivery provider) to chain
* 'targetChain', giving the user's contract 'receiverValue' target chain wei and performing the
* relay with the execution parameters (e.g. the gas limit) specified in 'encodedExecutionParameters'
*
* 2) encodedExecutionInfo: information relating to how this delivery provider
* will perform such a delivery (e.g. the gas limit, and the amount it will refund per gas unused)
*
* encodedExecutionParameters and encodedExecutionInfo both are encodings of versioned structs -
* version EVM_V1 of ExecutionParameters specifies the gas limit,
* and version EVM_V1 of ExecutionInfo specifies the gas limit and the amount that this delivery provider
* will refund per unit of gas unused
*/
function quoteDeliveryPrice(
uint16 targetChain,
uint256 receiverValue,
bytes memory encodedExecutionParams
) external view returns (uint256 nativePriceQuote, bytes memory encodedExecutionInfo);

/**
* @notice This function returns the amount of extra 'receiverValue' (msg.value on the target chain)
* that will be sent to your contract, if you specify 'currentChainAmount' in the
* 'paymentForExtraReceiverValue' field on 'send'
*/
function quoteAssetConversion(
uint16 targetChain,
uint256 currentChainAmount
Expand All @@ -17,7 +38,6 @@ interface IDeliveryProvider {
/**
* @notice This function should return a payable address on this (source) chain where all awards
* should be sent for the relay provider.
*
*/
function getRewardAddress() external view returns (address payable rewardAddress);

Expand All @@ -29,6 +49,30 @@ interface IDeliveryProvider {
*/
function isChainSupported(uint16 targetChain) external view returns (bool supported);

/**
* @notice This function determines whether a relay provider supports the given keyType.
*
* Note: 0-127 are reserved for standardized keyTypes and 128-255 are allowed to be custom per DeliveryProvider
* Practically this means that 0-127 must mean the same thing for all DeliveryProviders,
* while x within 128-255 may have different meanings between DeliveryProviders
* (e.g. 130 for provider A means pyth price quotes while 130 for provider B means tweets,
* but 8 must mean the same for both)
*
* @param keyType - The keyType within MessageKey that specifies what the encodedKey within a MessageKey means
*/
function isMessageKeyTypeSupported(uint8 keyType) external view returns (bool supported);

/**
* @notice This function returns a bitmap encoding all the keyTypes this provider supports
*
* Note: 0-127 are reserved for standardized keyTypes and 128-255 are allowed to be custom per DeliveryProvider
* Practically this means that 0-127 must mean the same thing for all DeliveryProviders,
* while x within 128-255 may have different meanings between DeliveryProviders
* (e.g. 130 for provider A means pyth price quotes while 130 for provider B means tweets,
* but 8 must mean the same for both)
*/
function getSupportedKeys() external view returns (uint256 bitmap);

/**
* @notice If a DeliveryProvider supports a given chain, this function should provide the contract
* address (in wormhole format) of the relay provider on that chain.
Expand Down
46 changes: 45 additions & 1 deletion ethereum/contracts/interfaces/relayer/IDeliveryProviderTyped.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,33 @@ pragma solidity ^0.8.0;
import "./TypedUnits.sol";

interface IDeliveryProvider {

/**
* @notice This function returns
*
* 1) nativePriceQuote: the price of a delivery (by this delivery provider) to chain
* 'targetChain', giving the user's contract 'receiverValue' target chain wei and performing the
* relay with the execution parameters (e.g. the gas limit) specified in 'encodedExecutionParameters'
*
* 2) encodedExecutionInfo: information relating to how this delivery provider
* will perform such a delivery (e.g. the gas limit, and the amount it will refund per gas unused)
*
* encodedExecutionParameters and encodedExecutionInfo both are encodings of versioned structs -
* version EVM_V1 of ExecutionParameters specifies the gas limit,
* and version EVM_V1 of ExecutionInfo specifies the gas limit and the amount that this delivery provider
* will refund per unit of gas unused
*/
function quoteDeliveryPrice(
uint16 targetChain,
TargetNative receiverValue,
bytes memory encodedExecutionParams
) external view returns (LocalNative nativePriceQuote, bytes memory encodedExecutionInfo);

/**
* @notice This function returns the amount of extra 'receiverValue' (msg.value on the target chain)
* that will be sent to your contract, if you specify 'currentChainAmount' in the
* 'paymentForExtraReceiverValue' field on 'send'
*/
function quoteAssetConversion(
uint16 targetChain,
LocalNative currentChainAmount
Expand All @@ -19,7 +40,6 @@ interface IDeliveryProvider {
/**
* @notice This function should return a payable address on this (source) chain where all awards
* should be sent for the relay provider.
*
*/
function getRewardAddress() external view returns (address payable rewardAddress);

Expand All @@ -31,6 +51,30 @@ interface IDeliveryProvider {
*/
function isChainSupported(uint16 targetChain) external view returns (bool supported);

/**
* @notice This function determines whether a relay provider supports the given keyType.
*
* Note: 0-127 are reserved for standardized keyTypes and 128-255 are allowed to be custom per DeliveryProvider
* Practically this means that 0-127 must mean the same thing for all DeliveryProviders,
* while x within 128-255 may have different meanings between DeliveryProviders
* (e.g. 130 for provider A means pyth price quotes while 130 for provider B means tweets,
* but 8 must mean the same for both)
*
* @param keyType - The keyType within MessageKey that specifies what the encodedKey within a MessageKey means
*/
function isMessageKeyTypeSupported(uint8 keyType) external view returns (bool supported);

/**
* @notice This function returns a bitmap encoding all the keyTypes this provider supports
*
* Note: 0-127 are reserved for standardized keyTypes and 128-255 are allowed to be custom per DeliveryProvider
* Practically this means that 0-127 must mean the same thing for all DeliveryProviders,
* while x within 128-255 may have different meanings between DeliveryProviders
* (e.g. 130 for provider A means pyth price quotes while 130 for provider B means tweets,
* but 8 must mean the same for both)
*/
function getSupportedKeys() external view returns (uint256 bitmap);

/**
* @notice If a DeliveryProvider supports a given chain, this function should provide the contract
* address (in wormhole format) of the relay provider on that chain.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface IWormholeReceiver {
* on every call, checks that deliveryHash has not already been stored in the
* map (This is to prevent other users maliciously trying to relay the same message)
* - Checks that `sourceChain` and `sourceAddress` are indeed who
* you expect to have requested the calling of `send` or `forward` on the source chain
* you expect to have requested the calling of `send` on the source chain
*
* The invocation of this function corresponding to the `send` request will have msg.value equal
* to the receiverValue specified in the send request.
Expand Down
Loading

0 comments on commit faa397c

Please sign in to comment.