From 5168952575a3ad08b9e7d811825e2b15c23eaa6b Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Wed, 6 Nov 2024 23:56:43 +0000 Subject: [PATCH 1/7] feat: wormhole relayer for arbitrary msg.value-s --- abis/0.8.28/WormholeRelayer.json | 129 +++++++++++++++++++++++++ contracts/bridges/WormholeRelayer.sol | 133 ++++++++++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 abis/0.8.28/WormholeRelayer.json create mode 100644 contracts/bridges/WormholeRelayer.sol diff --git a/abis/0.8.28/WormholeRelayer.json b/abis/0.8.28/WormholeRelayer.json new file mode 100644 index 0000000..fcfcab3 --- /dev/null +++ b/abis/0.8.28/WormholeRelayer.json @@ -0,0 +1,129 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "WormholeRelayer", + "sourceName": "contracts/bridges/WormholeRelayer.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_wormholeRelayer", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "provided", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expected", + "type": "uint256" + } + ], + "name": "LowerThan", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroValue", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "leftovers", + "type": "uint256" + } + ], + "name": "LeftoversRefunded", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "targetChain", + "type": "uint16" + }, + { + "internalType": "address", + "name": "targetAddress", + "type": "address" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "receiverValue", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "gasLimit", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "refundChain", + "type": "uint16" + }, + { + "internalType": "address", + "name": "refundAddress", + "type": "address" + } + ], + "name": "sendPayloadToEvm", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "wormholeRelayer", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x60a0604052348015600e575f5ffd5b50604051610799380380610799833981016040819052602b91603b565b6001600160a01b03166080526066565b5f60208284031215604a575f5ffd5b81516001600160a01b0381168114605f575f5ffd5b9392505050565b60805161070e61008b5f395f8181606e015281816101c30152610355015261070e5ff3fe608060405260043610610028575f3560e01c80634b5ca6f41461002c578063da25b7251461005d575b5f5ffd5b61003f61003a36600461044d565b6100b5565b60405167ffffffffffffffff90911681526020015b60405180910390f35b348015610068575f5ffd5b506100907f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610054565b5f73ffffffffffffffffffffffffffffffffffffffff871615806100ed575073ffffffffffffffffffffffffffffffffffffffff8216155b15610124576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61ffff8816158061013457508551155b8061013d575083155b8061014a575061ffff8316155b15610181576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fc23ee3c300000000000000000000000000000000000000000000000000000000815261ffff891660048201525f6024820181905260448201869052907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063c23ee3c3906064016040805180830381865afa15801561021c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102409190610590565b5090503481111561028a576040517f491a2bb10000000000000000000000000000000000000000000000000000000081523460048201526024810182905260440160405180910390fd5b5f61029582346105b2565b9050801561031857604051329082905f81818185875af1925050503d805f81146102da576040519150601f19603f3d011682016040523d82523d5f602084013e6102df565b606091505b50506040518281523291507f8e49ed3e274fbea1556bdfaa9a37a0c28445bfe26d57beaf9f04fd517aa417419060200160405180910390a25b6040517f4b5ca6f400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690634b5ca6f4908490610398908e908e908e908e908e908e908e906004016105f0565b60206040518083038185885af11580156103b4573d5f5f3e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906103d991906106aa565b9a9950505050505050505050565b803561ffff811681146103f8575f5ffd5b919050565b803573ffffffffffffffffffffffffffffffffffffffff811681146103f8575f5ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f5f5f5f5f5f5f60e0888a031215610463575f5ffd5b61046c886103e7565b965061047a602089016103fd565b9550604088013567ffffffffffffffff811115610495575f5ffd5b8801601f81018a136104a5575f5ffd5b803567ffffffffffffffff8111156104bf576104bf610420565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff8211171561052b5761052b610420565b6040528181528282016020018c1015610542575f5ffd5b816020840160208301375f91810160200191909152955050606088013593506080880135925061057460a089016103e7565b915061058260c089016103fd565b905092959891949750929550565b5f5f604083850312156105a1575f5ffd5b505080516020909101519092909150565b818103818111156105ea577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b92915050565b61ffff8816815273ffffffffffffffffffffffffffffffffffffffff8716602082015260e060408201525f86518060e0840152806020890161010085015e5f61010082850101526101007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011684010191505085606083015284608083015261ffff841660a083015261069e60c083018473ffffffffffffffffffffffffffffffffffffffff169052565b98975050505050505050565b5f602082840312156106ba575f5ffd5b815167ffffffffffffffff811681146106d1575f5ffd5b939250505056fea264697066735822122033354bbea4bd99b5a23b0d613690efc7804dc9278bf279de0ad05b62cff0358464736f6c634300081c0033", + "deployedBytecode": "0x608060405260043610610028575f3560e01c80634b5ca6f41461002c578063da25b7251461005d575b5f5ffd5b61003f61003a36600461044d565b6100b5565b60405167ffffffffffffffff90911681526020015b60405180910390f35b348015610068575f5ffd5b506100907f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610054565b5f73ffffffffffffffffffffffffffffffffffffffff871615806100ed575073ffffffffffffffffffffffffffffffffffffffff8216155b15610124576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61ffff8816158061013457508551155b8061013d575083155b8061014a575061ffff8316155b15610181576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fc23ee3c300000000000000000000000000000000000000000000000000000000815261ffff891660048201525f6024820181905260448201869052907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063c23ee3c3906064016040805180830381865afa15801561021c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102409190610590565b5090503481111561028a576040517f491a2bb10000000000000000000000000000000000000000000000000000000081523460048201526024810182905260440160405180910390fd5b5f61029582346105b2565b9050801561031857604051329082905f81818185875af1925050503d805f81146102da576040519150601f19603f3d011682016040523d82523d5f602084013e6102df565b606091505b50506040518281523291507f8e49ed3e274fbea1556bdfaa9a37a0c28445bfe26d57beaf9f04fd517aa417419060200160405180910390a25b6040517f4b5ca6f400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690634b5ca6f4908490610398908e908e908e908e908e908e908e906004016105f0565b60206040518083038185885af11580156103b4573d5f5f3e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906103d991906106aa565b9a9950505050505050505050565b803561ffff811681146103f8575f5ffd5b919050565b803573ffffffffffffffffffffffffffffffffffffffff811681146103f8575f5ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f5f5f5f5f5f5f60e0888a031215610463575f5ffd5b61046c886103e7565b965061047a602089016103fd565b9550604088013567ffffffffffffffff811115610495575f5ffd5b8801601f81018a136104a5575f5ffd5b803567ffffffffffffffff8111156104bf576104bf610420565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff8211171561052b5761052b610420565b6040528181528282016020018c1015610542575f5ffd5b816020840160208301375f91810160200191909152955050606088013593506080880135925061057460a089016103e7565b915061058260c089016103fd565b905092959891949750929550565b5f5f604083850312156105a1575f5ffd5b505080516020909101519092909150565b818103818111156105ea577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b92915050565b61ffff8816815273ffffffffffffffffffffffffffffffffffffffff8716602082015260e060408201525f86518060e0840152806020890161010085015e5f61010082850101526101007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011684010191505085606083015284608083015261ffff841660a083015261069e60c083018473ffffffffffffffffffffffffffffffffffffffff169052565b98975050505050505050565b5f602082840312156106ba575f5ffd5b815167ffffffffffffffff811681146106d1575f5ffd5b939250505056fea264697066735822122033354bbea4bd99b5a23b0d613690efc7804dc9278bf279de0ad05b62cff0358464736f6c634300081c0033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/contracts/bridges/WormholeRelayer.sol b/contracts/bridges/WormholeRelayer.sol new file mode 100644 index 0000000..750c2ea --- /dev/null +++ b/contracts/bridges/WormholeRelayer.sol @@ -0,0 +1,133 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.28; + +interface IWormhole { + /// @dev Returns the price to request a relay to chain `targetChain`, using the default delivery provider + /// + /// @param targetChain in Wormhole Chain ID format + /// @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) + /// @param gasLimit gas limit with which to call `targetAddress`. + /// @return nativePriceQuote Price, in units of current chain currency, that the delivery provider charges to perform the relay + /// @return targetChainRefundPerGasUnused amount of target chain currency that will be refunded per unit of gas unused, + /// if a refundAddress is specified. + /// Note: This value can be overridden by the delivery provider on the target chain. The returned value here should be considered to be a + /// promise by the delivery provider of the amount of refund per gas unused that will be returned to the refundAddress at the target chain. + /// If a delivery provider decides to override, this will be visible as part of the emitted Delivery event on the target chain. + /// + function quoteEVMDeliveryPrice( + uint16 targetChain, + uint256 receiverValue, + uint256 gasLimit + ) external view returns (uint256 nativePriceQuote, uint256 targetChainRefundPerGasUnused); + + /// @dev Publishes an instruction for the default delivery provider + /// to relay a payload to the address `targetAddress` on chain `targetChain` + /// with gas limit `gasLimit` and `msg.value` equal to `receiverValue` + /// + /// Any refunds (from leftover gas) will be sent to `refundAddress` on chain `refundChain` + /// `targetAddress` must implement the IWormholeReceiver interface + /// + /// This function must be called with `msg.value` equal to `quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit)` + /// + /// @param targetChain in Wormhole Chain ID format + /// @param targetAddress address to call on targetChain (that implements IWormholeReceiver) + /// @param payload arbitrary bytes to pass in as parameter in call to `targetAddress` + /// @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) + /// @param gasLimit gas limit with which to call `targetAddress`. Any units of gas unused will be refunded according to the + /// `targetChainRefundPerGasUnused` rate quoted by the delivery provider + /// @param refundChain The chain to deliver any refund to, in Wormhole Chain ID format + /// @param refundAddress The address on `refundChain` to deliver any refund to + /// @return sequence sequence number of published VAA containing delivery instructions + function sendPayloadToEvm( + uint16 targetChain, + address targetAddress, + bytes memory payload, + uint256 receiverValue, + uint256 gasLimit, + uint16 refundChain, + address refundAddress + ) external payable returns (uint64 sequence); +} + +/// @dev Provided zero address. +error ZeroAddress(); + +/// @dev Zero value when it has to be different from zero. +error ZeroValue(); + +/// @dev Received lower value than the expected one. +/// @param provided Provided value is lower. +/// @param expected Expected value. +error LowerThan(uint256 provided, uint256 expected); + +/// @title WormholeRelayer - Smart contract for the contract interaction with wormhole relayer with any msg.value +/// @author Aleksandr Kuperman - +/// @author Andrey Lebedev - +contract WormholeRelayer { + event LeftoversRefunded(address indexed sender, uint256 leftovers); + + // L1 Wormhole Relayer address that sends the message across the bridge + address public immutable wormholeRelayer; + + /// @dev WormholeRelayer constructor. + /// @param _wormholeRelayer Wormhole relayer address. + constructor(address _wormholeRelayer) { + wormholeRelayer = _wormholeRelayer; + } + + /// @dev Relays a payload via Wormhole relayer to the address `targetAddress` on chain `targetChain` + /// with gas limit `gasLimit` and `msg.value` equal to `receiverValue`. + /// @notice This function takes arbitrary `msg.value` and adjusts the cost for relayer exact amount. + /// @param targetChain in Wormhole Chain ID format + /// @param targetAddress address to call on targetChain (that implements IWormholeReceiver) + /// @param payload arbitrary bytes to pass in as parameter in call to `targetAddress` + /// @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) + /// @param gasLimit gas limit with which to call `targetAddress`. Any units of gas unused will be refunded according to the + /// `targetChainRefundPerGasUnused` rate quoted by the delivery provider + /// @param refundChain The chain to deliver any refund to, in Wormhole Chain ID format + /// @param refundAddress The address on `refundChain` to deliver any refund to + /// @return sequence sequence number of published VAA containing delivery instructions + function sendPayloadToEvm( + uint16 targetChain, + address targetAddress, + bytes memory payload, + uint256 receiverValue, + uint256 gasLimit, + uint16 refundChain, + address refundAddress + ) external payable returns (uint64) { + // Check for zero addresses + if (targetAddress == address(0) || refundAddress == address(0)) { + revert ZeroAddress(); + } + + // Check for zero values + if (targetChain == 0 || payload.length == 0 || gasLimit == 0 || refundChain == 0) { + revert ZeroValue(); + } + + // Get the message cost in order to adjust leftovers + (uint256 cost, ) = IWormhole(wormholeRelayer).quoteEVMDeliveryPrice(targetChain, 0, gasLimit); + + // Check fot msg.value to cover the cost + if (cost > msg.value) { + revert LowerThan(msg.value, cost); + } + + // Return value leftovers + uint256 leftovers = msg.value - cost; + + // Send leftover amount back to the sender, if any + if (leftovers > 0) { + // If the call fails, ignore to avoid the attack that would prevent this function from executing + // solhint-disable-next-line avoid-low-level-calls + tx.origin.call{value: leftovers}(""); + + emit LeftoversRefunded(tx.origin, leftovers); + } + + // Send payload via the Wormhole relayer with exact required cost + return IWormhole(wormholeRelayer).sendPayloadToEvm{value: cost}(targetChain, targetAddress, payload, + receiverValue, gasLimit, refundChain, refundAddress); + } +} \ No newline at end of file From abb5c88f9acda235a5a84536ee647897a3978ef2 Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Wed, 6 Nov 2024 23:58:43 +0000 Subject: [PATCH 2/7] fix: adding receiver value into the quote --- contracts/bridges/WormholeRelayer.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/bridges/WormholeRelayer.sol b/contracts/bridges/WormholeRelayer.sol index 750c2ea..2cbc60a 100644 --- a/contracts/bridges/WormholeRelayer.sol +++ b/contracts/bridges/WormholeRelayer.sol @@ -107,7 +107,7 @@ contract WormholeRelayer { } // Get the message cost in order to adjust leftovers - (uint256 cost, ) = IWormhole(wormholeRelayer).quoteEVMDeliveryPrice(targetChain, 0, gasLimit); + (uint256 cost, ) = IWormhole(wormholeRelayer).quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit); // Check fot msg.value to cover the cost if (cost > msg.value) { From 7d3b60396e62a7888a9a8172f384c23078db966c Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Thu, 7 Nov 2024 06:06:13 +0000 Subject: [PATCH 3/7] refactor: transfer fail revert --- contracts/bridges/WormholeRelayer.sol | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/contracts/bridges/WormholeRelayer.sol b/contracts/bridges/WormholeRelayer.sol index 2cbc60a..0fc7e42 100644 --- a/contracts/bridges/WormholeRelayer.sol +++ b/contracts/bridges/WormholeRelayer.sol @@ -60,6 +60,11 @@ error ZeroValue(); /// @param expected Expected value. error LowerThan(uint256 provided, uint256 expected); +/// @dev Failure of a native token transfer. +/// @param to Address `to`. +/// @param amount Token amount. +error TransferFailed(address to, uint256 amount); + /// @title WormholeRelayer - Smart contract for the contract interaction with wormhole relayer with any msg.value /// @author Aleksandr Kuperman - /// @author Andrey Lebedev - @@ -119,9 +124,11 @@ contract WormholeRelayer { // Send leftover amount back to the sender, if any if (leftovers > 0) { - // If the call fails, ignore to avoid the attack that would prevent this function from executing // solhint-disable-next-line avoid-low-level-calls - tx.origin.call{value: leftovers}(""); + (bool success, ) = tx.origin.call{value: leftovers}(""); + if (!success) { + revert TransferFailed(tx.origin, leftovers); + } emit LeftoversRefunded(tx.origin, leftovers); } From bbdf1f63af520cbcf4df1ba814772edb23fa1558 Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Thu, 7 Nov 2024 06:12:20 +0000 Subject: [PATCH 4/7] chore: deployment scripts --- abis/0.8.28/WormholeRelayer.json | 20 +++++- .../deployment/deploy_23_vote_weighting.js | 1 - scripts/deployment/deploy_24_burner.js | 1 - .../deployment/deploy_25_wormhole_relayer.js | 61 +++++++++++++++++++ scripts/deployment/globals_mainnet.json | 2 +- .../deployment/verify_25_wormhole_relayer.js | 8 +++ 6 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 scripts/deployment/deploy_25_wormhole_relayer.js create mode 100644 scripts/deployment/verify_25_wormhole_relayer.js diff --git a/abis/0.8.28/WormholeRelayer.json b/abis/0.8.28/WormholeRelayer.json index fcfcab3..a44022f 100644 --- a/abis/0.8.28/WormholeRelayer.json +++ b/abis/0.8.28/WormholeRelayer.json @@ -30,6 +30,22 @@ "name": "LowerThan", "type": "error" }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TransferFailed", + "type": "error" + }, { "inputs": [], "name": "ZeroAddress", @@ -122,8 +138,8 @@ "type": "function" } ], - "bytecode": "0x60a0604052348015600e575f5ffd5b50604051610799380380610799833981016040819052602b91603b565b6001600160a01b03166080526066565b5f60208284031215604a575f5ffd5b81516001600160a01b0381168114605f575f5ffd5b9392505050565b60805161070e61008b5f395f8181606e015281816101c30152610355015261070e5ff3fe608060405260043610610028575f3560e01c80634b5ca6f41461002c578063da25b7251461005d575b5f5ffd5b61003f61003a36600461044d565b6100b5565b60405167ffffffffffffffff90911681526020015b60405180910390f35b348015610068575f5ffd5b506100907f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610054565b5f73ffffffffffffffffffffffffffffffffffffffff871615806100ed575073ffffffffffffffffffffffffffffffffffffffff8216155b15610124576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61ffff8816158061013457508551155b8061013d575083155b8061014a575061ffff8316155b15610181576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fc23ee3c300000000000000000000000000000000000000000000000000000000815261ffff891660048201525f6024820181905260448201869052907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063c23ee3c3906064016040805180830381865afa15801561021c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102409190610590565b5090503481111561028a576040517f491a2bb10000000000000000000000000000000000000000000000000000000081523460048201526024810182905260440160405180910390fd5b5f61029582346105b2565b9050801561031857604051329082905f81818185875af1925050503d805f81146102da576040519150601f19603f3d011682016040523d82523d5f602084013e6102df565b606091505b50506040518281523291507f8e49ed3e274fbea1556bdfaa9a37a0c28445bfe26d57beaf9f04fd517aa417419060200160405180910390a25b6040517f4b5ca6f400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690634b5ca6f4908490610398908e908e908e908e908e908e908e906004016105f0565b60206040518083038185885af11580156103b4573d5f5f3e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906103d991906106aa565b9a9950505050505050505050565b803561ffff811681146103f8575f5ffd5b919050565b803573ffffffffffffffffffffffffffffffffffffffff811681146103f8575f5ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f5f5f5f5f5f5f60e0888a031215610463575f5ffd5b61046c886103e7565b965061047a602089016103fd565b9550604088013567ffffffffffffffff811115610495575f5ffd5b8801601f81018a136104a5575f5ffd5b803567ffffffffffffffff8111156104bf576104bf610420565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff8211171561052b5761052b610420565b6040528181528282016020018c1015610542575f5ffd5b816020840160208301375f91810160200191909152955050606088013593506080880135925061057460a089016103e7565b915061058260c089016103fd565b905092959891949750929550565b5f5f604083850312156105a1575f5ffd5b505080516020909101519092909150565b818103818111156105ea577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b92915050565b61ffff8816815273ffffffffffffffffffffffffffffffffffffffff8716602082015260e060408201525f86518060e0840152806020890161010085015e5f61010082850101526101007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011684010191505085606083015284608083015261ffff841660a083015261069e60c083018473ffffffffffffffffffffffffffffffffffffffff169052565b98975050505050505050565b5f602082840312156106ba575f5ffd5b815167ffffffffffffffff811681146106d1575f5ffd5b939250505056fea264697066735822122033354bbea4bd99b5a23b0d613690efc7804dc9278bf279de0ad05b62cff0358464736f6c634300081c0033", - "deployedBytecode": "0x608060405260043610610028575f3560e01c80634b5ca6f41461002c578063da25b7251461005d575b5f5ffd5b61003f61003a36600461044d565b6100b5565b60405167ffffffffffffffff90911681526020015b60405180910390f35b348015610068575f5ffd5b506100907f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610054565b5f73ffffffffffffffffffffffffffffffffffffffff871615806100ed575073ffffffffffffffffffffffffffffffffffffffff8216155b15610124576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61ffff8816158061013457508551155b8061013d575083155b8061014a575061ffff8316155b15610181576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fc23ee3c300000000000000000000000000000000000000000000000000000000815261ffff891660048201525f6024820181905260448201869052907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063c23ee3c3906064016040805180830381865afa15801561021c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102409190610590565b5090503481111561028a576040517f491a2bb10000000000000000000000000000000000000000000000000000000081523460048201526024810182905260440160405180910390fd5b5f61029582346105b2565b9050801561031857604051329082905f81818185875af1925050503d805f81146102da576040519150601f19603f3d011682016040523d82523d5f602084013e6102df565b606091505b50506040518281523291507f8e49ed3e274fbea1556bdfaa9a37a0c28445bfe26d57beaf9f04fd517aa417419060200160405180910390a25b6040517f4b5ca6f400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690634b5ca6f4908490610398908e908e908e908e908e908e908e906004016105f0565b60206040518083038185885af11580156103b4573d5f5f3e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906103d991906106aa565b9a9950505050505050505050565b803561ffff811681146103f8575f5ffd5b919050565b803573ffffffffffffffffffffffffffffffffffffffff811681146103f8575f5ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f5f5f5f5f5f5f60e0888a031215610463575f5ffd5b61046c886103e7565b965061047a602089016103fd565b9550604088013567ffffffffffffffff811115610495575f5ffd5b8801601f81018a136104a5575f5ffd5b803567ffffffffffffffff8111156104bf576104bf610420565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff8211171561052b5761052b610420565b6040528181528282016020018c1015610542575f5ffd5b816020840160208301375f91810160200191909152955050606088013593506080880135925061057460a089016103e7565b915061058260c089016103fd565b905092959891949750929550565b5f5f604083850312156105a1575f5ffd5b505080516020909101519092909150565b818103818111156105ea577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b92915050565b61ffff8816815273ffffffffffffffffffffffffffffffffffffffff8716602082015260e060408201525f86518060e0840152806020890161010085015e5f61010082850101526101007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011684010191505085606083015284608083015261ffff841660a083015261069e60c083018473ffffffffffffffffffffffffffffffffffffffff169052565b98975050505050505050565b5f602082840312156106ba575f5ffd5b815167ffffffffffffffff811681146106d1575f5ffd5b939250505056fea264697066735822122033354bbea4bd99b5a23b0d613690efc7804dc9278bf279de0ad05b62cff0358464736f6c634300081c0033", + "bytecode": "0x60a0604052348015600e575f5ffd5b506040516107de3803806107de833981016040819052602b91603b565b6001600160a01b03166080526066565b5f60208284031215604a575f5ffd5b81516001600160a01b0381168114605f575f5ffd5b9392505050565b60805161075361008b5f395f8181606e015281816101c3015261039a01526107535ff3fe608060405260043610610028575f3560e01c80634b5ca6f41461002c578063da25b7251461005d575b5f5ffd5b61003f61003a366004610492565b6100b5565b60405167ffffffffffffffff90911681526020015b60405180910390f35b348015610068575f5ffd5b506100907f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610054565b5f73ffffffffffffffffffffffffffffffffffffffff871615806100ed575073ffffffffffffffffffffffffffffffffffffffff8216155b15610124576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61ffff8816158061013457508551155b8061013d575083155b8061014a575061ffff8316155b15610181576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fc23ee3c300000000000000000000000000000000000000000000000000000000815261ffff8916600482015260248101869052604481018590525f907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063c23ee3c3906064016040805180830381865afa15801561021c573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061024091906105d5565b5090503481111561028b576040517f491a2bb1000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044015b60405180910390fd5b5f61029682346105f7565b9050801561035d576040515f90329083908381818185875af1925050503d805f81146102dd576040519150601f19603f3d011682016040523d82523d5f602084013e6102e2565b606091505b5050905080610326576040517f1c43b97600000000000000000000000000000000000000000000000000000000815232600482015260248101839052604401610282565b60405182815232907f8e49ed3e274fbea1556bdfaa9a37a0c28445bfe26d57beaf9f04fd517aa417419060200160405180910390a2505b6040517f4b5ca6f400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690634b5ca6f49084906103dd908e908e908e908e908e908e908e90600401610635565b60206040518083038185885af11580156103f9573d5f5f3e3d5ffd5b50505050506040513d601f19601f8201168201806040525081019061041e91906106ef565b9a9950505050505050505050565b803561ffff8116811461043d575f5ffd5b919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461043d575f5ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f5f5f5f5f5f5f60e0888a0312156104a8575f5ffd5b6104b18861042c565b96506104bf60208901610442565b9550604088013567ffffffffffffffff8111156104da575f5ffd5b8801601f81018a136104ea575f5ffd5b803567ffffffffffffffff81111561050457610504610465565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff8211171561057057610570610465565b6040528181528282016020018c1015610587575f5ffd5b816020840160208301375f9181016020019190915295505060608801359350608088013592506105b960a0890161042c565b91506105c760c08901610442565b905092959891949750929550565b5f5f604083850312156105e6575f5ffd5b505080516020909101519092909150565b8181038181111561062f577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b92915050565b61ffff8816815273ffffffffffffffffffffffffffffffffffffffff8716602082015260e060408201525f86518060e0840152806020890161010085015e5f61010082850101526101007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011684010191505085606083015284608083015261ffff841660a08301526106e360c083018473ffffffffffffffffffffffffffffffffffffffff169052565b98975050505050505050565b5f602082840312156106ff575f5ffd5b815167ffffffffffffffff81168114610716575f5ffd5b939250505056fea2646970667358221220cdf4554f73cef611853522433444fb87bce53dfabf2ccaa91c92000d670204da64736f6c634300081c0033", + "deployedBytecode": "0x608060405260043610610028575f3560e01c80634b5ca6f41461002c578063da25b7251461005d575b5f5ffd5b61003f61003a366004610492565b6100b5565b60405167ffffffffffffffff90911681526020015b60405180910390f35b348015610068575f5ffd5b506100907f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610054565b5f73ffffffffffffffffffffffffffffffffffffffff871615806100ed575073ffffffffffffffffffffffffffffffffffffffff8216155b15610124576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61ffff8816158061013457508551155b8061013d575083155b8061014a575061ffff8316155b15610181576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fc23ee3c300000000000000000000000000000000000000000000000000000000815261ffff8916600482015260248101869052604481018590525f907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063c23ee3c3906064016040805180830381865afa15801561021c573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061024091906105d5565b5090503481111561028b576040517f491a2bb1000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044015b60405180910390fd5b5f61029682346105f7565b9050801561035d576040515f90329083908381818185875af1925050503d805f81146102dd576040519150601f19603f3d011682016040523d82523d5f602084013e6102e2565b606091505b5050905080610326576040517f1c43b97600000000000000000000000000000000000000000000000000000000815232600482015260248101839052604401610282565b60405182815232907f8e49ed3e274fbea1556bdfaa9a37a0c28445bfe26d57beaf9f04fd517aa417419060200160405180910390a2505b6040517f4b5ca6f400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690634b5ca6f49084906103dd908e908e908e908e908e908e908e90600401610635565b60206040518083038185885af11580156103f9573d5f5f3e3d5ffd5b50505050506040513d601f19601f8201168201806040525081019061041e91906106ef565b9a9950505050505050505050565b803561ffff8116811461043d575f5ffd5b919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461043d575f5ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f5f5f5f5f5f5f60e0888a0312156104a8575f5ffd5b6104b18861042c565b96506104bf60208901610442565b9550604088013567ffffffffffffffff8111156104da575f5ffd5b8801601f81018a136104ea575f5ffd5b803567ffffffffffffffff81111561050457610504610465565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff8211171561057057610570610465565b6040528181528282016020018c1015610587575f5ffd5b816020840160208301375f9181016020019190915295505060608801359350608088013592506105b960a0890161042c565b91506105c760c08901610442565b905092959891949750929550565b5f5f604083850312156105e6575f5ffd5b505080516020909101519092909150565b8181038181111561062f577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b92915050565b61ffff8816815273ffffffffffffffffffffffffffffffffffffffff8716602082015260e060408201525f86518060e0840152806020890161010085015e5f61010082850101526101007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011684010191505085606083015284608083015261ffff841660a08301526106e360c083018473ffffffffffffffffffffffffffffffffffffffff169052565b98975050505050505050565b5f602082840312156106ff575f5ffd5b815167ffffffffffffffff81168114610716575f5ffd5b939250505056fea2646970667358221220cdf4554f73cef611853522433444fb87bce53dfabf2ccaa91c92000d670204da64736f6c634300081c0033", "linkReferences": {}, "deployedLinkReferences": {} } diff --git a/scripts/deployment/deploy_23_vote_weighting.js b/scripts/deployment/deploy_23_vote_weighting.js index 18261ab..51a760f 100644 --- a/scripts/deployment/deploy_23_vote_weighting.js +++ b/scripts/deployment/deploy_23_vote_weighting.js @@ -1,6 +1,5 @@ /*global process*/ -const { expect } = require("chai"); const { ethers } = require("hardhat"); const { LedgerSigner } = require("@anders-t/ethers-ledger"); diff --git a/scripts/deployment/deploy_24_burner.js b/scripts/deployment/deploy_24_burner.js index 75ef6c1..14edb1f 100644 --- a/scripts/deployment/deploy_24_burner.js +++ b/scripts/deployment/deploy_24_burner.js @@ -1,6 +1,5 @@ /*global process*/ -const { expect } = require("chai"); const { ethers } = require("hardhat"); const { LedgerSigner } = require("@anders-t/ethers-ledger"); diff --git a/scripts/deployment/deploy_25_wormhole_relayer.js b/scripts/deployment/deploy_25_wormhole_relayer.js new file mode 100644 index 0000000..ad2950b --- /dev/null +++ b/scripts/deployment/deploy_25_wormhole_relayer.js @@ -0,0 +1,61 @@ +/*global process*/ + +const { ethers } = require("hardhat"); +const { LedgerSigner } = require("@anders-t/ethers-ledger"); + +async function main() { + const fs = require("fs"); + const globalsFile = "globals.json"; + const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); + let parsedData = JSON.parse(dataFromJSON); + const derivationPath = parsedData.derivationPath; + const useLedger = parsedData.useLedger; + const providerName = parsedData.providerName; + let EOA; + + const provider = await ethers.providers.getDefaultProvider(providerName); + const signers = await ethers.getSigners(); + + if (useLedger) { + EOA = new LedgerSigner(provider, derivationPath); + } else { + EOA = signers[0]; + } + // EOA address + const deployer = await EOA.getAddress(); + console.log("EOA is:", deployer); + + // Transaction signing and execution + console.log("25. EOA to deploy WormholeRelayer contract"); + const WormholeRelayer = await ethers.getContractFactory("WormholeRelayer"); + console.log("You are signing the following transaction: WormholeRelayer.connect(EOA).deploy(OLAS)"); + const wormholeRelayer = await WormholeRelayer.connect(EOA).deploy(parsedData.wormholeL1MessageRelayerAddress); + const result = await wormholeRelayer.deployed(); + + // Transaction details + console.log("Contract deployment: wormholeRelayer"); + console.log("Contract address:", wormholeRelayer.address); + console.log("Transaction:", result.deployTransaction.hash); + + // If on sepolia, wait half a minute for the transaction completion + if (providerName === "sepolia") { + await new Promise(r => setTimeout(r, 30000)); + } + + // Contract verification + if (parsedData.contractVerification) { + const execSync = require("child_process").execSync; + execSync("npx hardhat verify --constructor-args scripts/deployment/verify_25_wormhole_relayer.js --network " + providerName + " " + wormholeRelayer.address, { encoding: "utf-8" }); + } + + // Writing updated parameters back to the JSON file + parsedData.wormholeRelayerAddress = wormholeRelayer.address; + fs.writeFileSync(globalsFile, JSON.stringify(parsedData)); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); \ No newline at end of file diff --git a/scripts/deployment/globals_mainnet.json b/scripts/deployment/globals_mainnet.json index ba59dbf..ebb1ee3 100644 --- a/scripts/deployment/globals_mainnet.json +++ b/scripts/deployment/globals_mainnet.json @@ -1 +1 @@ -{"contractVerification":true,"useLedger":true,"valoryMultisig":"0x87cc0d34f6111c8A7A4Bdf758a9a715A3675f941","derivationPath":"m/44'/60'/2'/0/0","CM":"0x04C06323Fe3D53Deb7364c0055E1F68458Cc2570","providerName":"mainnet","olasSaltString":"0xeb2a22b27c7ad5eee424fd90b376c745e60f914e25fe2b399268300038939d65","timelockMinDelay":"13091","veOlasSaltString":"0xeb2a22b27c7ad5eee424fd90b376c745e60f914e8c4b6f56e64f24010eba714f","initialVotingDelay":"13091","initialVotingPeriod":"19636","initialProposalThreshold":"5000000000000000000000","quorum":"3","initSupply":"526500000000000000000000000","timelockSupply":"100000000000000000000000000","saleSupply":"292874580000000000000000000","valorySupply":"133625420000000000000000000","GnosisSafe":"0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552","GnosisSafeProxyFactory":"0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2","MultiSendCallOnly":"0x40A2aCCbd92BCA938b02010E17A5b8929b49130D","deploymentFactory":"0x9338b5153AE39BB89f50468E608eD9d764B755fD","olasAddress":"0x0001A500A6B18995B03f44bb040A5fFc28E45CB0","timelockAddress":"0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE","veOLASAddress":"0x7e01A500805f8A52Fad229b3015AD130A332B7b3","governorAddress":"0x34C895f302D0b5cf52ec0Edd3945321EB0f83dd5","buOLASAddress":"0xb09CcF0Dbf0C178806Aaee28956c74bd66d21f73","wveOLASAddress":"0x4039B809E0C0Ad04F6Fc880193366b251dDf4B40","governorTwoAddress":"0x8E84B5055492901988B831817e4Ace5275A3b401","treasuryAddress":"0xa0DA53447C0f6C4987964d8463da7e6628B30f82","guardCMAddress":"0x7bB7998b210cFfE10ca1e41f16341Abe53f76f3a","depositoryAddress":"0xfF8697d8d2998d6AA2e09B405795C6F4BEeB0C81","bridgedERC20Address":"0x06512E620A8317da51a73690A596Aca97287b31D","fxRootAddress":"0xfe5e5D361b2ad62c541bAb87C45a0B9B018389a2","childTokenAddress":"0x62309056c759c36879Cde93693E7903bF415E4Bc","checkpointManagerAddress":"0x86E4Dc95c7FBdBf52e33D563BbDB00823894C287","fxERC20RootTunnelAddress":"0x1737408def992AF04b29C8Ba4BBcD7397B08c930","fxERC20ChildTunnelAddress":"0x1fe74A08ac89300B102AdCd474C721AE8764E850","voteWeightingAddress":"0x95418b46d5566d3d1ea62c12aea91227e566c5c1","burnerAddress":"0x51eb65012ca5cEB07320c497F4151aC207FEa4E0"} \ No newline at end of file +{"contractVerification":true,"useLedger":true,"valoryMultisig":"0x87cc0d34f6111c8A7A4Bdf758a9a715A3675f941","derivationPath":"m/44'/60'/2'/0/0","CM":"0x04C06323Fe3D53Deb7364c0055E1F68458Cc2570","providerName":"mainnet","olasSaltString":"0xeb2a22b27c7ad5eee424fd90b376c745e60f914e25fe2b399268300038939d65","timelockMinDelay":"13091","veOlasSaltString":"0xeb2a22b27c7ad5eee424fd90b376c745e60f914e8c4b6f56e64f24010eba714f","initialVotingDelay":"13091","initialVotingPeriod":"19636","initialProposalThreshold":"5000000000000000000000","quorum":"3","initSupply":"526500000000000000000000000","timelockSupply":"100000000000000000000000000","saleSupply":"292874580000000000000000000","valorySupply":"133625420000000000000000000","GnosisSafe":"0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552","GnosisSafeProxyFactory":"0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2","MultiSendCallOnly":"0x40A2aCCbd92BCA938b02010E17A5b8929b49130D","deploymentFactory":"0x9338b5153AE39BB89f50468E608eD9d764B755fD","olasAddress":"0x0001A500A6B18995B03f44bb040A5fFc28E45CB0","timelockAddress":"0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE","veOLASAddress":"0x7e01A500805f8A52Fad229b3015AD130A332B7b3","governorAddress":"0x34C895f302D0b5cf52ec0Edd3945321EB0f83dd5","buOLASAddress":"0xb09CcF0Dbf0C178806Aaee28956c74bd66d21f73","wveOLASAddress":"0x4039B809E0C0Ad04F6Fc880193366b251dDf4B40","governorTwoAddress":"0x8E84B5055492901988B831817e4Ace5275A3b401","treasuryAddress":"0xa0DA53447C0f6C4987964d8463da7e6628B30f82","guardCMAddress":"0x7bB7998b210cFfE10ca1e41f16341Abe53f76f3a","depositoryAddress":"0xfF8697d8d2998d6AA2e09B405795C6F4BEeB0C81","bridgedERC20Address":"0x06512E620A8317da51a73690A596Aca97287b31D","fxRootAddress":"0xfe5e5D361b2ad62c541bAb87C45a0B9B018389a2","childTokenAddress":"0x62309056c759c36879Cde93693E7903bF415E4Bc","checkpointManagerAddress":"0x86E4Dc95c7FBdBf52e33D563BbDB00823894C287","fxERC20RootTunnelAddress":"0x1737408def992AF04b29C8Ba4BBcD7397B08c930","fxERC20ChildTunnelAddress":"0x1fe74A08ac89300B102AdCd474C721AE8764E850","voteWeightingAddress":"0x95418b46d5566d3d1ea62c12aea91227e566c5c1","burnerAddress":"0x51eb65012ca5cEB07320c497F4151aC207FEa4E0","wormholeL1MessageRelayerAddress":"0x27428DD2d3DD32A4D7f7C497eAaa23130d894911"} \ No newline at end of file diff --git a/scripts/deployment/verify_25_wormhole_relayer.js b/scripts/deployment/verify_25_wormhole_relayer.js new file mode 100644 index 0000000..5d1950e --- /dev/null +++ b/scripts/deployment/verify_25_wormhole_relayer.js @@ -0,0 +1,8 @@ +const fs = require("fs"); +const globalsFile = "globals.json"; +const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); +const parsedData = JSON.parse(dataFromJSON); + +module.exports = [ + parsedData.wormholeL1MessageRelayerAddress +]; \ No newline at end of file From 42efdea54bf8af34e4ecbc3dcd08962121bfd7f7 Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Thu, 7 Nov 2024 06:17:14 +0000 Subject: [PATCH 5/7] chore: linters --- .gitleaksignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitleaksignore b/.gitleaksignore index 4679d11..767dff3 100644 --- a/.gitleaksignore +++ b/.gitleaksignore @@ -60,3 +60,4 @@ fa17ac186753911eb9d2ae0a4ab59db5f7e8e563:scripts/deployment/bridges/solana/test/ 9fe74d22fc7a98851616d58985e0355914662552:scripts/deployment/globals_mainnet.json:generic-api-key:1 9fe74d22fc7a98851616d58985e0355914662552:scripts/deployment/globals_mainnet.json:generic-api-key:2 391af0ca125e1e7f03149195d4bd04d023bb8b0f:scripts/deployment/globals_mainnet.json:generic-api-key:1 +bbdf1f63af520cbcf4df1ba814772edb23fa1558:scripts/deployment/globals_mainnet.json:generic-api-key:1 From 277d860379f70a0f73df7f6a3bd4526b8d3ad453 Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Thu, 7 Nov 2024 06:25:58 +0000 Subject: [PATCH 6/7] feat: reentrancy lock --- abis/0.8.28/WormholeRelayer.json | 11 ++++++++--- contracts/bridges/WormholeRelayer.sol | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/abis/0.8.28/WormholeRelayer.json b/abis/0.8.28/WormholeRelayer.json index a44022f..8312061 100644 --- a/abis/0.8.28/WormholeRelayer.json +++ b/abis/0.8.28/WormholeRelayer.json @@ -30,6 +30,11 @@ "name": "LowerThan", "type": "error" }, + { + "inputs": [], + "name": "ReentrancyGuard", + "type": "error" + }, { "inputs": [ { @@ -117,7 +122,7 @@ "outputs": [ { "internalType": "uint64", - "name": "", + "name": "sequence", "type": "uint64" } ], @@ -138,8 +143,8 @@ "type": "function" } ], - "bytecode": "0x60a0604052348015600e575f5ffd5b506040516107de3803806107de833981016040819052602b91603b565b6001600160a01b03166080526066565b5f60208284031215604a575f5ffd5b81516001600160a01b0381168114605f575f5ffd5b9392505050565b60805161075361008b5f395f8181606e015281816101c3015261039a01526107535ff3fe608060405260043610610028575f3560e01c80634b5ca6f41461002c578063da25b7251461005d575b5f5ffd5b61003f61003a366004610492565b6100b5565b60405167ffffffffffffffff90911681526020015b60405180910390f35b348015610068575f5ffd5b506100907f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610054565b5f73ffffffffffffffffffffffffffffffffffffffff871615806100ed575073ffffffffffffffffffffffffffffffffffffffff8216155b15610124576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61ffff8816158061013457508551155b8061013d575083155b8061014a575061ffff8316155b15610181576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fc23ee3c300000000000000000000000000000000000000000000000000000000815261ffff8916600482015260248101869052604481018590525f907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063c23ee3c3906064016040805180830381865afa15801561021c573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061024091906105d5565b5090503481111561028b576040517f491a2bb1000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044015b60405180910390fd5b5f61029682346105f7565b9050801561035d576040515f90329083908381818185875af1925050503d805f81146102dd576040519150601f19603f3d011682016040523d82523d5f602084013e6102e2565b606091505b5050905080610326576040517f1c43b97600000000000000000000000000000000000000000000000000000000815232600482015260248101839052604401610282565b60405182815232907f8e49ed3e274fbea1556bdfaa9a37a0c28445bfe26d57beaf9f04fd517aa417419060200160405180910390a2505b6040517f4b5ca6f400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690634b5ca6f49084906103dd908e908e908e908e908e908e908e90600401610635565b60206040518083038185885af11580156103f9573d5f5f3e3d5ffd5b50505050506040513d601f19601f8201168201806040525081019061041e91906106ef565b9a9950505050505050505050565b803561ffff8116811461043d575f5ffd5b919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461043d575f5ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f5f5f5f5f5f5f60e0888a0312156104a8575f5ffd5b6104b18861042c565b96506104bf60208901610442565b9550604088013567ffffffffffffffff8111156104da575f5ffd5b8801601f81018a136104ea575f5ffd5b803567ffffffffffffffff81111561050457610504610465565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff8211171561057057610570610465565b6040528181528282016020018c1015610587575f5ffd5b816020840160208301375f9181016020019190915295505060608801359350608088013592506105b960a0890161042c565b91506105c760c08901610442565b905092959891949750929550565b5f5f604083850312156105e6575f5ffd5b505080516020909101519092909150565b8181038181111561062f577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b92915050565b61ffff8816815273ffffffffffffffffffffffffffffffffffffffff8716602082015260e060408201525f86518060e0840152806020890161010085015e5f61010082850101526101007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011684010191505085606083015284608083015261ffff841660a08301526106e360c083018473ffffffffffffffffffffffffffffffffffffffff169052565b98975050505050505050565b5f602082840312156106ff575f5ffd5b815167ffffffffffffffff81168114610716575f5ffd5b939250505056fea2646970667358221220cdf4554f73cef611853522433444fb87bce53dfabf2ccaa91c92000d670204da64736f6c634300081c0033", - "deployedBytecode": "0x608060405260043610610028575f3560e01c80634b5ca6f41461002c578063da25b7251461005d575b5f5ffd5b61003f61003a366004610492565b6100b5565b60405167ffffffffffffffff90911681526020015b60405180910390f35b348015610068575f5ffd5b506100907f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610054565b5f73ffffffffffffffffffffffffffffffffffffffff871615806100ed575073ffffffffffffffffffffffffffffffffffffffff8216155b15610124576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61ffff8816158061013457508551155b8061013d575083155b8061014a575061ffff8316155b15610181576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fc23ee3c300000000000000000000000000000000000000000000000000000000815261ffff8916600482015260248101869052604481018590525f907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063c23ee3c3906064016040805180830381865afa15801561021c573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061024091906105d5565b5090503481111561028b576040517f491a2bb1000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044015b60405180910390fd5b5f61029682346105f7565b9050801561035d576040515f90329083908381818185875af1925050503d805f81146102dd576040519150601f19603f3d011682016040523d82523d5f602084013e6102e2565b606091505b5050905080610326576040517f1c43b97600000000000000000000000000000000000000000000000000000000815232600482015260248101839052604401610282565b60405182815232907f8e49ed3e274fbea1556bdfaa9a37a0c28445bfe26d57beaf9f04fd517aa417419060200160405180910390a2505b6040517f4b5ca6f400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690634b5ca6f49084906103dd908e908e908e908e908e908e908e90600401610635565b60206040518083038185885af11580156103f9573d5f5f3e3d5ffd5b50505050506040513d601f19601f8201168201806040525081019061041e91906106ef565b9a9950505050505050505050565b803561ffff8116811461043d575f5ffd5b919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461043d575f5ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f5f5f5f5f5f5f60e0888a0312156104a8575f5ffd5b6104b18861042c565b96506104bf60208901610442565b9550604088013567ffffffffffffffff8111156104da575f5ffd5b8801601f81018a136104ea575f5ffd5b803567ffffffffffffffff81111561050457610504610465565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff8211171561057057610570610465565b6040528181528282016020018c1015610587575f5ffd5b816020840160208301375f9181016020019190915295505060608801359350608088013592506105b960a0890161042c565b91506105c760c08901610442565b905092959891949750929550565b5f5f604083850312156105e6575f5ffd5b505080516020909101519092909150565b8181038181111561062f577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b92915050565b61ffff8816815273ffffffffffffffffffffffffffffffffffffffff8716602082015260e060408201525f86518060e0840152806020890161010085015e5f61010082850101526101007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011684010191505085606083015284608083015261ffff841660a08301526106e360c083018473ffffffffffffffffffffffffffffffffffffffff169052565b98975050505050505050565b5f602082840312156106ff575f5ffd5b815167ffffffffffffffff81168114610716575f5ffd5b939250505056fea2646970667358221220cdf4554f73cef611853522433444fb87bce53dfabf2ccaa91c92000d670204da64736f6c634300081c0033", + "bytecode": "0x60a060405260015f553480156012575f5ffd5b50604051610826380380610826833981016040819052602f91603f565b6001600160a01b0316608052606a565b5f60208284031215604e575f5ffd5b81516001600160a01b03811681146063575f5ffd5b9392505050565b60805161079761008f5f395f8181606e0152818161020301526103da01526107975ff3fe608060405260043610610028575f3560e01c80634b5ca6f41461002c578063da25b7251461005d575b5f5ffd5b61003f61003a3660046104d6565b6100b5565b60405167ffffffffffffffff90911681526020015b60405180910390f35b348015610068575f5ffd5b506100907f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610054565b5f60015f5411156100f2576040517f8beb9d1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025f5573ffffffffffffffffffffffffffffffffffffffff8716158061012d575073ffffffffffffffffffffffffffffffffffffffff8216155b15610164576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61ffff8816158061017457508551155b8061017d575083155b8061018a575061ffff8316155b156101c1576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fc23ee3c300000000000000000000000000000000000000000000000000000000815261ffff8916600482015260248101869052604481018590525f907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063c23ee3c3906064016040805180830381865afa15801561025c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102809190610619565b509050348111156102cb576040517f491a2bb1000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044015b60405180910390fd5b5f6102d6823461063b565b9050801561039d576040515f90329083908381818185875af1925050503d805f811461031d576040519150601f19603f3d011682016040523d82523d5f602084013e610322565b606091505b5050905080610366576040517f1c43b976000000000000000000000000000000000000000000000000000000008152326004820152602481018390526044016102c2565b60405182815232907f8e49ed3e274fbea1556bdfaa9a37a0c28445bfe26d57beaf9f04fd517aa417419060200160405180910390a2505b6040517f4b5ca6f400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690634b5ca6f490849061041d908e908e908e908e908e908e908e90600401610679565b60206040518083038185885af1158015610439573d5f5f3e3d5ffd5b50505050506040513d601f19601f8201168201806040525081019061045e9190610733565b60015f559a9950505050505050505050565b803561ffff81168114610481575f5ffd5b919050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610481575f5ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f5f5f5f5f5f5f60e0888a0312156104ec575f5ffd5b6104f588610470565b965061050360208901610486565b9550604088013567ffffffffffffffff81111561051e575f5ffd5b8801601f81018a1361052e575f5ffd5b803567ffffffffffffffff811115610548576105486104a9565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff821117156105b4576105b46104a9565b6040528181528282016020018c10156105cb575f5ffd5b816020840160208301375f9181016020019190915295505060608801359350608088013592506105fd60a08901610470565b915061060b60c08901610486565b905092959891949750929550565b5f5f6040838503121561062a575f5ffd5b505080516020909101519092909150565b81810381811115610673577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b92915050565b61ffff8816815273ffffffffffffffffffffffffffffffffffffffff8716602082015260e060408201525f86518060e0840152806020890161010085015e5f61010082850101526101007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011684010191505085606083015284608083015261ffff841660a083015261072760c083018473ffffffffffffffffffffffffffffffffffffffff169052565b98975050505050505050565b5f60208284031215610743575f5ffd5b815167ffffffffffffffff8116811461075a575f5ffd5b939250505056fea2646970667358221220d6e1a3d1fe201bf16c4ed18bd81b481ca79ca4c0d03f37ce9852bc9ae063de3d64736f6c634300081c0033", + "deployedBytecode": "0x608060405260043610610028575f3560e01c80634b5ca6f41461002c578063da25b7251461005d575b5f5ffd5b61003f61003a3660046104d6565b6100b5565b60405167ffffffffffffffff90911681526020015b60405180910390f35b348015610068575f5ffd5b506100907f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610054565b5f60015f5411156100f2576040517f8beb9d1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025f5573ffffffffffffffffffffffffffffffffffffffff8716158061012d575073ffffffffffffffffffffffffffffffffffffffff8216155b15610164576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61ffff8816158061017457508551155b8061017d575083155b8061018a575061ffff8316155b156101c1576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fc23ee3c300000000000000000000000000000000000000000000000000000000815261ffff8916600482015260248101869052604481018590525f907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063c23ee3c3906064016040805180830381865afa15801561025c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102809190610619565b509050348111156102cb576040517f491a2bb1000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044015b60405180910390fd5b5f6102d6823461063b565b9050801561039d576040515f90329083908381818185875af1925050503d805f811461031d576040519150601f19603f3d011682016040523d82523d5f602084013e610322565b606091505b5050905080610366576040517f1c43b976000000000000000000000000000000000000000000000000000000008152326004820152602481018390526044016102c2565b60405182815232907f8e49ed3e274fbea1556bdfaa9a37a0c28445bfe26d57beaf9f04fd517aa417419060200160405180910390a2505b6040517f4b5ca6f400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690634b5ca6f490849061041d908e908e908e908e908e908e908e90600401610679565b60206040518083038185885af1158015610439573d5f5f3e3d5ffd5b50505050506040513d601f19601f8201168201806040525081019061045e9190610733565b60015f559a9950505050505050505050565b803561ffff81168114610481575f5ffd5b919050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610481575f5ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f5f5f5f5f5f5f60e0888a0312156104ec575f5ffd5b6104f588610470565b965061050360208901610486565b9550604088013567ffffffffffffffff81111561051e575f5ffd5b8801601f81018a1361052e575f5ffd5b803567ffffffffffffffff811115610548576105486104a9565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff821117156105b4576105b46104a9565b6040528181528282016020018c10156105cb575f5ffd5b816020840160208301375f9181016020019190915295505060608801359350608088013592506105fd60a08901610470565b915061060b60c08901610486565b905092959891949750929550565b5f5f6040838503121561062a575f5ffd5b505080516020909101519092909150565b81810381811115610673577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b92915050565b61ffff8816815273ffffffffffffffffffffffffffffffffffffffff8716602082015260e060408201525f86518060e0840152806020890161010085015e5f61010082850101526101007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011684010191505085606083015284608083015261ffff841660a083015261072760c083018473ffffffffffffffffffffffffffffffffffffffff169052565b98975050505050505050565b5f60208284031215610743575f5ffd5b815167ffffffffffffffff8116811461075a575f5ffd5b939250505056fea2646970667358221220d6e1a3d1fe201bf16c4ed18bd81b481ca79ca4c0d03f37ce9852bc9ae063de3d64736f6c634300081c0033", "linkReferences": {}, "deployedLinkReferences": {} } diff --git a/contracts/bridges/WormholeRelayer.sol b/contracts/bridges/WormholeRelayer.sol index 0fc7e42..3e00d3f 100644 --- a/contracts/bridges/WormholeRelayer.sol +++ b/contracts/bridges/WormholeRelayer.sol @@ -65,6 +65,9 @@ error LowerThan(uint256 provided, uint256 expected); /// @param amount Token amount. error TransferFailed(address to, uint256 amount); +// @dev Reentrancy guard. +error ReentrancyGuard(); + /// @title WormholeRelayer - Smart contract for the contract interaction with wormhole relayer with any msg.value /// @author Aleksandr Kuperman - /// @author Andrey Lebedev - @@ -74,6 +77,9 @@ contract WormholeRelayer { // L1 Wormhole Relayer address that sends the message across the bridge address public immutable wormholeRelayer; + // Reentrancy lock + uint256 internal _locked = 1; + /// @dev WormholeRelayer constructor. /// @param _wormholeRelayer Wormhole relayer address. constructor(address _wormholeRelayer) { @@ -100,7 +106,12 @@ contract WormholeRelayer { uint256 gasLimit, uint16 refundChain, address refundAddress - ) external payable returns (uint64) { + ) external payable returns (uint64 sequence) { + if (_locked > 1) { + revert ReentrancyGuard(); + } + _locked = 2; + // Check for zero addresses if (targetAddress == address(0) || refundAddress == address(0)) { revert ZeroAddress(); @@ -134,7 +145,9 @@ contract WormholeRelayer { } // Send payload via the Wormhole relayer with exact required cost - return IWormhole(wormholeRelayer).sendPayloadToEvm{value: cost}(targetChain, targetAddress, payload, + sequence = IWormhole(wormholeRelayer).sendPayloadToEvm{value: cost}(targetChain, targetAddress, payload, receiverValue, gasLimit, refundChain, refundAddress); + + _locked = 1; } } \ No newline at end of file From 89af5ed6c188bfb90ddde7ff0f9e6e4ab32d6521 Mon Sep 17 00:00:00 2001 From: Aleksandr Kuperman Date: Thu, 7 Nov 2024 06:30:34 +0000 Subject: [PATCH 7/7] doc: natspec --- abis/0.8.28/WormholeRelayer.json | 4 ++-- contracts/bridges/WormholeRelayer.sol | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/abis/0.8.28/WormholeRelayer.json b/abis/0.8.28/WormholeRelayer.json index 8312061..2f38016 100644 --- a/abis/0.8.28/WormholeRelayer.json +++ b/abis/0.8.28/WormholeRelayer.json @@ -143,8 +143,8 @@ "type": "function" } ], - "bytecode": "0x60a060405260015f553480156012575f5ffd5b50604051610826380380610826833981016040819052602f91603f565b6001600160a01b0316608052606a565b5f60208284031215604e575f5ffd5b81516001600160a01b03811681146063575f5ffd5b9392505050565b60805161079761008f5f395f8181606e0152818161020301526103da01526107975ff3fe608060405260043610610028575f3560e01c80634b5ca6f41461002c578063da25b7251461005d575b5f5ffd5b61003f61003a3660046104d6565b6100b5565b60405167ffffffffffffffff90911681526020015b60405180910390f35b348015610068575f5ffd5b506100907f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610054565b5f60015f5411156100f2576040517f8beb9d1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025f5573ffffffffffffffffffffffffffffffffffffffff8716158061012d575073ffffffffffffffffffffffffffffffffffffffff8216155b15610164576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61ffff8816158061017457508551155b8061017d575083155b8061018a575061ffff8316155b156101c1576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fc23ee3c300000000000000000000000000000000000000000000000000000000815261ffff8916600482015260248101869052604481018590525f907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063c23ee3c3906064016040805180830381865afa15801561025c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102809190610619565b509050348111156102cb576040517f491a2bb1000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044015b60405180910390fd5b5f6102d6823461063b565b9050801561039d576040515f90329083908381818185875af1925050503d805f811461031d576040519150601f19603f3d011682016040523d82523d5f602084013e610322565b606091505b5050905080610366576040517f1c43b976000000000000000000000000000000000000000000000000000000008152326004820152602481018390526044016102c2565b60405182815232907f8e49ed3e274fbea1556bdfaa9a37a0c28445bfe26d57beaf9f04fd517aa417419060200160405180910390a2505b6040517f4b5ca6f400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690634b5ca6f490849061041d908e908e908e908e908e908e908e90600401610679565b60206040518083038185885af1158015610439573d5f5f3e3d5ffd5b50505050506040513d601f19601f8201168201806040525081019061045e9190610733565b60015f559a9950505050505050505050565b803561ffff81168114610481575f5ffd5b919050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610481575f5ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f5f5f5f5f5f5f60e0888a0312156104ec575f5ffd5b6104f588610470565b965061050360208901610486565b9550604088013567ffffffffffffffff81111561051e575f5ffd5b8801601f81018a1361052e575f5ffd5b803567ffffffffffffffff811115610548576105486104a9565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff821117156105b4576105b46104a9565b6040528181528282016020018c10156105cb575f5ffd5b816020840160208301375f9181016020019190915295505060608801359350608088013592506105fd60a08901610470565b915061060b60c08901610486565b905092959891949750929550565b5f5f6040838503121561062a575f5ffd5b505080516020909101519092909150565b81810381811115610673577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b92915050565b61ffff8816815273ffffffffffffffffffffffffffffffffffffffff8716602082015260e060408201525f86518060e0840152806020890161010085015e5f61010082850101526101007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011684010191505085606083015284608083015261ffff841660a083015261072760c083018473ffffffffffffffffffffffffffffffffffffffff169052565b98975050505050505050565b5f60208284031215610743575f5ffd5b815167ffffffffffffffff8116811461075a575f5ffd5b939250505056fea2646970667358221220d6e1a3d1fe201bf16c4ed18bd81b481ca79ca4c0d03f37ce9852bc9ae063de3d64736f6c634300081c0033", - "deployedBytecode": "0x608060405260043610610028575f3560e01c80634b5ca6f41461002c578063da25b7251461005d575b5f5ffd5b61003f61003a3660046104d6565b6100b5565b60405167ffffffffffffffff90911681526020015b60405180910390f35b348015610068575f5ffd5b506100907f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610054565b5f60015f5411156100f2576040517f8beb9d1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025f5573ffffffffffffffffffffffffffffffffffffffff8716158061012d575073ffffffffffffffffffffffffffffffffffffffff8216155b15610164576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61ffff8816158061017457508551155b8061017d575083155b8061018a575061ffff8316155b156101c1576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fc23ee3c300000000000000000000000000000000000000000000000000000000815261ffff8916600482015260248101869052604481018590525f907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063c23ee3c3906064016040805180830381865afa15801561025c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102809190610619565b509050348111156102cb576040517f491a2bb1000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044015b60405180910390fd5b5f6102d6823461063b565b9050801561039d576040515f90329083908381818185875af1925050503d805f811461031d576040519150601f19603f3d011682016040523d82523d5f602084013e610322565b606091505b5050905080610366576040517f1c43b976000000000000000000000000000000000000000000000000000000008152326004820152602481018390526044016102c2565b60405182815232907f8e49ed3e274fbea1556bdfaa9a37a0c28445bfe26d57beaf9f04fd517aa417419060200160405180910390a2505b6040517f4b5ca6f400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690634b5ca6f490849061041d908e908e908e908e908e908e908e90600401610679565b60206040518083038185885af1158015610439573d5f5f3e3d5ffd5b50505050506040513d601f19601f8201168201806040525081019061045e9190610733565b60015f559a9950505050505050505050565b803561ffff81168114610481575f5ffd5b919050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610481575f5ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f5f5f5f5f5f5f60e0888a0312156104ec575f5ffd5b6104f588610470565b965061050360208901610486565b9550604088013567ffffffffffffffff81111561051e575f5ffd5b8801601f81018a1361052e575f5ffd5b803567ffffffffffffffff811115610548576105486104a9565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff821117156105b4576105b46104a9565b6040528181528282016020018c10156105cb575f5ffd5b816020840160208301375f9181016020019190915295505060608801359350608088013592506105fd60a08901610470565b915061060b60c08901610486565b905092959891949750929550565b5f5f6040838503121561062a575f5ffd5b505080516020909101519092909150565b81810381811115610673577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b92915050565b61ffff8816815273ffffffffffffffffffffffffffffffffffffffff8716602082015260e060408201525f86518060e0840152806020890161010085015e5f61010082850101526101007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011684010191505085606083015284608083015261ffff841660a083015261072760c083018473ffffffffffffffffffffffffffffffffffffffff169052565b98975050505050505050565b5f60208284031215610743575f5ffd5b815167ffffffffffffffff8116811461075a575f5ffd5b939250505056fea2646970667358221220d6e1a3d1fe201bf16c4ed18bd81b481ca79ca4c0d03f37ce9852bc9ae063de3d64736f6c634300081c0033", + "bytecode": "0x60a060405260015f553480156012575f5ffd5b50604051610826380380610826833981016040819052602f91603f565b6001600160a01b0316608052606a565b5f60208284031215604e575f5ffd5b81516001600160a01b03811681146063575f5ffd5b9392505050565b60805161079761008f5f395f8181606e0152818161020301526103da01526107975ff3fe608060405260043610610028575f3560e01c80634b5ca6f41461002c578063da25b7251461005d575b5f5ffd5b61003f61003a3660046104d6565b6100b5565b60405167ffffffffffffffff90911681526020015b60405180910390f35b348015610068575f5ffd5b506100907f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610054565b5f60015f5411156100f2576040517f8beb9d1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025f5573ffffffffffffffffffffffffffffffffffffffff8716158061012d575073ffffffffffffffffffffffffffffffffffffffff8216155b15610164576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61ffff8816158061017457508551155b8061017d575083155b8061018a575061ffff8316155b156101c1576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fc23ee3c300000000000000000000000000000000000000000000000000000000815261ffff8916600482015260248101869052604481018590525f907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063c23ee3c3906064016040805180830381865afa15801561025c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102809190610619565b509050348111156102cb576040517f491a2bb1000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044015b60405180910390fd5b5f6102d6823461063b565b9050801561039d576040515f90329083908381818185875af1925050503d805f811461031d576040519150601f19603f3d011682016040523d82523d5f602084013e610322565b606091505b5050905080610366576040517f1c43b976000000000000000000000000000000000000000000000000000000008152326004820152602481018390526044016102c2565b60405182815232907f8e49ed3e274fbea1556bdfaa9a37a0c28445bfe26d57beaf9f04fd517aa417419060200160405180910390a2505b6040517f4b5ca6f400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690634b5ca6f490849061041d908e908e908e908e908e908e908e90600401610679565b60206040518083038185885af1158015610439573d5f5f3e3d5ffd5b50505050506040513d601f19601f8201168201806040525081019061045e9190610733565b60015f559a9950505050505050505050565b803561ffff81168114610481575f5ffd5b919050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610481575f5ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f5f5f5f5f5f5f60e0888a0312156104ec575f5ffd5b6104f588610470565b965061050360208901610486565b9550604088013567ffffffffffffffff81111561051e575f5ffd5b8801601f81018a1361052e575f5ffd5b803567ffffffffffffffff811115610548576105486104a9565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff821117156105b4576105b46104a9565b6040528181528282016020018c10156105cb575f5ffd5b816020840160208301375f9181016020019190915295505060608801359350608088013592506105fd60a08901610470565b915061060b60c08901610486565b905092959891949750929550565b5f5f6040838503121561062a575f5ffd5b505080516020909101519092909150565b81810381811115610673577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b92915050565b61ffff8816815273ffffffffffffffffffffffffffffffffffffffff8716602082015260e060408201525f86518060e0840152806020890161010085015e5f61010082850101526101007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011684010191505085606083015284608083015261ffff841660a083015261072760c083018473ffffffffffffffffffffffffffffffffffffffff169052565b98975050505050505050565b5f60208284031215610743575f5ffd5b815167ffffffffffffffff8116811461075a575f5ffd5b939250505056fea264697066735822122080362fd425a0ad8c3722a03f29d26a8c8118ef255714070a663ec545a85a33bb64736f6c634300081c0033", + "deployedBytecode": "0x608060405260043610610028575f3560e01c80634b5ca6f41461002c578063da25b7251461005d575b5f5ffd5b61003f61003a3660046104d6565b6100b5565b60405167ffffffffffffffff90911681526020015b60405180910390f35b348015610068575f5ffd5b506100907f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610054565b5f60015f5411156100f2576040517f8beb9d1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025f5573ffffffffffffffffffffffffffffffffffffffff8716158061012d575073ffffffffffffffffffffffffffffffffffffffff8216155b15610164576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61ffff8816158061017457508551155b8061017d575083155b8061018a575061ffff8316155b156101c1576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fc23ee3c300000000000000000000000000000000000000000000000000000000815261ffff8916600482015260248101869052604481018590525f907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063c23ee3c3906064016040805180830381865afa15801561025c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102809190610619565b509050348111156102cb576040517f491a2bb1000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044015b60405180910390fd5b5f6102d6823461063b565b9050801561039d576040515f90329083908381818185875af1925050503d805f811461031d576040519150601f19603f3d011682016040523d82523d5f602084013e610322565b606091505b5050905080610366576040517f1c43b976000000000000000000000000000000000000000000000000000000008152326004820152602481018390526044016102c2565b60405182815232907f8e49ed3e274fbea1556bdfaa9a37a0c28445bfe26d57beaf9f04fd517aa417419060200160405180910390a2505b6040517f4b5ca6f400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690634b5ca6f490849061041d908e908e908e908e908e908e908e90600401610679565b60206040518083038185885af1158015610439573d5f5f3e3d5ffd5b50505050506040513d601f19601f8201168201806040525081019061045e9190610733565b60015f559a9950505050505050505050565b803561ffff81168114610481575f5ffd5b919050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610481575f5ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f5f5f5f5f5f5f60e0888a0312156104ec575f5ffd5b6104f588610470565b965061050360208901610486565b9550604088013567ffffffffffffffff81111561051e575f5ffd5b8801601f81018a1361052e575f5ffd5b803567ffffffffffffffff811115610548576105486104a9565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff821117156105b4576105b46104a9565b6040528181528282016020018c10156105cb575f5ffd5b816020840160208301375f9181016020019190915295505060608801359350608088013592506105fd60a08901610470565b915061060b60c08901610486565b905092959891949750929550565b5f5f6040838503121561062a575f5ffd5b505080516020909101519092909150565b81810381811115610673577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b92915050565b61ffff8816815273ffffffffffffffffffffffffffffffffffffffff8716602082015260e060408201525f86518060e0840152806020890161010085015e5f61010082850101526101007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011684010191505085606083015284608083015261ffff841660a083015261072760c083018473ffffffffffffffffffffffffffffffffffffffff169052565b98975050505050505050565b5f60208284031215610743575f5ffd5b815167ffffffffffffffff8116811461075a575f5ffd5b939250505056fea264697066735822122080362fd425a0ad8c3722a03f29d26a8c8118ef255714070a663ec545a85a33bb64736f6c634300081c0033", "linkReferences": {}, "deployedLinkReferences": {} } diff --git a/contracts/bridges/WormholeRelayer.sol b/contracts/bridges/WormholeRelayer.sol index 3e00d3f..a0279e9 100644 --- a/contracts/bridges/WormholeRelayer.sol +++ b/contracts/bridges/WormholeRelayer.sol @@ -13,7 +13,6 @@ interface IWormhole { /// Note: This value can be overridden by the delivery provider on the target chain. The returned value here should be considered to be a /// promise by the delivery provider of the amount of refund per gas unused that will be returned to the refundAddress at the target chain. /// If a delivery provider decides to override, this will be visible as part of the emitted Delivery event on the target chain. - /// function quoteEVMDeliveryPrice( uint16 targetChain, uint256 receiverValue, @@ -89,15 +88,16 @@ contract WormholeRelayer { /// @dev Relays a payload via Wormhole relayer to the address `targetAddress` on chain `targetChain` /// with gas limit `gasLimit` and `msg.value` equal to `receiverValue`. /// @notice This function takes arbitrary `msg.value` and adjusts the cost for relayer exact amount. - /// @param targetChain in Wormhole Chain ID format - /// @param targetAddress address to call on targetChain (that implements IWormholeReceiver) - /// @param payload arbitrary bytes to pass in as parameter in call to `targetAddress` - /// @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` (in targetChain currency units) + /// @param targetChain in Wormhole Chain ID format. + /// @param targetAddress address to call on targetChain (that implements IWormholeReceiver). + /// @param payload arbitrary bytes to pass in as parameter in call to `targetAddress`. + /// @param receiverValue msg.value that delivery provider should pass in for call to `targetAddress` + /// in `targetChain` currency units. /// @param gasLimit gas limit with which to call `targetAddress`. Any units of gas unused will be refunded according to the - /// `targetChainRefundPerGasUnused` rate quoted by the delivery provider - /// @param refundChain The chain to deliver any refund to, in Wormhole Chain ID format - /// @param refundAddress The address on `refundChain` to deliver any refund to - /// @return sequence sequence number of published VAA containing delivery instructions + /// `targetChainRefundPerGasUnused` rate quoted by the delivery provider. + /// @param refundChain The chain to deliver any refund to, in Wormhole Chain ID format. + /// @param refundAddress The address on `refundChain` to deliver any refund to. + /// @return sequence Sequence number of published VAA containing delivery instructions. function sendPayloadToEvm( uint16 targetChain, address targetAddress,