2022-09-30 09:18:49 -07:00
|
|
|
// contracts/Bridge.sol
|
|
|
|
// SPDX-License-Identifier: Apache 2
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
|
|
|
|
import "../libraries/external/BytesLib.sol";
|
|
|
|
|
|
|
|
import "./CoreRelayerGetters.sol";
|
|
|
|
import "./CoreRelayerStructs.sol";
|
2023-02-27 11:32:57 -08:00
|
|
|
import "../interfaces/IWormholeRelayer.sol";
|
2022-09-30 09:18:49 -07:00
|
|
|
|
|
|
|
contract CoreRelayerMessages is CoreRelayerStructs, CoreRelayerGetters {
|
|
|
|
using BytesLib for bytes;
|
|
|
|
|
2023-01-19 06:59:35 -08:00
|
|
|
error InvalidPayloadId(uint8 payloadId);
|
|
|
|
error InvalidDeliveryInstructionsPayload(uint256 length);
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
/**
|
|
|
|
* @notice This function calculates the total fee to execute all of the Send requests in this MultichainSend container
|
|
|
|
* @param sendContainer A MultichainSend struct describing all of the Send requests
|
|
|
|
* @return totalFee
|
|
|
|
*/
|
|
|
|
function getTotalFeeMultichainSend(IWormholeRelayer.MultichainSend memory sendContainer, uint256 wormholeMessageFee)
|
2023-02-27 11:32:57 -08:00
|
|
|
internal
|
|
|
|
view
|
|
|
|
returns (uint256 totalFee)
|
|
|
|
{
|
2023-02-28 07:09:01 -08:00
|
|
|
totalFee = wormholeMessageFee;
|
2023-02-27 11:32:57 -08:00
|
|
|
uint256 length = sendContainer.requests.length;
|
|
|
|
for (uint256 i = 0; i < length; i++) {
|
|
|
|
IWormholeRelayer.Send memory request = sendContainer.requests[i];
|
|
|
|
totalFee += request.maxTransactionFee + request.receiverValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
/**
|
|
|
|
* @notice This function converts a MultichainSend struct into a DeliveryInstructionsContainer struct that
|
|
|
|
* describes to the relayer exactly how to relay for each of the Send requests.
|
|
|
|
* Specifically, each Send is converted to a DeliveryInstruction, which is a struct that contains six fields:
|
|
|
|
* 1) targetChain, 2) targetAddress, 3) refundAddress (all which are part of the Send struct),
|
|
|
|
* 4) maximumRefundTarget: The maximum amount that can be refunded to 'refundAddress' (e.g. if the call to 'receiveWormholeMessages' takes 0 gas),
|
|
|
|
* 5) receiverValueTarget: The amount that will be passed into 'receiveWormholeMessages' as value, in target chain currency
|
|
|
|
* 6) executionParameters: a struct with information about execution, specifically:
|
|
|
|
* executionParameters.gasLimit: The maximum amount of gas 'receiveWormholeMessages' is allowed to use
|
|
|
|
* executionParameters.providerDeliveryAddress: The address of the relayer that will execute this Send request
|
|
|
|
* The latter 3 fields are calculated using the relayProvider's getters
|
|
|
|
* @param sendContainer A MultichainSend struct describing all of the Send requests
|
|
|
|
* @return instructionsContainer A DeliveryInstructionsContainer struct
|
|
|
|
*/
|
2023-02-27 11:32:57 -08:00
|
|
|
function convertMultichainSendToDeliveryInstructionsContainer(IWormholeRelayer.MultichainSend memory sendContainer)
|
|
|
|
internal
|
|
|
|
view
|
|
|
|
returns (DeliveryInstructionsContainer memory instructionsContainer)
|
|
|
|
{
|
|
|
|
instructionsContainer.payloadId = 1;
|
|
|
|
IRelayProvider relayProvider = IRelayProvider(sendContainer.relayProviderAddress);
|
|
|
|
uint256 length = sendContainer.requests.length;
|
|
|
|
instructionsContainer.instructions = new DeliveryInstruction[](length);
|
|
|
|
for (uint256 i = 0; i < length; i++) {
|
|
|
|
instructionsContainer.instructions[i] =
|
|
|
|
convertSendToDeliveryInstruction(sendContainer.requests[i], relayProvider);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
/**
|
|
|
|
* @notice This function converts a Send struct into a DeliveryInstruction struct that
|
|
|
|
* describes to the relayer exactly how to relay for the Send.
|
|
|
|
* Specifically, the DeliveryInstruction struct that contains six fields:
|
|
|
|
* 1) targetChain, 2) targetAddress, 3) refundAddress (all which are part of the Send struct),
|
|
|
|
* 4) maximumRefundTarget: The maximum amount that can be refunded to 'refundAddress' (e.g. if the call to 'receiveWormholeMessages' takes 0 gas),
|
|
|
|
* 5) receiverValueTarget: The amount that will be passed into 'receiveWormholeMessages' as value, in target chain currency
|
|
|
|
* 6) executionParameters: a struct with information about execution, specifically:
|
|
|
|
* executionParameters.gasLimit: The maximum amount of gas 'receiveWormholeMessages' is allowed to use
|
|
|
|
* executionParameters.providerDeliveryAddress: The address of the relayer that will execute this Send request
|
|
|
|
* The latter 3 fields are calculated using the relayProvider's getters
|
|
|
|
* @param send A Send struct
|
|
|
|
* @param relayProvider The relay provider chosen for this Send
|
|
|
|
* @return instruction A DeliveryInstruction
|
|
|
|
*/
|
2023-02-27 11:32:57 -08:00
|
|
|
function convertSendToDeliveryInstruction(IWormholeRelayer.Send memory send, IRelayProvider relayProvider)
|
|
|
|
internal
|
|
|
|
view
|
|
|
|
returns (DeliveryInstruction memory instruction)
|
|
|
|
{
|
|
|
|
instruction.targetChain = send.targetChain;
|
|
|
|
instruction.targetAddress = send.targetAddress;
|
|
|
|
instruction.refundAddress = send.refundAddress;
|
|
|
|
instruction.maximumRefundTarget =
|
|
|
|
calculateTargetDeliveryMaximumRefund(send.targetChain, send.maxTransactionFee, relayProvider);
|
|
|
|
instruction.receiverValueTarget =
|
|
|
|
convertReceiverValueAmount(send.receiverValue, send.targetChain, relayProvider);
|
|
|
|
instruction.executionParameters = ExecutionParameters({
|
|
|
|
version: 1,
|
|
|
|
gasLimit: calculateTargetGasDeliveryAmount(send.targetChain, send.maxTransactionFee, relayProvider),
|
|
|
|
providerDeliveryAddress: relayProvider.getDeliveryAddress(send.targetChain)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
/**
|
|
|
|
* @notice Check if for each instruction in the DeliveryInstructionContainer,
|
|
|
|
* - the total amount of target chain currency needed for execution of the instruction is within the maximum budget,
|
|
|
|
* i.e. (maximumRefundTarget + receiverValueTarget) <= (the relayProvider's maximum budget for the target chain)
|
|
|
|
* - the gasLimit is greater than 0
|
|
|
|
* @param container A DeliveryInstructionsContainer
|
|
|
|
* @param relayProvider The relayProvider whos maximum budget we are checking against
|
|
|
|
*/
|
2023-02-27 11:32:57 -08:00
|
|
|
function checkInstructions(DeliveryInstructionsContainer memory container, IRelayProvider relayProvider)
|
|
|
|
internal
|
|
|
|
view
|
|
|
|
{
|
|
|
|
uint256 length = container.instructions.length;
|
|
|
|
for (uint8 i = 0; i < length; i++) {
|
|
|
|
DeliveryInstruction memory instruction = container.instructions[i];
|
|
|
|
if (instruction.executionParameters.gasLimit == 0) {
|
|
|
|
revert IWormholeRelayer.MaxTransactionFeeNotEnough(i);
|
|
|
|
}
|
|
|
|
if (
|
2023-02-28 07:09:01 -08:00
|
|
|
instruction.maximumRefundTarget + instruction.receiverValueTarget
|
2023-02-27 11:32:57 -08:00
|
|
|
> relayProvider.quoteMaximumBudget(instruction.targetChain)
|
|
|
|
) {
|
|
|
|
revert IWormholeRelayer.FundsTooMuch(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
/**
|
|
|
|
* @notice Check if for a redelivery instruction,
|
|
|
|
* - the total amount of target chain currency needed for execution of this instruction is within the maximum budget,
|
|
|
|
* i.e. (maximumRefundTarget + receiverValueTarget) <= (the relayProvider's maximum budget for the target chain)
|
|
|
|
* - the gasLimit is greater than 0
|
|
|
|
* @param instruction A RedeliveryByTxHashInstruction
|
|
|
|
* @param relayProvider The relayProvider whos maximum budget we are checking against
|
|
|
|
*/
|
|
|
|
function checkRedeliveryInstruction(
|
|
|
|
RedeliveryByTxHashInstruction memory instruction,
|
|
|
|
IRelayProvider relayProvider,
|
|
|
|
uint256 wormholeMessageFee
|
|
|
|
) internal view {
|
2023-02-27 11:32:57 -08:00
|
|
|
if (instruction.executionParameters.gasLimit == 0) {
|
|
|
|
revert IWormholeRelayer.MaxTransactionFeeNotEnough(0);
|
|
|
|
}
|
|
|
|
if (
|
2023-02-28 07:09:01 -08:00
|
|
|
instruction.newMaximumRefundTarget + instruction.newReceiverValueTarget + wormholeMessageFee
|
2023-02-27 11:32:57 -08:00
|
|
|
> relayProvider.quoteMaximumBudget(instruction.targetChain)
|
|
|
|
) {
|
|
|
|
revert IWormholeRelayer.FundsTooMuch(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
/**
|
|
|
|
* @notice This function converts a ResendByTx struct into a RedeliveryByTxHashInstruction struct that
|
|
|
|
* describes to the relayer exactly how to relay for the ResendByTx.
|
|
|
|
* Specifically, the RedeliveryByTxHashInstruction struct that contains nine fields:
|
|
|
|
* 1) sourceChain, 2) sourceTxHash, 3) sourceNonce, 4) targetChain, 5) deliveryIndex, 6) multisendIndex (all which are part of the ResendByTxHash struct),
|
|
|
|
* 7) newMaximumRefundTarget: The new maximum amount that can be refunded to 'refundAddress' (e.g. if the call to 'receiveWormholeMessages' takes 0 gas),
|
|
|
|
* 8) newReceiverValueTarget: The new amount that will be passed into 'receiveWormholeMessages' as value, in target chain currency
|
|
|
|
* 9) executionParameters: a struct with information about execution, specifically:
|
|
|
|
* executionParameters.gasLimit: The maximum amount of gas 'receiveWormholeMessages' is allowed to use
|
|
|
|
* executionParameters.providerDeliveryAddress: The address of the relayer that will execute this ResendByTx request
|
|
|
|
* The latter 3 fields are calculated using the relayProvider's getters
|
|
|
|
* @param resend A ResendByTx struct
|
|
|
|
* @param relayProvider The relay provider chosen for this ResendByTx
|
|
|
|
* @return instruction A DeliveryInstruction
|
|
|
|
*/
|
|
|
|
function convertResendToRedeliveryInstruction(
|
|
|
|
IWormholeRelayer.ResendByTx memory resend,
|
|
|
|
IRelayProvider relayProvider
|
|
|
|
) internal view returns (RedeliveryByTxHashInstruction memory instruction) {
|
2023-02-27 11:32:57 -08:00
|
|
|
instruction.payloadId = 2;
|
2023-02-28 07:09:01 -08:00
|
|
|
instruction.sourceChain = resend.sourceChain;
|
|
|
|
instruction.sourceTxHash = resend.sourceTxHash;
|
|
|
|
instruction.sourceNonce = resend.sourceNonce;
|
|
|
|
instruction.targetChain = resend.targetChain;
|
|
|
|
instruction.deliveryIndex = resend.deliveryIndex;
|
|
|
|
instruction.multisendIndex = resend.multisendIndex;
|
2023-02-27 11:32:57 -08:00
|
|
|
instruction.newMaximumRefundTarget =
|
2023-02-28 07:09:01 -08:00
|
|
|
calculateTargetRedeliveryMaximumRefund(resend.targetChain, resend.newMaxTransactionFee, relayProvider);
|
2023-02-27 11:32:57 -08:00
|
|
|
instruction.newReceiverValueTarget =
|
2023-02-28 07:09:01 -08:00
|
|
|
convertReceiverValueAmount(resend.newReceiverValue, resend.targetChain, relayProvider);
|
2023-02-27 11:32:57 -08:00
|
|
|
instruction.executionParameters = ExecutionParameters({
|
|
|
|
version: 1,
|
2023-02-28 07:09:01 -08:00
|
|
|
gasLimit: calculateTargetGasRedeliveryAmount(resend.targetChain, resend.newMaxTransactionFee, relayProvider),
|
|
|
|
providerDeliveryAddress: relayProvider.getDeliveryAddress(resend.targetChain)
|
2023-02-27 11:32:57 -08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
// encode a 'RedeliveryByTxHashInstruction' into bytes
|
2023-02-27 11:32:57 -08:00
|
|
|
function encodeRedeliveryInstruction(RedeliveryByTxHashInstruction memory instruction)
|
2023-01-05 16:46:58 -08:00
|
|
|
internal
|
|
|
|
pure
|
2023-02-27 11:32:57 -08:00
|
|
|
returns (bytes memory encoded)
|
|
|
|
{
|
|
|
|
encoded = abi.encodePacked(
|
|
|
|
instruction.payloadId,
|
|
|
|
instruction.sourceChain,
|
|
|
|
instruction.sourceTxHash,
|
|
|
|
instruction.sourceNonce,
|
|
|
|
instruction.targetChain,
|
|
|
|
instruction.deliveryIndex,
|
|
|
|
instruction.multisendIndex,
|
|
|
|
instruction.newMaximumRefundTarget,
|
|
|
|
instruction.newReceiverValueTarget,
|
|
|
|
instruction.executionParameters.version,
|
|
|
|
instruction.executionParameters.gasLimit,
|
|
|
|
instruction.executionParameters.providerDeliveryAddress
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
// encode a 'DeliveryInstructionsContainer' into bytes
|
2023-02-27 11:32:57 -08:00
|
|
|
function encodeDeliveryInstructionsContainer(DeliveryInstructionsContainer memory container)
|
|
|
|
internal
|
|
|
|
pure
|
|
|
|
returns (bytes memory encoded)
|
|
|
|
{
|
|
|
|
encoded = abi.encodePacked(
|
|
|
|
container.payloadId, uint8(container.sufficientlyFunded ? 1 : 0), uint8(container.instructions.length)
|
|
|
|
);
|
|
|
|
|
|
|
|
for (uint256 i = 0; i < container.instructions.length; i++) {
|
|
|
|
encoded = abi.encodePacked(encoded, encodeDeliveryInstruction(container.instructions[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
// encode a 'DeliveryInstruction' into bytes
|
2023-02-27 11:32:57 -08:00
|
|
|
function encodeDeliveryInstruction(DeliveryInstruction memory instruction)
|
|
|
|
internal
|
|
|
|
pure
|
|
|
|
returns (bytes memory encoded)
|
|
|
|
{
|
|
|
|
encoded = abi.encodePacked(
|
|
|
|
instruction.targetChain,
|
|
|
|
instruction.targetAddress,
|
|
|
|
instruction.refundAddress,
|
|
|
|
instruction.maximumRefundTarget,
|
|
|
|
instruction.receiverValueTarget,
|
|
|
|
instruction.executionParameters.version,
|
|
|
|
instruction.executionParameters.gasLimit,
|
|
|
|
instruction.executionParameters.providerDeliveryAddress
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a targetChain, maxTransactionFee, and a relay provider, this function calculates what the gas limit of the delivery transaction
|
2023-02-28 07:09:01 -08:00
|
|
|
* should be
|
|
|
|
*
|
|
|
|
* It does this by calculating (maxTransactionFee - deliveryOverhead)/gasPrice
|
|
|
|
* where 'deliveryOverhead' is the relayProvider's base fee for delivering to targetChain (in units of source chain currency)
|
|
|
|
* and 'gasPrice' is the relayProvider's fee per unit of target chain gas (in units of source chain currency)
|
|
|
|
*
|
|
|
|
* @param targetChain target chain
|
|
|
|
* @param maxTransactionFee uint256
|
|
|
|
* @param provider IRelayProvider
|
|
|
|
* @return gasAmount
|
2023-02-27 11:32:57 -08:00
|
|
|
*/
|
|
|
|
function calculateTargetGasDeliveryAmount(uint16 targetChain, uint256 maxTransactionFee, IRelayProvider provider)
|
|
|
|
internal
|
|
|
|
view
|
|
|
|
returns (uint32 gasAmount)
|
|
|
|
{
|
|
|
|
gasAmount = calculateTargetGasDeliveryAmountHelper(
|
|
|
|
targetChain, maxTransactionFee, provider.quoteDeliveryOverhead(targetChain), provider
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
/**
|
|
|
|
* Given a targetChain, maxTransactionFee, and a relay provider, this function calculates what the maximum refund of the delivery transaction
|
|
|
|
* should be, in terms of target chain currency
|
|
|
|
*
|
|
|
|
* The maximum refund is the amount that would be refunded to refundAddress if the call to 'receiveWormholeMessages' takes 0 gas
|
|
|
|
*
|
|
|
|
* It does this by calculating (maxTransactionFee - deliveryOverhead) and converting (using the relay provider's prices) to target chain currency
|
|
|
|
* (where 'deliveryOverhead' is the relayProvider's base fee for delivering to targetChain [in units of source chain currency])
|
|
|
|
*
|
|
|
|
* @param targetChain target chain
|
|
|
|
* @param maxTransactionFee uint256
|
|
|
|
* @param provider IRelayProvider
|
|
|
|
* @return maximumRefund uint256
|
|
|
|
*/
|
2023-02-27 11:32:57 -08:00
|
|
|
function calculateTargetDeliveryMaximumRefund(
|
|
|
|
uint16 targetChain,
|
|
|
|
uint256 maxTransactionFee,
|
|
|
|
IRelayProvider provider
|
|
|
|
) internal view returns (uint256 maximumRefund) {
|
|
|
|
maximumRefund = calculateTargetDeliveryMaximumRefundHelper(
|
|
|
|
targetChain, maxTransactionFee, provider.quoteDeliveryOverhead(targetChain), provider
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a targetChain, maxTransactionFee, and a relay provider, this function calculates what the gas limit of the redelivery transaction
|
2023-02-28 07:09:01 -08:00
|
|
|
* should be
|
|
|
|
*
|
|
|
|
* It does this by calculating (maxTransactionFee - redeliveryOverhead)/gasPrice
|
|
|
|
* where 'redeliveryOverhead' is the relayProvider's base fee for redelivering to targetChain (in units of source chain currency)
|
|
|
|
* and 'gasPrice' is the relayProvider's fee per unit of target chain gas (in units of source chain currency)
|
|
|
|
*
|
|
|
|
* @param targetChain target chain
|
|
|
|
* @param maxTransactionFee uint256
|
|
|
|
* @param provider IRelayProvider
|
|
|
|
* @return gasAmount
|
2023-02-27 11:32:57 -08:00
|
|
|
*/
|
|
|
|
function calculateTargetGasRedeliveryAmount(uint16 targetChain, uint256 maxTransactionFee, IRelayProvider provider)
|
|
|
|
internal
|
|
|
|
view
|
|
|
|
returns (uint32 gasAmount)
|
|
|
|
{
|
|
|
|
gasAmount = calculateTargetGasDeliveryAmountHelper(
|
|
|
|
targetChain, maxTransactionFee, provider.quoteRedeliveryOverhead(targetChain), provider
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
/**
|
|
|
|
* Given a targetChain, maxTransactionFee, and a relay provider, this function calculates what the maximum refund of the redelivery transaction
|
|
|
|
* should be, in terms of target chain currency
|
|
|
|
*
|
|
|
|
* The maximum refund is the amount that would be refunded to refundAddress if the call to 'receiveWormholeMessages' takes 0 gas
|
|
|
|
*
|
|
|
|
* It does this by calculating (maxTransactionFee - redeliveryOverhead) and converting (using the relay provider's prices) to target chain currency
|
|
|
|
* (where 'redeliveryOverhead' is the relayProvider's base fee for redelivering to targetChain [in units of source chain currency])
|
|
|
|
*
|
|
|
|
* @param targetChain target chain
|
|
|
|
* @param maxTransactionFee uint256
|
|
|
|
* @param provider IRelayProvider
|
|
|
|
* @return maximumRefund uint256
|
|
|
|
*/
|
2023-02-27 11:32:57 -08:00
|
|
|
function calculateTargetRedeliveryMaximumRefund(
|
|
|
|
uint16 targetChain,
|
|
|
|
uint256 maxTransactionFee,
|
|
|
|
IRelayProvider provider
|
|
|
|
) internal view returns (uint256 maximumRefund) {
|
|
|
|
maximumRefund = calculateTargetDeliveryMaximumRefundHelper(
|
|
|
|
targetChain, maxTransactionFee, provider.quoteRedeliveryOverhead(targetChain), provider
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
/**
|
|
|
|
* Performs the calculation (maxTransactionFee - overhead)/(price of 1 unit of target chain gas, in source chain currency)
|
|
|
|
* and bounds the result between 0 and 2^32-1, inclusive
|
|
|
|
*
|
|
|
|
* @param targetChain uint16
|
|
|
|
* @param maxTransactionFee uint256
|
|
|
|
* @param overhead uint256
|
|
|
|
* @param provider IRelayProvider
|
|
|
|
*/
|
2023-02-27 11:32:57 -08:00
|
|
|
function calculateTargetGasDeliveryAmountHelper(
|
|
|
|
uint16 targetChain,
|
|
|
|
uint256 maxTransactionFee,
|
2023-02-28 07:09:01 -08:00
|
|
|
uint256 overhead,
|
2023-02-27 11:32:57 -08:00
|
|
|
IRelayProvider provider
|
|
|
|
) internal view returns (uint32 gasAmount) {
|
2023-02-28 07:09:01 -08:00
|
|
|
if (maxTransactionFee <= overhead) {
|
2023-02-27 11:32:57 -08:00
|
|
|
gasAmount = 0;
|
|
|
|
} else {
|
2023-02-28 07:09:01 -08:00
|
|
|
uint256 gas = (maxTransactionFee - overhead) / provider.quoteGasPrice(targetChain);
|
2023-02-27 11:32:57 -08:00
|
|
|
if (gas > type(uint32).max) {
|
|
|
|
gasAmount = type(uint32).max;
|
|
|
|
} else {
|
|
|
|
gasAmount = uint32(gas);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
/**
|
|
|
|
* Converts (maxTransactionFee - overhead) from source to target chain currency, using the provider's prices
|
|
|
|
*
|
|
|
|
* @param targetChain uint16
|
|
|
|
* @param maxTransactionFee uint256
|
|
|
|
* @param overhead uint256
|
|
|
|
* @param provider IRelayProvider
|
|
|
|
*/
|
2023-02-27 11:32:57 -08:00
|
|
|
function calculateTargetDeliveryMaximumRefundHelper(
|
|
|
|
uint16 targetChain,
|
|
|
|
uint256 maxTransactionFee,
|
2023-02-28 07:09:01 -08:00
|
|
|
uint256 overhead,
|
2023-02-27 11:32:57 -08:00
|
|
|
IRelayProvider provider
|
|
|
|
) internal view returns (uint256 maximumRefund) {
|
2023-02-28 07:09:01 -08:00
|
|
|
if (maxTransactionFee >= overhead) {
|
|
|
|
uint256 remainder = maxTransactionFee - overhead;
|
2023-02-27 11:32:57 -08:00
|
|
|
maximumRefund = assetConversionHelper(chainId(), remainder, targetChain, 1, 1, false, provider);
|
|
|
|
} else {
|
|
|
|
maximumRefund = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
/**
|
|
|
|
* Converts 'sourceAmount' of source chain currency to units of target chain currency
|
|
|
|
* using the prices of 'provider'
|
|
|
|
* and also multiplying by a specified fraction 'multiplier/multiplierDenominator',
|
|
|
|
* rounding up or down specified by 'roundUp', and without performing intermediate rounding,
|
|
|
|
* i.e. the result should be as if float arithmetic was done and the rounding performed at the end
|
|
|
|
*
|
|
|
|
* @param sourceChain source chain
|
|
|
|
* @param sourceAmount amount of source chain currency to be converted
|
|
|
|
* @param targetChain target chain
|
|
|
|
* @param multiplier numerator of a fraction to multiply by
|
|
|
|
* @param multiplierDenominator denominator of a fraction to multiply by
|
|
|
|
* @param roundUp whether or not to round up
|
|
|
|
* @param provider relay provider
|
|
|
|
* @return targetAmount amount of target chain currency
|
|
|
|
*/
|
2023-02-27 11:32:57 -08:00
|
|
|
function assetConversionHelper(
|
|
|
|
uint16 sourceChain,
|
|
|
|
uint256 sourceAmount,
|
|
|
|
uint16 targetChain,
|
|
|
|
uint256 multiplier,
|
|
|
|
uint256 multiplierDenominator,
|
|
|
|
bool roundUp,
|
|
|
|
IRelayProvider provider
|
|
|
|
) internal view returns (uint256 targetAmount) {
|
|
|
|
uint256 srcNativeCurrencyPrice = provider.quoteAssetPrice(sourceChain);
|
|
|
|
if (srcNativeCurrencyPrice == 0) {
|
|
|
|
revert IWormholeRelayer.RelayProviderDoesNotSupportTargetChain();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint256 dstNativeCurrencyPrice = provider.quoteAssetPrice(targetChain);
|
|
|
|
if (dstNativeCurrencyPrice == 0) {
|
|
|
|
revert IWormholeRelayer.RelayProviderDoesNotSupportTargetChain();
|
|
|
|
}
|
|
|
|
uint256 numerator = sourceAmount * srcNativeCurrencyPrice * multiplier;
|
|
|
|
uint256 denominator = dstNativeCurrencyPrice * multiplierDenominator;
|
|
|
|
if (roundUp) {
|
|
|
|
targetAmount = (numerator + denominator - 1) / denominator;
|
|
|
|
} else {
|
|
|
|
targetAmount = numerator / denominator;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
/**
|
|
|
|
* If the user specifies (for 'receiverValue) 'sourceAmount' of source chain currency, with relay provider 'provider',
|
|
|
|
* then this function calculates how much the relayer will pass into receiveWormholeMessages on the target chain (in target chain currency)
|
|
|
|
*
|
|
|
|
* The calculation simply converts this amount to target chain currency, but also applies a multiplier of 'denominator/(denominator + buffer)'
|
|
|
|
* where these values are also specified by the relay provider 'provider'
|
|
|
|
*
|
|
|
|
* @param sourceAmount amount of source chain currency
|
|
|
|
* @param targetChain target chain
|
|
|
|
* @param provider relay provider
|
|
|
|
* @return targetAmount amount of target chain currency
|
|
|
|
*/
|
2023-02-27 11:32:57 -08:00
|
|
|
function convertReceiverValueAmount(uint256 sourceAmount, uint16 targetChain, IRelayProvider provider)
|
|
|
|
internal
|
|
|
|
view
|
|
|
|
returns (uint256 targetAmount)
|
|
|
|
{
|
|
|
|
(uint16 buffer, uint16 denominator) = provider.getAssetConversionBuffer(targetChain);
|
|
|
|
|
|
|
|
targetAmount = assetConversionHelper(
|
|
|
|
chainId(), sourceAmount, targetChain, denominator, uint256(0) + denominator + buffer, false, provider
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
// decode a 'RedeliveryByTxHashInstruction' from bytes
|
2023-02-27 11:32:57 -08:00
|
|
|
function decodeRedeliveryInstruction(bytes memory encoded)
|
|
|
|
public
|
|
|
|
pure
|
2023-01-05 16:46:58 -08:00
|
|
|
returns (RedeliveryByTxHashInstruction memory instruction)
|
|
|
|
{
|
|
|
|
uint256 index = 0;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
2023-01-05 16:46:58 -08:00
|
|
|
instruction.payloadId = encoded.toUint8(index);
|
2023-02-27 11:32:57 -08:00
|
|
|
if (instruction.payloadId != 2) {
|
|
|
|
revert InvalidPayloadId(instruction.payloadId);
|
|
|
|
}
|
2023-01-05 16:46:58 -08:00
|
|
|
index += 1;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
2023-01-05 16:46:58 -08:00
|
|
|
instruction.sourceChain = encoded.toUint16(index);
|
|
|
|
index += 2;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
2023-01-05 16:46:58 -08:00
|
|
|
instruction.sourceTxHash = encoded.toBytes32(index);
|
|
|
|
index += 32;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
2023-01-05 16:46:58 -08:00
|
|
|
instruction.sourceNonce = encoded.toUint32(index);
|
|
|
|
index += 4;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
2023-01-05 16:46:58 -08:00
|
|
|
instruction.targetChain = encoded.toUint16(index);
|
|
|
|
index += 2;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
2023-01-26 12:10:44 -08:00
|
|
|
instruction.deliveryIndex = encoded.toUint8(index);
|
|
|
|
index += 1;
|
|
|
|
|
|
|
|
instruction.multisendIndex = encoded.toUint8(index);
|
|
|
|
index += 1;
|
|
|
|
|
2023-01-05 16:46:58 -08:00
|
|
|
instruction.newMaximumRefundTarget = encoded.toUint256(index);
|
|
|
|
index += 32;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
2023-02-10 12:52:39 -08:00
|
|
|
instruction.newReceiverValueTarget = encoded.toUint256(index);
|
2023-01-05 16:46:58 -08:00
|
|
|
index += 32;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
2023-01-05 16:46:58 -08:00
|
|
|
instruction.executionParameters.version = encoded.toUint8(index);
|
|
|
|
index += 1;
|
Move development branch to main (#23)
* refactoring for multidelivery
* partial ts-test fixes
* use typechain in integration tests, update prettier, fix remaining integration tests
* run formatter on solidity files
* gas refunding
* gas forwarding logic
* msg.send -> refundAmount
* minor test refactor & additions
* created relayer engine directory
* more testing & tilt environment config for relayer engine
* starting work on the xMint example contracts
* additions for relayer engine
* minor modifications & todos
* fixed some errors
* refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend
* Merged refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend with new interface'
* refactoring interfaces & files for single VAA design
* GasOracle implementation of new interface
* GasOracle compiles
* Gas oracle upgradable
* Fix compile errors in GasOracleGovernance
* minor core relayer cleanup
* Changes to getters, setters, state
* implement quoteEvmDeliveryPrice, quoteTargetEvmGas, assetConversionAmount for corerelayer
* Correcting interface inconsistencies between CoreRelayerStructs and ICoreRelayer
* Fix encodeDeliveryRequestsContainer
* added single vaa delivery entrypoint logic
* Encode and Decode delivery instructions
* Fixed many compile errors
* First attempt at removing stacktoodeep error
* Commenting out chunks of code to identify stack too deep error
* Continue stack too deep quest
* Revert "Commenting out chunks of code to identify stack too deep error"
This reverts commit 8cd55d26cea2c49dc6e6bfa481c310f1a1c1143a.
* Revert "Continue stack too deep quest"
This reverts commit f0cde6871e26a7063e20d9a83b63b6a50e32bf37.
* Fix stack too deep error in CoreRelayerMessages
* tests compile, run, pass
* fixing up fee collection assertions
* GasOracle tests altering
* Rename encodeDeliveryIntructions to convertToEncodedDeliveryInstructions because we are going from delivery request to delivery instruction
* adding evm events to delivery execution
* forwarding refactor for single vaa
* relay provider name refactor
* Test file slight refactor to allow for multiple chains
* first impl of hub and spoke example
* Forward test progress
* Forwarding test passes!
* More general parameters for test
* Testing file more modular, calls 'generic relayer'
* redelivery implementation
* removing todos
* Tests can use arbitrary amount of chains
* Address various TODOs
* refactored RelayProvider to be upgradeable via proxy
* Add overhead inteface to RelayProvider & adjusted necessary fee calculations
* added TODOs related to rewardAddress payout
* provider price quoting changes
* provider payments made at source
* Fixed all compile errors
* testForward and testSend pass again!
* Switched quoteAssetConversion to quoteApplicationBudgetFee in CoreRelayer interface
* First round of changes to support individual vaas in offchain relayer
- Use new custom plugin event source api in relayer engine
- Supports mulit delivery
- Config for celo and fuji
* contracts deploy successfully to tilt
* bug fixes, contracts deploy to tilt
* Starting the redelivery test
* Tests pass again, with exception of the RelayProvider tests that tested reverts, and the new testRedelivery which isn't finished
* small plugin changes
* MockRelayerIntegration is used for sending
* prepare offchain relayer to run in both tilt and testnet
* update readme and npm scripts for offchain relayer
* nit: remove console.log(argv)
* solc version bump
* Tests changed to pass (commented out the tests with differing require statements and kept redelivery incomplete
* chain registration typescript scripts
* Redeliver works!
* Redelivery test works!
* testnet deploy + relayer engine test
* Testing two sends
* Friday changes to round trip on testnet
* Shortening current tests
* Funds are correct! Relayer gets paid!
* Remove extraneous comments
* ts scripts for deployment and config
* Wormhole Fee Test
Co-authored-by: chase-45 <chasemoran45@gmail.com>
Co-authored-by: derpy-duck <115193320+derpy-duck@users.noreply.github.com>
2023-01-05 14:26:27 -08:00
|
|
|
|
2023-01-05 16:46:58 -08:00
|
|
|
instruction.executionParameters.gasLimit = encoded.toUint32(index);
|
|
|
|
index += 4;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
2023-01-05 16:46:58 -08:00
|
|
|
instruction.executionParameters.providerDeliveryAddress = encoded.toBytes32(index);
|
|
|
|
index += 32;
|
2022-09-30 09:18:49 -07:00
|
|
|
}
|
|
|
|
|
2023-02-28 07:09:01 -08:00
|
|
|
// decode a 'DeliveryInstructionsContainer' from bytes
|
Move development branch to main (#23)
* refactoring for multidelivery
* partial ts-test fixes
* use typechain in integration tests, update prettier, fix remaining integration tests
* run formatter on solidity files
* gas refunding
* gas forwarding logic
* msg.send -> refundAmount
* minor test refactor & additions
* created relayer engine directory
* more testing & tilt environment config for relayer engine
* starting work on the xMint example contracts
* additions for relayer engine
* minor modifications & todos
* fixed some errors
* refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend
* Merged refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend with new interface'
* refactoring interfaces & files for single VAA design
* GasOracle implementation of new interface
* GasOracle compiles
* Gas oracle upgradable
* Fix compile errors in GasOracleGovernance
* minor core relayer cleanup
* Changes to getters, setters, state
* implement quoteEvmDeliveryPrice, quoteTargetEvmGas, assetConversionAmount for corerelayer
* Correcting interface inconsistencies between CoreRelayerStructs and ICoreRelayer
* Fix encodeDeliveryRequestsContainer
* added single vaa delivery entrypoint logic
* Encode and Decode delivery instructions
* Fixed many compile errors
* First attempt at removing stacktoodeep error
* Commenting out chunks of code to identify stack too deep error
* Continue stack too deep quest
* Revert "Commenting out chunks of code to identify stack too deep error"
This reverts commit 8cd55d26cea2c49dc6e6bfa481c310f1a1c1143a.
* Revert "Continue stack too deep quest"
This reverts commit f0cde6871e26a7063e20d9a83b63b6a50e32bf37.
* Fix stack too deep error in CoreRelayerMessages
* tests compile, run, pass
* fixing up fee collection assertions
* GasOracle tests altering
* Rename encodeDeliveryIntructions to convertToEncodedDeliveryInstructions because we are going from delivery request to delivery instruction
* adding evm events to delivery execution
* forwarding refactor for single vaa
* relay provider name refactor
* Test file slight refactor to allow for multiple chains
* first impl of hub and spoke example
* Forward test progress
* Forwarding test passes!
* More general parameters for test
* Testing file more modular, calls 'generic relayer'
* redelivery implementation
* removing todos
* Tests can use arbitrary amount of chains
* Address various TODOs
* refactored RelayProvider to be upgradeable via proxy
* Add overhead inteface to RelayProvider & adjusted necessary fee calculations
* added TODOs related to rewardAddress payout
* provider price quoting changes
* provider payments made at source
* Fixed all compile errors
* testForward and testSend pass again!
* Switched quoteAssetConversion to quoteApplicationBudgetFee in CoreRelayer interface
* First round of changes to support individual vaas in offchain relayer
- Use new custom plugin event source api in relayer engine
- Supports mulit delivery
- Config for celo and fuji
* contracts deploy successfully to tilt
* bug fixes, contracts deploy to tilt
* Starting the redelivery test
* Tests pass again, with exception of the RelayProvider tests that tested reverts, and the new testRedelivery which isn't finished
* small plugin changes
* MockRelayerIntegration is used for sending
* prepare offchain relayer to run in both tilt and testnet
* update readme and npm scripts for offchain relayer
* nit: remove console.log(argv)
* solc version bump
* Tests changed to pass (commented out the tests with differing require statements and kept redelivery incomplete
* chain registration typescript scripts
* Redeliver works!
* Redelivery test works!
* testnet deploy + relayer engine test
* Testing two sends
* Friday changes to round trip on testnet
* Shortening current tests
* Funds are correct! Relayer gets paid!
* Remove extraneous comments
* ts scripts for deployment and config
* Wormhole Fee Test
Co-authored-by: chase-45 <chasemoran45@gmail.com>
Co-authored-by: derpy-duck <115193320+derpy-duck@users.noreply.github.com>
2023-01-05 14:26:27 -08:00
|
|
|
function decodeDeliveryInstructionsContainer(bytes memory encoded)
|
2023-02-27 11:32:57 -08:00
|
|
|
public
|
Move development branch to main (#23)
* refactoring for multidelivery
* partial ts-test fixes
* use typechain in integration tests, update prettier, fix remaining integration tests
* run formatter on solidity files
* gas refunding
* gas forwarding logic
* msg.send -> refundAmount
* minor test refactor & additions
* created relayer engine directory
* more testing & tilt environment config for relayer engine
* starting work on the xMint example contracts
* additions for relayer engine
* minor modifications & todos
* fixed some errors
* refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend
* Merged refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend with new interface'
* refactoring interfaces & files for single VAA design
* GasOracle implementation of new interface
* GasOracle compiles
* Gas oracle upgradable
* Fix compile errors in GasOracleGovernance
* minor core relayer cleanup
* Changes to getters, setters, state
* implement quoteEvmDeliveryPrice, quoteTargetEvmGas, assetConversionAmount for corerelayer
* Correcting interface inconsistencies between CoreRelayerStructs and ICoreRelayer
* Fix encodeDeliveryRequestsContainer
* added single vaa delivery entrypoint logic
* Encode and Decode delivery instructions
* Fixed many compile errors
* First attempt at removing stacktoodeep error
* Commenting out chunks of code to identify stack too deep error
* Continue stack too deep quest
* Revert "Commenting out chunks of code to identify stack too deep error"
This reverts commit 8cd55d26cea2c49dc6e6bfa481c310f1a1c1143a.
* Revert "Continue stack too deep quest"
This reverts commit f0cde6871e26a7063e20d9a83b63b6a50e32bf37.
* Fix stack too deep error in CoreRelayerMessages
* tests compile, run, pass
* fixing up fee collection assertions
* GasOracle tests altering
* Rename encodeDeliveryIntructions to convertToEncodedDeliveryInstructions because we are going from delivery request to delivery instruction
* adding evm events to delivery execution
* forwarding refactor for single vaa
* relay provider name refactor
* Test file slight refactor to allow for multiple chains
* first impl of hub and spoke example
* Forward test progress
* Forwarding test passes!
* More general parameters for test
* Testing file more modular, calls 'generic relayer'
* redelivery implementation
* removing todos
* Tests can use arbitrary amount of chains
* Address various TODOs
* refactored RelayProvider to be upgradeable via proxy
* Add overhead inteface to RelayProvider & adjusted necessary fee calculations
* added TODOs related to rewardAddress payout
* provider price quoting changes
* provider payments made at source
* Fixed all compile errors
* testForward and testSend pass again!
* Switched quoteAssetConversion to quoteApplicationBudgetFee in CoreRelayer interface
* First round of changes to support individual vaas in offchain relayer
- Use new custom plugin event source api in relayer engine
- Supports mulit delivery
- Config for celo and fuji
* contracts deploy successfully to tilt
* bug fixes, contracts deploy to tilt
* Starting the redelivery test
* Tests pass again, with exception of the RelayProvider tests that tested reverts, and the new testRedelivery which isn't finished
* small plugin changes
* MockRelayerIntegration is used for sending
* prepare offchain relayer to run in both tilt and testnet
* update readme and npm scripts for offchain relayer
* nit: remove console.log(argv)
* solc version bump
* Tests changed to pass (commented out the tests with differing require statements and kept redelivery incomplete
* chain registration typescript scripts
* Redeliver works!
* Redelivery test works!
* testnet deploy + relayer engine test
* Testing two sends
* Friday changes to round trip on testnet
* Shortening current tests
* Funds are correct! Relayer gets paid!
* Remove extraneous comments
* ts scripts for deployment and config
* Wormhole Fee Test
Co-authored-by: chase-45 <chasemoran45@gmail.com>
Co-authored-by: derpy-duck <115193320+derpy-duck@users.noreply.github.com>
2023-01-05 14:26:27 -08:00
|
|
|
pure
|
|
|
|
returns (DeliveryInstructionsContainer memory)
|
|
|
|
{
|
2022-09-30 09:18:49 -07:00
|
|
|
uint256 index = 0;
|
|
|
|
|
Move development branch to main (#23)
* refactoring for multidelivery
* partial ts-test fixes
* use typechain in integration tests, update prettier, fix remaining integration tests
* run formatter on solidity files
* gas refunding
* gas forwarding logic
* msg.send -> refundAmount
* minor test refactor & additions
* created relayer engine directory
* more testing & tilt environment config for relayer engine
* starting work on the xMint example contracts
* additions for relayer engine
* minor modifications & todos
* fixed some errors
* refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend
* Merged refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend with new interface'
* refactoring interfaces & files for single VAA design
* GasOracle implementation of new interface
* GasOracle compiles
* Gas oracle upgradable
* Fix compile errors in GasOracleGovernance
* minor core relayer cleanup
* Changes to getters, setters, state
* implement quoteEvmDeliveryPrice, quoteTargetEvmGas, assetConversionAmount for corerelayer
* Correcting interface inconsistencies between CoreRelayerStructs and ICoreRelayer
* Fix encodeDeliveryRequestsContainer
* added single vaa delivery entrypoint logic
* Encode and Decode delivery instructions
* Fixed many compile errors
* First attempt at removing stacktoodeep error
* Commenting out chunks of code to identify stack too deep error
* Continue stack too deep quest
* Revert "Commenting out chunks of code to identify stack too deep error"
This reverts commit 8cd55d26cea2c49dc6e6bfa481c310f1a1c1143a.
* Revert "Continue stack too deep quest"
This reverts commit f0cde6871e26a7063e20d9a83b63b6a50e32bf37.
* Fix stack too deep error in CoreRelayerMessages
* tests compile, run, pass
* fixing up fee collection assertions
* GasOracle tests altering
* Rename encodeDeliveryIntructions to convertToEncodedDeliveryInstructions because we are going from delivery request to delivery instruction
* adding evm events to delivery execution
* forwarding refactor for single vaa
* relay provider name refactor
* Test file slight refactor to allow for multiple chains
* first impl of hub and spoke example
* Forward test progress
* Forwarding test passes!
* More general parameters for test
* Testing file more modular, calls 'generic relayer'
* redelivery implementation
* removing todos
* Tests can use arbitrary amount of chains
* Address various TODOs
* refactored RelayProvider to be upgradeable via proxy
* Add overhead inteface to RelayProvider & adjusted necessary fee calculations
* added TODOs related to rewardAddress payout
* provider price quoting changes
* provider payments made at source
* Fixed all compile errors
* testForward and testSend pass again!
* Switched quoteAssetConversion to quoteApplicationBudgetFee in CoreRelayer interface
* First round of changes to support individual vaas in offchain relayer
- Use new custom plugin event source api in relayer engine
- Supports mulit delivery
- Config for celo and fuji
* contracts deploy successfully to tilt
* bug fixes, contracts deploy to tilt
* Starting the redelivery test
* Tests pass again, with exception of the RelayProvider tests that tested reverts, and the new testRedelivery which isn't finished
* small plugin changes
* MockRelayerIntegration is used for sending
* prepare offchain relayer to run in both tilt and testnet
* update readme and npm scripts for offchain relayer
* nit: remove console.log(argv)
* solc version bump
* Tests changed to pass (commented out the tests with differing require statements and kept redelivery incomplete
* chain registration typescript scripts
* Redeliver works!
* Redelivery test works!
* testnet deploy + relayer engine test
* Testing two sends
* Friday changes to round trip on testnet
* Shortening current tests
* Funds are correct! Relayer gets paid!
* Remove extraneous comments
* ts scripts for deployment and config
* Wormhole Fee Test
Co-authored-by: chase-45 <chasemoran45@gmail.com>
Co-authored-by: derpy-duck <115193320+derpy-duck@users.noreply.github.com>
2023-01-05 14:26:27 -08:00
|
|
|
uint8 payloadId = encoded.toUint8(index);
|
2023-01-19 06:59:35 -08:00
|
|
|
if (payloadId != 1) {
|
|
|
|
revert InvalidPayloadId(payloadId);
|
|
|
|
}
|
2022-09-30 09:18:49 -07:00
|
|
|
index += 1;
|
Move development branch to main (#23)
* refactoring for multidelivery
* partial ts-test fixes
* use typechain in integration tests, update prettier, fix remaining integration tests
* run formatter on solidity files
* gas refunding
* gas forwarding logic
* msg.send -> refundAmount
* minor test refactor & additions
* created relayer engine directory
* more testing & tilt environment config for relayer engine
* starting work on the xMint example contracts
* additions for relayer engine
* minor modifications & todos
* fixed some errors
* refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend
* Merged refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend with new interface'
* refactoring interfaces & files for single VAA design
* GasOracle implementation of new interface
* GasOracle compiles
* Gas oracle upgradable
* Fix compile errors in GasOracleGovernance
* minor core relayer cleanup
* Changes to getters, setters, state
* implement quoteEvmDeliveryPrice, quoteTargetEvmGas, assetConversionAmount for corerelayer
* Correcting interface inconsistencies between CoreRelayerStructs and ICoreRelayer
* Fix encodeDeliveryRequestsContainer
* added single vaa delivery entrypoint logic
* Encode and Decode delivery instructions
* Fixed many compile errors
* First attempt at removing stacktoodeep error
* Commenting out chunks of code to identify stack too deep error
* Continue stack too deep quest
* Revert "Commenting out chunks of code to identify stack too deep error"
This reverts commit 8cd55d26cea2c49dc6e6bfa481c310f1a1c1143a.
* Revert "Continue stack too deep quest"
This reverts commit f0cde6871e26a7063e20d9a83b63b6a50e32bf37.
* Fix stack too deep error in CoreRelayerMessages
* tests compile, run, pass
* fixing up fee collection assertions
* GasOracle tests altering
* Rename encodeDeliveryIntructions to convertToEncodedDeliveryInstructions because we are going from delivery request to delivery instruction
* adding evm events to delivery execution
* forwarding refactor for single vaa
* relay provider name refactor
* Test file slight refactor to allow for multiple chains
* first impl of hub and spoke example
* Forward test progress
* Forwarding test passes!
* More general parameters for test
* Testing file more modular, calls 'generic relayer'
* redelivery implementation
* removing todos
* Tests can use arbitrary amount of chains
* Address various TODOs
* refactored RelayProvider to be upgradeable via proxy
* Add overhead inteface to RelayProvider & adjusted necessary fee calculations
* added TODOs related to rewardAddress payout
* provider price quoting changes
* provider payments made at source
* Fixed all compile errors
* testForward and testSend pass again!
* Switched quoteAssetConversion to quoteApplicationBudgetFee in CoreRelayer interface
* First round of changes to support individual vaas in offchain relayer
- Use new custom plugin event source api in relayer engine
- Supports mulit delivery
- Config for celo and fuji
* contracts deploy successfully to tilt
* bug fixes, contracts deploy to tilt
* Starting the redelivery test
* Tests pass again, with exception of the RelayProvider tests that tested reverts, and the new testRedelivery which isn't finished
* small plugin changes
* MockRelayerIntegration is used for sending
* prepare offchain relayer to run in both tilt and testnet
* update readme and npm scripts for offchain relayer
* nit: remove console.log(argv)
* solc version bump
* Tests changed to pass (commented out the tests with differing require statements and kept redelivery incomplete
* chain registration typescript scripts
* Redeliver works!
* Redelivery test works!
* testnet deploy + relayer engine test
* Testing two sends
* Friday changes to round trip on testnet
* Shortening current tests
* Funds are correct! Relayer gets paid!
* Remove extraneous comments
* ts scripts for deployment and config
* Wormhole Fee Test
Co-authored-by: chase-45 <chasemoran45@gmail.com>
Co-authored-by: derpy-duck <115193320+derpy-duck@users.noreply.github.com>
2023-01-05 14:26:27 -08:00
|
|
|
bool sufficientlyFunded = encoded.toUint8(index) == 1;
|
|
|
|
index += 1;
|
|
|
|
uint8 arrayLen = encoded.toUint8(index);
|
|
|
|
index += 1;
|
2023-01-05 16:46:58 -08:00
|
|
|
|
Move development branch to main (#23)
* refactoring for multidelivery
* partial ts-test fixes
* use typechain in integration tests, update prettier, fix remaining integration tests
* run formatter on solidity files
* gas refunding
* gas forwarding logic
* msg.send -> refundAmount
* minor test refactor & additions
* created relayer engine directory
* more testing & tilt environment config for relayer engine
* starting work on the xMint example contracts
* additions for relayer engine
* minor modifications & todos
* fixed some errors
* refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend
* Merged refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend with new interface'
* refactoring interfaces & files for single VAA design
* GasOracle implementation of new interface
* GasOracle compiles
* Gas oracle upgradable
* Fix compile errors in GasOracleGovernance
* minor core relayer cleanup
* Changes to getters, setters, state
* implement quoteEvmDeliveryPrice, quoteTargetEvmGas, assetConversionAmount for corerelayer
* Correcting interface inconsistencies between CoreRelayerStructs and ICoreRelayer
* Fix encodeDeliveryRequestsContainer
* added single vaa delivery entrypoint logic
* Encode and Decode delivery instructions
* Fixed many compile errors
* First attempt at removing stacktoodeep error
* Commenting out chunks of code to identify stack too deep error
* Continue stack too deep quest
* Revert "Commenting out chunks of code to identify stack too deep error"
This reverts commit 8cd55d26cea2c49dc6e6bfa481c310f1a1c1143a.
* Revert "Continue stack too deep quest"
This reverts commit f0cde6871e26a7063e20d9a83b63b6a50e32bf37.
* Fix stack too deep error in CoreRelayerMessages
* tests compile, run, pass
* fixing up fee collection assertions
* GasOracle tests altering
* Rename encodeDeliveryIntructions to convertToEncodedDeliveryInstructions because we are going from delivery request to delivery instruction
* adding evm events to delivery execution
* forwarding refactor for single vaa
* relay provider name refactor
* Test file slight refactor to allow for multiple chains
* first impl of hub and spoke example
* Forward test progress
* Forwarding test passes!
* More general parameters for test
* Testing file more modular, calls 'generic relayer'
* redelivery implementation
* removing todos
* Tests can use arbitrary amount of chains
* Address various TODOs
* refactored RelayProvider to be upgradeable via proxy
* Add overhead inteface to RelayProvider & adjusted necessary fee calculations
* added TODOs related to rewardAddress payout
* provider price quoting changes
* provider payments made at source
* Fixed all compile errors
* testForward and testSend pass again!
* Switched quoteAssetConversion to quoteApplicationBudgetFee in CoreRelayer interface
* First round of changes to support individual vaas in offchain relayer
- Use new custom plugin event source api in relayer engine
- Supports mulit delivery
- Config for celo and fuji
* contracts deploy successfully to tilt
* bug fixes, contracts deploy to tilt
* Starting the redelivery test
* Tests pass again, with exception of the RelayProvider tests that tested reverts, and the new testRedelivery which isn't finished
* small plugin changes
* MockRelayerIntegration is used for sending
* prepare offchain relayer to run in both tilt and testnet
* update readme and npm scripts for offchain relayer
* nit: remove console.log(argv)
* solc version bump
* Tests changed to pass (commented out the tests with differing require statements and kept redelivery incomplete
* chain registration typescript scripts
* Redeliver works!
* Redelivery test works!
* testnet deploy + relayer engine test
* Testing two sends
* Friday changes to round trip on testnet
* Shortening current tests
* Funds are correct! Relayer gets paid!
* Remove extraneous comments
* ts scripts for deployment and config
* Wormhole Fee Test
Co-authored-by: chase-45 <chasemoran45@gmail.com>
Co-authored-by: derpy-duck <115193320+derpy-duck@users.noreply.github.com>
2023-01-05 14:26:27 -08:00
|
|
|
DeliveryInstruction[] memory instructionArray = new DeliveryInstruction[](arrayLen);
|
2022-09-30 09:18:49 -07:00
|
|
|
|
Move development branch to main (#23)
* refactoring for multidelivery
* partial ts-test fixes
* use typechain in integration tests, update prettier, fix remaining integration tests
* run formatter on solidity files
* gas refunding
* gas forwarding logic
* msg.send -> refundAmount
* minor test refactor & additions
* created relayer engine directory
* more testing & tilt environment config for relayer engine
* starting work on the xMint example contracts
* additions for relayer engine
* minor modifications & todos
* fixed some errors
* refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend
* Merged refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend with new interface'
* refactoring interfaces & files for single VAA design
* GasOracle implementation of new interface
* GasOracle compiles
* Gas oracle upgradable
* Fix compile errors in GasOracleGovernance
* minor core relayer cleanup
* Changes to getters, setters, state
* implement quoteEvmDeliveryPrice, quoteTargetEvmGas, assetConversionAmount for corerelayer
* Correcting interface inconsistencies between CoreRelayerStructs and ICoreRelayer
* Fix encodeDeliveryRequestsContainer
* added single vaa delivery entrypoint logic
* Encode and Decode delivery instructions
* Fixed many compile errors
* First attempt at removing stacktoodeep error
* Commenting out chunks of code to identify stack too deep error
* Continue stack too deep quest
* Revert "Commenting out chunks of code to identify stack too deep error"
This reverts commit 8cd55d26cea2c49dc6e6bfa481c310f1a1c1143a.
* Revert "Continue stack too deep quest"
This reverts commit f0cde6871e26a7063e20d9a83b63b6a50e32bf37.
* Fix stack too deep error in CoreRelayerMessages
* tests compile, run, pass
* fixing up fee collection assertions
* GasOracle tests altering
* Rename encodeDeliveryIntructions to convertToEncodedDeliveryInstructions because we are going from delivery request to delivery instruction
* adding evm events to delivery execution
* forwarding refactor for single vaa
* relay provider name refactor
* Test file slight refactor to allow for multiple chains
* first impl of hub and spoke example
* Forward test progress
* Forwarding test passes!
* More general parameters for test
* Testing file more modular, calls 'generic relayer'
* redelivery implementation
* removing todos
* Tests can use arbitrary amount of chains
* Address various TODOs
* refactored RelayProvider to be upgradeable via proxy
* Add overhead inteface to RelayProvider & adjusted necessary fee calculations
* added TODOs related to rewardAddress payout
* provider price quoting changes
* provider payments made at source
* Fixed all compile errors
* testForward and testSend pass again!
* Switched quoteAssetConversion to quoteApplicationBudgetFee in CoreRelayer interface
* First round of changes to support individual vaas in offchain relayer
- Use new custom plugin event source api in relayer engine
- Supports mulit delivery
- Config for celo and fuji
* contracts deploy successfully to tilt
* bug fixes, contracts deploy to tilt
* Starting the redelivery test
* Tests pass again, with exception of the RelayProvider tests that tested reverts, and the new testRedelivery which isn't finished
* small plugin changes
* MockRelayerIntegration is used for sending
* prepare offchain relayer to run in both tilt and testnet
* update readme and npm scripts for offchain relayer
* nit: remove console.log(argv)
* solc version bump
* Tests changed to pass (commented out the tests with differing require statements and kept redelivery incomplete
* chain registration typescript scripts
* Redeliver works!
* Redelivery test works!
* testnet deploy + relayer engine test
* Testing two sends
* Friday changes to round trip on testnet
* Shortening current tests
* Funds are correct! Relayer gets paid!
* Remove extraneous comments
* ts scripts for deployment and config
* Wormhole Fee Test
Co-authored-by: chase-45 <chasemoran45@gmail.com>
Co-authored-by: derpy-duck <115193320+derpy-duck@users.noreply.github.com>
2023-01-05 14:26:27 -08:00
|
|
|
for (uint8 i = 0; i < arrayLen; i++) {
|
|
|
|
DeliveryInstruction memory instruction;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
Move development branch to main (#23)
* refactoring for multidelivery
* partial ts-test fixes
* use typechain in integration tests, update prettier, fix remaining integration tests
* run formatter on solidity files
* gas refunding
* gas forwarding logic
* msg.send -> refundAmount
* minor test refactor & additions
* created relayer engine directory
* more testing & tilt environment config for relayer engine
* starting work on the xMint example contracts
* additions for relayer engine
* minor modifications & todos
* fixed some errors
* refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend
* Merged refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend with new interface'
* refactoring interfaces & files for single VAA design
* GasOracle implementation of new interface
* GasOracle compiles
* Gas oracle upgradable
* Fix compile errors in GasOracleGovernance
* minor core relayer cleanup
* Changes to getters, setters, state
* implement quoteEvmDeliveryPrice, quoteTargetEvmGas, assetConversionAmount for corerelayer
* Correcting interface inconsistencies between CoreRelayerStructs and ICoreRelayer
* Fix encodeDeliveryRequestsContainer
* added single vaa delivery entrypoint logic
* Encode and Decode delivery instructions
* Fixed many compile errors
* First attempt at removing stacktoodeep error
* Commenting out chunks of code to identify stack too deep error
* Continue stack too deep quest
* Revert "Commenting out chunks of code to identify stack too deep error"
This reverts commit 8cd55d26cea2c49dc6e6bfa481c310f1a1c1143a.
* Revert "Continue stack too deep quest"
This reverts commit f0cde6871e26a7063e20d9a83b63b6a50e32bf37.
* Fix stack too deep error in CoreRelayerMessages
* tests compile, run, pass
* fixing up fee collection assertions
* GasOracle tests altering
* Rename encodeDeliveryIntructions to convertToEncodedDeliveryInstructions because we are going from delivery request to delivery instruction
* adding evm events to delivery execution
* forwarding refactor for single vaa
* relay provider name refactor
* Test file slight refactor to allow for multiple chains
* first impl of hub and spoke example
* Forward test progress
* Forwarding test passes!
* More general parameters for test
* Testing file more modular, calls 'generic relayer'
* redelivery implementation
* removing todos
* Tests can use arbitrary amount of chains
* Address various TODOs
* refactored RelayProvider to be upgradeable via proxy
* Add overhead inteface to RelayProvider & adjusted necessary fee calculations
* added TODOs related to rewardAddress payout
* provider price quoting changes
* provider payments made at source
* Fixed all compile errors
* testForward and testSend pass again!
* Switched quoteAssetConversion to quoteApplicationBudgetFee in CoreRelayer interface
* First round of changes to support individual vaas in offchain relayer
- Use new custom plugin event source api in relayer engine
- Supports mulit delivery
- Config for celo and fuji
* contracts deploy successfully to tilt
* bug fixes, contracts deploy to tilt
* Starting the redelivery test
* Tests pass again, with exception of the RelayProvider tests that tested reverts, and the new testRedelivery which isn't finished
* small plugin changes
* MockRelayerIntegration is used for sending
* prepare offchain relayer to run in both tilt and testnet
* update readme and npm scripts for offchain relayer
* nit: remove console.log(argv)
* solc version bump
* Tests changed to pass (commented out the tests with differing require statements and kept redelivery incomplete
* chain registration typescript scripts
* Redeliver works!
* Redelivery test works!
* testnet deploy + relayer engine test
* Testing two sends
* Friday changes to round trip on testnet
* Shortening current tests
* Funds are correct! Relayer gets paid!
* Remove extraneous comments
* ts scripts for deployment and config
* Wormhole Fee Test
Co-authored-by: chase-45 <chasemoran45@gmail.com>
Co-authored-by: derpy-duck <115193320+derpy-duck@users.noreply.github.com>
2023-01-05 14:26:27 -08:00
|
|
|
// target chain of the delivery instruction
|
|
|
|
instruction.targetChain = encoded.toUint16(index);
|
|
|
|
index += 2;
|
2023-01-05 16:46:58 -08:00
|
|
|
|
Move development branch to main (#23)
* refactoring for multidelivery
* partial ts-test fixes
* use typechain in integration tests, update prettier, fix remaining integration tests
* run formatter on solidity files
* gas refunding
* gas forwarding logic
* msg.send -> refundAmount
* minor test refactor & additions
* created relayer engine directory
* more testing & tilt environment config for relayer engine
* starting work on the xMint example contracts
* additions for relayer engine
* minor modifications & todos
* fixed some errors
* refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend
* Merged refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend with new interface'
* refactoring interfaces & files for single VAA design
* GasOracle implementation of new interface
* GasOracle compiles
* Gas oracle upgradable
* Fix compile errors in GasOracleGovernance
* minor core relayer cleanup
* Changes to getters, setters, state
* implement quoteEvmDeliveryPrice, quoteTargetEvmGas, assetConversionAmount for corerelayer
* Correcting interface inconsistencies between CoreRelayerStructs and ICoreRelayer
* Fix encodeDeliveryRequestsContainer
* added single vaa delivery entrypoint logic
* Encode and Decode delivery instructions
* Fixed many compile errors
* First attempt at removing stacktoodeep error
* Commenting out chunks of code to identify stack too deep error
* Continue stack too deep quest
* Revert "Commenting out chunks of code to identify stack too deep error"
This reverts commit 8cd55d26cea2c49dc6e6bfa481c310f1a1c1143a.
* Revert "Continue stack too deep quest"
This reverts commit f0cde6871e26a7063e20d9a83b63b6a50e32bf37.
* Fix stack too deep error in CoreRelayerMessages
* tests compile, run, pass
* fixing up fee collection assertions
* GasOracle tests altering
* Rename encodeDeliveryIntructions to convertToEncodedDeliveryInstructions because we are going from delivery request to delivery instruction
* adding evm events to delivery execution
* forwarding refactor for single vaa
* relay provider name refactor
* Test file slight refactor to allow for multiple chains
* first impl of hub and spoke example
* Forward test progress
* Forwarding test passes!
* More general parameters for test
* Testing file more modular, calls 'generic relayer'
* redelivery implementation
* removing todos
* Tests can use arbitrary amount of chains
* Address various TODOs
* refactored RelayProvider to be upgradeable via proxy
* Add overhead inteface to RelayProvider & adjusted necessary fee calculations
* added TODOs related to rewardAddress payout
* provider price quoting changes
* provider payments made at source
* Fixed all compile errors
* testForward and testSend pass again!
* Switched quoteAssetConversion to quoteApplicationBudgetFee in CoreRelayer interface
* First round of changes to support individual vaas in offchain relayer
- Use new custom plugin event source api in relayer engine
- Supports mulit delivery
- Config for celo and fuji
* contracts deploy successfully to tilt
* bug fixes, contracts deploy to tilt
* Starting the redelivery test
* Tests pass again, with exception of the RelayProvider tests that tested reverts, and the new testRedelivery which isn't finished
* small plugin changes
* MockRelayerIntegration is used for sending
* prepare offchain relayer to run in both tilt and testnet
* update readme and npm scripts for offchain relayer
* nit: remove console.log(argv)
* solc version bump
* Tests changed to pass (commented out the tests with differing require statements and kept redelivery incomplete
* chain registration typescript scripts
* Redeliver works!
* Redelivery test works!
* testnet deploy + relayer engine test
* Testing two sends
* Friday changes to round trip on testnet
* Shortening current tests
* Funds are correct! Relayer gets paid!
* Remove extraneous comments
* ts scripts for deployment and config
* Wormhole Fee Test
Co-authored-by: chase-45 <chasemoran45@gmail.com>
Co-authored-by: derpy-duck <115193320+derpy-duck@users.noreply.github.com>
2023-01-05 14:26:27 -08:00
|
|
|
// target contract address
|
|
|
|
instruction.targetAddress = encoded.toBytes32(index);
|
|
|
|
index += 32;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
Move development branch to main (#23)
* refactoring for multidelivery
* partial ts-test fixes
* use typechain in integration tests, update prettier, fix remaining integration tests
* run formatter on solidity files
* gas refunding
* gas forwarding logic
* msg.send -> refundAmount
* minor test refactor & additions
* created relayer engine directory
* more testing & tilt environment config for relayer engine
* starting work on the xMint example contracts
* additions for relayer engine
* minor modifications & todos
* fixed some errors
* refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend
* Merged refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend with new interface'
* refactoring interfaces & files for single VAA design
* GasOracle implementation of new interface
* GasOracle compiles
* Gas oracle upgradable
* Fix compile errors in GasOracleGovernance
* minor core relayer cleanup
* Changes to getters, setters, state
* implement quoteEvmDeliveryPrice, quoteTargetEvmGas, assetConversionAmount for corerelayer
* Correcting interface inconsistencies between CoreRelayerStructs and ICoreRelayer
* Fix encodeDeliveryRequestsContainer
* added single vaa delivery entrypoint logic
* Encode and Decode delivery instructions
* Fixed many compile errors
* First attempt at removing stacktoodeep error
* Commenting out chunks of code to identify stack too deep error
* Continue stack too deep quest
* Revert "Commenting out chunks of code to identify stack too deep error"
This reverts commit 8cd55d26cea2c49dc6e6bfa481c310f1a1c1143a.
* Revert "Continue stack too deep quest"
This reverts commit f0cde6871e26a7063e20d9a83b63b6a50e32bf37.
* Fix stack too deep error in CoreRelayerMessages
* tests compile, run, pass
* fixing up fee collection assertions
* GasOracle tests altering
* Rename encodeDeliveryIntructions to convertToEncodedDeliveryInstructions because we are going from delivery request to delivery instruction
* adding evm events to delivery execution
* forwarding refactor for single vaa
* relay provider name refactor
* Test file slight refactor to allow for multiple chains
* first impl of hub and spoke example
* Forward test progress
* Forwarding test passes!
* More general parameters for test
* Testing file more modular, calls 'generic relayer'
* redelivery implementation
* removing todos
* Tests can use arbitrary amount of chains
* Address various TODOs
* refactored RelayProvider to be upgradeable via proxy
* Add overhead inteface to RelayProvider & adjusted necessary fee calculations
* added TODOs related to rewardAddress payout
* provider price quoting changes
* provider payments made at source
* Fixed all compile errors
* testForward and testSend pass again!
* Switched quoteAssetConversion to quoteApplicationBudgetFee in CoreRelayer interface
* First round of changes to support individual vaas in offchain relayer
- Use new custom plugin event source api in relayer engine
- Supports mulit delivery
- Config for celo and fuji
* contracts deploy successfully to tilt
* bug fixes, contracts deploy to tilt
* Starting the redelivery test
* Tests pass again, with exception of the RelayProvider tests that tested reverts, and the new testRedelivery which isn't finished
* small plugin changes
* MockRelayerIntegration is used for sending
* prepare offchain relayer to run in both tilt and testnet
* update readme and npm scripts for offchain relayer
* nit: remove console.log(argv)
* solc version bump
* Tests changed to pass (commented out the tests with differing require statements and kept redelivery incomplete
* chain registration typescript scripts
* Redeliver works!
* Redelivery test works!
* testnet deploy + relayer engine test
* Testing two sends
* Friday changes to round trip on testnet
* Shortening current tests
* Funds are correct! Relayer gets paid!
* Remove extraneous comments
* ts scripts for deployment and config
* Wormhole Fee Test
Co-authored-by: chase-45 <chasemoran45@gmail.com>
Co-authored-by: derpy-duck <115193320+derpy-duck@users.noreply.github.com>
2023-01-05 14:26:27 -08:00
|
|
|
// address to send the refund to
|
|
|
|
instruction.refundAddress = encoded.toBytes32(index);
|
|
|
|
index += 32;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
Move development branch to main (#23)
* refactoring for multidelivery
* partial ts-test fixes
* use typechain in integration tests, update prettier, fix remaining integration tests
* run formatter on solidity files
* gas refunding
* gas forwarding logic
* msg.send -> refundAmount
* minor test refactor & additions
* created relayer engine directory
* more testing & tilt environment config for relayer engine
* starting work on the xMint example contracts
* additions for relayer engine
* minor modifications & todos
* fixed some errors
* refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend
* Merged refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend with new interface'
* refactoring interfaces & files for single VAA design
* GasOracle implementation of new interface
* GasOracle compiles
* Gas oracle upgradable
* Fix compile errors in GasOracleGovernance
* minor core relayer cleanup
* Changes to getters, setters, state
* implement quoteEvmDeliveryPrice, quoteTargetEvmGas, assetConversionAmount for corerelayer
* Correcting interface inconsistencies between CoreRelayerStructs and ICoreRelayer
* Fix encodeDeliveryRequestsContainer
* added single vaa delivery entrypoint logic
* Encode and Decode delivery instructions
* Fixed many compile errors
* First attempt at removing stacktoodeep error
* Commenting out chunks of code to identify stack too deep error
* Continue stack too deep quest
* Revert "Commenting out chunks of code to identify stack too deep error"
This reverts commit 8cd55d26cea2c49dc6e6bfa481c310f1a1c1143a.
* Revert "Continue stack too deep quest"
This reverts commit f0cde6871e26a7063e20d9a83b63b6a50e32bf37.
* Fix stack too deep error in CoreRelayerMessages
* tests compile, run, pass
* fixing up fee collection assertions
* GasOracle tests altering
* Rename encodeDeliveryIntructions to convertToEncodedDeliveryInstructions because we are going from delivery request to delivery instruction
* adding evm events to delivery execution
* forwarding refactor for single vaa
* relay provider name refactor
* Test file slight refactor to allow for multiple chains
* first impl of hub and spoke example
* Forward test progress
* Forwarding test passes!
* More general parameters for test
* Testing file more modular, calls 'generic relayer'
* redelivery implementation
* removing todos
* Tests can use arbitrary amount of chains
* Address various TODOs
* refactored RelayProvider to be upgradeable via proxy
* Add overhead inteface to RelayProvider & adjusted necessary fee calculations
* added TODOs related to rewardAddress payout
* provider price quoting changes
* provider payments made at source
* Fixed all compile errors
* testForward and testSend pass again!
* Switched quoteAssetConversion to quoteApplicationBudgetFee in CoreRelayer interface
* First round of changes to support individual vaas in offchain relayer
- Use new custom plugin event source api in relayer engine
- Supports mulit delivery
- Config for celo and fuji
* contracts deploy successfully to tilt
* bug fixes, contracts deploy to tilt
* Starting the redelivery test
* Tests pass again, with exception of the RelayProvider tests that tested reverts, and the new testRedelivery which isn't finished
* small plugin changes
* MockRelayerIntegration is used for sending
* prepare offchain relayer to run in both tilt and testnet
* update readme and npm scripts for offchain relayer
* nit: remove console.log(argv)
* solc version bump
* Tests changed to pass (commented out the tests with differing require statements and kept redelivery incomplete
* chain registration typescript scripts
* Redeliver works!
* Redelivery test works!
* testnet deploy + relayer engine test
* Testing two sends
* Friday changes to round trip on testnet
* Shortening current tests
* Funds are correct! Relayer gets paid!
* Remove extraneous comments
* ts scripts for deployment and config
* Wormhole Fee Test
Co-authored-by: chase-45 <chasemoran45@gmail.com>
Co-authored-by: derpy-duck <115193320+derpy-duck@users.noreply.github.com>
2023-01-05 14:26:27 -08:00
|
|
|
instruction.maximumRefundTarget = encoded.toUint256(index);
|
|
|
|
index += 32;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
2023-02-10 12:33:00 -08:00
|
|
|
instruction.receiverValueTarget = encoded.toUint256(index);
|
Move development branch to main (#23)
* refactoring for multidelivery
* partial ts-test fixes
* use typechain in integration tests, update prettier, fix remaining integration tests
* run formatter on solidity files
* gas refunding
* gas forwarding logic
* msg.send -> refundAmount
* minor test refactor & additions
* created relayer engine directory
* more testing & tilt environment config for relayer engine
* starting work on the xMint example contracts
* additions for relayer engine
* minor modifications & todos
* fixed some errors
* refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend
* Merged refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend with new interface'
* refactoring interfaces & files for single VAA design
* GasOracle implementation of new interface
* GasOracle compiles
* Gas oracle upgradable
* Fix compile errors in GasOracleGovernance
* minor core relayer cleanup
* Changes to getters, setters, state
* implement quoteEvmDeliveryPrice, quoteTargetEvmGas, assetConversionAmount for corerelayer
* Correcting interface inconsistencies between CoreRelayerStructs and ICoreRelayer
* Fix encodeDeliveryRequestsContainer
* added single vaa delivery entrypoint logic
* Encode and Decode delivery instructions
* Fixed many compile errors
* First attempt at removing stacktoodeep error
* Commenting out chunks of code to identify stack too deep error
* Continue stack too deep quest
* Revert "Commenting out chunks of code to identify stack too deep error"
This reverts commit 8cd55d26cea2c49dc6e6bfa481c310f1a1c1143a.
* Revert "Continue stack too deep quest"
This reverts commit f0cde6871e26a7063e20d9a83b63b6a50e32bf37.
* Fix stack too deep error in CoreRelayerMessages
* tests compile, run, pass
* fixing up fee collection assertions
* GasOracle tests altering
* Rename encodeDeliveryIntructions to convertToEncodedDeliveryInstructions because we are going from delivery request to delivery instruction
* adding evm events to delivery execution
* forwarding refactor for single vaa
* relay provider name refactor
* Test file slight refactor to allow for multiple chains
* first impl of hub and spoke example
* Forward test progress
* Forwarding test passes!
* More general parameters for test
* Testing file more modular, calls 'generic relayer'
* redelivery implementation
* removing todos
* Tests can use arbitrary amount of chains
* Address various TODOs
* refactored RelayProvider to be upgradeable via proxy
* Add overhead inteface to RelayProvider & adjusted necessary fee calculations
* added TODOs related to rewardAddress payout
* provider price quoting changes
* provider payments made at source
* Fixed all compile errors
* testForward and testSend pass again!
* Switched quoteAssetConversion to quoteApplicationBudgetFee in CoreRelayer interface
* First round of changes to support individual vaas in offchain relayer
- Use new custom plugin event source api in relayer engine
- Supports mulit delivery
- Config for celo and fuji
* contracts deploy successfully to tilt
* bug fixes, contracts deploy to tilt
* Starting the redelivery test
* Tests pass again, with exception of the RelayProvider tests that tested reverts, and the new testRedelivery which isn't finished
* small plugin changes
* MockRelayerIntegration is used for sending
* prepare offchain relayer to run in both tilt and testnet
* update readme and npm scripts for offchain relayer
* nit: remove console.log(argv)
* solc version bump
* Tests changed to pass (commented out the tests with differing require statements and kept redelivery incomplete
* chain registration typescript scripts
* Redeliver works!
* Redelivery test works!
* testnet deploy + relayer engine test
* Testing two sends
* Friday changes to round trip on testnet
* Shortening current tests
* Funds are correct! Relayer gets paid!
* Remove extraneous comments
* ts scripts for deployment and config
* Wormhole Fee Test
Co-authored-by: chase-45 <chasemoran45@gmail.com>
Co-authored-by: derpy-duck <115193320+derpy-duck@users.noreply.github.com>
2023-01-05 14:26:27 -08:00
|
|
|
index += 32;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
Move development branch to main (#23)
* refactoring for multidelivery
* partial ts-test fixes
* use typechain in integration tests, update prettier, fix remaining integration tests
* run formatter on solidity files
* gas refunding
* gas forwarding logic
* msg.send -> refundAmount
* minor test refactor & additions
* created relayer engine directory
* more testing & tilt environment config for relayer engine
* starting work on the xMint example contracts
* additions for relayer engine
* minor modifications & todos
* fixed some errors
* refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend
* Merged refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend with new interface'
* refactoring interfaces & files for single VAA design
* GasOracle implementation of new interface
* GasOracle compiles
* Gas oracle upgradable
* Fix compile errors in GasOracleGovernance
* minor core relayer cleanup
* Changes to getters, setters, state
* implement quoteEvmDeliveryPrice, quoteTargetEvmGas, assetConversionAmount for corerelayer
* Correcting interface inconsistencies between CoreRelayerStructs and ICoreRelayer
* Fix encodeDeliveryRequestsContainer
* added single vaa delivery entrypoint logic
* Encode and Decode delivery instructions
* Fixed many compile errors
* First attempt at removing stacktoodeep error
* Commenting out chunks of code to identify stack too deep error
* Continue stack too deep quest
* Revert "Commenting out chunks of code to identify stack too deep error"
This reverts commit 8cd55d26cea2c49dc6e6bfa481c310f1a1c1143a.
* Revert "Continue stack too deep quest"
This reverts commit f0cde6871e26a7063e20d9a83b63b6a50e32bf37.
* Fix stack too deep error in CoreRelayerMessages
* tests compile, run, pass
* fixing up fee collection assertions
* GasOracle tests altering
* Rename encodeDeliveryIntructions to convertToEncodedDeliveryInstructions because we are going from delivery request to delivery instruction
* adding evm events to delivery execution
* forwarding refactor for single vaa
* relay provider name refactor
* Test file slight refactor to allow for multiple chains
* first impl of hub and spoke example
* Forward test progress
* Forwarding test passes!
* More general parameters for test
* Testing file more modular, calls 'generic relayer'
* redelivery implementation
* removing todos
* Tests can use arbitrary amount of chains
* Address various TODOs
* refactored RelayProvider to be upgradeable via proxy
* Add overhead inteface to RelayProvider & adjusted necessary fee calculations
* added TODOs related to rewardAddress payout
* provider price quoting changes
* provider payments made at source
* Fixed all compile errors
* testForward and testSend pass again!
* Switched quoteAssetConversion to quoteApplicationBudgetFee in CoreRelayer interface
* First round of changes to support individual vaas in offchain relayer
- Use new custom plugin event source api in relayer engine
- Supports mulit delivery
- Config for celo and fuji
* contracts deploy successfully to tilt
* bug fixes, contracts deploy to tilt
* Starting the redelivery test
* Tests pass again, with exception of the RelayProvider tests that tested reverts, and the new testRedelivery which isn't finished
* small plugin changes
* MockRelayerIntegration is used for sending
* prepare offchain relayer to run in both tilt and testnet
* update readme and npm scripts for offchain relayer
* nit: remove console.log(argv)
* solc version bump
* Tests changed to pass (commented out the tests with differing require statements and kept redelivery incomplete
* chain registration typescript scripts
* Redeliver works!
* Redelivery test works!
* testnet deploy + relayer engine test
* Testing two sends
* Friday changes to round trip on testnet
* Shortening current tests
* Funds are correct! Relayer gets paid!
* Remove extraneous comments
* ts scripts for deployment and config
* Wormhole Fee Test
Co-authored-by: chase-45 <chasemoran45@gmail.com>
Co-authored-by: derpy-duck <115193320+derpy-duck@users.noreply.github.com>
2023-01-05 14:26:27 -08:00
|
|
|
instruction.executionParameters.version = encoded.toUint8(index);
|
|
|
|
index += 1;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
Move development branch to main (#23)
* refactoring for multidelivery
* partial ts-test fixes
* use typechain in integration tests, update prettier, fix remaining integration tests
* run formatter on solidity files
* gas refunding
* gas forwarding logic
* msg.send -> refundAmount
* minor test refactor & additions
* created relayer engine directory
* more testing & tilt environment config for relayer engine
* starting work on the xMint example contracts
* additions for relayer engine
* minor modifications & todos
* fixed some errors
* refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend
* Merged refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend with new interface'
* refactoring interfaces & files for single VAA design
* GasOracle implementation of new interface
* GasOracle compiles
* Gas oracle upgradable
* Fix compile errors in GasOracleGovernance
* minor core relayer cleanup
* Changes to getters, setters, state
* implement quoteEvmDeliveryPrice, quoteTargetEvmGas, assetConversionAmount for corerelayer
* Correcting interface inconsistencies between CoreRelayerStructs and ICoreRelayer
* Fix encodeDeliveryRequestsContainer
* added single vaa delivery entrypoint logic
* Encode and Decode delivery instructions
* Fixed many compile errors
* First attempt at removing stacktoodeep error
* Commenting out chunks of code to identify stack too deep error
* Continue stack too deep quest
* Revert "Commenting out chunks of code to identify stack too deep error"
This reverts commit 8cd55d26cea2c49dc6e6bfa481c310f1a1c1143a.
* Revert "Continue stack too deep quest"
This reverts commit f0cde6871e26a7063e20d9a83b63b6a50e32bf37.
* Fix stack too deep error in CoreRelayerMessages
* tests compile, run, pass
* fixing up fee collection assertions
* GasOracle tests altering
* Rename encodeDeliveryIntructions to convertToEncodedDeliveryInstructions because we are going from delivery request to delivery instruction
* adding evm events to delivery execution
* forwarding refactor for single vaa
* relay provider name refactor
* Test file slight refactor to allow for multiple chains
* first impl of hub and spoke example
* Forward test progress
* Forwarding test passes!
* More general parameters for test
* Testing file more modular, calls 'generic relayer'
* redelivery implementation
* removing todos
* Tests can use arbitrary amount of chains
* Address various TODOs
* refactored RelayProvider to be upgradeable via proxy
* Add overhead inteface to RelayProvider & adjusted necessary fee calculations
* added TODOs related to rewardAddress payout
* provider price quoting changes
* provider payments made at source
* Fixed all compile errors
* testForward and testSend pass again!
* Switched quoteAssetConversion to quoteApplicationBudgetFee in CoreRelayer interface
* First round of changes to support individual vaas in offchain relayer
- Use new custom plugin event source api in relayer engine
- Supports mulit delivery
- Config for celo and fuji
* contracts deploy successfully to tilt
* bug fixes, contracts deploy to tilt
* Starting the redelivery test
* Tests pass again, with exception of the RelayProvider tests that tested reverts, and the new testRedelivery which isn't finished
* small plugin changes
* MockRelayerIntegration is used for sending
* prepare offchain relayer to run in both tilt and testnet
* update readme and npm scripts for offchain relayer
* nit: remove console.log(argv)
* solc version bump
* Tests changed to pass (commented out the tests with differing require statements and kept redelivery incomplete
* chain registration typescript scripts
* Redeliver works!
* Redelivery test works!
* testnet deploy + relayer engine test
* Testing two sends
* Friday changes to round trip on testnet
* Shortening current tests
* Funds are correct! Relayer gets paid!
* Remove extraneous comments
* ts scripts for deployment and config
* Wormhole Fee Test
Co-authored-by: chase-45 <chasemoran45@gmail.com>
Co-authored-by: derpy-duck <115193320+derpy-duck@users.noreply.github.com>
2023-01-05 14:26:27 -08:00
|
|
|
instruction.executionParameters.gasLimit = encoded.toUint32(index);
|
|
|
|
index += 4;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
Move development branch to main (#23)
* refactoring for multidelivery
* partial ts-test fixes
* use typechain in integration tests, update prettier, fix remaining integration tests
* run formatter on solidity files
* gas refunding
* gas forwarding logic
* msg.send -> refundAmount
* minor test refactor & additions
* created relayer engine directory
* more testing & tilt environment config for relayer engine
* starting work on the xMint example contracts
* additions for relayer engine
* minor modifications & todos
* fixed some errors
* refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend
* Merged refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend with new interface'
* refactoring interfaces & files for single VAA design
* GasOracle implementation of new interface
* GasOracle compiles
* Gas oracle upgradable
* Fix compile errors in GasOracleGovernance
* minor core relayer cleanup
* Changes to getters, setters, state
* implement quoteEvmDeliveryPrice, quoteTargetEvmGas, assetConversionAmount for corerelayer
* Correcting interface inconsistencies between CoreRelayerStructs and ICoreRelayer
* Fix encodeDeliveryRequestsContainer
* added single vaa delivery entrypoint logic
* Encode and Decode delivery instructions
* Fixed many compile errors
* First attempt at removing stacktoodeep error
* Commenting out chunks of code to identify stack too deep error
* Continue stack too deep quest
* Revert "Commenting out chunks of code to identify stack too deep error"
This reverts commit 8cd55d26cea2c49dc6e6bfa481c310f1a1c1143a.
* Revert "Continue stack too deep quest"
This reverts commit f0cde6871e26a7063e20d9a83b63b6a50e32bf37.
* Fix stack too deep error in CoreRelayerMessages
* tests compile, run, pass
* fixing up fee collection assertions
* GasOracle tests altering
* Rename encodeDeliveryIntructions to convertToEncodedDeliveryInstructions because we are going from delivery request to delivery instruction
* adding evm events to delivery execution
* forwarding refactor for single vaa
* relay provider name refactor
* Test file slight refactor to allow for multiple chains
* first impl of hub and spoke example
* Forward test progress
* Forwarding test passes!
* More general parameters for test
* Testing file more modular, calls 'generic relayer'
* redelivery implementation
* removing todos
* Tests can use arbitrary amount of chains
* Address various TODOs
* refactored RelayProvider to be upgradeable via proxy
* Add overhead inteface to RelayProvider & adjusted necessary fee calculations
* added TODOs related to rewardAddress payout
* provider price quoting changes
* provider payments made at source
* Fixed all compile errors
* testForward and testSend pass again!
* Switched quoteAssetConversion to quoteApplicationBudgetFee in CoreRelayer interface
* First round of changes to support individual vaas in offchain relayer
- Use new custom plugin event source api in relayer engine
- Supports mulit delivery
- Config for celo and fuji
* contracts deploy successfully to tilt
* bug fixes, contracts deploy to tilt
* Starting the redelivery test
* Tests pass again, with exception of the RelayProvider tests that tested reverts, and the new testRedelivery which isn't finished
* small plugin changes
* MockRelayerIntegration is used for sending
* prepare offchain relayer to run in both tilt and testnet
* update readme and npm scripts for offchain relayer
* nit: remove console.log(argv)
* solc version bump
* Tests changed to pass (commented out the tests with differing require statements and kept redelivery incomplete
* chain registration typescript scripts
* Redeliver works!
* Redelivery test works!
* testnet deploy + relayer engine test
* Testing two sends
* Friday changes to round trip on testnet
* Shortening current tests
* Funds are correct! Relayer gets paid!
* Remove extraneous comments
* ts scripts for deployment and config
* Wormhole Fee Test
Co-authored-by: chase-45 <chasemoran45@gmail.com>
Co-authored-by: derpy-duck <115193320+derpy-duck@users.noreply.github.com>
2023-01-05 14:26:27 -08:00
|
|
|
instruction.executionParameters.providerDeliveryAddress = encoded.toBytes32(index);
|
|
|
|
index += 32;
|
2022-09-30 09:18:49 -07:00
|
|
|
|
Move development branch to main (#23)
* refactoring for multidelivery
* partial ts-test fixes
* use typechain in integration tests, update prettier, fix remaining integration tests
* run formatter on solidity files
* gas refunding
* gas forwarding logic
* msg.send -> refundAmount
* minor test refactor & additions
* created relayer engine directory
* more testing & tilt environment config for relayer engine
* starting work on the xMint example contracts
* additions for relayer engine
* minor modifications & todos
* fixed some errors
* refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend
* Merged refactoring + cleaned up some TODOs
* updated ICoreRelayer interface
* adjusted tests for new interface
* Working testSend with new interface'
* refactoring interfaces & files for single VAA design
* GasOracle implementation of new interface
* GasOracle compiles
* Gas oracle upgradable
* Fix compile errors in GasOracleGovernance
* minor core relayer cleanup
* Changes to getters, setters, state
* implement quoteEvmDeliveryPrice, quoteTargetEvmGas, assetConversionAmount for corerelayer
* Correcting interface inconsistencies between CoreRelayerStructs and ICoreRelayer
* Fix encodeDeliveryRequestsContainer
* added single vaa delivery entrypoint logic
* Encode and Decode delivery instructions
* Fixed many compile errors
* First attempt at removing stacktoodeep error
* Commenting out chunks of code to identify stack too deep error
* Continue stack too deep quest
* Revert "Commenting out chunks of code to identify stack too deep error"
This reverts commit 8cd55d26cea2c49dc6e6bfa481c310f1a1c1143a.
* Revert "Continue stack too deep quest"
This reverts commit f0cde6871e26a7063e20d9a83b63b6a50e32bf37.
* Fix stack too deep error in CoreRelayerMessages
* tests compile, run, pass
* fixing up fee collection assertions
* GasOracle tests altering
* Rename encodeDeliveryIntructions to convertToEncodedDeliveryInstructions because we are going from delivery request to delivery instruction
* adding evm events to delivery execution
* forwarding refactor for single vaa
* relay provider name refactor
* Test file slight refactor to allow for multiple chains
* first impl of hub and spoke example
* Forward test progress
* Forwarding test passes!
* More general parameters for test
* Testing file more modular, calls 'generic relayer'
* redelivery implementation
* removing todos
* Tests can use arbitrary amount of chains
* Address various TODOs
* refactored RelayProvider to be upgradeable via proxy
* Add overhead inteface to RelayProvider & adjusted necessary fee calculations
* added TODOs related to rewardAddress payout
* provider price quoting changes
* provider payments made at source
* Fixed all compile errors
* testForward and testSend pass again!
* Switched quoteAssetConversion to quoteApplicationBudgetFee in CoreRelayer interface
* First round of changes to support individual vaas in offchain relayer
- Use new custom plugin event source api in relayer engine
- Supports mulit delivery
- Config for celo and fuji
* contracts deploy successfully to tilt
* bug fixes, contracts deploy to tilt
* Starting the redelivery test
* Tests pass again, with exception of the RelayProvider tests that tested reverts, and the new testRedelivery which isn't finished
* small plugin changes
* MockRelayerIntegration is used for sending
* prepare offchain relayer to run in both tilt and testnet
* update readme and npm scripts for offchain relayer
* nit: remove console.log(argv)
* solc version bump
* Tests changed to pass (commented out the tests with differing require statements and kept redelivery incomplete
* chain registration typescript scripts
* Redeliver works!
* Redelivery test works!
* testnet deploy + relayer engine test
* Testing two sends
* Friday changes to round trip on testnet
* Shortening current tests
* Funds are correct! Relayer gets paid!
* Remove extraneous comments
* ts scripts for deployment and config
* Wormhole Fee Test
Co-authored-by: chase-45 <chasemoran45@gmail.com>
Co-authored-by: derpy-duck <115193320+derpy-duck@users.noreply.github.com>
2023-01-05 14:26:27 -08:00
|
|
|
instructionArray[i] = instruction;
|
|
|
|
}
|
2022-09-30 09:18:49 -07:00
|
|
|
|
2023-01-19 06:59:35 -08:00
|
|
|
if (index != encoded.length) {
|
|
|
|
revert InvalidDeliveryInstructionsPayload(encoded.length);
|
|
|
|
}
|
2022-09-30 09:18:49 -07:00
|
|
|
|
2023-01-13 12:27:59 -08:00
|
|
|
return DeliveryInstructionsContainer({
|
|
|
|
payloadId: payloadId,
|
|
|
|
sufficientlyFunded: sufficientlyFunded,
|
|
|
|
instructions: instructionArray
|
|
|
|
});
|
2022-09-30 09:18:49 -07:00
|
|
|
}
|
|
|
|
}
|