@layerzerolabs/lz-evm-messagelib-v2 2.0.13 → 2.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/artifacts/contracts/Executor.sol/Executor.json +20 -20
  2. package/artifacts/contracts/ExecutorFeeLib.sol/ExecutorFeeLib.json +19 -19
  3. package/artifacts/contracts/MessageLibBase.sol/MessageLibBase.json +1 -1
  4. package/artifacts/contracts/PriceFeed.sol/PriceFeed.json +15 -15
  5. package/artifacts/contracts/ReceiveLibBaseE2.sol/ReceiveLibBaseE2.json +1 -1
  6. package/artifacts/contracts/SendLibBase.sol/SendLibBase.json +6 -6
  7. package/artifacts/contracts/SendLibBaseE2.sol/SendLibBaseE2.json +10 -10
  8. package/artifacts/contracts/Treasury.sol/Treasury.json +9 -9
  9. package/artifacts/contracts/Worker.sol/Worker.json +18 -18
  10. package/artifacts/contracts/interfaces/IExecutor.sol/IExecutor.json +3 -3
  11. package/artifacts/contracts/interfaces/IExecutorFeeLib.sol/IExecutorFeeLib.json +4 -4
  12. package/artifacts/contracts/interfaces/ILayerZeroPriceFeed.sol/ILayerZeroPriceFeed.json +3 -3
  13. package/artifacts/contracts/interfaces/IWorker.sol/IWorker.json +3 -3
  14. package/artifacts/contracts/uln/LzExecutor.sol/IReceiveUlnView.json +35 -0
  15. package/artifacts/contracts/uln/LzExecutor.sol/LzExecutor.json +279 -20
  16. package/artifacts/contracts/uln/ReceiveUlnBase.sol/ReceiveUlnBase.json +90 -11
  17. package/artifacts/contracts/uln/SendUlnBase.sol/SendUlnBase.json +7 -7
  18. package/artifacts/contracts/uln/UlnBase.sol/UlnBase.json +7 -7
  19. package/artifacts/contracts/uln/dvn/DVN.sol/DVN.json +31 -31
  20. package/artifacts/contracts/uln/dvn/DVNFeeLib.sol/DVNFeeLib.json +14 -14
  21. package/artifacts/contracts/uln/dvn/MultiSig.sol/MultiSig.json +5 -5
  22. package/artifacts/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapter.sol/CCIPDVNAdapter.json +488 -169
  23. package/artifacts/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapterFeeLib.sol/CCIPDVNAdapterFeeLib.json +372 -16
  24. package/artifacts/contracts/uln/dvn/adapters/DVNAdapterBase.sol/DVNAdapterBase.json +419 -93
  25. package/artifacts/contracts/uln/dvn/adapters/DVNAdapterBase.sol/IReceiveUln.json +34 -0
  26. package/artifacts/contracts/uln/dvn/adapters/DVNAdapterBase.sol/ISendLibBase.json +30 -0
  27. package/artifacts/contracts/uln/dvn/adapters/arbitrum/ArbitrumDVNAdapterL1.sol/ArbitrumDVNAdapterL1.json +936 -0
  28. package/artifacts/contracts/uln/dvn/adapters/arbitrum/ArbitrumDVNAdapterL2.sol/ArbitrumDVNAdapterL2.json +868 -0
  29. package/artifacts/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapter.sol/AxelarDVNAdapter.json +611 -249
  30. package/artifacts/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapter.sol/ISendLibBase.json +30 -0
  31. package/artifacts/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapterFeeLib.sol/AxelarDVNAdapterFeeLib.json +526 -13
  32. package/artifacts/contracts/uln/dvn/adapters/libs/DVNAdapterMessageCodec.sol/DVNAdapterMessageCodec.json +16 -0
  33. package/artifacts/contracts/uln/dvn/adapters/optimism/OptimismDVNAdapterL1.sol/OptimismDVNAdapterL1.json +924 -0
  34. package/artifacts/contracts/uln/dvn/adapters/optimism/OptimismDVNAdapterL2.sol/OptimismDVNAdapterL2.json +891 -0
  35. package/artifacts/contracts/uln/interfaces/IDVN.sol/IDVN.json +3 -3
  36. package/artifacts/contracts/uln/interfaces/IDVNFeeLib.sol/IDVNFeeLib.json +1 -1
  37. package/artifacts/contracts/uln/interfaces/IReceiveUlnE2.sol/IReceiveUlnE2.json +0 -24
  38. package/artifacts/contracts/uln/interfaces/adapters/IAxelarDVNAdapter.sol/IAxelarDVNAdapter.json +160 -0
  39. package/artifacts/contracts/uln/interfaces/adapters/IAxelarDVNAdapterFeeLib.sol/IAxelarDVNAdapterFeeLib.json +282 -0
  40. package/artifacts/contracts/uln/interfaces/adapters/ICCIPDVNAdapter.sol/ICCIPDVNAdapter.json +91 -0
  41. package/artifacts/contracts/uln/interfaces/adapters/ICCIPDVNAdapterFeeLib.sol/ICCIPDVNAdapterFeeLib.json +290 -0
  42. package/artifacts/contracts/uln/libs/DVNOptions.sol/DVNOptions.json +4 -4
  43. package/artifacts/contracts/uln/libs/UlnOptions.sol/UlnOptions.json +7 -7
  44. package/artifacts/contracts/uln/uln301/AddressSizeConfig.sol/AddressSizeConfig.json +2 -2
  45. package/artifacts/contracts/uln/uln301/ReceiveLibBaseE1.sol/ReceiveLibBaseE1.json +5 -5
  46. package/artifacts/contracts/uln/uln301/ReceiveUln301.sol/ReceiveUln301.json +88 -57
  47. package/artifacts/contracts/uln/uln301/ReceiveUln301View.sol/IReceiveUln301.json +178 -0
  48. package/artifacts/contracts/uln/uln301/ReceiveUln301View.sol/ReceiveUln301View.json +126 -0
  49. package/artifacts/contracts/uln/uln301/SendLibBaseE1.sol/SendLibBaseE1.json +15 -15
  50. package/artifacts/contracts/uln/uln301/SendUln301.sol/SendUln301.json +76 -76
  51. package/artifacts/contracts/uln/uln301/TreasuryFeeHandler.sol/TreasuryFeeHandler.json +5 -5
  52. package/artifacts/contracts/uln/uln301/interfaces/IMessageLibE1.sol/IMessageLibE1.json +4 -4
  53. package/artifacts/contracts/uln/uln302/ReceiveUln302.sol/ReceiveUln302.json +79 -24
  54. package/artifacts/contracts/uln/uln302/ReceiveUln302View.sol/IReceiveUln302.json +146 -0
  55. package/artifacts/contracts/uln/uln302/ReceiveUln302View.sol/ReceiveUln302View.json +251 -0
  56. package/artifacts/contracts/uln/uln302/SendUln302.sol/SendUln302.json +75 -75
  57. package/artifacts/contracts/upgradeable/WorkerUpgradeable.sol/WorkerUpgradeable.json +18 -18
  58. package/contracts/ExecutorFeeLib.sol +6 -6
  59. package/contracts/MessageLibBase.sol +2 -2
  60. package/contracts/PriceFeed.sol +3 -3
  61. package/contracts/ReceiveLibBaseE2.sol +0 -26
  62. package/contracts/SendLibBase.sol +10 -10
  63. package/contracts/SendLibBaseE2.sol +4 -4
  64. package/contracts/Treasury.sol +2 -2
  65. package/contracts/Worker.sol +3 -3
  66. package/contracts/interfaces/IExecutorFeeLib.sol +4 -4
  67. package/contracts/interfaces/ILayerZeroPriceFeed.sol +3 -3
  68. package/contracts/interfaces/IWorker.sol +3 -3
  69. package/contracts/uln/LzExecutor.sol +51 -19
  70. package/contracts/uln/ReceiveUlnBase.sol +21 -14
  71. package/contracts/uln/UlnBase.sol +19 -19
  72. package/contracts/uln/dvn/DVN.sol +16 -16
  73. package/contracts/uln/dvn/DVNFeeLib.sol +2 -2
  74. package/contracts/uln/dvn/MultiSig.sol +13 -13
  75. package/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapter.sol +95 -97
  76. package/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapterFeeLib.sol +64 -2
  77. package/contracts/uln/dvn/adapters/DVNAdapterBase.sol +74 -124
  78. package/contracts/uln/dvn/adapters/arbitrum/ArbitrumDVNAdapterL1.sol +126 -0
  79. package/contracts/uln/dvn/adapters/arbitrum/ArbitrumDVNAdapterL2.sol +50 -0
  80. package/contracts/uln/dvn/adapters/avalanche/NOTES.md +4 -0
  81. package/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapter.sol +85 -100
  82. package/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapterFeeLib.sol +121 -2
  83. package/contracts/uln/dvn/adapters/libs/DVNAdapterMessageCodec.sol +36 -0
  84. package/contracts/uln/dvn/adapters/optimism/OptimismDVNAdapterL1.sol +86 -0
  85. package/contracts/uln/dvn/adapters/optimism/OptimismDVNAdapterL2.sol +58 -0
  86. package/contracts/uln/interfaces/IDVNFeeLib.sol +1 -1
  87. package/contracts/uln/interfaces/IReceiveUlnE2.sol +0 -5
  88. package/contracts/uln/interfaces/adapters/IAxelarDVNAdapter.sol +45 -0
  89. package/contracts/uln/interfaces/adapters/IAxelarDVNAdapterFeeLib.sol +48 -0
  90. package/contracts/uln/interfaces/adapters/ICCIPDVNAdapter.sol +30 -0
  91. package/contracts/uln/interfaces/adapters/ICCIPDVNAdapterFeeLib.sol +45 -0
  92. package/contracts/uln/libs/DVNOptions.sol +6 -6
  93. package/contracts/uln/libs/UlnOptions.sol +13 -13
  94. package/contracts/uln/uln301/AddressSizeConfig.sol +4 -4
  95. package/contracts/uln/uln301/ReceiveLibBaseE1.sol +4 -4
  96. package/contracts/uln/uln301/ReceiveUln301.sol +4 -41
  97. package/contracts/uln/uln301/ReceiveUln301View.sol +89 -0
  98. package/contracts/uln/uln301/SendLibBaseE1.sol +5 -5
  99. package/contracts/uln/uln301/SendUln301.sol +3 -3
  100. package/contracts/uln/uln301/TreasuryFeeHandler.sol +6 -6
  101. package/contracts/uln/uln301/interfaces/IMessageLibE1.sol +4 -4
  102. package/contracts/uln/uln302/ReceiveUln302.sol +4 -27
  103. package/contracts/uln/uln302/ReceiveUln302View.sol +89 -0
  104. package/contracts/uln/uln302/SendUln302.sol +3 -3
  105. package/contracts/upgradeable/WorkerUpgradeable.sol +3 -3
  106. package/package.json +7 -5
  107. package/artifacts/contracts/uln/dvn/adapters/DVNAdapterFeeLibBase.sol/DVNAdapterFeeLibBase.json +0 -50
  108. package/artifacts/contracts/uln/interfaces/IDVNAdapterFeeLib.sol/IDVNAdapterFeeLib.json +0 -50
  109. package/contracts/uln/dvn/adapters/DVNAdapterFeeLibBase.sol +0 -20
  110. package/contracts/uln/interfaces/IDVNAdapterFeeLib.sol +0 -13
