trustless-generic-relayer/ethereum/contracts/mock/MockRelayerIntegration.sol

302 lines
12 KiB
Solidity
Raw Normal View History

Add tests for send and deliver functionality (#9) * Complete send and deliver functionality * Clean up * Add tests for relayer send method * ethereum: remove interfaces * ethereum: fix test * ethereum: rename directory * ethereum: clean up; add ts tests * Add tests and clean up * ethereum: fix test * ethereum: fix output * Add reentrancy protection and reduce gas overhead for relayers * Add tests for full batch delivery * Update relayer contracts to reflect changes to batch VAA implementation * add rewards payout * implement redeliveries, replay protection * Complete full batch test suite * sdk: add sdk * sdk: fix package.json * Add partial batch unit test and add to integration test * Fix comments in integration test * sdk: fix tsconfig.json * ethereum: fix build * Add relayer registration to integration test * Finish integration test suite * ethereum: fix readAbi * ethereum: fix merge conflict * Complete full batch test suite * Add partial batch unit test and add to integration test * Finish integration test suite * Fix local validator test * Fix merge conflict * Add Makefile * Add documentation to relayer contracts * Fix Makefile * ethereum: clean up * ethereum: fix interface * ethereum: fix method names and tests * Prepare integration test for off-chain relayer changes * Refactor contracts Co-authored-by: Drew <dsterioti@users.noreply.github.com> Co-authored-by: Karl Kempe <karlkempe@users.noreply.github.com> Co-authored-by: valentin <valentinvonalbrecht@yahoo.de> Co-authored-by: justinschuldt <justinschuldt@gmail.com>
2022-09-30 09:18:49 -07:00
// contracts/mock/MockBatchedVAASender.sol
// SPDX-License-Identifier: Apache 2
pragma solidity ^0.8.0;
import "../libraries/external/BytesLib.sol";
import "../interfaces/IWormhole.sol";
2023-02-10 12:33:00 -08:00
import "../interfaces/IWormholeRelayer.sol";
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
import "../interfaces/IWormholeReceiver.sol";
Add tests for send and deliver functionality (#9) * Complete send and deliver functionality * Clean up * Add tests for relayer send method * ethereum: remove interfaces * ethereum: fix test * ethereum: rename directory * ethereum: clean up; add ts tests * Add tests and clean up * ethereum: fix test * ethereum: fix output * Add reentrancy protection and reduce gas overhead for relayers * Add tests for full batch delivery * Update relayer contracts to reflect changes to batch VAA implementation * add rewards payout * implement redeliveries, replay protection * Complete full batch test suite * sdk: add sdk * sdk: fix package.json * Add partial batch unit test and add to integration test * Fix comments in integration test * sdk: fix tsconfig.json * ethereum: fix build * Add relayer registration to integration test * Finish integration test suite * ethereum: fix readAbi * ethereum: fix merge conflict * Complete full batch test suite * Add partial batch unit test and add to integration test * Finish integration test suite * Fix local validator test * Fix merge conflict * Add Makefile * Add documentation to relayer contracts * Fix Makefile * ethereum: clean up * ethereum: fix interface * ethereum: fix method names and tests * Prepare integration test for off-chain relayer changes * Refactor contracts Co-authored-by: Drew <dsterioti@users.noreply.github.com> Co-authored-by: Karl Kempe <karlkempe@users.noreply.github.com> Co-authored-by: valentin <valentinvonalbrecht@yahoo.de> Co-authored-by: justinschuldt <justinschuldt@gmail.com>
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
import "forge-std/console.sol";
interface Structs {
struct XAddress {
uint16 chainId;
bytes32 addr;
}
}
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
contract MockRelayerIntegration is IWormholeReceiver {
Add tests for send and deliver functionality (#9) * Complete send and deliver functionality * Clean up * Add tests for relayer send method * ethereum: remove interfaces * ethereum: fix test * ethereum: rename directory * ethereum: clean up; add ts tests * Add tests and clean up * ethereum: fix test * ethereum: fix output * Add reentrancy protection and reduce gas overhead for relayers * Add tests for full batch delivery * Update relayer contracts to reflect changes to batch VAA implementation * add rewards payout * implement redeliveries, replay protection * Complete full batch test suite * sdk: add sdk * sdk: fix package.json * Add partial batch unit test and add to integration test * Fix comments in integration test * sdk: fix tsconfig.json * ethereum: fix build * Add relayer registration to integration test * Finish integration test suite * ethereum: fix readAbi * ethereum: fix merge conflict * Complete full batch test suite * Add partial batch unit test and add to integration test * Finish integration test suite * Fix local validator test * Fix merge conflict * Add Makefile * Add documentation to relayer contracts * Fix Makefile * ethereum: clean up * ethereum: fix interface * ethereum: fix method names and tests * Prepare integration test for off-chain relayer changes * Refactor contracts Co-authored-by: Drew <dsterioti@users.noreply.github.com> Co-authored-by: Karl Kempe <karlkempe@users.noreply.github.com> Co-authored-by: valentin <valentinvonalbrecht@yahoo.de> Co-authored-by: justinschuldt <justinschuldt@gmail.com>
2022-09-30 09:18:49 -07:00
using BytesLib for bytes;
// wormhole instance on this chain
IWormhole immutable wormhole;
// trusted relayer contract on this chain
2023-02-10 12:33:00 -08:00
IWormholeRelayer immutable relayer;
Add tests for send and deliver functionality (#9) * Complete send and deliver functionality * Clean up * Add tests for relayer send method * ethereum: remove interfaces * ethereum: fix test * ethereum: rename directory * ethereum: clean up; add ts tests * Add tests and clean up * ethereum: fix test * ethereum: fix output * Add reentrancy protection and reduce gas overhead for relayers * Add tests for full batch delivery * Update relayer contracts to reflect changes to batch VAA implementation * add rewards payout * implement redeliveries, replay protection * Complete full batch test suite * sdk: add sdk * sdk: fix package.json * Add partial batch unit test and add to integration test * Fix comments in integration test * sdk: fix tsconfig.json * ethereum: fix build * Add relayer registration to integration test * Finish integration test suite * ethereum: fix readAbi * ethereum: fix merge conflict * Complete full batch test suite * Add partial batch unit test and add to integration test * Finish integration test suite * Fix local validator test * Fix merge conflict * Add Makefile * Add documentation to relayer contracts * Fix Makefile * ethereum: clean up * ethereum: fix interface * ethereum: fix method names and tests * Prepare integration test for off-chain relayer changes * Refactor contracts Co-authored-by: Drew <dsterioti@users.noreply.github.com> Co-authored-by: Karl Kempe <karlkempe@users.noreply.github.com> Co-authored-by: valentin <valentinvonalbrecht@yahoo.de> Co-authored-by: justinschuldt <justinschuldt@gmail.com>
2022-09-30 09:18:49 -07:00
// deployer of this contract
address immutable owner;
// map that stores payloads from received VAAs
mapping(bytes32 => bytes) verifiedPayloads;
2023-02-10 15:32:44 -08:00
// mapping of other MockRelayerIntegration contracts
mapping(uint16 => bytes32) registeredContracts;
// bytes[] messages;
bytes[][] messageHistory;
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
struct FurtherInstructions {
bool keepSending;
2023-02-10 15:32:44 -08:00
bytes[] newMessages;
uint16[] chains;
uint32[] gasLimits;
}
Add tests for send and deliver functionality (#9) * Complete send and deliver functionality * Clean up * Add tests for relayer send method * ethereum: remove interfaces * ethereum: fix test * ethereum: rename directory * ethereum: clean up; add ts tests * Add tests and clean up * ethereum: fix test * ethereum: fix output * Add reentrancy protection and reduce gas overhead for relayers * Add tests for full batch delivery * Update relayer contracts to reflect changes to batch VAA implementation * add rewards payout * implement redeliveries, replay protection * Complete full batch test suite * sdk: add sdk * sdk: fix package.json * Add partial batch unit test and add to integration test * Fix comments in integration test * sdk: fix tsconfig.json * ethereum: fix build * Add relayer registration to integration test * Finish integration test suite * ethereum: fix readAbi * ethereum: fix merge conflict * Complete full batch test suite * Add partial batch unit test and add to integration test * Finish integration test suite * Fix local validator test * Fix merge conflict * Add Makefile * Add documentation to relayer contracts * Fix Makefile * ethereum: clean up * ethereum: fix interface * ethereum: fix method names and tests * Prepare integration test for off-chain relayer changes * Refactor contracts Co-authored-by: Drew <dsterioti@users.noreply.github.com> Co-authored-by: Karl Kempe <karlkempe@users.noreply.github.com> Co-authored-by: valentin <valentinvonalbrecht@yahoo.de> Co-authored-by: justinschuldt <justinschuldt@gmail.com>
2022-09-30 09:18:49 -07:00
constructor(address _wormholeCore, address _coreRelayer) {
wormhole = IWormhole(_wormholeCore);
2023-02-10 12:33:00 -08:00
relayer = IWormholeRelayer(_coreRelayer);
Add tests for send and deliver functionality (#9) * Complete send and deliver functionality * Clean up * Add tests for relayer send method * ethereum: remove interfaces * ethereum: fix test * ethereum: rename directory * ethereum: clean up; add ts tests * Add tests and clean up * ethereum: fix test * ethereum: fix output * Add reentrancy protection and reduce gas overhead for relayers * Add tests for full batch delivery * Update relayer contracts to reflect changes to batch VAA implementation * add rewards payout * implement redeliveries, replay protection * Complete full batch test suite * sdk: add sdk * sdk: fix package.json * Add partial batch unit test and add to integration test * Fix comments in integration test * sdk: fix tsconfig.json * ethereum: fix build * Add relayer registration to integration test * Finish integration test suite * ethereum: fix readAbi * ethereum: fix merge conflict * Complete full batch test suite * Add partial batch unit test and add to integration test * Finish integration test suite * Fix local validator test * Fix merge conflict * Add Makefile * Add documentation to relayer contracts * Fix Makefile * ethereum: clean up * ethereum: fix interface * ethereum: fix method names and tests * Prepare integration test for off-chain relayer changes * Refactor contracts Co-authored-by: Drew <dsterioti@users.noreply.github.com> Co-authored-by: Karl Kempe <karlkempe@users.noreply.github.com> Co-authored-by: valentin <valentinvonalbrecht@yahoo.de> Co-authored-by: justinschuldt <justinschuldt@gmail.com>
2022-09-30 09:18:49 -07:00
owner = msg.sender;
}
2023-02-10 15:32:44 -08:00
function sendMessage(bytes memory _message, uint16 targetChainId, address destination) public payable {
sendMessageGeneral(_message, targetChainId, destination, destination, 0, 1);
2023-02-10 15:32:44 -08:00
}
2023-02-13 07:29:45 -08:00
function sendMessageWithRefundAddress(
bytes memory _message,
uint16 targetChainId,
address destination,
address refundAddress
) public payable {
2023-02-10 15:32:44 -08:00
sendMessageGeneral(_message, targetChainId, destination, refundAddress, 0, 1);
Add tests for send and deliver functionality (#9) * Complete send and deliver functionality * Clean up * Add tests for relayer send method * ethereum: remove interfaces * ethereum: fix test * ethereum: rename directory * ethereum: clean up; add ts tests * Add tests and clean up * ethereum: fix test * ethereum: fix output * Add reentrancy protection and reduce gas overhead for relayers * Add tests for full batch delivery * Update relayer contracts to reflect changes to batch VAA implementation * add rewards payout * implement redeliveries, replay protection * Complete full batch test suite * sdk: add sdk * sdk: fix package.json * Add partial batch unit test and add to integration test * Fix comments in integration test * sdk: fix tsconfig.json * ethereum: fix build * Add relayer registration to integration test * Finish integration test suite * ethereum: fix readAbi * ethereum: fix merge conflict * Complete full batch test suite * Add partial batch unit test and add to integration test * Finish integration test suite * Fix local validator test * Fix merge conflict * Add Makefile * Add documentation to relayer contracts * Fix Makefile * ethereum: clean up * ethereum: fix interface * ethereum: fix method names and tests * Prepare integration test for off-chain relayer changes * Refactor contracts Co-authored-by: Drew <dsterioti@users.noreply.github.com> Co-authored-by: Karl Kempe <karlkempe@users.noreply.github.com> Co-authored-by: valentin <valentinvonalbrecht@yahoo.de> Co-authored-by: justinschuldt <justinschuldt@gmail.com>
2022-09-30 09:18:49 -07:00
}
2023-01-05 16:46:58 -08:00
function sendMessageWithForwardedResponse(
bytes memory _message,
uint16 targetChainId,
address destination,
address refundAddress
2023-02-10 12:33:00 -08:00
) public payable {
2023-02-10 15:32:44 -08:00
uint16[] memory chains = new uint16[](1);
chains[0] = wormhole.chainId();
uint32[] memory gasLimits = new uint32[](1);
gasLimits[0] = 1000000;
bytes[] memory newMessages = new bytes[](2);
2023-02-10 15:32:44 -08:00
newMessages[0] = bytes("received!");
newMessages[1] = abi.encodePacked(uint8(0));
FurtherInstructions memory instructions =
FurtherInstructions({keepSending: true, newMessages: newMessages, chains: chains, gasLimits: gasLimits});
2023-02-10 15:32:44 -08:00
wormhole.publishMessage{value: wormhole.messageFee()}(1, _message, 200);
wormhole.publishMessage{value: wormhole.messageFee()}(1, encodeFurtherInstructions(instructions), 200);
executeSend(targetChainId, destination, refundAddress, 0, 1);
Add tests for send and deliver functionality (#9) * Complete send and deliver functionality * Clean up * Add tests for relayer send method * ethereum: remove interfaces * ethereum: fix test * ethereum: rename directory * ethereum: clean up; add ts tests * Add tests and clean up * ethereum: fix test * ethereum: fix output * Add reentrancy protection and reduce gas overhead for relayers * Add tests for full batch delivery * Update relayer contracts to reflect changes to batch VAA implementation * add rewards payout * implement redeliveries, replay protection * Complete full batch test suite * sdk: add sdk * sdk: fix package.json * Add partial batch unit test and add to integration test * Fix comments in integration test * sdk: fix tsconfig.json * ethereum: fix build * Add relayer registration to integration test * Finish integration test suite * ethereum: fix readAbi * ethereum: fix merge conflict * Complete full batch test suite * Add partial batch unit test and add to integration test * Finish integration test suite * Fix local validator test * Fix merge conflict * Add Makefile * Add documentation to relayer contracts * Fix Makefile * ethereum: clean up * ethereum: fix interface * ethereum: fix method names and tests * Prepare integration test for off-chain relayer changes * Refactor contracts Co-authored-by: Drew <dsterioti@users.noreply.github.com> Co-authored-by: Karl Kempe <karlkempe@users.noreply.github.com> Co-authored-by: valentin <valentinvonalbrecht@yahoo.de> Co-authored-by: justinschuldt <justinschuldt@gmail.com>
2022-09-30 09:18:49 -07:00
}
2023-01-05 16:46:58 -08:00
function sendMessageGeneral(
bytes memory fullMessage,
uint16 targetChainId,
address destination,
address refundAddress,
2023-02-10 12:33:00 -08:00
uint256 receiverValue,
2023-01-05 16:46:58 -08:00
uint32 nonce
2023-02-10 12:33:00 -08:00
) public payable {
2023-02-10 15:32:44 -08:00
wormhole.publishMessage{value: wormhole.messageFee()}(nonce, fullMessage, 200);
wormhole.publishMessage{value: wormhole.messageFee()}(nonce, abi.encodePacked(uint8(0)), 200);
2023-02-10 15:32:44 -08:00
executeSend(targetChainId, destination, refundAddress, receiverValue, nonce);
2023-01-05 16:21:30 -08:00
}
2023-02-13 10:23:25 -08:00
function sendMessagesWithFurtherInstructions(
bytes[] memory messages,
FurtherInstructions memory furtherInstructions,
uint16[] memory chains,
uint256[] memory computeBudgets
2023-02-13 10:23:25 -08:00
) public payable {
2023-02-13 16:43:12 -08:00
for (uint16 i = 0; i < messages.length; i++) {
wormhole.publishMessage{value: wormhole.messageFee()}(1, messages[i], 200);
}
wormhole.publishMessage{value: wormhole.messageFee()}(1, encodeFurtherInstructions(furtherInstructions), 200);
2023-02-13 16:43:12 -08:00
IWormholeRelayer.Send[] memory requests = new IWormholeRelayer.Send[](chains.length);
for (uint16 i = 0; i < chains.length; i++) {
requests[i] = IWormholeRelayer.Send({
targetChain: chains[i],
targetAddress: registeredContracts[chains[i]],
refundAddress: registeredContracts[chains[i]],
2023-02-13 16:43:12 -08:00
maxTransactionFee: computeBudgets[i],
receiverValue: 0,
relayParameters: relayer.getDefaultRelayParams()
2023-02-13 16:43:12 -08:00
});
2023-02-13 10:23:25 -08:00
}
2023-02-13 16:43:12 -08:00
IWormholeRelayer.MultichainSend memory container = IWormholeRelayer.MultichainSend({
requests: requests,
2023-02-13 16:43:12 -08:00
relayProviderAddress: relayer.getDefaultRelayProvider()
});
2023-02-13 16:43:12 -08:00
relayer.multichainSend{value: (msg.value - wormhole.messageFee() * (1 + messages.length))}(container, 1);
2023-02-13 10:23:25 -08:00
}
2023-01-05 16:46:58 -08:00
function executeSend(
uint16 targetChainId,
address destination,
address refundAddress,
2023-02-10 12:33:00 -08:00
uint256 receiverValue,
2023-01-05 16:46:58 -08:00
uint32 nonce
2023-02-10 12:33:00 -08:00
) internal {
IWormholeRelayer.Send memory request = IWormholeRelayer.Send({
targetChain: targetChainId,
targetAddress: relayer.toWormholeFormat(address(destination)),
refundAddress: relayer.toWormholeFormat(address(refundAddress)), // This will be ignored on the target chain if the intent is to perform a forward
2023-02-13 16:43:12 -08:00
maxTransactionFee: msg.value - 3 * wormhole.messageFee() - receiverValue,
receiverValue: receiverValue,
relayParameters: relayer.getDefaultRelayParams()
});
Add tests for send and deliver functionality (#9) * Complete send and deliver functionality * Clean up * Add tests for relayer send method * ethereum: remove interfaces * ethereum: fix test * ethereum: rename directory * ethereum: clean up; add ts tests * Add tests and clean up * ethereum: fix test * ethereum: fix output * Add reentrancy protection and reduce gas overhead for relayers * Add tests for full batch delivery * Update relayer contracts to reflect changes to batch VAA implementation * add rewards payout * implement redeliveries, replay protection * Complete full batch test suite * sdk: add sdk * sdk: fix package.json * Add partial batch unit test and add to integration test * Fix comments in integration test * sdk: fix tsconfig.json * ethereum: fix build * Add relayer registration to integration test * Finish integration test suite * ethereum: fix readAbi * ethereum: fix merge conflict * Complete full batch test suite * Add partial batch unit test and add to integration test * Finish integration test suite * Fix local validator test * Fix merge conflict * Add Makefile * Add documentation to relayer contracts * Fix Makefile * ethereum: clean up * ethereum: fix interface * ethereum: fix method names and tests * Prepare integration test for off-chain relayer changes * Refactor contracts Co-authored-by: Drew <dsterioti@users.noreply.github.com> Co-authored-by: Karl Kempe <karlkempe@users.noreply.github.com> Co-authored-by: valentin <valentinvonalbrecht@yahoo.de> Co-authored-by: justinschuldt <justinschuldt@gmail.com>
2022-09-30 09:18:49 -07:00
2023-02-13 16:43:12 -08:00
relayer.send{value: msg.value - 2 * wormhole.messageFee()}(request, nonce, relayer.getDefaultRelayProvider());
Add tests for send and deliver functionality (#9) * Complete send and deliver functionality * Clean up * Add tests for relayer send method * ethereum: remove interfaces * ethereum: fix test * ethereum: rename directory * ethereum: clean up; add ts tests * Add tests and clean up * ethereum: fix test * ethereum: fix output * Add reentrancy protection and reduce gas overhead for relayers * Add tests for full batch delivery * Update relayer contracts to reflect changes to batch VAA implementation * add rewards payout * implement redeliveries, replay protection * Complete full batch test suite * sdk: add sdk * sdk: fix package.json * Add partial batch unit test and add to integration test * Fix comments in integration test * sdk: fix tsconfig.json * ethereum: fix build * Add relayer registration to integration test * Finish integration test suite * ethereum: fix readAbi * ethereum: fix merge conflict * Complete full batch test suite * Add partial batch unit test and add to integration test * Finish integration test suite * Fix local validator test * Fix merge conflict * Add Makefile * Add documentation to relayer contracts * Fix Makefile * ethereum: clean up * ethereum: fix interface * ethereum: fix method names and tests * Prepare integration test for off-chain relayer changes * Refactor contracts Co-authored-by: Drew <dsterioti@users.noreply.github.com> Co-authored-by: Karl Kempe <karlkempe@users.noreply.github.com> Co-authored-by: valentin <valentinvonalbrecht@yahoo.de> Co-authored-by: justinschuldt <justinschuldt@gmail.com>
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
function receiveWormholeMessages(bytes[] memory wormholeObservations, bytes[] memory) public payable override {
// loop through the array of wormhole observations from the batch and store each payload
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
uint256 numObservations = wormholeObservations.length;
bytes[] memory messages = new bytes[](wormholeObservations.length - 2);
uint16 emitterChainId;
2023-02-10 15:32:44 -08:00
for (uint256 i = 0; i < numObservations - 2; i++) {
(IWormhole.VM memory parsed, bool valid, string memory reason) =
wormhole.parseAndVerifyVM(wormholeObservations[i]);
require(valid, reason);
2023-02-10 15:32:44 -08:00
require(registeredContracts[parsed.emitterChainId] == parsed.emitterAddress);
emitterChainId = parsed.emitterChainId;
2023-02-10 15:32:44 -08:00
messages[i] = parsed.payload;
}
messageHistory.push(messages);
2023-02-10 15:32:44 -08:00
(IWormhole.VM memory parsed, bool valid, string memory reason) =
wormhole.parseAndVerifyVM(wormholeObservations[wormholeObservations.length - 2]);
2023-02-10 15:32:44 -08:00
FurtherInstructions memory instructions = decodeFurtherInstructions(parsed.payload);
if (instructions.keepSending) {
for (uint16 i = 0; i < instructions.newMessages.length; i++) {
wormhole.publishMessage{value: wormhole.messageFee()}(parsed.nonce, instructions.newMessages[i], 200);
2023-02-10 15:32:44 -08:00
}
2023-02-13 16:43:12 -08:00
IWormholeRelayer.Send[] memory sendRequests = new IWormholeRelayer.Send[](instructions.chains.length);
for (uint16 i = 0; i < instructions.chains.length; i++) {
sendRequests[i] = IWormholeRelayer.Send({
2023-02-10 15:32:44 -08:00
targetChain: instructions.chains[i],
targetAddress: registeredContracts[instructions.chains[i]],
refundAddress: registeredContracts[instructions.chains[i]],
maxTransactionFee: relayer.quoteGas(
instructions.chains[i], instructions.gasLimits[i], relayer.getDefaultRelayProvider()
),
2023-02-10 12:33:00 -08:00
receiverValue: 0,
relayParameters: relayer.getDefaultRelayParams()
});
}
2023-02-13 16:44:05 -08:00
IWormholeRelayer.MultichainSend memory container = IWormholeRelayer.MultichainSend({
requests: sendRequests,
relayProviderAddress: relayer.getDefaultRelayProvider()
});
relayer.multichainForward(container, parsed.nonce);
}
Add tests for send and deliver functionality (#9) * Complete send and deliver functionality * Clean up * Add tests for relayer send method * ethereum: remove interfaces * ethereum: fix test * ethereum: rename directory * ethereum: clean up; add ts tests * Add tests and clean up * ethereum: fix test * ethereum: fix output * Add reentrancy protection and reduce gas overhead for relayers * Add tests for full batch delivery * Update relayer contracts to reflect changes to batch VAA implementation * add rewards payout * implement redeliveries, replay protection * Complete full batch test suite * sdk: add sdk * sdk: fix package.json * Add partial batch unit test and add to integration test * Fix comments in integration test * sdk: fix tsconfig.json * ethereum: fix build * Add relayer registration to integration test * Finish integration test suite * ethereum: fix readAbi * ethereum: fix merge conflict * Complete full batch test suite * Add partial batch unit test and add to integration test * Finish integration test suite * Fix local validator test * Fix merge conflict * Add Makefile * Add documentation to relayer contracts * Fix Makefile * ethereum: clean up * ethereum: fix interface * ethereum: fix method names and tests * Prepare integration test for off-chain relayer changes * Refactor contracts Co-authored-by: Drew <dsterioti@users.noreply.github.com> Co-authored-by: Karl Kempe <karlkempe@users.noreply.github.com> Co-authored-by: valentin <valentinvonalbrecht@yahoo.de> Co-authored-by: justinschuldt <justinschuldt@gmail.com>
2022-09-30 09:18:49 -07:00
}
function getPayload(bytes32 hash) public view returns (bytes memory) {
return verifiedPayloads[hash];
}
2023-02-13 07:14:49 -08:00
function getMessage() public view returns (bytes memory) {
if (messageHistory.length == 0 || messageHistory[messageHistory.length - 1].length == 0) {
2023-02-10 15:32:44 -08:00
return new bytes(0);
}
return messageHistory[messageHistory.length - 1][0];
Add tests for send and deliver functionality (#9) * Complete send and deliver functionality * Clean up * Add tests for relayer send method * ethereum: remove interfaces * ethereum: fix test * ethereum: rename directory * ethereum: clean up; add ts tests * Add tests and clean up * ethereum: fix test * ethereum: fix output * Add reentrancy protection and reduce gas overhead for relayers * Add tests for full batch delivery * Update relayer contracts to reflect changes to batch VAA implementation * add rewards payout * implement redeliveries, replay protection * Complete full batch test suite * sdk: add sdk * sdk: fix package.json * Add partial batch unit test and add to integration test * Fix comments in integration test * sdk: fix tsconfig.json * ethereum: fix build * Add relayer registration to integration test * Finish integration test suite * ethereum: fix readAbi * ethereum: fix merge conflict * Complete full batch test suite * Add partial batch unit test and add to integration test * Finish integration test suite * Fix local validator test * Fix merge conflict * Add Makefile * Add documentation to relayer contracts * Fix Makefile * ethereum: clean up * ethereum: fix interface * ethereum: fix method names and tests * Prepare integration test for off-chain relayer changes * Refactor contracts Co-authored-by: Drew <dsterioti@users.noreply.github.com> Co-authored-by: Karl Kempe <karlkempe@users.noreply.github.com> Co-authored-by: valentin <valentinvonalbrecht@yahoo.de> Co-authored-by: justinschuldt <justinschuldt@gmail.com>
2022-09-30 09:18:49 -07:00
}
2023-02-13 07:14:49 -08:00
function getMessages() public view returns (bytes[] memory) {
if (messageHistory.length == 0 || messageHistory[messageHistory.length - 1].length == 0) {
return new bytes[](0);
}
return messageHistory[messageHistory.length - 1];
}
function getMessageHistory() public view returns (bytes[][] memory) {
return messageHistory;
2023-02-13 07:14:49 -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
function clearPayload(bytes32 hash) public {
delete verifiedPayloads[hash];
Add tests for send and deliver functionality (#9) * Complete send and deliver functionality * Clean up * Add tests for relayer send method * ethereum: remove interfaces * ethereum: fix test * ethereum: rename directory * ethereum: clean up; add ts tests * Add tests and clean up * ethereum: fix test * ethereum: fix output * Add reentrancy protection and reduce gas overhead for relayers * Add tests for full batch delivery * Update relayer contracts to reflect changes to batch VAA implementation * add rewards payout * implement redeliveries, replay protection * Complete full batch test suite * sdk: add sdk * sdk: fix package.json * Add partial batch unit test and add to integration test * Fix comments in integration test * sdk: fix tsconfig.json * ethereum: fix build * Add relayer registration to integration test * Finish integration test suite * ethereum: fix readAbi * ethereum: fix merge conflict * Complete full batch test suite * Add partial batch unit test and add to integration test * Finish integration test suite * Fix local validator test * Fix merge conflict * Add Makefile * Add documentation to relayer contracts * Fix Makefile * ethereum: clean up * ethereum: fix interface * ethereum: fix method names and tests * Prepare integration test for off-chain relayer changes * Refactor contracts Co-authored-by: Drew <dsterioti@users.noreply.github.com> Co-authored-by: Karl Kempe <karlkempe@users.noreply.github.com> Co-authored-by: valentin <valentinvonalbrecht@yahoo.de> Co-authored-by: justinschuldt <justinschuldt@gmail.com>
2022-09-30 09:18:49 -07:00
}
function parseWormholeObservation(bytes memory encoded) public view returns (IWormhole.VM memory) {
Add tests for send and deliver functionality (#9) * Complete send and deliver functionality * Clean up * Add tests for relayer send method * ethereum: remove interfaces * ethereum: fix test * ethereum: rename directory * ethereum: clean up; add ts tests * Add tests and clean up * ethereum: fix test * ethereum: fix output * Add reentrancy protection and reduce gas overhead for relayers * Add tests for full batch delivery * Update relayer contracts to reflect changes to batch VAA implementation * add rewards payout * implement redeliveries, replay protection * Complete full batch test suite * sdk: add sdk * sdk: fix package.json * Add partial batch unit test and add to integration test * Fix comments in integration test * sdk: fix tsconfig.json * ethereum: fix build * Add relayer registration to integration test * Finish integration test suite * ethereum: fix readAbi * ethereum: fix merge conflict * Complete full batch test suite * Add partial batch unit test and add to integration test * Finish integration test suite * Fix local validator test * Fix merge conflict * Add Makefile * Add documentation to relayer contracts * Fix Makefile * ethereum: clean up * ethereum: fix interface * ethereum: fix method names and tests * Prepare integration test for off-chain relayer changes * Refactor contracts Co-authored-by: Drew <dsterioti@users.noreply.github.com> Co-authored-by: Karl Kempe <karlkempe@users.noreply.github.com> Co-authored-by: valentin <valentinvonalbrecht@yahoo.de> Co-authored-by: justinschuldt <justinschuldt@gmail.com>
2022-09-30 09:18:49 -07:00
return wormhole.parseVM(encoded);
}
function emitterAddress() public view returns (bytes32) {
return bytes32(uint256(uint160(address(this))));
}
2023-02-10 15:32:44 -08:00
function registerEmitter(uint16 chainId, bytes32 emitterAddress) public {
require(msg.sender == owner);
registeredContracts[chainId] = emitterAddress;
}
function registerEmitters(Structs.XAddress[] calldata emitters) public {
require(msg.sender == owner);
for (uint256 i = 0; i < emitters.length; i++) {
registeredContracts[emitters[i].chainId] = emitters[i].addr;
}
}
function encodeFurtherInstructions(FurtherInstructions memory furtherInstructions)
public
view
returns (bytes memory encodedFurtherInstructions)
{
encodedFurtherInstructions = abi.encodePacked(
furtherInstructions.keepSending ? uint8(1) : uint8(0), uint16(furtherInstructions.newMessages.length)
);
for (uint16 i = 0; i < furtherInstructions.newMessages.length; i++) {
encodedFurtherInstructions = abi.encodePacked(
encodedFurtherInstructions,
uint16(furtherInstructions.newMessages[i].length),
furtherInstructions.newMessages[i]
);
2023-02-10 15:32:44 -08:00
}
encodedFurtherInstructions =
abi.encodePacked(encodedFurtherInstructions, uint16(furtherInstructions.chains.length));
for (uint16 i = 0; i < furtherInstructions.chains.length; i++) {
encodedFurtherInstructions = abi.encodePacked(
encodedFurtherInstructions, furtherInstructions.chains[i], furtherInstructions.gasLimits[i]
);
}
}
function decodeFurtherInstructions(bytes memory encodedFurtherInstructions)
public
view
returns (FurtherInstructions memory furtherInstructions)
{
uint256 index = 0;
2023-02-10 15:32:44 -08:00
furtherInstructions.keepSending = encodedFurtherInstructions.toUint8(index) == 1;
index += 1;
2023-02-10 15:32:44 -08:00
if (!furtherInstructions.keepSending) {
2023-02-10 15:32:44 -08:00
return furtherInstructions;
}
uint16 length = encodedFurtherInstructions.toUint16(index);
index += 2;
2023-02-10 15:32:44 -08:00
furtherInstructions.newMessages = new bytes[](length);
for (uint16 i = 0; i < length; i++) {
2023-02-10 15:32:44 -08:00
uint16 msgLength = encodedFurtherInstructions.toUint16(index);
index += 2;
furtherInstructions.newMessages[i] = encodedFurtherInstructions.slice(index, msgLength);
index += msgLength;
}
2023-02-10 15:32:44 -08:00
length = encodedFurtherInstructions.toUint16(index);
index += 2;
uint16[] memory chains = new uint16[](length);
uint32[] memory gasLimits = new uint32[](length);
for (uint16 i = 0; i < length; i++) {
2023-02-10 15:32:44 -08:00
chains[i] = encodedFurtherInstructions.toUint16(index);
index += 2;
gasLimits[i] = encodedFurtherInstructions.toUint32(index);
index += 4;
}
furtherInstructions.chains = chains;
furtherInstructions.gasLimits = gasLimits;
}
receive() external payable {}
Add tests for send and deliver functionality (#9) * Complete send and deliver functionality * Clean up * Add tests for relayer send method * ethereum: remove interfaces * ethereum: fix test * ethereum: rename directory * ethereum: clean up; add ts tests * Add tests and clean up * ethereum: fix test * ethereum: fix output * Add reentrancy protection and reduce gas overhead for relayers * Add tests for full batch delivery * Update relayer contracts to reflect changes to batch VAA implementation * add rewards payout * implement redeliveries, replay protection * Complete full batch test suite * sdk: add sdk * sdk: fix package.json * Add partial batch unit test and add to integration test * Fix comments in integration test * sdk: fix tsconfig.json * ethereum: fix build * Add relayer registration to integration test * Finish integration test suite * ethereum: fix readAbi * ethereum: fix merge conflict * Complete full batch test suite * Add partial batch unit test and add to integration test * Finish integration test suite * Fix local validator test * Fix merge conflict * Add Makefile * Add documentation to relayer contracts * Fix Makefile * ethereum: clean up * ethereum: fix interface * ethereum: fix method names and tests * Prepare integration test for off-chain relayer changes * Refactor contracts Co-authored-by: Drew <dsterioti@users.noreply.github.com> Co-authored-by: Karl Kempe <karlkempe@users.noreply.github.com> Co-authored-by: valentin <valentinvonalbrecht@yahoo.de> Co-authored-by: justinschuldt <justinschuldt@gmail.com>
2022-09-30 09:18:49 -07:00
}