From 9175736395b7b3d281e49ab7256e038df86d7a7e Mon Sep 17 00:00:00 2001 From: Carmen Cheng Date: Wed, 17 Jan 2024 08:51:17 +0800 Subject: [PATCH 1/3] remove dvn adapter --- .../uln/dvn/adapters/CCIP/CCIPDVNAdapter.sol | 152 --------------- .../adapters/CCIP/CCIPDVNAdapterFeeLib.sol | 7 - .../uln/dvn/adapters/DVNAdapterBase.sol | 162 ---------------- .../uln/dvn/adapters/DVNAdapterFeeLibBase.sol | 20 -- .../dvn/adapters/axelar/AxelarDVNAdapter.sol | 156 --------------- .../axelar/AxelarDVNAdapterFeeLib.sol | 7 - messagelib/test/DVNAdapterBase.t.sol | 177 ------------------ messagelib/test/DVNAdapterFeeLibBase.t.sol | 35 ---- 8 files changed, 716 deletions(-) delete mode 100644 messagelib/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapter.sol delete mode 100644 messagelib/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapterFeeLib.sol delete mode 100644 messagelib/contracts/uln/dvn/adapters/DVNAdapterBase.sol delete mode 100644 messagelib/contracts/uln/dvn/adapters/DVNAdapterFeeLibBase.sol delete mode 100644 messagelib/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapter.sol delete mode 100644 messagelib/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapterFeeLib.sol delete mode 100644 messagelib/test/DVNAdapterBase.t.sol delete mode 100644 messagelib/test/DVNAdapterFeeLibBase.t.sol diff --git a/messagelib/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapter.sol b/messagelib/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapter.sol deleted file mode 100644 index 26021ad..0000000 --- a/messagelib/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapter.sol +++ /dev/null @@ -1,152 +0,0 @@ -// SPDX-License-Identifier: LZBL-1.2 - -pragma solidity ^0.8.22; - -import { IRouterClient } from "@chainlink/contracts-ccip/src/v0.8/ccip/interfaces/IRouterClient.sol"; -import { CCIPReceiver } from "@chainlink/contracts-ccip/src/v0.8/ccip/applications/CCIPReceiver.sol"; -import { Client } from "@chainlink/contracts-ccip/src/v0.8/ccip/libraries/Client.sol"; - -import { DVNAdapterBase } from "../DVNAdapterBase.sol"; - -contract CCIPDVNAdapter is CCIPReceiver, DVNAdapterBase { - struct DstConfigParam { - uint32 dstEid; - // https://docs.chain.link/ccip/supported-networks/v1_2_0/testnet#ethereum-sepolia - // https://docs.chain.link/ccip/supported-networks/v1_0_0/mainnet - uint64 chainSelector; - uint16 multiplierBps; - uint256 gasLimit; - bytes peer; - } - - struct DstConfig { - uint64 chainSelector; - uint16 multiplierBps; - uint256 gasLimit; - bytes peer; - } - - address private constant NATIVE_GAS_TOKEN_ADDRESS = address(0); - - event DstConfigSet(DstConfigParam[] params); - - mapping(uint32 dstEid => DstConfig config) public dstConfig; - mapping(uint64 chainSelector => uint32 eid) public CCIPChainToEid; - - constructor( - address _sendLib, - address _receiveLib, - address[] memory _admins, - address router - ) CCIPReceiver(router) DVNAdapterBase(_sendLib, _receiveLib, _admins) {} - - /// @notice sets configuration (`chainSelector`, `multiplierBps`, `gasLimit` and `peer`) for destination chains - /// @dev The `multiplierBps` can be updated separately using `setDstMultiplierBps` function - /// @param _params array of chain configurations - function setDstConfig(DstConfigParam[] calldata _params) external onlyAdmin { - for (uint256 i = 0; i < _params.length; i++) { - DstConfigParam calldata param = _params[i]; - - delete CCIPChainToEid[dstConfig[param.dstEid].chainSelector]; - - CCIPChainToEid[param.chainSelector] = param.dstEid; - dstConfig[param.dstEid] = DstConfig({ - chainSelector: param.chainSelector, - multiplierBps: param.multiplierBps, - gasLimit: param.gasLimit, - peer: param.peer - }); - } - - emit DstConfigSet(_params); - } - - /// @notice sets fee multiplier in basis points for destination chains - /// @param _params array of multipliers for destination chains - function setDstMultiplier(DstMultiplierParam[] calldata _params) external onlyAdmin { - for (uint256 i = 0; i < _params.length; i++) { - DstMultiplierParam calldata param = _params[i]; - dstConfig[param.dstEid].multiplierBps = param.multiplierBps; - } - - emit DstMultiplierSet(_params); - } - - function getFee( - uint32 _dstEid, - uint64 /*_confirmations*/, - address _sender, - bytes calldata /*_options*/ - ) external view override returns (uint256 fee) { - DstConfig storage config = dstConfig[_dstEid]; - - Client.EVM2AnyMessage memory message = _createCCIPMessage( - new bytes(PACKET_HEADER_SIZE), - bytes32(0), - config.peer, - config.gasLimit - ); - - fee = _getCCIPFee(config.chainSelector, message); - if (address(feeLib) != address(0)) { - fee = feeLib.getFee(_dstEid, _sender, defaultMultiplierBps, config.multiplierBps, fee); - } - } - - function assignJob( - AssignJobParam calldata _param, - bytes calldata /*_options*/ - ) external payable override onlySendLib returns (uint256 fee) { - DstConfig memory config = dstConfig[_param.dstEid]; - - Client.EVM2AnyMessage memory message = _createCCIPMessage( - _param.packetHeader, - _param.payloadHash, - config.peer, - config.gasLimit - ); - - fee = _getCCIPFee(config.chainSelector, message); - _assertBalanceAndWithdrawFee(fee); - - IRouterClient(getRouter()).ccipSend{ value: fee }(config.chainSelector, message); - - if (address(feeLib) != address(0)) { - fee = feeLib.getFee(_param.dstEid, _param.sender, defaultMultiplierBps, config.multiplierBps, fee); - } - } - - function _createCCIPMessage( - bytes memory _packetHeader, - bytes32 _payloadHash, - bytes memory _receiver, - uint256 _gasLimit - ) private pure returns (Client.EVM2AnyMessage memory message) { - message = Client.EVM2AnyMessage({ - receiver: _receiver, - data: _encodePayload(_packetHeader, _payloadHash), - tokenAmounts: new Client.EVMTokenAmount[](0), // Empty array indicating no tokens are being sent - extraArgs: Client._argsToBytes(Client.EVMExtraArgsV1({ gasLimit: _gasLimit, strict: false })), - feeToken: NATIVE_GAS_TOKEN_ADDRESS - }); - } - - function _getCCIPFee( - uint64 _dstChainSelector, - Client.EVM2AnyMessage memory _message - ) private view returns (uint256 ccipFee) { - ccipFee = IRouterClient(getRouter()).getFee(_dstChainSelector, _message); - } - - function _ccipReceive(Client.Any2EVMMessage memory _message) internal override { - _assertPeer(_message.sourceChainSelector, _message.sender); - _verify(_message.data); - } - - function _assertPeer(uint64 _sourceChainSelector, bytes memory _sourceAddress) private view { - uint32 sourceEid = CCIPChainToEid[_sourceChainSelector]; - bytes memory sourcePeer = dstConfig[sourceEid].peer; - - if (keccak256(_sourceAddress) != keccak256(sourcePeer)) revert Unauthorized(); - } -} diff --git a/messagelib/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapterFeeLib.sol b/messagelib/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapterFeeLib.sol deleted file mode 100644 index 54887c4..0000000 --- a/messagelib/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapterFeeLib.sol +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: LZBL-1.2 - -pragma solidity ^0.8.22; - -import { DVNAdapterFeeLibBase } from "../DVNAdapterFeeLibBase.sol"; - -contract CCIPDVNAdapterFeeLib is DVNAdapterFeeLibBase {} diff --git a/messagelib/contracts/uln/dvn/adapters/DVNAdapterBase.sol b/messagelib/contracts/uln/dvn/adapters/DVNAdapterBase.sol deleted file mode 100644 index 396c963..0000000 --- a/messagelib/contracts/uln/dvn/adapters/DVNAdapterBase.sol +++ /dev/null @@ -1,162 +0,0 @@ -// SPDX-License-Identifier: LZBL-1.2 - -pragma solidity ^0.8.22; - -import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; -import { BytesLib } from "solidity-bytes-utils/contracts/BytesLib.sol"; - -import { Transfer } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/Transfer.sol"; -import { IMessageLib } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessageLib.sol"; -import { ISendLib } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ISendLib.sol"; - -import { ILayerZeroDVN } from "../../interfaces/ILayerZeroDVN.sol"; -import { IReceiveUlnE2 } from "../../interfaces/IReceiveUlnE2.sol"; -import { IDVNAdapterFeeLib } from "../../interfaces/IDVNAdapterFeeLib.sol"; - -/// @title DVNAdapterBase -/// @notice base contract for DVN adapters -/// @dev limitations: -/// - doesn't accept alt token -/// - doesn't respect block confirmations -/// - doesn't support multiple libraries. One deployment per library -abstract contract DVNAdapterBase is Ownable, ILayerZeroDVN { - using BytesLib for bytes; - - struct DstMultiplierParam { - uint32 dstEid; - uint16 multiplierBps; - } - - /// @dev for protocols that doesn't allow to configure outbound block confirmations per message, - /// ignore confirmations set in the config and use the maximum possible confirmations to prevent failure - /// in the receive library due to insufficient confirmations if the config was changed before the message is received - uint64 internal constant MAX_CONFIRMATIONS = type(uint64).max; - - uint256 internal constant PACKET_HEADER_SIZE = 81; - uint256 internal constant PAYLOAD_HASH_SIZE = 32; - uint256 internal constant PAYLOAD_SIZE = PACKET_HEADER_SIZE + PAYLOAD_HASH_SIZE; - - ISendLib public immutable sendLib; - IReceiveUlnE2 public immutable receiveLib; - IDVNAdapterFeeLib public feeLib; - - uint16 public defaultMultiplierBps = 10_000; // no multiplier - mapping(address admin => bool) public admins; - - error OnlySendLib(); - error Unauthorized(); - error InvalidPayloadSize(); - error VersionMismatch(); - - event AdminSet(address indexed admin, bool isAdmin); - event DefaultMultiplierSet(uint16 multiplierBps); - event DstMultiplierSet(DstMultiplierParam[] params); - event FeeLibSet(address indexed feeLib); - event FeeWithdrawn(address indexed to, uint256 amount); - event TokenWithdrawn(address indexed to, address token, uint256 amount); - - modifier onlySendLib() { - if (msg.sender != address(sendLib)) revert OnlySendLib(); - _; - } - - modifier onlyAdmin() { - if (!admins[msg.sender]) revert Unauthorized(); - _; - } - - constructor(address _sendLib, address _receiveLib, address[] memory _admins) { - (uint64 sendMajor, uint8 sendMinor, uint8 sendEndpoint) = IMessageLib(_sendLib).version(); - (uint64 receiveMajor, uint8 receiveMinor, uint8 receiveEndpoint) = IMessageLib(_receiveLib).version(); - - if (sendMajor != receiveMajor || sendMinor != receiveMinor || sendEndpoint != receiveEndpoint) { - revert VersionMismatch(); - } - - sendLib = ISendLib(_sendLib); - receiveLib = IReceiveUlnE2(_receiveLib); - - for (uint256 i = 0; i < _admins.length; i++) { - admins[_admins[i]] = true; - emit AdminSet(_admins[i], true); - } - } - - function setAdmin(address _admin, bool _isAdmin) external onlyOwner { - admins[_admin] = _isAdmin; - emit AdminSet(_admin, _isAdmin); - } - - // -------------------- Only Admin -------------------- - - /// @notice sets the default fee multiplier in basis points - /// @param _defaultMultiplierBps default fee multiplier - function setDefaultMultiplier(uint16 _defaultMultiplierBps) external onlyAdmin { - defaultMultiplierBps = _defaultMultiplierBps; - emit DefaultMultiplierSet(_defaultMultiplierBps); - } - - function setFeeLib(address _feeLib) external onlyAdmin { - feeLib = IDVNAdapterFeeLib(_feeLib); - emit FeeLibSet(_feeLib); - } - - /// @dev supports withdrawing fee from ULN301, ULN302 and more - /// @param _to address to withdraw fee to - /// @param _amount amount to withdraw - function withdrawFee(address _to, uint256 _amount) external onlyAdmin { - _withdrawFee(_to, _amount); - } - - /// @dev supports withdrawing token from the contract - /// @param _token token address - /// @param _to address to withdraw token to - /// @param _amount amount to withdraw - function withdrawToken(address _token, address _to, uint256 _amount) external onlyAdmin { - // transfers native if _token is address(0x0) - Transfer.nativeOrToken(_token, _to, _amount); - emit TokenWithdrawn(_to, _token, _amount); - } - - // -------------------- Internal Functions -------------------- - - function _assertBalanceAndWithdrawFee(uint256 _messageFee) internal { - uint256 balance = address(this).balance; - - if (balance < _messageFee) { - // withdraw fees from the sendLib if balance is insufficient - // sendLib will revert if not enough fees were accumulated - _withdrawFee(address(this), _messageFee - balance); // todo: why not withdraw all fees from sendLib? so that dont need to withdraw every time - } - } - - function _withdrawFee(address _to, uint256 _amount) internal { - sendLib.withdrawFee(_to, _amount); - emit FeeWithdrawn(_to, _amount); - } - - function _encodePayload( - bytes memory _packetHeader, - bytes32 _payloadHash - ) internal pure returns (bytes memory payload) { - return abi.encodePacked(_packetHeader, _payloadHash); - } - - function _decodePayload( - bytes memory _payload - ) internal pure returns (bytes memory packetHeader, bytes32 payloadHash) { - if (_payload.length != PAYLOAD_SIZE) revert InvalidPayloadSize(); - uint256 start = 0; - packetHeader = _payload.slice(start, PACKET_HEADER_SIZE); - - start += PACKET_HEADER_SIZE; - payloadHash = _payload.toBytes32(start); - } - - function _verify(bytes memory _payload) internal { - (bytes memory packetHeader, bytes32 payloadHash) = _decodePayload(_payload); - receiveLib.verify(packetHeader, payloadHash, MAX_CONFIRMATIONS); - } - - receive() external payable {} -} diff --git a/messagelib/contracts/uln/dvn/adapters/DVNAdapterFeeLibBase.sol b/messagelib/contracts/uln/dvn/adapters/DVNAdapterFeeLibBase.sol deleted file mode 100644 index 1f66502..0000000 --- a/messagelib/contracts/uln/dvn/adapters/DVNAdapterFeeLibBase.sol +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: LZBL-1.2 - -pragma solidity ^0.8.22; - -import { IDVNAdapterFeeLib } from "../../interfaces/IDVNAdapterFeeLib.sol"; - -contract DVNAdapterFeeLibBase is IDVNAdapterFeeLib { - uint16 internal constant BPS_DENOMINATOR = 10000; - - function getFee( - uint32 /*_dstEid*/, - address /*_sender*/, - uint16 _defaultMultiplierBps, - uint16 _multiplierBps, - uint256 _executionFee - ) public pure virtual returns (uint256 fee) { - uint256 multiplier = _multiplierBps == 0 ? _defaultMultiplierBps : _multiplierBps; - fee = (_executionFee * multiplier) / BPS_DENOMINATOR; - } -} diff --git a/messagelib/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapter.sol b/messagelib/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapter.sol deleted file mode 100644 index 9de78f8..0000000 --- a/messagelib/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapter.sol +++ /dev/null @@ -1,156 +0,0 @@ -// SPDX-License-Identifier: LZBL-1.2 - -pragma solidity ^0.8.22; - -import { AxelarExecutable } from "@axelar-network/axelar-gmp-sdk-solidity/contracts/executable/AxelarExecutable.sol"; -import { IAxelarGasService } from "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGasService.sol"; - -import { DVNAdapterBase } from "../DVNAdapterBase.sol"; - -contract AxelarDVNAdapter is AxelarExecutable, DVNAdapterBase { - struct DstConfigParam { - uint32 dstEid; - uint16 multiplierBps; - uint256 nativeGasFee; - string peer; - string chainName; - } - - struct DstFeeParam { - uint32 dstEid; - uint256 nativeGasFee; - } - - struct DstConfig { - uint256 nativeGasFee; - uint16 multiplierBps; - string peer; - string chainName; - } - - event DstConfigSet(DstConfigParam[] params); - event DstFeeSet(DstFeeParam[] params); - - IAxelarGasService public immutable gasService; - - mapping(uint32 dstEid => DstConfig config) public dstConfig; - mapping(string axelarChain => uint32 eid) public axelarChainToEid; - - constructor( - address _sendLib, - address _receiveLib, - address[] memory _admins, - address _gateway, - address _gasReceiver - ) AxelarExecutable(_gateway) DVNAdapterBase(_sendLib, _receiveLib, _admins) { - gasService = IAxelarGasService(_gasReceiver); - } - - /// @notice sets configuration (`nativeGasFee`, `multiplierBps`, `peer`, and `chainName`) for destination chains - /// @dev The `nativeGasFee` and `multiplierBps` can be updated separately using `setDstNativeGasFee` and `setDstMultiplier` functions - /// @param _params array of chain configurations - function setDstConfig(DstConfigParam[] calldata _params) external onlyAdmin { - for (uint256 i = 0; i < _params.length; i++) { - DstConfigParam calldata param = _params[i]; - - delete axelarChainToEid[dstConfig[param.dstEid].chainName]; - - axelarChainToEid[param.chainName] = param.dstEid; - dstConfig[param.dstEid] = DstConfig({ - nativeGasFee: param.nativeGasFee, - multiplierBps: param.multiplierBps, - peer: param.peer, - chainName: param.chainName - }); - } - - emit DstConfigSet(_params); - } - - /// @notice sets message fee in native gas for destination chains. - /// @dev Axelar does not support quoting fee onchain. Instead, the fee needs to be obtained off-chain by querying through the Axelar SDK. - /// @dev The fee may change over time when token prices change, requiring admins to monitor and make necessary updates to reflect the actual fee. - /// @dev Adding a buffer to the required fee is advisable. Any surplus fee will be refunded asynchronously if it exceeds the necessary amount. - /// https://docs.axelar.dev/dev/general-message-passing/gas-services/pay-gas - /// https://github.com/axelarnetwork/axelarjs/blob/070c8fe061f1082e79772fdc5c4675c0237bbba2/packages/api/src/axelar-query/isomorphic.ts#L54 - /// https://github.com/axelarnetwork/axelar-cgp-solidity/blob/d4536599321774927bf9716178a9e360f8e0efac/contracts/gas-service/AxelarGasService.sol#L403 - /// @param _params array of message fees for destination chains - function setDstNativeGasFee(DstFeeParam[] calldata _params) external onlyAdmin { - // TODO - can delete and call setDstConfig instead? - for (uint256 i = 0; i < _params.length; i++) { - DstFeeParam calldata param = _params[i]; - dstConfig[param.dstEid].nativeGasFee = param.nativeGasFee; - } - - emit DstFeeSet(_params); - } - - /// @notice sets fee multiplier in basis points for destination chains - /// @param _params array of multipliers for destination chains - function setDstMultiplier(DstMultiplierParam[] calldata _params) external onlyAdmin { - // TODO - can delete and call setDstConfig instead? - for (uint256 i = 0; i < _params.length; i++) { - DstMultiplierParam calldata param = _params[i]; - dstConfig[param.dstEid].multiplierBps = param.multiplierBps; - } - - emit DstMultiplierSet(_params); - } - - function assignJob( - AssignJobParam calldata _param, - bytes calldata /*_options*/ - ) external payable override onlySendLib returns (uint256 fee) { - DstConfig storage config = dstConfig[_param.dstEid]; - fee = config.nativeGasFee; - string memory dstChainName = config.chainName; - string memory dstPeer = config.peer; - bytes memory payload = _encodePayload(_param.packetHeader, _param.payloadHash); - - _assertBalanceAndWithdrawFee(fee); - - // https://docs.axelar.dev/dev/general-message-passing/gas-services/pay-gas#paynativegasforcontractcall - gasService.payNativeGasForContractCall{ value: fee }( - address(this), // sender - dstChainName, // destinationChain - dstPeer, // destinationAddress - payload, // payload - address(this) // refundAddress - ); - // https://docs.axelar.dev/dev/general-message-passing/gmp-messages#call-a-contract-on-chain-b-from-chain-a - gateway.callContract(dstChainName, dstPeer, payload); - - if (address(feeLib) != address(0)) { - fee = feeLib.getFee(_param.dstEid, _param.sender, defaultMultiplierBps, config.multiplierBps, fee); - } - } - - function getFee( - uint32 _dstEid, - uint64 /*_confirmations*/, - address _sender, - bytes calldata /*_options*/ - ) external view override returns (uint256 fee) { - DstConfig storage config = dstConfig[_dstEid]; - fee = config.nativeGasFee; - if (address(feeLib) != address(0)) { - fee = feeLib.getFee(_dstEid, _sender, defaultMultiplierBps, config.multiplierBps, fee); - } - } - - function _execute( - string calldata _sourceChain, - string calldata _sourceAddress, - bytes calldata _payload - ) internal override { - _assertPeer(_sourceChain, _sourceAddress); - _verify(_payload); - } - - function _assertPeer(string calldata _sourceChain, string calldata _sourceAddress) private view { - uint32 sourceEid = axelarChainToEid[_sourceChain]; - string memory sourcePeer = dstConfig[sourceEid].peer; - - if (keccak256(bytes(_sourceAddress)) != keccak256(bytes(sourcePeer))) revert Unauthorized(); - } -} diff --git a/messagelib/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapterFeeLib.sol b/messagelib/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapterFeeLib.sol deleted file mode 100644 index bca56bb..0000000 --- a/messagelib/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapterFeeLib.sol +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: LZBL-1.2 - -pragma solidity ^0.8.22; - -import { DVNAdapterFeeLibBase } from "../DVNAdapterFeeLibBase.sol"; - -contract AxelarDVNAdapterFeeLib is DVNAdapterFeeLibBase {} diff --git a/messagelib/test/DVNAdapterBase.t.sol b/messagelib/test/DVNAdapterBase.t.sol deleted file mode 100644 index a56353c..0000000 --- a/messagelib/test/DVNAdapterBase.t.sol +++ /dev/null @@ -1,177 +0,0 @@ -// SPDX-License-Identifier: UNLICENSE - -pragma solidity ^0.8.0; - -import { Test } from "forge-std/Test.sol"; - -import { ILayerZeroDVN } from "../contracts/uln/interfaces/ILayerZeroDVN.sol"; -import { DVNAdapterBase } from "../contracts/uln/dvn/adapters/DVNAdapterBase.sol"; -import { DVNAdapterFeeLibBase } from "../contracts/uln/dvn/adapters/DVNAdapterFeeLibBase.sol"; -import { SendLibMock } from "./mocks/SendLibMock.sol"; -import { ReceiveLibMock } from "./mocks/ReceiveLibMock.sol"; - -contract DVNAdapterBaseHarness is DVNAdapterBase { - constructor( - address _sendLib, - address _receiveLib, - address[] memory _admins - ) DVNAdapterBase(_sendLib, _receiveLib, _admins) {} - - function exposed_PACKET_HEADER_SIZE() external pure returns (uint256) { - return PACKET_HEADER_SIZE; - } - - function exposed_PAYLOAD_SIZE() external pure returns (uint256) { - return PAYLOAD_SIZE; - } - - function exposed_assertBalanceAndWithdrawFee(uint256 _messageFee) external { - _assertBalanceAndWithdrawFee(_messageFee); - } - - function exposed_encodePayload( - bytes memory _packetHeader, - bytes32 _payloadHash - ) external pure returns (bytes memory payload) { - return _encodePayload(_packetHeader, _payloadHash); - } - - function exposed_decodePayload(bytes memory _payload) external pure returns (bytes memory, bytes32) { - return _decodePayload(_payload); - } - - function assignJob(AssignJobParam calldata, bytes calldata) external payable returns (uint256) { - return 0; - } - - function getFee(uint32, uint64, address, bytes calldata) external pure returns (uint256) { - return 0; - } -} - -contract DVNAdapterFeeLib is DVNAdapterFeeLibBase {} - -contract DVNAdapterBaseTest is Test { - DVNAdapterBaseHarness dvnAdapter; - SendLibMock sendLib; - ReceiveLibMock receiveLib; - - address admin = address(0x01); - - function setUp() public { - address[] memory admins = new address[](1); - admins[0] = admin; - sendLib = new SendLibMock(); - receiveLib = new ReceiveLibMock(); - dvnAdapter = new DVNAdapterBaseHarness(address(sendLib), address(receiveLib), admins); - } - - function testFuzz_setAdmin(address newAdmin) public { - dvnAdapter.setAdmin(newAdmin, true); - assertEq(dvnAdapter.admins(newAdmin), true); - - dvnAdapter.setAdmin(newAdmin, false); - assertEq(dvnAdapter.admins(newAdmin), false); - } - - function test_setAdmin_notOwner_revert() public { - address newAdmin = vm.addr(1); - - vm.prank(admin); - vm.expectRevert(); - dvnAdapter.setAdmin(newAdmin, true); - } - - function testFuzz_setDefaultMultiplier(uint16 defaultMultiplierBps) public { - vm.prank(admin); - dvnAdapter.setDefaultMultiplier(defaultMultiplierBps); - - assertEq(dvnAdapter.defaultMultiplierBps(), defaultMultiplierBps); - } - - function testFuzz_setAdmin_notAdmin_revert(address caller, uint16 defaultMultiplierBps) public { - vm.assume(caller != admin); - - vm.prank(caller); - vm.expectRevert(DVNAdapterBase.Unauthorized.selector); - dvnAdapter.setDefaultMultiplier(defaultMultiplierBps); - } - - function test_setFeeLib() public { - DVNAdapterFeeLib feeLib = new DVNAdapterFeeLib(); - - vm.prank(admin); - dvnAdapter.setFeeLib(address(feeLib)); - - assertEq(address(dvnAdapter.feeLib()), address(feeLib)); - } - - function testFuzz_setFeeLib_notAdmin_revert(address caller) public { - vm.assume(caller != admin); - - DVNAdapterFeeLib feeLib = new DVNAdapterFeeLib(); - - vm.prank(caller); - vm.expectRevert(DVNAdapterBase.Unauthorized.selector); - dvnAdapter.setFeeLib(address(feeLib)); - } - - function testFuzz_withdrawFee(uint256 fee) public { - assertEq(address(dvnAdapter).balance, 0); - - vm.deal(admin, fee); - vm.prank(admin); - sendLib.setFee{ value: fee }(address(dvnAdapter)); - - vm.prank(admin); - dvnAdapter.withdrawFee(address(dvnAdapter), fee); - - assertEq(address(dvnAdapter).balance, fee); - } - - function testFuzz_assertBalanceAndWithdrawFee_sufficientBalance_noWithdraw(uint256 fee) public { - vm.deal(address(dvnAdapter), fee); - assertEq(address(dvnAdapter).balance, fee); - - dvnAdapter.exposed_assertBalanceAndWithdrawFee(fee); - assertEq(address(dvnAdapter).balance, fee); - } - - function testFuzz_assertBalanceAndWithdrawFee_insufficientBalance_withdraw(uint256 fee) public { - vm.deal(admin, fee); - vm.prank(admin); - sendLib.setFee{ value: fee }(address(dvnAdapter)); - assertEq(sendLib.fees(address(dvnAdapter)), fee); - assertEq(address(dvnAdapter).balance, 0); - - dvnAdapter.exposed_assertBalanceAndWithdrawFee(fee); - assertEq(address(dvnAdapter).balance, fee); - assertEq(sendLib.fees(address(dvnAdapter)), 0); - } - - function testFuzz_encodePayload(bytes memory packetHeader, bytes32 payloadHash) public { - vm.assume(packetHeader.length == dvnAdapter.exposed_PACKET_HEADER_SIZE()); - - bytes memory expected = abi.encodePacked(packetHeader, payloadHash); - bytes memory actual = dvnAdapter.exposed_encodePayload(packetHeader, payloadHash); - - assertEq(actual, expected); - } - - function testFuzz_decodePayload(bytes memory packetHeader, bytes32 payloadHash) public { - vm.assume(packetHeader.length == dvnAdapter.exposed_PACKET_HEADER_SIZE()); - - bytes memory payload = abi.encodePacked(packetHeader, payloadHash); - (bytes memory actualPacketHeader, bytes32 actualPayloadHash) = dvnAdapter.exposed_decodePayload(payload); - - assertEq(actualPacketHeader, packetHeader); - assertEq(actualPayloadHash, payloadHash); - } - - function testFuzz_decodePayload_invalidPayloadSize_revert(bytes memory payload) public { - vm.assume(payload.length != dvnAdapter.exposed_PAYLOAD_SIZE()); - - vm.expectRevert(DVNAdapterBase.InvalidPayloadSize.selector); - dvnAdapter.exposed_decodePayload(payload); - } -} diff --git a/messagelib/test/DVNAdapterFeeLibBase.t.sol b/messagelib/test/DVNAdapterFeeLibBase.t.sol deleted file mode 100644 index a741800..0000000 --- a/messagelib/test/DVNAdapterFeeLibBase.t.sol +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED - -pragma solidity ^0.8.22; - -import { Test } from "forge-std/Test.sol"; - -import { DVNAdapterFeeLibBase } from "../contracts/uln/dvn/adapters/DVNAdapterFeeLibBase.sol"; - -contract DVNAdapterFeeLibBaseTest is DVNAdapterFeeLibBase, Test { - uint256 constant MIN_EXECUTION_FEE = 0; - uint256 constant MAX_EXECUTION_FEE = 1 ether; - uint16 constant MAX_MULTIPLIER_BPS = 20000; - - function testFuzz_getFee_useDefaultMultiplier(uint16 defaultMultiplierBps, uint256 executionFee) public { - uint16 multiplierBps = 0; - defaultMultiplierBps = uint16(bound(defaultMultiplierBps, 0, MAX_MULTIPLIER_BPS)); - executionFee = bound(executionFee, MIN_EXECUTION_FEE, MAX_EXECUTION_FEE); - - uint256 actual = getFee(0, address(0), defaultMultiplierBps, multiplierBps, executionFee); - uint256 expected = (executionFee * defaultMultiplierBps) / BPS_DENOMINATOR; - - assertEq(actual, expected); - } - - function testFuzz_getFee_useMultiplier(uint16 multiplierBps, uint256 executionFee) public { - uint16 defaultMultiplierBps = 12000; - multiplierBps = uint16(bound(defaultMultiplierBps, 1, MAX_MULTIPLIER_BPS)); - executionFee = bound(executionFee, MIN_EXECUTION_FEE, MAX_EXECUTION_FEE); - - uint256 actual = getFee(0, address(0), defaultMultiplierBps, multiplierBps, executionFee); - uint256 expected = (executionFee * multiplierBps) / BPS_DENOMINATOR; - - assertEq(actual, expected); - } -} From 5679050dc8ef28d964c0ea3410e91792879c66e8 Mon Sep 17 00:00:00 2001 From: Carmen Cheng Date: Wed, 17 Jan 2024 08:51:49 +0800 Subject: [PATCH 2/3] lz executor commitAndExecute with an array of native drop --- messagelib/contracts/uln/LzExecutor.sol | 9 +++++---- messagelib/test/LzExecutor.t.sol | 22 +++++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/messagelib/contracts/uln/LzExecutor.sol b/messagelib/contracts/uln/LzExecutor.sol index 673228c..25f011d 100644 --- a/messagelib/contracts/uln/LzExecutor.sol +++ b/messagelib/contracts/uln/LzExecutor.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; @@ -47,7 +47,7 @@ contract LzExecutor is Ownable { function commitAndExecute( address _receiveLib, LzReceiveParam calldata _lzReceiveParam, - NativeDropParam calldata _nativeDropParam + NativeDropParam[] calldata _nativeDropParams ) external payable { /// 1. check if executable, revert if executed ExecutionState executionState = endpoint.executable(_lzReceiveParam.origin, _lzReceiveParam.receiver); @@ -76,8 +76,9 @@ contract LzExecutor is Ownable { } /// 3. native drop - if (_nativeDropParam._amount > 0 && _nativeDropParam._receiver != address(0x0)) { - Transfer.native(_nativeDropParam._receiver, _nativeDropParam._amount); + for (uint256 i = 0; i < _nativeDropParams.length; i++) { + NativeDropParam calldata param = _nativeDropParams[i]; + Transfer.native(param._receiver, param._amount); } /// 4. try execute, will revert if not executable diff --git a/messagelib/test/LzExecutor.t.sol b/messagelib/test/LzExecutor.t.sol index 97c5795..598ddc1 100644 --- a/messagelib/test/LzExecutor.t.sol +++ b/messagelib/test/LzExecutor.t.sol @@ -69,10 +69,11 @@ contract LzExecutorTest is Test, ILayerZeroReceiver { assertEq(uint256(endpointV2.executable(origin, receiver)), uint256(ExecutionState.Executable)); // commit and execute + NativeDropParam[] memory nativeDrop = new NativeDropParam[](0); lzExecutor.commitAndExecute( address(receiveUln302), LzReceiveParam(origin, receiver, packet.guid, packet.message, "", 100000, 0), - NativeDropParam(address(0x0), 0) + nativeDrop ); // executed @@ -88,10 +89,12 @@ contract LzExecutorTest is Test, ILayerZeroReceiver { vm.deal(address(this), 1000); assertEq(alice.balance, 0); // alice had no funds // commit and execute + NativeDropParam[] memory nativeDrop = new NativeDropParam[](1); + nativeDrop[0] = NativeDropParam(alice, 1000); lzExecutor.commitAndExecute{ value: 1000 }( address(receiveUln302), LzReceiveParam(origin, receiver, packet.guid, packet.message, "", 100000, 0), - NativeDropParam(alice, 1000) + nativeDrop ); assertEq(address(this).balance, 0); assertEq(address(lzExecutor).balance, 0); @@ -109,10 +112,11 @@ contract LzExecutorTest is Test, ILayerZeroReceiver { vm.deal(address(this), 1000); // commit and execute + NativeDropParam[] memory nativeDrop = new NativeDropParam[](0); lzExecutor.commitAndExecute{ value: 1000 }( address(receiveUln302), LzReceiveParam(origin, receiver, packet.guid, packet.message, "", 100000, 1000), - NativeDropParam(address(0x0), 0) + nativeDrop ); assertEq(address(lzExecutor).balance, 0); assertEq(address(this).balance, 1000); @@ -132,10 +136,11 @@ contract LzExecutorTest is Test, ILayerZeroReceiver { assertEq(uint256(endpointV2.executable(origin, receiver)), uint256(ExecutionState.NotExecutable)); // commit and execute + NativeDropParam[] memory nativeDrop = new NativeDropParam[](0); lzExecutor.commitAndExecute( address(receiveUln302), LzReceiveParam(origin, receiver, packet.guid, packet.message, "", 100000, 0), - NativeDropParam(address(0x0), 0) + nativeDrop ); // verified @@ -147,21 +152,24 @@ contract LzExecutorTest is Test, ILayerZeroReceiver { function test_CommitAndExecute_Revert_Verifying() public { assertEq(uint256(receiveUln302.verifiable(packetHeader, payloadHash)), uint256(VerificationState.Verifying)); + NativeDropParam[] memory nativeDrop = new NativeDropParam[](0); vm.expectRevert(LzExecutor.Verifying.selector); lzExecutor.commitAndExecute( address(receiveUln302), LzReceiveParam(origin, receiver, packet.guid, packet.message, "", 100000, 0), - NativeDropParam(address(0x0), 0) + nativeDrop ); } function test_CommitAndExecute_Revert_Executed() public { + NativeDropParam[] memory nativeDrop = new NativeDropParam[](0); + vm.prank(address(fixtureV2.dvn)); receiveUln302.verify(packetHeader, payloadHash, 1); lzExecutor.commitAndExecute( address(receiveUln302), LzReceiveParam(origin, receiver, packet.guid, packet.message, "", 100000, 0), - NativeDropParam(address(0x0), 0) + nativeDrop ); // try again @@ -169,7 +177,7 @@ contract LzExecutorTest is Test, ILayerZeroReceiver { lzExecutor.commitAndExecute( address(receiveUln302), LzReceiveParam(origin, receiver, packet.guid, packet.message, "", 100000, 0), - NativeDropParam(address(0x0), 0) + nativeDrop ); } From bf4318b5e88e46400931bb4c1f6aa0343c035a79 Mon Sep 17 00:00:00 2001 From: Carmen Cheng Date: Wed, 17 Jan 2024 08:52:38 +0800 Subject: [PATCH 3/3] update pragma to ^0.8.20 --- messagelib/contracts/Executor.sol | 2 +- messagelib/contracts/ExecutorFeeLib.sol | 2 +- messagelib/contracts/MessageLibBase.sol | 2 +- messagelib/contracts/PriceFeed.sol | 2 +- messagelib/contracts/ReceiveLibBaseE2.sol | 2 +- messagelib/contracts/SendLibBase.sol | 2 +- messagelib/contracts/SendLibBaseE2.sol | 2 +- messagelib/contracts/Treasury.sol | 2 +- messagelib/contracts/Worker.sol | 2 +- messagelib/contracts/libs/SafeCall.sol | 2 +- messagelib/contracts/uln/ReceiveUlnBase.sol | 2 +- messagelib/contracts/uln/SendUlnBase.sol | 2 +- messagelib/contracts/uln/UlnBase.sol | 2 +- messagelib/contracts/uln/dvn/DVN.sol | 2 +- messagelib/contracts/uln/dvn/DVNFeeLib.sol | 2 +- messagelib/contracts/uln/dvn/MultiSig.sol | 2 +- messagelib/contracts/uln/libs/DVNOptions.sol | 2 +- messagelib/contracts/uln/libs/UlnOptions.sol | 2 +- messagelib/contracts/uln/uln301/AddressSizeConfig.sol | 2 +- messagelib/contracts/uln/uln301/ReceiveLibBaseE1.sol | 2 +- messagelib/contracts/uln/uln301/ReceiveUln301.sol | 2 +- messagelib/contracts/uln/uln301/SendLibBaseE1.sol | 2 +- messagelib/contracts/uln/uln301/SendUln301.sol | 2 +- .../contracts/uln/uln301/TreasuryFeeHandler.sol | 2 +- messagelib/contracts/uln/uln302/ReceiveUln302.sol | 2 +- messagelib/contracts/uln/uln302/SendUln302.sol | 2 +- .../contracts/upgradeable/WorkerUpgradeable.sol | 4 ++-- messagelib/test/mocks/ReceiveLibMock.sol | 2 +- messagelib/test/mocks/SendLibMock.sol | 2 +- oapp/contracts/oapp/OApp.sol | 2 +- oapp/contracts/oapp/OAppCore.sol | 2 +- oapp/contracts/oapp/OAppReceiver.sol | 2 +- oapp/contracts/oapp/OAppSender.sol | 2 +- oapp/contracts/oapp/examples/OmniCounter.sol | 2 +- oapp/contracts/oapp/examples/OmniCounterPreCrime.sol | 2 +- oapp/contracts/oapp/interfaces/IOAppComposer.sol | 2 +- oapp/contracts/oapp/interfaces/IOAppCore.sol | 2 +- oapp/contracts/oapp/interfaces/IOAppMsgInspector.sol | 2 +- oapp/contracts/oapp/interfaces/IOAppOptionsType3.sol | 2 +- oapp/contracts/oapp/libs/OAppOptionsType3.sol | 2 +- oapp/contracts/oapp/libs/OptionsBuilder.sol | 2 +- oapp/contracts/oft/OFT.sol | 2 +- oapp/contracts/oft/OFTAdapter.sol | 2 +- oapp/contracts/oft/OFTCore.sol | 4 ++-- oapp/contracts/oft/OFTPrecrime.sol | 2 +- oapp/contracts/oft/interfaces/IOFT.sol | 2 +- oapp/contracts/oft/libs/OFTComposeMsgCodec.sol | 2 +- oapp/contracts/oft/libs/OFTMsgCodec.sol | 2 +- oapp/contracts/precrime/OAppPreCrimeSimulator.sol | 2 +- oapp/contracts/precrime/PreCrime.sol | 2 +- oapp/contracts/precrime/extensions/PreCrimeE1.sol | 2 +- .../precrime/interfaces/IOAppPreCrimeSimulator.sol | 2 +- oapp/contracts/precrime/interfaces/IPreCrime.sol | 2 +- oapp/contracts/precrime/libs/Packet.sol | 2 +- oapp/test/OFT.t.sol | 2 +- oapp/test/TestHelper.sol | 2 +- oapp/test/mocks/ERC20Mock.sol | 2 +- oapp/test/mocks/ExecutorFeeLibMock.sol | 2 +- protocol/contracts/EndpointV2.sol | 2 +- protocol/contracts/EndpointV2Alt.sol | 2 +- protocol/contracts/MessageLibManager.sol | 2 +- protocol/contracts/MessagingChannel.sol | 2 +- protocol/contracts/MessagingComposer.sol | 2 +- protocol/contracts/MessagingContext.sol | 2 +- protocol/contracts/interfaces/ILayerZeroComposer.sol | 11 +++++++++++ protocol/contracts/libs/AddressCast.sol | 2 +- protocol/contracts/libs/CalldataBytesLib.sol | 2 +- protocol/contracts/libs/Errors.sol | 2 +- protocol/contracts/libs/GUID.sol | 2 +- protocol/contracts/libs/Transfer.sol | 2 +- protocol/contracts/messagelib/BlockedMessageLib.sol | 2 +- protocol/contracts/messagelib/SimpleMessageLib.sol | 2 +- protocol/contracts/messagelib/libs/BitMaps.sol | 2 +- .../contracts/messagelib/libs/ExecutorOptions.sol | 2 +- protocol/contracts/messagelib/libs/PacketV1Codec.sol | 2 +- 75 files changed, 87 insertions(+), 76 deletions(-) diff --git a/messagelib/contracts/Executor.sol b/messagelib/contracts/Executor.sol index 9380c83..5420833 100644 --- a/messagelib/contracts/Executor.sol +++ b/messagelib/contracts/Executor.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import { Proxied } from "hardhat-deploy/solc_0.8/proxy/Proxied.sol"; diff --git a/messagelib/contracts/ExecutorFeeLib.sol b/messagelib/contracts/ExecutorFeeLib.sol index 6dce884..3b62e7d 100644 --- a/messagelib/contracts/ExecutorFeeLib.sol +++ b/messagelib/contracts/ExecutorFeeLib.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; diff --git a/messagelib/contracts/MessageLibBase.sol b/messagelib/contracts/MessageLibBase.sol index 358f5ef..f34fd38 100644 --- a/messagelib/contracts/MessageLibBase.sol +++ b/messagelib/contracts/MessageLibBase.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; /// @dev simply a container of endpoint address and local eid abstract contract MessageLibBase { diff --git a/messagelib/contracts/PriceFeed.sol b/messagelib/contracts/PriceFeed.sol index 77a018f..1bf1e6b 100644 --- a/messagelib/contracts/PriceFeed.sol +++ b/messagelib/contracts/PriceFeed.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import { Proxied } from "hardhat-deploy/solc_0.8/proxy/Proxied.sol"; diff --git a/messagelib/contracts/ReceiveLibBaseE2.sol b/messagelib/contracts/ReceiveLibBaseE2.sol index a740304..fce7207 100644 --- a/messagelib/contracts/ReceiveLibBaseE2.sol +++ b/messagelib/contracts/ReceiveLibBaseE2.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; diff --git a/messagelib/contracts/SendLibBase.sol b/messagelib/contracts/SendLibBase.sol index 63c5ee4..9245546 100644 --- a/messagelib/contracts/SendLibBase.sol +++ b/messagelib/contracts/SendLibBase.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { Transfer } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/Transfer.sol"; diff --git a/messagelib/contracts/SendLibBaseE2.sol b/messagelib/contracts/SendLibBaseE2.sol index c8b2212..981f769 100644 --- a/messagelib/contracts/SendLibBaseE2.sol +++ b/messagelib/contracts/SendLibBaseE2.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; diff --git a/messagelib/contracts/Treasury.sol b/messagelib/contracts/Treasury.sol index e2c2a58..2438329 100644 --- a/messagelib/contracts/Treasury.sol +++ b/messagelib/contracts/Treasury.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; diff --git a/messagelib/contracts/Worker.sol b/messagelib/contracts/Worker.sol index 2a3bd28..31e08f7 100644 --- a/messagelib/contracts/Worker.sol +++ b/messagelib/contracts/Worker.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Pausable } from "@openzeppelin/contracts/security/Pausable.sol"; import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol"; diff --git a/messagelib/contracts/libs/SafeCall.sol b/messagelib/contracts/libs/SafeCall.sol index d8edae6..13866eb 100644 --- a/messagelib/contracts/libs/SafeCall.sol +++ b/messagelib/contracts/libs/SafeCall.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; /// @dev copied from https://github.com/nomad-xyz/ExcessivelySafeCall/blob/main/src/ExcessivelySafeCall.sol. library SafeCall { diff --git a/messagelib/contracts/uln/ReceiveUlnBase.sol b/messagelib/contracts/uln/ReceiveUlnBase.sol index 93e4e52..8c09cd3 100644 --- a/messagelib/contracts/uln/ReceiveUlnBase.sol +++ b/messagelib/contracts/uln/ReceiveUlnBase.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { PacketV1Codec } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/PacketV1Codec.sol"; diff --git a/messagelib/contracts/uln/SendUlnBase.sol b/messagelib/contracts/uln/SendUlnBase.sol index 8654f25..c1a2071 100644 --- a/messagelib/contracts/uln/SendUlnBase.sol +++ b/messagelib/contracts/uln/SendUlnBase.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Packet } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ISendLib.sol"; import { PacketV1Codec } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/PacketV1Codec.sol"; diff --git a/messagelib/contracts/uln/UlnBase.sol b/messagelib/contracts/uln/UlnBase.sol index f330cf2..5b9e61d 100644 --- a/messagelib/contracts/uln/UlnBase.sol +++ b/messagelib/contracts/uln/UlnBase.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; diff --git a/messagelib/contracts/uln/dvn/DVN.sol b/messagelib/contracts/uln/dvn/DVN.sol index 3a7f492..a24c73a 100644 --- a/messagelib/contracts/uln/dvn/DVN.sol +++ b/messagelib/contracts/uln/dvn/DVN.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { ILayerZeroUltraLightNodeV2 } from "@layerzerolabs/lz-evm-v1-0.7/contracts/interfaces/ILayerZeroUltraLightNodeV2.sol"; diff --git a/messagelib/contracts/uln/dvn/DVNFeeLib.sol b/messagelib/contracts/uln/dvn/DVNFeeLib.sol index e7e9001..1bbe6a9 100644 --- a/messagelib/contracts/uln/dvn/DVNFeeLib.sol +++ b/messagelib/contracts/uln/dvn/DVNFeeLib.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { Transfer } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/Transfer.sol"; diff --git a/messagelib/contracts/uln/dvn/MultiSig.sol b/messagelib/contracts/uln/dvn/MultiSig.sol index 1043889..9b6ffcd 100644 --- a/messagelib/contracts/uln/dvn/MultiSig.sol +++ b/messagelib/contracts/uln/dvn/MultiSig.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; diff --git a/messagelib/contracts/uln/libs/DVNOptions.sol b/messagelib/contracts/uln/libs/DVNOptions.sol index e2da734..cd937fe 100644 --- a/messagelib/contracts/uln/libs/DVNOptions.sol +++ b/messagelib/contracts/uln/libs/DVNOptions.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { BytesLib } from "solidity-bytes-utils/contracts/BytesLib.sol"; diff --git a/messagelib/contracts/uln/libs/UlnOptions.sol b/messagelib/contracts/uln/libs/UlnOptions.sol index a7122e7..e5b19f3 100644 --- a/messagelib/contracts/uln/libs/UlnOptions.sol +++ b/messagelib/contracts/uln/libs/UlnOptions.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol"; diff --git a/messagelib/contracts/uln/uln301/AddressSizeConfig.sol b/messagelib/contracts/uln/uln301/AddressSizeConfig.sol index af96d37..d9986e1 100644 --- a/messagelib/contracts/uln/uln301/AddressSizeConfig.sol +++ b/messagelib/contracts/uln/uln301/AddressSizeConfig.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; diff --git a/messagelib/contracts/uln/uln301/ReceiveLibBaseE1.sol b/messagelib/contracts/uln/uln301/ReceiveLibBaseE1.sol index 451f95b..61426b6 100644 --- a/messagelib/contracts/uln/uln301/ReceiveLibBaseE1.sol +++ b/messagelib/contracts/uln/uln301/ReceiveLibBaseE1.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol"; import { ILayerZeroEndpoint } from "@layerzerolabs/lz-evm-v1-0.7/contracts/interfaces/ILayerZeroEndpoint.sol"; diff --git a/messagelib/contracts/uln/uln301/ReceiveUln301.sol b/messagelib/contracts/uln/uln301/ReceiveUln301.sol index 1f2b73f..fcd1daf 100644 --- a/messagelib/contracts/uln/uln301/ReceiveUln301.sol +++ b/messagelib/contracts/uln/uln301/ReceiveUln301.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol"; diff --git a/messagelib/contracts/uln/uln301/SendLibBaseE1.sol b/messagelib/contracts/uln/uln301/SendLibBaseE1.sol index 01d152d..ce5e7c0 100644 --- a/messagelib/contracts/uln/uln301/SendLibBaseE1.sol +++ b/messagelib/contracts/uln/uln301/SendLibBaseE1.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Packet } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ISendLib.sol"; import { AddressCast } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/AddressCast.sol"; diff --git a/messagelib/contracts/uln/uln301/SendUln301.sol b/messagelib/contracts/uln/uln301/SendUln301.sol index 97b9029..d354700 100644 --- a/messagelib/contracts/uln/uln301/SendUln301.sol +++ b/messagelib/contracts/uln/uln301/SendUln301.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Packet } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ISendLib.sol"; diff --git a/messagelib/contracts/uln/uln301/TreasuryFeeHandler.sol b/messagelib/contracts/uln/uln301/TreasuryFeeHandler.sol index 4914b2a..707f60a 100644 --- a/messagelib/contracts/uln/uln301/TreasuryFeeHandler.sol +++ b/messagelib/contracts/uln/uln301/TreasuryFeeHandler.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; diff --git a/messagelib/contracts/uln/uln302/ReceiveUln302.sol b/messagelib/contracts/uln/uln302/ReceiveUln302.sol index 7c5d41c..f648794 100644 --- a/messagelib/contracts/uln/uln302/ReceiveUln302.sol +++ b/messagelib/contracts/uln/uln302/ReceiveUln302.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { PacketV1Codec } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/PacketV1Codec.sol"; import { SetConfigParam } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessageLibManager.sol"; diff --git a/messagelib/contracts/uln/uln302/SendUln302.sol b/messagelib/contracts/uln/uln302/SendUln302.sol index d6b7515..cfa8ccb 100644 --- a/messagelib/contracts/uln/uln302/SendUln302.sol +++ b/messagelib/contracts/uln/uln302/SendUln302.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Packet } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ISendLib.sol"; import { SetConfigParam } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessageLibManager.sol"; diff --git a/messagelib/contracts/upgradeable/WorkerUpgradeable.sol b/messagelib/contracts/upgradeable/WorkerUpgradeable.sol index 8d0a091..c975e94 100644 --- a/messagelib/contracts/upgradeable/WorkerUpgradeable.sol +++ b/messagelib/contracts/upgradeable/WorkerUpgradeable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; @@ -182,5 +182,5 @@ abstract contract WorkerUpgradeable is Initializable, AccessControlUpgradeable, * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ - uint256[45] private __gap; + uint256[47] private __gap; } diff --git a/messagelib/test/mocks/ReceiveLibMock.sol b/messagelib/test/mocks/ReceiveLibMock.sol index 421b08f..a4cc739 100644 --- a/messagelib/test/mocks/ReceiveLibMock.sol +++ b/messagelib/test/mocks/ReceiveLibMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { SetConfigParam } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessageLibManager.sol"; import { IMessageLib, MessageLibType } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessageLib.sol"; diff --git a/messagelib/test/mocks/SendLibMock.sol b/messagelib/test/mocks/SendLibMock.sol index 8a57254..780fe63 100644 --- a/messagelib/test/mocks/SendLibMock.sol +++ b/messagelib/test/mocks/SendLibMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { SetConfigParam } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessageLibManager.sol"; import { MessagingFee } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol"; diff --git a/oapp/contracts/oapp/OApp.sol b/oapp/contracts/oapp/OApp.sol index c1b7299..1e7a832 100644 --- a/oapp/contracts/oapp/OApp.sol +++ b/oapp/contracts/oapp/OApp.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; // @dev Import the 'MessagingFee' so it's exposed to OApp implementers // solhint-disable-next-line no-unused-import diff --git a/oapp/contracts/oapp/OAppCore.sol b/oapp/contracts/oapp/OAppCore.sol index b81750a..d078abe 100644 --- a/oapp/contracts/oapp/OAppCore.sol +++ b/oapp/contracts/oapp/OAppCore.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IOAppCore, ILayerZeroEndpointV2 } from "./interfaces/IOAppCore.sol"; diff --git a/oapp/contracts/oapp/OAppReceiver.sol b/oapp/contracts/oapp/OAppReceiver.sol index cc0d87c..76bb2c3 100644 --- a/oapp/contracts/oapp/OAppReceiver.sol +++ b/oapp/contracts/oapp/OAppReceiver.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { ILayerZeroReceiver, Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroReceiver.sol"; import { OAppCore } from "./OAppCore.sol"; diff --git a/oapp/contracts/oapp/OAppSender.sol b/oapp/contracts/oapp/OAppSender.sol index d2b5b6f..e9209b5 100644 --- a/oapp/contracts/oapp/OAppSender.sol +++ b/oapp/contracts/oapp/OAppSender.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { SafeERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { MessagingParams, MessagingFee, MessagingReceipt } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol"; diff --git a/oapp/contracts/oapp/examples/OmniCounter.sol b/oapp/contracts/oapp/examples/OmniCounter.sol index ce44ab5..cc21492 100644 --- a/oapp/contracts/oapp/examples/OmniCounter.sol +++ b/oapp/contracts/oapp/examples/OmniCounter.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { ILayerZeroEndpointV2, MessagingFee, MessagingReceipt, Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol"; import { ILayerZeroComposer } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroComposer.sol"; diff --git a/oapp/contracts/oapp/examples/OmniCounterPreCrime.sol b/oapp/contracts/oapp/examples/OmniCounterPreCrime.sol index 7e9b2aa..280f236 100644 --- a/oapp/contracts/oapp/examples/OmniCounterPreCrime.sol +++ b/oapp/contracts/oapp/examples/OmniCounterPreCrime.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { PreCrime, PreCrimePeer } from "../../precrime/PreCrime.sol"; import { InboundPacket } from "../../precrime/libs/Packet.sol"; diff --git a/oapp/contracts/oapp/interfaces/IOAppComposer.sol b/oapp/contracts/oapp/interfaces/IOAppComposer.sol index cfb0c26..d6c0386 100644 --- a/oapp/contracts/oapp/interfaces/IOAppComposer.sol +++ b/oapp/contracts/oapp/interfaces/IOAppComposer.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { ILayerZeroComposer } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroComposer.sol"; diff --git a/oapp/contracts/oapp/interfaces/IOAppCore.sol b/oapp/contracts/oapp/interfaces/IOAppCore.sol index c255b91..ffa943e 100644 --- a/oapp/contracts/oapp/interfaces/IOAppCore.sol +++ b/oapp/contracts/oapp/interfaces/IOAppCore.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { ILayerZeroEndpointV2 } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol"; diff --git a/oapp/contracts/oapp/interfaces/IOAppMsgInspector.sol b/oapp/contracts/oapp/interfaces/IOAppMsgInspector.sol index 6a654f9..22c0ef9 100644 --- a/oapp/contracts/oapp/interfaces/IOAppMsgInspector.sol +++ b/oapp/contracts/oapp/interfaces/IOAppMsgInspector.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; /** * @title IOAppMsgInspector diff --git a/oapp/contracts/oapp/interfaces/IOAppOptionsType3.sol b/oapp/contracts/oapp/interfaces/IOAppOptionsType3.sol index 74ba469..e013973 100644 --- a/oapp/contracts/oapp/interfaces/IOAppOptionsType3.sol +++ b/oapp/contracts/oapp/interfaces/IOAppOptionsType3.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; /** * @dev Struct representing enforced option parameters. diff --git a/oapp/contracts/oapp/libs/OAppOptionsType3.sol b/oapp/contracts/oapp/libs/OAppOptionsType3.sol index 5e81fb6..5b1159a 100644 --- a/oapp/contracts/oapp/libs/OAppOptionsType3.sol +++ b/oapp/contracts/oapp/libs/OAppOptionsType3.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IOAppOptionsType3, EnforcedOptionParam } from "../interfaces/IOAppOptionsType3.sol"; diff --git a/oapp/contracts/oapp/libs/OptionsBuilder.sol b/oapp/contracts/oapp/libs/OptionsBuilder.sol index e0660e1..b6748bd 100644 --- a/oapp/contracts/oapp/libs/OptionsBuilder.sol +++ b/oapp/contracts/oapp/libs/OptionsBuilder.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { BytesLib } from "solidity-bytes-utils/contracts/BytesLib.sol"; import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol"; diff --git a/oapp/contracts/oft/OFT.sol b/oapp/contracts/oft/OFT.sol index 4e2edad..089962c 100644 --- a/oapp/contracts/oft/OFT.sol +++ b/oapp/contracts/oft/OFT.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import { OFTCore } from "./OFTCore.sol"; diff --git a/oapp/contracts/oft/OFTAdapter.sol b/oapp/contracts/oft/OFTAdapter.sol index b9d2107..7473458 100644 --- a/oapp/contracts/oft/OFTAdapter.sol +++ b/oapp/contracts/oft/OFTAdapter.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { IERC20Metadata, IERC20 } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; diff --git a/oapp/contracts/oft/OFTCore.sol b/oapp/contracts/oft/OFTCore.sol index 76f6a77..778b14a 100644 --- a/oapp/contracts/oft/OFTCore.sol +++ b/oapp/contracts/oft/OFTCore.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { OApp, Origin } from "../oapp/OApp.sol"; import { OAppOptionsType3 } from "../oapp/libs/OAppOptionsType3.sol"; @@ -314,7 +314,7 @@ abstract contract OFTCore is IOFT, OApp, OAppPreCrimeSimulator, OAppOptionsType3 } /** - * @dev Internal function to check if peer is considered 'trusted' by the OApp. + * @dev Check if the peer is considered 'trusted' by the OApp. * @param _eid The endpoint ID to check. * @param _peer The peer to check. * @return Whether the peer passed is considered 'trusted' by the OApp. diff --git a/oapp/contracts/oft/OFTPrecrime.sol b/oapp/contracts/oft/OFTPrecrime.sol index d894b88..5797bba 100644 --- a/oapp/contracts/oft/OFTPrecrime.sol +++ b/oapp/contracts/oft/OFTPrecrime.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; // import { IOApp } from "../../interfaces/IOApp.sol"; // import { IOFT } from "./interfaces/IOFT.sol"; diff --git a/oapp/contracts/oft/interfaces/IOFT.sol b/oapp/contracts/oft/interfaces/IOFT.sol index cce0172..c666d4a 100644 --- a/oapp/contracts/oft/interfaces/IOFT.sol +++ b/oapp/contracts/oft/interfaces/IOFT.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { MessagingReceipt, MessagingFee } from "../../oapp/OAppSender.sol"; diff --git a/oapp/contracts/oft/libs/OFTComposeMsgCodec.sol b/oapp/contracts/oft/libs/OFTComposeMsgCodec.sol index d70450a..13e3ffb 100644 --- a/oapp/contracts/oft/libs/OFTComposeMsgCodec.sol +++ b/oapp/contracts/oft/libs/OFTComposeMsgCodec.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; library OFTComposeMsgCodec { // Offset constants for decoding composed messages diff --git a/oapp/contracts/oft/libs/OFTMsgCodec.sol b/oapp/contracts/oft/libs/OFTMsgCodec.sol index c91f650..f57a82e 100644 --- a/oapp/contracts/oft/libs/OFTMsgCodec.sol +++ b/oapp/contracts/oft/libs/OFTMsgCodec.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; library OFTMsgCodec { // Offset constants for encoding and decoding OFT messages diff --git a/oapp/contracts/precrime/OAppPreCrimeSimulator.sol b/oapp/contracts/precrime/OAppPreCrimeSimulator.sol index da89ce1..0355279 100644 --- a/oapp/contracts/precrime/OAppPreCrimeSimulator.sol +++ b/oapp/contracts/precrime/OAppPreCrimeSimulator.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IPreCrime } from "./interfaces/IPreCrime.sol"; diff --git a/oapp/contracts/precrime/PreCrime.sol b/oapp/contracts/precrime/PreCrime.sol index f2e5802..5c9f8fc 100644 --- a/oapp/contracts/precrime/PreCrime.sol +++ b/oapp/contracts/precrime/PreCrime.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { BytesLib } from "solidity-bytes-utils/contracts/BytesLib.sol"; diff --git a/oapp/contracts/precrime/extensions/PreCrimeE1.sol b/oapp/contracts/precrime/extensions/PreCrimeE1.sol index 0052534..ae737f3 100644 --- a/oapp/contracts/precrime/extensions/PreCrimeE1.sol +++ b/oapp/contracts/precrime/extensions/PreCrimeE1.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol"; diff --git a/oapp/contracts/precrime/interfaces/IOAppPreCrimeSimulator.sol b/oapp/contracts/precrime/interfaces/IOAppPreCrimeSimulator.sol index 4b8406c..96168ea 100644 --- a/oapp/contracts/precrime/interfaces/IOAppPreCrimeSimulator.sol +++ b/oapp/contracts/precrime/interfaces/IOAppPreCrimeSimulator.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; // @dev Import the Origin so it's exposed to OAppPreCrimeSimulator implementers. // solhint-disable-next-line no-unused-import diff --git a/oapp/contracts/precrime/interfaces/IPreCrime.sol b/oapp/contracts/precrime/interfaces/IPreCrime.sol index 92310ec..43c3d84 100644 --- a/oapp/contracts/precrime/interfaces/IPreCrime.sol +++ b/oapp/contracts/precrime/interfaces/IPreCrime.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; struct PreCrimePeer { uint32 eid; bytes32 preCrime; diff --git a/oapp/contracts/precrime/libs/Packet.sol b/oapp/contracts/precrime/libs/Packet.sol index 4af4cfc..dc4dd39 100644 --- a/oapp/contracts/precrime/libs/Packet.sol +++ b/oapp/contracts/precrime/libs/Packet.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol"; import { PacketV1Codec } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/PacketV1Codec.sol"; diff --git a/oapp/test/OFT.t.sol b/oapp/test/OFT.t.sol index d4aeb7d..8e00e9a 100644 --- a/oapp/test/OFT.t.sol +++ b/oapp/test/OFT.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { OptionsBuilder } from "../contracts/oapp/libs/OptionsBuilder.sol"; diff --git a/oapp/test/TestHelper.sol b/oapp/test/TestHelper.sol index b434d6f..cf868ce 100644 --- a/oapp/test/TestHelper.sol +++ b/oapp/test/TestHelper.sol @@ -51,7 +51,7 @@ contract TestHelper is Test, OptionsHelper { uint256 public constant TREASURY_GAS_CAP = 1000000000000; uint256 public constant TREASURY_GAS_FOR_FEE_CAP = 100000; - + uint128 public executorValueCap = 0.1 ether; function setUp() public virtual {} diff --git a/oapp/test/mocks/ERC20Mock.sol b/oapp/test/mocks/ERC20Mock.sol index 6f0e76c..6ce17e4 100644 --- a/oapp/test/mocks/ERC20Mock.sol +++ b/oapp/test/mocks/ERC20Mock.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; diff --git a/oapp/test/mocks/ExecutorFeeLibMock.sol b/oapp/test/mocks/ExecutorFeeLibMock.sol index a2be7f4..b0b8365 100644 --- a/oapp/test/mocks/ExecutorFeeLibMock.sol +++ b/oapp/test/mocks/ExecutorFeeLibMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { ExecutorFeeLib } from "@layerzerolabs/lz-evm-messagelib-v2/contracts/ExecutorFeeLib.sol"; diff --git a/protocol/contracts/EndpointV2.sol b/protocol/contracts/EndpointV2.sol index d8e5c9a..cc0d738 100644 --- a/protocol/contracts/EndpointV2.sol +++ b/protocol/contracts/EndpointV2.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; diff --git a/protocol/contracts/EndpointV2Alt.sol b/protocol/contracts/EndpointV2Alt.sol index d4d2d6f..4750ca2 100644 --- a/protocol/contracts/EndpointV2Alt.sol +++ b/protocol/contracts/EndpointV2Alt.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; diff --git a/protocol/contracts/MessageLibManager.sol b/protocol/contracts/MessageLibManager.sol index c47bf44..89a6292 100644 --- a/protocol/contracts/MessageLibManager.sol +++ b/protocol/contracts/MessageLibManager.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; diff --git a/protocol/contracts/MessagingChannel.sol b/protocol/contracts/MessagingChannel.sol index 3956ad9..5661bc2 100644 --- a/protocol/contracts/MessagingChannel.sol +++ b/protocol/contracts/MessagingChannel.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { IMessagingChannel } from "./interfaces/IMessagingChannel.sol"; import { Errors } from "./libs/Errors.sol"; diff --git a/protocol/contracts/MessagingComposer.sol b/protocol/contracts/MessagingComposer.sol index 01cb4d3..f5ce35c 100644 --- a/protocol/contracts/MessagingComposer.sol +++ b/protocol/contracts/MessagingComposer.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { IMessagingComposer } from "./interfaces/IMessagingComposer.sol"; import { ILayerZeroComposer } from "./interfaces/ILayerZeroComposer.sol"; diff --git a/protocol/contracts/MessagingContext.sol b/protocol/contracts/MessagingContext.sol index ec1b074..220dda1 100644 --- a/protocol/contracts/MessagingContext.sol +++ b/protocol/contracts/MessagingContext.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { IMessagingContext } from "./interfaces/IMessagingContext.sol"; import { Errors } from "./libs/Errors.sol"; diff --git a/protocol/contracts/interfaces/ILayerZeroComposer.sol b/protocol/contracts/interfaces/ILayerZeroComposer.sol index a937904..69d577a 100644 --- a/protocol/contracts/interfaces/ILayerZeroComposer.sol +++ b/protocol/contracts/interfaces/ILayerZeroComposer.sol @@ -2,7 +2,18 @@ pragma solidity >=0.8.0; +/** + * @title ILayerZeroComposer + */ interface ILayerZeroComposer { + /** + * @notice Composes a LayerZero message from an OApp. + * @param _from The address initiating the composition, typically the OApp where the lzReceive was called. + * @param _guid The unique identifier for the corresponding LayerZero src/dst tx. + * @param _message The composed message payload in bytes. NOT necessarily the same payload passed via lzReceive. + * @param _executor The address of the executor for the composed message. + * @param _extraData Additional arbitrary data in bytes passed by the entity who executes the lzCompose. + */ function lzCompose( address _from, bytes32 _guid, diff --git a/protocol/contracts/libs/AddressCast.sol b/protocol/contracts/libs/AddressCast.sol index b3b83d3..43e30bd 100644 --- a/protocol/contracts/libs/AddressCast.sol +++ b/protocol/contracts/libs/AddressCast.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Errors } from "./Errors.sol"; diff --git a/protocol/contracts/libs/CalldataBytesLib.sol b/protocol/contracts/libs/CalldataBytesLib.sol index e49cd10..f92a9b7 100644 --- a/protocol/contracts/libs/CalldataBytesLib.sol +++ b/protocol/contracts/libs/CalldataBytesLib.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; library CalldataBytesLib { function toU8(bytes calldata _bytes, uint256 _start) internal pure returns (uint8) { diff --git a/protocol/contracts/libs/Errors.sol b/protocol/contracts/libs/Errors.sol index ef68e81..67e0414 100644 --- a/protocol/contracts/libs/Errors.sol +++ b/protocol/contracts/libs/Errors.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; library Errors { error LzTokenUnavailable(); diff --git a/protocol/contracts/libs/GUID.sol b/protocol/contracts/libs/GUID.sol index 7ca36ad..2737ee7 100644 --- a/protocol/contracts/libs/GUID.sol +++ b/protocol/contracts/libs/GUID.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { AddressCast } from "./AddressCast.sol"; diff --git a/protocol/contracts/libs/Transfer.sol b/protocol/contracts/libs/Transfer.sol index 2a75355..f25b5a1 100644 --- a/protocol/contracts/libs/Transfer.sol +++ b/protocol/contracts/libs/Transfer.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; diff --git a/protocol/contracts/messagelib/BlockedMessageLib.sol b/protocol/contracts/messagelib/BlockedMessageLib.sol index a409749..9711c6e 100644 --- a/protocol/contracts/messagelib/BlockedMessageLib.sol +++ b/protocol/contracts/messagelib/BlockedMessageLib.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; diff --git a/protocol/contracts/messagelib/SimpleMessageLib.sol b/protocol/contracts/messagelib/SimpleMessageLib.sol index bb8b368..c46ad69 100644 --- a/protocol/contracts/messagelib/SimpleMessageLib.sol +++ b/protocol/contracts/messagelib/SimpleMessageLib.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; diff --git a/protocol/contracts/messagelib/libs/BitMaps.sol b/protocol/contracts/messagelib/libs/BitMaps.sol index 944b28e..b720d0e 100644 --- a/protocol/contracts/messagelib/libs/BitMaps.sol +++ b/protocol/contracts/messagelib/libs/BitMaps.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT // modified from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/structs/BitMaps.sol -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; type BitMap256 is uint256; diff --git a/protocol/contracts/messagelib/libs/ExecutorOptions.sol b/protocol/contracts/messagelib/libs/ExecutorOptions.sol index dfa8395..fe55726 100644 --- a/protocol/contracts/messagelib/libs/ExecutorOptions.sol +++ b/protocol/contracts/messagelib/libs/ExecutorOptions.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { CalldataBytesLib } from "../../libs/CalldataBytesLib.sol"; diff --git a/protocol/contracts/messagelib/libs/PacketV1Codec.sol b/protocol/contracts/messagelib/libs/PacketV1Codec.sol index c4d02f7..2ae902b 100644 --- a/protocol/contracts/messagelib/libs/PacketV1Codec.sol +++ b/protocol/contracts/messagelib/libs/PacketV1Codec.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: LZBL-1.2 -pragma solidity ^0.8.22; +pragma solidity ^0.8.20; import { Packet } from "../../interfaces/ISendLib.sol"; import { AddressCast } from "../../libs/AddressCast.sol";