@@ -49,15 +49,15 @@ abstract contract ReceiveLibBaseE1 is MessageLibBase, AddressSizeConfig, ILayerZ
49
49
  event DefaultExecutorsSet(SetDefaultExecutorParam[] params);
50
50
  event ExecutorSet(address oapp, uint32 eid, address executor);
51
51
 
52
- error InvalidExecutor();
53
- error OnlyExecutor();
52
+ error LZ_MessageLib_InvalidExecutor();
53
+ error LZ_MessageLib_OnlyExecutor();
54
54
 
55
55
  constructor(address _endpoint, uint32 _localEid) MessageLibBase(_endpoint, _localEid) {}
56
56
 
57
57
  function setDefaultExecutors(SetDefaultExecutorParam[] calldata _params) external onlyOwner {
58
58
  for (uint256 i = 0; i < _params.length; ++i) {
59
59
  SetDefaultExecutorParam calldata param = _params[i];
60
- if (param.executor == address(0x0)) revert InvalidExecutor();
60
+ if (param.executor == address(0x0)) revert LZ_MessageLib_InvalidExecutor();
61
61
  defaultExecutors[param.eid] = param.executor;
62
62
  }
63
63
  emit DefaultExecutorsSet(_params);
@@ -85,7 +85,7 @@ abstract contract ReceiveLibBaseE1 is MessageLibBase, AddressSizeConfig, ILayerZ
85
85
  // if the executor is malicious, it can make the msg as a storedPayload or fail in the nonBlockingApp
86
86
  // which might result in unintended behaviour and risks, like grieving.
87
87
  // to err on the safe side, we should assert the executor here.
88
- if (msg.sender != getExecutor(_receiver, _srcEid)) revert OnlyExecutor();
88
+ if (msg.sender != getExecutor(_receiver, _srcEid)) revert LZ_MessageLib_OnlyExecutor();
89
89
 
90
90
  if (_receiver.code.length == 0) {
91
91
  /// on chains where EOA has no codes, it will early return and emit InvalidDst event
@@ -3,29 +3,24 @@
3
3
  pragma solidity ^0.8.20;
4
4
 
5
5
  import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";
6
-
7
- import { ILayerZeroEndpoint } from "@layerzerolabs/lz-evm-v1-0.7/contracts/interfaces/ILayerZeroEndpoint.sol";
8
- import { AddressCast } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/AddressCast.sol";
9
- import { ExecutionState } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
10
6
  import { PacketV1Codec } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/PacketV1Codec.sol";
11
7
 
12
8
  import { IUltraLightNode301 } from "./interfaces/IUltraLightNode301.sol";
13
9
  import { ReceiveLibBaseE1 } from "./ReceiveLibBaseE1.sol";
14
- import { VerificationState, ReceiveUlnBase } from "../ReceiveUlnBase.sol";
10
+ import { ReceiveUlnBase } from "../ReceiveUlnBase.sol";
15
11
  import { UlnConfig } from "../UlnBase.sol";
16
12
 
17
13
  /// @dev ULN301 will be deployed on EndpointV1 and is for backward compatibility with ULN302 on EndpointV2. 301 can talk to both 301 and 302
18
14
  /// @dev This is a gluing contract. It simply parses the requests and forward to the super.impl() accordingly.
19
15
  /// @dev In this case, it combines the logic of ReceiveUlnBase and ReceiveLibBaseE1
20
16
  contract ReceiveUln301 is IUltraLightNode301, ReceiveUlnBase, ReceiveLibBaseE1 {
21
- using AddressCast for bytes32;
22
17
  using PacketV1Codec for bytes;
23
18
  using SafeCast for uint32; // for chain ID uint32 to uint16 conversion
24
19
 
25
20
  uint256 internal constant CONFIG_TYPE_EXECUTOR = 1;
26
21
  uint256 internal constant CONFIG_TYPE_ULN = 2;
27
22
 
28
- error InvalidConfigType(uint256 configType);
23
+ error LZ_ULN_InvalidConfigType(uint256 configType);
29
24
 
30
25
  constructor(address _endpoint, uint32 _localEid) ReceiveLibBaseE1(_endpoint, _localEid) {}
31
26
 
@@ -43,7 +38,7 @@ contract ReceiveUln301 is IUltraLightNode301, ReceiveUlnBase, ReceiveLibBaseE1 {
43
38
  } else if (_configType == CONFIG_TYPE_ULN) {
44
39
  _setUlnConfig(_eid, _oapp, abi.decode(_config, (UlnConfig)));
45
40
  } else {
46
- revert InvalidConfigType(_configType);
41
+ revert LZ_ULN_InvalidConfigType(_configType);
47
42
  }
48
43
  }
49
44
 
@@ -78,43 +73,11 @@ contract ReceiveUln301 is IUltraLightNode301, ReceiveUlnBase, ReceiveLibBaseE1 {
78
73
  } else if (_configType == CONFIG_TYPE_ULN) {
79
74
  return abi.encode(getUlnConfig(_oapp, _eid));
80
75
  } else {
81
- revert InvalidConfigType(_configType);
76
+ revert LZ_ULN_InvalidConfigType(_configType);
82
77
  }
83
78
  }
84
79
 
85
80
  function version() external pure returns (uint64 major, uint8 minor, uint8 endpointVersion) {
86
81
  return (3, 0, 1);
87
82
  }
88
-
89
- // ========================= VIEW FUNCTIONS FOR OFFCHAIN ONLY =========================
90
- // Not involved in any state transition function.
91
- // ====================================================================================
92
-
93
- function executable(bytes calldata _packetHeader, bytes32 _payloadHash) public view returns (ExecutionState) {
94
- _assertHeader(_packetHeader, localEid);
95
-
96
- address receiver = _packetHeader.receiverB20();
97
- uint16 srcEid = _packetHeader.srcEid().toUint16();
98
- uint64 nonce = _packetHeader.nonce();
99
-
100
- // executed if nonce less than or equal to inboundNonce
101
- bytes memory path = abi.encodePacked(_packetHeader.sender().toBytes(addressSizes[srcEid]), receiver);
102
- if (nonce <= ILayerZeroEndpoint(endpoint).getInboundNonce(srcEid, path)) return ExecutionState.Executed;
103
-
104
- // executable if not executed and _verified
105
- if (_checkVerifiable(getUlnConfig(receiver, srcEid), keccak256(_packetHeader), _payloadHash)) {
106
- return ExecutionState.Executable;
107
- }
108
-
109
- return ExecutionState.NotExecutable;
110
- }
111
-
112
- /// @dev keeping the same interface as 302
113
- /// @dev a verifiable message requires it to be ULN verifiable only, excluding the endpoint verifiable check
114
- function verifiable(bytes calldata _packetHeader, bytes32 _payloadHash) external view returns (VerificationState) {
115
- if (executable(_packetHeader, _payloadHash) == ExecutionState.NotExecutable) {
116
- return VerificationState.Verifying;
117
- }
118
- return VerificationState.Verified;
119
- }
120
83
  }
@@ -0,0 +1,89 @@
1
+ // SPDX-License-Identifier: LZBL-1.2
2
+
3
+ pragma solidity ^0.8.20;
4
+
5
+ import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";
6
+ import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
7
+ import { Proxied } from "hardhat-deploy/solc_0.8/proxy/Proxied.sol";
8
+
9
+ import { ILayerZeroEndpoint } from "@layerzerolabs/lz-evm-v1-0.7/contracts/interfaces/ILayerZeroEndpoint.sol";
10
+ import { AddressCast } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/AddressCast.sol";
11
+ import { PacketV1Codec } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/PacketV1Codec.sol";
12
+ import { ExecutionState, EndpointV2View } from "@layerzerolabs/lz-evm-protocol-v2/contracts/EndpointV2View.sol";
13
+
14
+ import { UlnConfig } from "../UlnBase.sol";
15
+
16
+ enum VerificationState {
17
+ Verifying,
18
+ Verifiable,
19
+ Verified
20
+ }
21
+
22
+ interface IReceiveUln301 {
23
+ function assertHeader(bytes calldata _packetHeader, uint32 _localEid) external pure;
24
+
25
+ function addressSizes(uint32 _dstEid) external view returns (uint256);
26
+
27
+ function endpoint() external view returns (address);
28
+
29
+ function verifiable(
30
+ UlnConfig memory _config,
31
+ bytes32 _headerHash,
32
+ bytes32 _payloadHash
33
+ ) external view returns (bool);
34
+
35
+ function getUlnConfig(address _oapp, uint32 _remoteEid) external view returns (UlnConfig memory rtnConfig);
36
+ }
37
+
38
+ contract ReceiveUln301View is Initializable, Proxied {
39
+ using PacketV1Codec for bytes;
40
+ using AddressCast for bytes32;
41
+ using SafeCast for uint32;
42
+
43
+ ILayerZeroEndpoint public endpoint;
44
+ IReceiveUln301 public receiveUln301;
45
+ uint32 internal localEid;
46
+
47
+ function initialize(address _endpoint, uint32 _localEid, address _receiveUln301) external proxied initializer {
48
+ receiveUln301 = IReceiveUln301(_receiveUln301);
49
+ endpoint = ILayerZeroEndpoint(_endpoint);
50
+ localEid = _localEid;
51
+ }
52
+
53
+ function executable(bytes calldata _packetHeader, bytes32 _payloadHash) public view returns (ExecutionState) {
54
+ receiveUln301.assertHeader(_packetHeader, localEid);
55
+
56
+ address receiver = _packetHeader.receiverB20();
57
+ uint16 srcEid = _packetHeader.srcEid().toUint16();
58
+ uint64 nonce = _packetHeader.nonce();
59
+
60
+ // executed if nonce less than or equal to inboundNonce
61
+ bytes memory path = abi.encodePacked(
62
+ _packetHeader.sender().toBytes(receiveUln301.addressSizes(srcEid)),
63
+ receiver
64
+ );
65
+ if (nonce <= endpoint.getInboundNonce(srcEid, path)) return ExecutionState.Executed;
66
+
67
+ // executable if not executed and _verified
68
+ if (
69
+ receiveUln301.verifiable(
70
+ receiveUln301.getUlnConfig(receiver, srcEid),
71
+ keccak256(_packetHeader),
72
+ _payloadHash
73
+ )
74
+ ) {
75
+ return ExecutionState.Executable;
76
+ }
77
+
78
+ return ExecutionState.NotExecutable;
79
+ }
80
+
81
+ /// @dev keeping the same interface as 302
82
+ /// @dev a verifiable message requires it to be ULN verifiable only, excluding the endpoint verifiable check
83
+ function verifiable(bytes calldata _packetHeader, bytes32 _payloadHash) external view returns (VerificationState) {
84
+ if (executable(_packetHeader, _payloadHash) == ExecutionState.NotExecutable) {
85
+ return VerificationState.Verifying;
86
+ }
87
+ return VerificationState.Verified;
88
+ }
89
+ }
@@ -68,7 +68,7 @@ abstract contract SendLibBaseE1 is SendLibBase, AddressSizeConfig, IMessageLibE1
68
68
 
69
69
  // pay native fee
70
70
  // assert the user has attached enough native token for this address
71
- if (msg.value < totalNativeFee) revert InsufficientMsgValue();
71
+ if (msg.value < totalNativeFee) revert LZ_MessageLib_InsufficientMsgValue();
72
72
  // refund if they send too much
73
73
  uint256 refundAmt = msg.value - totalNativeFee;
74
74
  if (refundAmt > 0) {
@@ -79,7 +79,7 @@ abstract contract SendLibBaseE1 is SendLibBase, AddressSizeConfig, IMessageLibE1
79
79
  if (lzTokenFee > 0) {
80
80
  // in v2, we let user pass a payInLzToken boolean but always charging the sender
81
81
  // likewise in v1, if _lzTokenPaymentAddress is passed, it must be the sender
82
- if (_lzTokenPaymentAddress != sender) revert LzTokenPaymentAddressMustBeSender();
82
+ if (_lzTokenPaymentAddress != sender) revert LZ_MessageLib_LzTokenPaymentAddressMustBeSender();
83
83
  _payLzTokenFee(sender, lzTokenFee);
84
84
  }
85
85
 
@@ -117,9 +117,9 @@ abstract contract SendLibBaseE1 is SendLibBase, AddressSizeConfig, IMessageLibE1
117
117
  // ======================= Internal =======================
118
118
  /// @dev path = remoteAddress + localAddress.
119
119
  function _assertPath(address _sender, bytes calldata _path, uint256 remoteAddressSize) internal pure {
120
- if (_path.length != 20 + remoteAddressSize) revert InvalidPath();
120
+ if (_path.length != 20 + remoteAddressSize) revert LZ_MessageLib_InvalidPath();
121
121
  address srcInPath = AddressCast.toAddress(_path[remoteAddressSize:]);
122
- if (_sender != srcInPath) revert InvalidSender();
122
+ if (_sender != srcInPath) revert LZ_MessageLib_InvalidSender();
123
123
  }
124
124
 
125
125
  function _payLzTokenFee(address _sender, uint256 _lzTokenFee) internal {
@@ -145,7 +145,7 @@ abstract contract SendLibBaseE1 is SendLibBase, AddressSizeConfig, IMessageLibE1
145
145
  ) internal returns (Packet memory packet) {
146
146
  // assert toAddress size
147
147
  uint256 remoteAddressSize = addressSizes[_dstEid];
148
- if (remoteAddressSize == 0) revert InvalidPath();
148
+ if (remoteAddressSize == 0) revert LZ_MessageLib_InvalidPath();
149
149
  _assertPath(_sender, _path, remoteAddressSize);
150
150
 
151
151
  // increment nonce
@@ -16,7 +16,7 @@ contract SendUln301 is SendUlnBase, SendLibBaseE1 {
16
16
  uint256 internal constant CONFIG_TYPE_EXECUTOR = 1;
17
17
  uint256 internal constant CONFIG_TYPE_ULN = 2;
18
18
 
19
- error InvalidConfigType(uint256 configType);
19
+ error LZ_ULN_InvalidConfigType(uint256 configType);
20
20
 
21
21
  constructor(
22
22
  address _endpoint,
@@ -50,7 +50,7 @@ contract SendUln301 is SendUlnBase, SendLibBaseE1 {
50
50
  } else if (_configType == CONFIG_TYPE_ULN) {
51
51
  _setUlnConfig(_eid, _oapp, abi.decode(_config, (UlnConfig)));
52
52
  } else {
53
- revert InvalidConfigType(_configType);
53
+ revert LZ_ULN_InvalidConfigType(_configType);
54
54
  }
55
55
  }
56
56
 
@@ -62,7 +62,7 @@ contract SendUln301 is SendUlnBase, SendLibBaseE1 {
62
62
  } else if (_configType == CONFIG_TYPE_ULN) {
63
63
  return abi.encode(getUlnConfig(_oapp, _eid));
64
64
  } else {
65
- revert InvalidConfigType(_configType);
65
+ revert LZ_ULN_InvalidConfigType(_configType);
66
66
  }
67
67
  }
68
68
 
@@ -14,9 +14,9 @@ contract TreasuryFeeHandler is ITreasuryFeeHandler {
14
14
 
15
15
  ILayerZeroEndpoint public immutable endpoint;
16
16
 
17
- error OnlySendLibrary();
18
- error OnlyOnSending();
19
- error InvalidAmount(uint256 required, uint256 supplied);
17
+ error LZ_TreasuryFeeHandler_OnlySendLibrary();
18
+ error LZ_TreasuryFeeHandler_OnlyOnSending();
19
+ error LZ_TreasuryFeeHandler_InvalidAmount(uint256 required, uint256 supplied);
20
20
 
21
21
  constructor(address _endpoint) {
22
22
  endpoint = ILayerZeroEndpoint(_endpoint);
@@ -31,9 +31,9 @@ contract TreasuryFeeHandler is ITreasuryFeeHandler {
31
31
  address _treasury
32
32
  ) external {
33
33
  // only sender's message library can call this function and only when sending a payload
34
- if (endpoint.getSendLibraryAddress(_sender) != msg.sender) revert OnlySendLibrary();
35
- if (!endpoint.isSendingPayload()) revert OnlyOnSending();
36
- if (_required > _supplied) revert InvalidAmount(_required, _supplied);
34
+ if (endpoint.getSendLibraryAddress(_sender) != msg.sender) revert LZ_TreasuryFeeHandler_OnlySendLibrary();
35
+ if (!endpoint.isSendingPayload()) revert LZ_TreasuryFeeHandler_OnlyOnSending();
36
+ if (_required > _supplied) revert LZ_TreasuryFeeHandler_InvalidAmount(_required, _supplied);
37
37
 
38
38
  // send lz token fee to the treasury directly
39
39
  IERC20(_lzToken).safeTransferFrom(_sender, _treasury, _required);
@@ -6,10 +6,10 @@ import { ILayerZeroMessagingLibrary } from "@layerzerolabs/lz-evm-v1-0.7/contrac
6
6
 
7
7
  /// extends ILayerZeroMessagingLibrary instead of ILayerZeroMessagingLibraryV2 for reducing the contract size
8
8
  interface IMessageLibE1 is ILayerZeroMessagingLibrary {
9
- error InvalidPath();
10
- error InvalidSender();
11
- error InsufficientMsgValue();
12
- error LzTokenPaymentAddressMustBeSender();
9
+ error LZ_MessageLib_InvalidPath();
10
+ error LZ_MessageLib_InvalidSender();
11
+ error LZ_MessageLib_InsufficientMsgValue();
12
+ error LZ_MessageLib_LzTokenPaymentAddressMustBeSender();
13
13
 
14
14
  function setLzToken(address _lzToken) external;
15
15
 
@@ -7,7 +7,7 @@ import { SetConfigParam } from "@layerzerolabs/lz-evm-protocol-v2/contracts/inte
7
7
  import { ILayerZeroEndpointV2, Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
8
8
 
9
9
  import { IReceiveUlnE2 } from "../interfaces/IReceiveUlnE2.sol";
10
- import { VerificationState, ReceiveUlnBase } from "../ReceiveUlnBase.sol";
10
+ import { ReceiveUlnBase } from "../ReceiveUlnBase.sol";
11
11
  import { ReceiveLibBaseE2 } from "../../ReceiveLibBaseE2.sol";
12
12
  import { UlnConfig } from "../UlnBase.sol";
13
13
 
@@ -19,7 +19,7 @@ contract ReceiveUln302 is IReceiveUlnE2, ReceiveUlnBase, ReceiveLibBaseE2 {
19
19
  /// @dev CONFIG_TYPE_ULN=2 here to align with SendUln302/ReceiveUln302/ReceiveUln301
20
20
  uint32 internal constant CONFIG_TYPE_ULN = 2;
21
21
 
22
- error InvalidConfigType(uint32 configType);
22
+ error LZ_ULN_InvalidConfigType(uint32 configType);
23
23
 
24
24
  constructor(address _endpoint) ReceiveLibBaseE2(_endpoint) {}
25
25
 
@@ -37,7 +37,7 @@ contract ReceiveUln302 is IReceiveUlnE2, ReceiveUlnBase, ReceiveLibBaseE2 {
37
37
  if (param.configType == CONFIG_TYPE_ULN) {
38
38
  _setUlnConfig(param.eid, _oapp, abi.decode(param.config, (UlnConfig)));
39
39
  } else {
40
- revert InvalidConfigType(param.configType);
40
+ revert LZ_ULN_InvalidConfigType(param.configType);
41
41
  }
42
42
  }
43
43
  }
@@ -71,7 +71,7 @@ contract ReceiveUln302 is IReceiveUlnE2, ReceiveUlnBase, ReceiveLibBaseE2 {
71
71
  if (_configType == CONFIG_TYPE_ULN) {
72
72
  return abi.encode(getUlnConfig(_oapp, _eid));
73
73
  } else {
74
- revert InvalidConfigType(_configType);
74
+ revert LZ_ULN_InvalidConfigType(_configType);
75
75
  }
76
76
  }
77
77
 
@@ -82,27 +82,4 @@ contract ReceiveUln302 is IReceiveUlnE2, ReceiveUlnBase, ReceiveLibBaseE2 {
82
82
  function version() external pure override returns (uint64 major, uint8 minor, uint8 endpointVersion) {
83
83
  return (3, 0, 2);
84
84
  }
85
-
86
- // ========================= VIEW FUNCTIONS FOR OFFCHAIN ONLY =========================
87
- // Not involved in any state transition function.
88
- // ====================================================================================
89
-
90
- /// @dev a ULN verifiable requires it to be endpoint verifiable and committable
91
- function verifiable(bytes calldata _packetHeader, bytes32 _payloadHash) external view returns (VerificationState) {
92
- _assertHeader(_packetHeader, localEid);
93
-
94
- address receiver = _packetHeader.receiverB20();
95
- uint32 srcEid = _packetHeader.srcEid();
96
-
97
- // check endpoint verifiable
98
- if (!_verifiable(srcEid, receiver, _packetHeader, _payloadHash)) {
99
- return VerificationState.Verified;
100
- }
101
-
102
- // check uln verifiable
103
- if (_checkVerifiable(getUlnConfig(receiver, srcEid), keccak256(_packetHeader), _payloadHash)) {
104
- return VerificationState.Verifiable;
105
- }
106
- return VerificationState.Verifying;
107
- }
108
85
  }
@@ -0,0 +1,89 @@
1
+ // SPDX-License-Identifier: LZBL-1.2
2
+
3
+ pragma solidity ^0.8.20;
4
+
5
+ import { Proxied } from "hardhat-deploy/solc_0.8/proxy/Proxied.sol";
6
+ import { PacketV1Codec } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/PacketV1Codec.sol";
7
+ import { Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
8
+ import { EndpointV2ViewUpgradeable } from "@layerzerolabs/lz-evm-protocol-v2/contracts/EndpointV2ViewUpgradeable.sol";
9
+ import { UlnConfig } from "../UlnBase.sol";
10
+
11
+ enum VerificationState {
12
+ Verifying,
13
+ Verifiable,
14
+ Verified,
15
+ NotInitializable
16
+ }
17
+
18
+ interface IReceiveUln302 {
19
+ function assertHeader(bytes calldata _packetHeader, uint32 _localEid) external pure;
20
+
21
+ function verifiable(
22
+ UlnConfig memory _config,
23
+ bytes32 _headerHash,
24
+ bytes32 _payloadHash
25
+ ) external view returns (bool);
26
+
27
+ function getUlnConfig(address _oapp, uint32 _remoteEid) external view returns (UlnConfig memory rtnConfig);
28
+ }
29
+
30
+ contract ReceiveUln302View is EndpointV2ViewUpgradeable, Proxied {
31
+ using PacketV1Codec for bytes;
32
+
33
+ IReceiveUln302 public receiveUln302;
34
+ uint32 internal localEid;
35
+
36
+ function initialize(address _endpoint, address _receiveUln302) external proxied initializer {
37
+ __EndpointV2View_init(_endpoint);
38
+ receiveUln302 = IReceiveUln302(_receiveUln302);
39
+ localEid = endpoint.eid();
40
+ }
41
+
42
+ /// @dev a ULN verifiable requires it to be endpoint verifiable and committable
43
+ function verifiable(bytes calldata _packetHeader, bytes32 _payloadHash) external view returns (VerificationState) {
44
+ receiveUln302.assertHeader(_packetHeader, localEid);
45
+
46
+ address receiver = _packetHeader.receiverB20();
47
+
48
+ Origin memory origin = Origin(_packetHeader.srcEid(), _packetHeader.sender(), _packetHeader.nonce());
49
+
50
+ // check endpoint initializable
51
+ if (!initializable(origin, receiver)) {
52
+ return VerificationState.NotInitializable;
53
+ }
54
+
55
+ // check endpoint verifiable
56
+ if (!_endpointVerifiable(origin, receiver, _payloadHash)) {
57
+ return VerificationState.Verified;
58
+ }
59
+
60
+ // check uln verifiable
61
+ if (
62
+ receiveUln302.verifiable(
63
+ receiveUln302.getUlnConfig(receiver, origin.srcEid),
64
+ keccak256(_packetHeader),
65
+ _payloadHash
66
+ )
67
+ ) {
68
+ return VerificationState.Verifiable;
69
+ }
70
+ return VerificationState.Verifying;
71
+ }
72
+
73
+ /// @dev checks for endpoint verifiable and endpoint has payload hash
74
+ function _endpointVerifiable(
75
+ Origin memory origin,
76
+ address _receiver,
77
+ bytes32 _payloadHash
78
+ ) internal view returns (bool) {
79
+ // check endpoint verifiable
80
+ if (!verifiable(origin, _receiver, address(receiveUln302), _payloadHash)) return false;
81
+
82
+ // if endpoint.verifiable, also check if the payload hash matches
83
+ // endpoint allows re-verify, check if this payload has already been verified
84
+ if (endpoint.inboundPayloadHash(_receiver, origin.srcEid, origin.sender, origin.nonce) == _payloadHash)
85
+ return false;
86
+
87
+ return true;
88
+ }
89
+ }
@@ -16,7 +16,7 @@ contract SendUln302 is SendUlnBase, SendLibBaseE2 {
16
16
  uint32 internal constant CONFIG_TYPE_EXECUTOR = 1;
17
17
  uint32 internal constant CONFIG_TYPE_ULN = 2;
18
18
 
19
- error InvalidConfigType(uint32 configType);
19
+ error LZ_ULN_InvalidConfigType(uint32 configType);
20
20
 
21
21
  constructor(
22
22
  address _endpoint,
@@ -36,7 +36,7 @@ contract SendUln302 is SendUlnBase, SendLibBaseE2 {
36
36
  } else if (param.configType == CONFIG_TYPE_ULN) {
37
37
  _setUlnConfig(param.eid, _oapp, abi.decode(param.config, (UlnConfig)));
38
38
  } else {
39
- revert InvalidConfigType(param.configType);
39
+ revert LZ_ULN_InvalidConfigType(param.configType);
40
40
  }
41
41
  }
42
42
  }
@@ -49,7 +49,7 @@ contract SendUln302 is SendUlnBase, SendLibBaseE2 {
49
49
  } else if (_configType == CONFIG_TYPE_ULN) {
50
50
  return abi.encode(getUlnConfig(_oapp, _eid));
51
51
  } else {
52
- revert InvalidConfigType(_configType);
52
+ revert LZ_ULN_InvalidConfigType(_configType);
53
53
  }
54
54
  }
55
55
 
@@ -70,7 +70,7 @@ abstract contract WorkerUpgradeable is Initializable, AccessControlUpgradeable,
70
70
 
71
71
  modifier onlyAcl(address _sender) {
72
72
  if (!hasAcl(_sender)) {
73
- revert NotAllowed();
73
+ revert Worker_NotAllowed();
74
74
  }
75
75
  _;
76
76
  }
@@ -127,7 +127,7 @@ abstract contract WorkerUpgradeable is Initializable, AccessControlUpgradeable,
127
127
  /// @param _to address to withdraw fee to
128
128
  /// @param _amount amount to withdraw
129
129
  function withdrawFee(address _lib, address _to, uint256 _amount) external onlyRole(ADMIN_ROLE) {
130
- if (!hasRole(MESSAGE_LIB_ROLE, _lib)) revert OnlyMessageLib();
130
+ if (!hasRole(MESSAGE_LIB_ROLE, _lib)) revert Worker_OnlyMessageLib();
131
131
  ISendLib(_lib).withdrawFee(_to, _amount);
132
132
  emit Withdraw(_lib, _to, _amount);
133
133
  }
@@ -174,7 +174,7 @@ abstract contract WorkerUpgradeable is Initializable, AccessControlUpgradeable,
174
174
 
175
175
  /// @dev overrides AccessControl to disable renouncing of roles
176
176
  function renounceRole(bytes32 /*role*/, address /*account*/) public pure override {
177
- revert RoleRenouncingDisabled();
177
+ revert Worker_RoleRenouncingDisabled();
178
178
  }
179
179
 
180
180
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layerzerolabs/lz-evm-messagelib-v2",
3
- "version": "2.0.13",
3
+ "version": "2.0.15",
4
4
  "license": "LZBL-1.2",
5
5
  "files": [
6
6
  "artifacts/contracts/**/!(*.dbg).json",
@@ -11,8 +11,8 @@
11
11
  },
12
12
  "dependencies": {},
13
13
  "devDependencies": {
14
- "@layerzerolabs/lz-evm-protocol-v2": "^2.0.13",
15
- "@layerzerolabs/lz-evm-v1-0.7": "^2.0.13",
14
+ "@layerzerolabs/lz-evm-protocol-v2": "^2.0.15",
15
+ "@layerzerolabs/lz-evm-v1-0.7": "^2.0.15",
16
16
  "@openzeppelin/contracts": "^4.8.1",
17
17
  "@openzeppelin/contracts-upgradeable": "^4.8.1",
18
18
  "hardhat-deploy": "^0.11.44",
@@ -20,10 +20,12 @@
20
20
  "solidity-bytes-utils": "^0.8.0"
21
21
  },
22
22
  "peerDependencies": {
23
+ "@arbitrum/nitro-contracts": "^1.1.0",
23
24
  "@axelar-network/axelar-gmp-sdk-solidity": "^5.6.3",
24
25
  "@chainlink/contracts-ccip": "^0.7.6",
25
- "@layerzerolabs/lz-evm-protocol-v2": "^2.0.13",
26
- "@layerzerolabs/lz-evm-v1-0.7": "^2.0.13",
26
+ "@eth-optimism/contracts": "^0.6.0",
27
+ "@layerzerolabs/lz-evm-protocol-v2": "^2.0.15",
28
+ "@layerzerolabs/lz-evm-v1-0.7": "^2.0.15",
27
29
  "@openzeppelin/contracts": "^4.8.1",
28
30
  "@openzeppelin/contracts-upgradeable": "^4.8.1",
29
31
  "hardhat-deploy": "^0.11.44",
@@ -1,50 +0,0 @@
1
- {
2
- "_format": "hh-sol-artifact-1",
3
- "contractName": "DVNAdapterFeeLibBase",
4
- "sourceName": "contracts/uln/dvn/adapters/DVNAdapterFeeLibBase.sol",
5
- "abi": [
6
- {
7
- "inputs": [
8
- {
9
- "internalType": "uint32",
10
- "name": "",
11
- "type": "uint32"
12
- },
13
- {
14
- "internalType": "address",
15
- "name": "",
16
- "type": "address"
17
- },
18
- {
19
- "internalType": "uint16",
20
- "name": "_defaultMultiplierBps",
21
- "type": "uint16"
22
- },
23
- {
24
- "internalType": "uint16",
25
- "name": "_multiplierBps",
26
- "type": "uint16"
27
- },
28
- {
29
- "internalType": "uint256",
30
- "name": "_executionFee",
31
- "type": "uint256"
32
- }
33
- ],
34
- "name": "getFee",
35
- "outputs": [
36
- {
37
- "internalType": "uint256",
38
- "name": "fee",
39
- "type": "uint256"
40
- }
41
- ],
42
- "stateMutability": "pure",
43
- "type": "function"
44
- }
45
- ],
46
- "bytecode": "0x608060405234801561001057600080fd5b506101e0806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063212cf54f14610030575b600080fd5b61004361003e3660046100a9565b610055565b60405190815260200160405180910390f35b60008061ffff841615610068578361006a565b845b61ffff16905061271061007d828561012b565b610087919061016f565b979650505050505050565b803561ffff811681146100a457600080fd5b919050565b600080600080600060a086880312156100c157600080fd5b853563ffffffff811681146100d557600080fd5b9450602086013573ffffffffffffffffffffffffffffffffffffffff811681146100fe57600080fd5b935061010c60408701610092565b925061011a60608701610092565b949793965091946080013592915050565b8082028115828204841417610169577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b6000826101a5577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b50049056fea26469706673582212205079d7cb809d22313be9d4cdefde1befec031a875d3ae02d842d9221be0c353264736f6c63430008160033",
47
- "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063212cf54f14610030575b600080fd5b61004361003e3660046100a9565b610055565b60405190815260200160405180910390f35b60008061ffff841615610068578361006a565b845b61ffff16905061271061007d828561012b565b610087919061016f565b979650505050505050565b803561ffff811681146100a457600080fd5b919050565b600080600080600060a086880312156100c157600080fd5b853563ffffffff811681146100d557600080fd5b9450602086013573ffffffffffffffffffffffffffffffffffffffff811681146100fe57600080fd5b935061010c60408701610092565b925061011a60608701610092565b949793965091946080013592915050565b8082028115828204841417610169577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b6000826101a5577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b50049056fea26469706673582212205079d7cb809d22313be9d4cdefde1befec031a875d3ae02d842d9221be0c353264736f6c63430008160033",
48
- "linkReferences": {},
49
- "deployedLinkReferences": {}
50
- }
@@ -1,50 +0,0 @@
1
- {
2
- "_format": "hh-sol-artifact-1",
3
- "contractName": "IDVNAdapterFeeLib",
4
- "sourceName": "contracts/uln/interfaces/IDVNAdapterFeeLib.sol",
5
- "abi": [
6
- {
7
- "inputs": [
8
- {
9
- "internalType": "uint32",
10
- "name": "_dstEid",
11
- "type": "uint32"
12
- },
13
- {
14
- "internalType": "address",
15
- "name": "_sender",
16
- "type": "address"
17
- },
18
- {
19
- "internalType": "uint16",
20
- "name": "_defaultMultiplierBps",
21
- "type": "uint16"
22
- },
23
- {
24
- "internalType": "uint16",
25
- "name": "_multiplierBps",
26
- "type": "uint16"
27
- },
28
- {
29
- "internalType": "uint256",
30
- "name": "_executionFee",
31
- "type": "uint256"
32
- }
33
- ],
34
- "name": "getFee",
35
- "outputs": [
36
- {
37
- "internalType": "uint256",
38
- "name": "fee",
39
- "type": "uint256"
40
- }
41
- ],
42
- "stateMutability": "view",
43
- "type": "function"
44
- }
45
- ],
46
- "bytecode": "0x",
47
- "deployedBytecode": "0x",
48
- "linkReferences": {},
49
- "deployedLinkReferences": {}
50
- }