@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.
- package/artifacts/contracts/Executor.sol/Executor.json +20 -20
- package/artifacts/contracts/ExecutorFeeLib.sol/ExecutorFeeLib.json +19 -19
- package/artifacts/contracts/MessageLibBase.sol/MessageLibBase.json +1 -1
- package/artifacts/contracts/PriceFeed.sol/PriceFeed.json +15 -15
- package/artifacts/contracts/ReceiveLibBaseE2.sol/ReceiveLibBaseE2.json +1 -1
- package/artifacts/contracts/SendLibBase.sol/SendLibBase.json +6 -6
- package/artifacts/contracts/SendLibBaseE2.sol/SendLibBaseE2.json +10 -10
- package/artifacts/contracts/Treasury.sol/Treasury.json +9 -9
- package/artifacts/contracts/Worker.sol/Worker.json +18 -18
- package/artifacts/contracts/interfaces/IExecutor.sol/IExecutor.json +3 -3
- package/artifacts/contracts/interfaces/IExecutorFeeLib.sol/IExecutorFeeLib.json +4 -4
- package/artifacts/contracts/interfaces/ILayerZeroPriceFeed.sol/ILayerZeroPriceFeed.json +3 -3
- package/artifacts/contracts/interfaces/IWorker.sol/IWorker.json +3 -3
- package/artifacts/contracts/uln/LzExecutor.sol/IReceiveUlnView.json +35 -0
- package/artifacts/contracts/uln/LzExecutor.sol/LzExecutor.json +279 -20
- package/artifacts/contracts/uln/ReceiveUlnBase.sol/ReceiveUlnBase.json +90 -11
- package/artifacts/contracts/uln/SendUlnBase.sol/SendUlnBase.json +7 -7
- package/artifacts/contracts/uln/UlnBase.sol/UlnBase.json +7 -7
- package/artifacts/contracts/uln/dvn/DVN.sol/DVN.json +31 -31
- package/artifacts/contracts/uln/dvn/DVNFeeLib.sol/DVNFeeLib.json +14 -14
- package/artifacts/contracts/uln/dvn/MultiSig.sol/MultiSig.json +5 -5
- package/artifacts/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapter.sol/CCIPDVNAdapter.json +488 -169
- package/artifacts/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapterFeeLib.sol/CCIPDVNAdapterFeeLib.json +372 -16
- package/artifacts/contracts/uln/dvn/adapters/DVNAdapterBase.sol/DVNAdapterBase.json +419 -93
- package/artifacts/contracts/uln/dvn/adapters/DVNAdapterBase.sol/IReceiveUln.json +34 -0
- package/artifacts/contracts/uln/dvn/adapters/DVNAdapterBase.sol/ISendLibBase.json +30 -0
- package/artifacts/contracts/uln/dvn/adapters/arbitrum/ArbitrumDVNAdapterL1.sol/ArbitrumDVNAdapterL1.json +936 -0
- package/artifacts/contracts/uln/dvn/adapters/arbitrum/ArbitrumDVNAdapterL2.sol/ArbitrumDVNAdapterL2.json +868 -0
- package/artifacts/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapter.sol/AxelarDVNAdapter.json +611 -249
- package/artifacts/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapter.sol/ISendLibBase.json +30 -0
- package/artifacts/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapterFeeLib.sol/AxelarDVNAdapterFeeLib.json +526 -13
- package/artifacts/contracts/uln/dvn/adapters/libs/DVNAdapterMessageCodec.sol/DVNAdapterMessageCodec.json +16 -0
- package/artifacts/contracts/uln/dvn/adapters/optimism/OptimismDVNAdapterL1.sol/OptimismDVNAdapterL1.json +924 -0
- package/artifacts/contracts/uln/dvn/adapters/optimism/OptimismDVNAdapterL2.sol/OptimismDVNAdapterL2.json +891 -0
- package/artifacts/contracts/uln/interfaces/IDVN.sol/IDVN.json +3 -3
- package/artifacts/contracts/uln/interfaces/IDVNFeeLib.sol/IDVNFeeLib.json +1 -1
- package/artifacts/contracts/uln/interfaces/IReceiveUlnE2.sol/IReceiveUlnE2.json +0 -24
- package/artifacts/contracts/uln/interfaces/adapters/IAxelarDVNAdapter.sol/IAxelarDVNAdapter.json +160 -0
- package/artifacts/contracts/uln/interfaces/adapters/IAxelarDVNAdapterFeeLib.sol/IAxelarDVNAdapterFeeLib.json +282 -0
- package/artifacts/contracts/uln/interfaces/adapters/ICCIPDVNAdapter.sol/ICCIPDVNAdapter.json +91 -0
- package/artifacts/contracts/uln/interfaces/adapters/ICCIPDVNAdapterFeeLib.sol/ICCIPDVNAdapterFeeLib.json +290 -0
- package/artifacts/contracts/uln/libs/DVNOptions.sol/DVNOptions.json +4 -4
- package/artifacts/contracts/uln/libs/UlnOptions.sol/UlnOptions.json +7 -7
- package/artifacts/contracts/uln/uln301/AddressSizeConfig.sol/AddressSizeConfig.json +2 -2
- package/artifacts/contracts/uln/uln301/ReceiveLibBaseE1.sol/ReceiveLibBaseE1.json +5 -5
- package/artifacts/contracts/uln/uln301/ReceiveUln301.sol/ReceiveUln301.json +88 -57
- package/artifacts/contracts/uln/uln301/ReceiveUln301View.sol/IReceiveUln301.json +178 -0
- package/artifacts/contracts/uln/uln301/ReceiveUln301View.sol/ReceiveUln301View.json +126 -0
- package/artifacts/contracts/uln/uln301/SendLibBaseE1.sol/SendLibBaseE1.json +15 -15
- package/artifacts/contracts/uln/uln301/SendUln301.sol/SendUln301.json +76 -76
- package/artifacts/contracts/uln/uln301/TreasuryFeeHandler.sol/TreasuryFeeHandler.json +5 -5
- package/artifacts/contracts/uln/uln301/interfaces/IMessageLibE1.sol/IMessageLibE1.json +4 -4
- package/artifacts/contracts/uln/uln302/ReceiveUln302.sol/ReceiveUln302.json +79 -24
- package/artifacts/contracts/uln/uln302/ReceiveUln302View.sol/IReceiveUln302.json +146 -0
- package/artifacts/contracts/uln/uln302/ReceiveUln302View.sol/ReceiveUln302View.json +251 -0
- package/artifacts/contracts/uln/uln302/SendUln302.sol/SendUln302.json +75 -75
- package/artifacts/contracts/upgradeable/WorkerUpgradeable.sol/WorkerUpgradeable.json +18 -18
- package/contracts/ExecutorFeeLib.sol +6 -6
- package/contracts/MessageLibBase.sol +2 -2
- package/contracts/PriceFeed.sol +3 -3
- package/contracts/ReceiveLibBaseE2.sol +0 -26
- package/contracts/SendLibBase.sol +10 -10
- package/contracts/SendLibBaseE2.sol +4 -4
- package/contracts/Treasury.sol +2 -2
- package/contracts/Worker.sol +3 -3
- package/contracts/interfaces/IExecutorFeeLib.sol +4 -4
- package/contracts/interfaces/ILayerZeroPriceFeed.sol +3 -3
- package/contracts/interfaces/IWorker.sol +3 -3
- package/contracts/uln/LzExecutor.sol +51 -19
- package/contracts/uln/ReceiveUlnBase.sol +21 -14
- package/contracts/uln/UlnBase.sol +19 -19
- package/contracts/uln/dvn/DVN.sol +16 -16
- package/contracts/uln/dvn/DVNFeeLib.sol +2 -2
- package/contracts/uln/dvn/MultiSig.sol +13 -13
- package/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapter.sol +95 -97
- package/contracts/uln/dvn/adapters/CCIP/CCIPDVNAdapterFeeLib.sol +64 -2
- package/contracts/uln/dvn/adapters/DVNAdapterBase.sol +74 -124
- package/contracts/uln/dvn/adapters/arbitrum/ArbitrumDVNAdapterL1.sol +126 -0
- package/contracts/uln/dvn/adapters/arbitrum/ArbitrumDVNAdapterL2.sol +50 -0
- package/contracts/uln/dvn/adapters/avalanche/NOTES.md +4 -0
- package/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapter.sol +85 -100
- package/contracts/uln/dvn/adapters/axelar/AxelarDVNAdapterFeeLib.sol +121 -2
- package/contracts/uln/dvn/adapters/libs/DVNAdapterMessageCodec.sol +36 -0
- package/contracts/uln/dvn/adapters/optimism/OptimismDVNAdapterL1.sol +86 -0
- package/contracts/uln/dvn/adapters/optimism/OptimismDVNAdapterL2.sol +58 -0
- package/contracts/uln/interfaces/IDVNFeeLib.sol +1 -1
- package/contracts/uln/interfaces/IReceiveUlnE2.sol +0 -5
- package/contracts/uln/interfaces/adapters/IAxelarDVNAdapter.sol +45 -0
- package/contracts/uln/interfaces/adapters/IAxelarDVNAdapterFeeLib.sol +48 -0
- package/contracts/uln/interfaces/adapters/ICCIPDVNAdapter.sol +30 -0
- package/contracts/uln/interfaces/adapters/ICCIPDVNAdapterFeeLib.sol +45 -0
- package/contracts/uln/libs/DVNOptions.sol +6 -6
- package/contracts/uln/libs/UlnOptions.sol +13 -13
- package/contracts/uln/uln301/AddressSizeConfig.sol +4 -4
- package/contracts/uln/uln301/ReceiveLibBaseE1.sol +4 -4
- package/contracts/uln/uln301/ReceiveUln301.sol +4 -41
- package/contracts/uln/uln301/ReceiveUln301View.sol +89 -0
- package/contracts/uln/uln301/SendLibBaseE1.sol +5 -5
- package/contracts/uln/uln301/SendUln301.sol +3 -3
- package/contracts/uln/uln301/TreasuryFeeHandler.sol +6 -6
- package/contracts/uln/uln301/interfaces/IMessageLibE1.sol +4 -4
- package/contracts/uln/uln302/ReceiveUln302.sol +4 -27
- package/contracts/uln/uln302/ReceiveUln302View.sol +89 -0
- package/contracts/uln/uln302/SendUln302.sol +3 -3
- package/contracts/upgradeable/WorkerUpgradeable.sol +3 -3
- package/package.json +7 -5
- package/artifacts/contracts/uln/dvn/adapters/DVNAdapterFeeLibBase.sol/DVNAdapterFeeLibBase.json +0 -50
- package/artifacts/contracts/uln/interfaces/IDVNAdapterFeeLib.sol/IDVNAdapterFeeLib.json +0 -50
- package/contracts/uln/dvn/adapters/DVNAdapterFeeLibBase.sol +0 -20
- package/contracts/uln/interfaces/IDVNAdapterFeeLib.sol +0 -13
|
@@ -4,39 +4,39 @@
|
|
|
4
4
|
"sourceName": "contracts/upgradeable/WorkerUpgradeable.sol",
|
|
5
5
|
"abi": [
|
|
6
6
|
{
|
|
7
|
-
"inputs": [
|
|
8
|
-
|
|
7
|
+
"inputs": [
|
|
8
|
+
{
|
|
9
|
+
"internalType": "address",
|
|
10
|
+
"name": "_to",
|
|
11
|
+
"type": "address"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"internalType": "uint256",
|
|
15
|
+
"name": "_value",
|
|
16
|
+
"type": "uint256"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"name": "Transfer_NativeFailed",
|
|
9
20
|
"type": "error"
|
|
10
21
|
},
|
|
11
22
|
{
|
|
12
23
|
"inputs": [],
|
|
13
|
-
"name": "
|
|
24
|
+
"name": "Transfer_ToAddressIsZero",
|
|
14
25
|
"type": "error"
|
|
15
26
|
},
|
|
16
27
|
{
|
|
17
28
|
"inputs": [],
|
|
18
|
-
"name": "
|
|
29
|
+
"name": "Worker_NotAllowed",
|
|
19
30
|
"type": "error"
|
|
20
31
|
},
|
|
21
32
|
{
|
|
22
33
|
"inputs": [],
|
|
23
|
-
"name": "
|
|
34
|
+
"name": "Worker_OnlyMessageLib",
|
|
24
35
|
"type": "error"
|
|
25
36
|
},
|
|
26
37
|
{
|
|
27
|
-
"inputs": [
|
|
28
|
-
|
|
29
|
-
"internalType": "address",
|
|
30
|
-
"name": "_to",
|
|
31
|
-
"type": "address"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"internalType": "uint256",
|
|
35
|
-
"name": "_value",
|
|
36
|
-
"type": "uint256"
|
|
37
|
-
}
|
|
38
|
-
],
|
|
39
|
-
"name": "TransferNativeFailed",
|
|
38
|
+
"inputs": [],
|
|
39
|
+
"name": "Worker_RoleRenouncingDisabled",
|
|
40
40
|
"type": "error"
|
|
41
41
|
},
|
|
42
42
|
{
|
|
@@ -106,7 +106,7 @@ contract ExecutorFeeLib is Ownable, IExecutorFeeLib {
|
|
|
106
106
|
bytes calldata _options
|
|
107
107
|
) internal pure returns (uint256 dstAmount, uint256 totalGas) {
|
|
108
108
|
if (_options.length == 0) {
|
|
109
|
-
revert
|
|
109
|
+
revert Executor_NoOptions();
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
uint256 cursor = 0;
|
|
@@ -121,7 +121,7 @@ contract ExecutorFeeLib is Ownable, IExecutorFeeLib {
|
|
|
121
121
|
(uint128 gas, uint128 value) = ExecutorOptions.decodeLzReceiveOption(option);
|
|
122
122
|
|
|
123
123
|
// endpoint v1 does not support lzReceive with value
|
|
124
|
-
if (_v1Eid && value > 0) revert
|
|
124
|
+
if (_v1Eid && value > 0) revert Executor_UnsupportedOptionType(optionType);
|
|
125
125
|
|
|
126
126
|
dstAmount += value;
|
|
127
127
|
totalGas += gas;
|
|
@@ -130,7 +130,7 @@ contract ExecutorFeeLib is Ownable, IExecutorFeeLib {
|
|
|
130
130
|
dstAmount += nativeDropAmount;
|
|
131
131
|
} else if (optionType == ExecutorOptions.OPTION_TYPE_LZCOMPOSE) {
|
|
132
132
|
// endpoint v1 does not support lzCompose
|
|
133
|
-
if (_v1Eid) revert
|
|
133
|
+
if (_v1Eid) revert Executor_UnsupportedOptionType(optionType);
|
|
134
134
|
|
|
135
135
|
(, uint128 gas, uint128 value) = ExecutorOptions.decodeLzComposeOption(option);
|
|
136
136
|
dstAmount += value;
|
|
@@ -138,11 +138,11 @@ contract ExecutorFeeLib is Ownable, IExecutorFeeLib {
|
|
|
138
138
|
} else if (optionType == ExecutorOptions.OPTION_TYPE_ORDERED_EXECUTION) {
|
|
139
139
|
ordered = true;
|
|
140
140
|
} else {
|
|
141
|
-
revert
|
|
141
|
+
revert Executor_UnsupportedOptionType(optionType);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
if (cursor != _options.length) revert
|
|
145
|
-
if (dstAmount > _nativeCap) revert
|
|
144
|
+
if (cursor != _options.length) revert Executor_InvalidExecutorOptions(cursor);
|
|
145
|
+
if (dstAmount > _nativeCap) revert Executor_NativeAmountExceedsCap(dstAmount, _nativeCap);
|
|
146
146
|
|
|
147
147
|
if (ordered) {
|
|
148
148
|
// todo: finalize the premium for ordered
|
|
@@ -7,10 +7,10 @@ abstract contract MessageLibBase {
|
|
|
7
7
|
address internal immutable endpoint;
|
|
8
8
|
uint32 internal immutable localEid;
|
|
9
9
|
|
|
10
|
-
error
|
|
10
|
+
error LZ_MessageLib_OnlyEndpoint();
|
|
11
11
|
|
|
12
12
|
modifier onlyEndpoint() {
|
|
13
|
-
if (endpoint != msg.sender) revert
|
|
13
|
+
if (endpoint != msg.sender) revert LZ_MessageLib_OnlyEndpoint();
|
|
14
14
|
_;
|
|
15
15
|
}
|
|
16
16
|
|
package/contracts/PriceFeed.sol
CHANGED
|
@@ -43,7 +43,7 @@ contract PriceFeed is ILayerZeroPriceFeed, OwnableUpgradeable, Proxied {
|
|
|
43
43
|
modifier onlyPriceUpdater() {
|
|
44
44
|
if (owner() != msg.sender) {
|
|
45
45
|
if (!priceUpdater[msg.sender]) {
|
|
46
|
-
revert
|
|
46
|
+
revert LZ_PriceFeed_OnlyPriceUpdater();
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
_;
|
|
@@ -102,7 +102,7 @@ contract PriceFeed is ILayerZeroPriceFeed, OwnableUpgradeable, Proxied {
|
|
|
102
102
|
uint256 _gas
|
|
103
103
|
) external payable returns (uint256, uint128, uint128, uint128) {
|
|
104
104
|
uint256 fee = getFee(_dstEid, _callDataSize, _gas);
|
|
105
|
-
if (msg.value < fee) revert
|
|
105
|
+
if (msg.value < fee) revert LZ_PriceFeed_InsufficientFee(msg.value, fee);
|
|
106
106
|
return _estimateFeeByEid(_dstEid, _callDataSize, _gas);
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -181,7 +181,7 @@ contract PriceFeed is ILayerZeroPriceFeed, OwnableUpgradeable, Proxied {
|
|
|
181
181
|
} else if (l2Eid == 20132) {
|
|
182
182
|
return 20121; // ethereum-goerli
|
|
183
183
|
}
|
|
184
|
-
revert
|
|
184
|
+
revert LZ_PriceFeed_UnknownL2Eid(l2Eid);
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
function _estimateFeeWithDefaultModel(
|
|
@@ -25,30 +25,4 @@ abstract contract ReceiveLibBaseE2 is MessageLibBase, ERC165, IMessageLib {
|
|
|
25
25
|
function messageLibType() external pure virtual override returns (MessageLibType) {
|
|
26
26
|
return MessageLibType.Receive;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
// ========================= VIEW FUNCTIONS FOR OFFCHAIN ONLY =========================
|
|
30
|
-
// Not involved in any state transition function.
|
|
31
|
-
// ====================================================================================
|
|
32
|
-
|
|
33
|
-
/// @dev checks for endpoint verifiable and endpoint has payload hash
|
|
34
|
-
function _verifiable(
|
|
35
|
-
uint32 _srcEid,
|
|
36
|
-
address _receiver,
|
|
37
|
-
bytes calldata _packetHeader,
|
|
38
|
-
bytes32 _payloadHash
|
|
39
|
-
) internal view returns (bool) {
|
|
40
|
-
Origin memory origin = Origin(_srcEid, _packetHeader.sender(), _packetHeader.nonce());
|
|
41
|
-
|
|
42
|
-
// check endpoint verifiable
|
|
43
|
-
if (!ILayerZeroEndpointV2(endpoint).verifiable(origin, _receiver, address(this), _payloadHash)) return false;
|
|
44
|
-
|
|
45
|
-
// if endpoint.verifiable, also check if the payload hash matches
|
|
46
|
-
// endpoint allows re-verify, check if this payload has already been verified
|
|
47
|
-
if (
|
|
48
|
-
ILayerZeroEndpointV2(endpoint).inboundPayloadHash(_receiver, origin.srcEid, origin.sender, origin.nonce) ==
|
|
49
|
-
_payloadHash
|
|
50
|
-
) return false;
|
|
51
|
-
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
28
|
}
|
|
@@ -48,11 +48,11 @@ abstract contract SendLibBase is MessageLibBase, Ownable {
|
|
|
48
48
|
event ExecutorConfigSet(address oapp, uint32 eid, ExecutorConfig config);
|
|
49
49
|
event TreasuryNativeFeeCapSet(uint256 newTreasuryNativeFeeCap);
|
|
50
50
|
|
|
51
|
-
error
|
|
52
|
-
error
|
|
53
|
-
error
|
|
54
|
-
error
|
|
55
|
-
error
|
|
51
|
+
error LZ_MessageLib_InvalidMessageSize(uint256 actual, uint256 max);
|
|
52
|
+
error LZ_MessageLib_InvalidAmount(uint256 requested, uint256 available);
|
|
53
|
+
error LZ_MessageLib_TransferFailed();
|
|
54
|
+
error LZ_MessageLib_InvalidExecutor();
|
|
55
|
+
error LZ_MessageLib_ZeroMessageSize();
|
|
56
56
|
|
|
57
57
|
constructor(
|
|
58
58
|
address _endpoint,
|
|
@@ -68,8 +68,8 @@ abstract contract SendLibBase is MessageLibBase, Ownable {
|
|
|
68
68
|
for (uint256 i = 0; i < _params.length; ++i) {
|
|
69
69
|
SetDefaultExecutorConfigParam calldata param = _params[i];
|
|
70
70
|
|
|
71
|
-
if (param.config.executor == address(0x0)) revert
|
|
72
|
-
if (param.config.maxMessageSize == 0) revert
|
|
71
|
+
if (param.config.executor == address(0x0)) revert LZ_MessageLib_InvalidExecutor();
|
|
72
|
+
if (param.config.maxMessageSize == 0) revert LZ_MessageLib_ZeroMessageSize();
|
|
73
73
|
|
|
74
74
|
executorConfigs[DEFAULT_CONFIG][param.eid] = param.config;
|
|
75
75
|
}
|
|
@@ -80,7 +80,7 @@ abstract contract SendLibBase is MessageLibBase, Ownable {
|
|
|
80
80
|
function setTreasuryNativeFeeCap(uint256 _newTreasuryNativeFeeCap) external onlyOwner {
|
|
81
81
|
// assert the new value is no greater than the old value
|
|
82
82
|
if (_newTreasuryNativeFeeCap > treasuryNativeFeeCap)
|
|
83
|
-
revert
|
|
83
|
+
revert LZ_MessageLib_InvalidAmount(_newTreasuryNativeFeeCap, treasuryNativeFeeCap);
|
|
84
84
|
treasuryNativeFeeCap = _newTreasuryNativeFeeCap;
|
|
85
85
|
emit TreasuryNativeFeeCapSet(_newTreasuryNativeFeeCap);
|
|
86
86
|
}
|
|
@@ -100,7 +100,7 @@ abstract contract SendLibBase is MessageLibBase, Ownable {
|
|
|
100
100
|
|
|
101
101
|
// ======================= Internal =======================
|
|
102
102
|
function _assertMessageSize(uint256 _actual, uint256 _max) internal pure {
|
|
103
|
-
if (_actual > _max) revert
|
|
103
|
+
if (_actual > _max) revert LZ_MessageLib_InvalidMessageSize(_actual, _max);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
function _payExecutor(
|
|
@@ -227,7 +227,7 @@ abstract contract SendLibBase is MessageLibBase, Ownable {
|
|
|
227
227
|
/// @dev authenticated by msg.sender only
|
|
228
228
|
function _debitFee(uint256 _amount) internal {
|
|
229
229
|
uint256 fee = fees[msg.sender];
|
|
230
|
-
if (_amount > fee) revert
|
|
230
|
+
if (_amount > fee) revert LZ_MessageLib_InvalidAmount(_amount, fee);
|
|
231
231
|
unchecked {
|
|
232
232
|
fees[msg.sender] = fee - _amount;
|
|
233
233
|
}
|
|
@@ -20,8 +20,8 @@ abstract contract SendLibBaseE2 is SendLibBase, ERC165, ISendLib {
|
|
|
20
20
|
event NativeFeeWithdrawn(address worker, address receiver, uint256 amount);
|
|
21
21
|
event LzTokenFeeWithdrawn(address lzToken, address receiver, uint256 amount);
|
|
22
22
|
|
|
23
|
-
error
|
|
24
|
-
error
|
|
23
|
+
error LZ_MessageLib_NotTreasury();
|
|
24
|
+
error LZ_MessageLib_CannotWithdrawAltToken();
|
|
25
25
|
|
|
26
26
|
constructor(
|
|
27
27
|
address _endpoint,
|
|
@@ -75,10 +75,10 @@ abstract contract SendLibBaseE2 is SendLibBase, ERC165, ISendLib {
|
|
|
75
75
|
/// @dev E2 only
|
|
76
76
|
/// @dev treasury only function
|
|
77
77
|
function withdrawLzTokenFee(address _lzToken, address _to, uint256 _amount) external {
|
|
78
|
-
if (msg.sender != treasury) revert
|
|
78
|
+
if (msg.sender != treasury) revert LZ_MessageLib_NotTreasury();
|
|
79
79
|
|
|
80
80
|
// lz token cannot be the same as the native token
|
|
81
|
-
if (ILayerZeroEndpointV2(endpoint).nativeToken() == _lzToken) revert
|
|
81
|
+
if (ILayerZeroEndpointV2(endpoint).nativeToken() == _lzToken) revert LZ_MessageLib_CannotWithdrawAltToken();
|
|
82
82
|
|
|
83
83
|
Transfer.token(_lzToken, _to, _amount);
|
|
84
84
|
|
package/contracts/Treasury.sol
CHANGED
|
@@ -14,7 +14,7 @@ contract Treasury is Ownable, ILayerZeroTreasury {
|
|
|
14
14
|
uint256 public lzTokenFee;
|
|
15
15
|
bool public lzTokenEnabled;
|
|
16
16
|
|
|
17
|
-
error
|
|
17
|
+
error LZ_Treasury_LzTokenNotEnabled();
|
|
18
18
|
|
|
19
19
|
function getFee(
|
|
20
20
|
address /*_sender*/,
|
|
@@ -65,7 +65,7 @@ contract Treasury is Ownable, ILayerZeroTreasury {
|
|
|
65
65
|
|
|
66
66
|
function _getFee(uint256 _totalFee, bool _payInLzToken) internal view returns (uint256) {
|
|
67
67
|
if (_payInLzToken) {
|
|
68
|
-
if (!lzTokenEnabled) revert
|
|
68
|
+
if (!lzTokenEnabled) revert LZ_Treasury_LzTokenNotEnabled();
|
|
69
69
|
return lzTokenFee;
|
|
70
70
|
} else {
|
|
71
71
|
return (_totalFee * nativeBP) / 10000;
|
package/contracts/Worker.sol
CHANGED
|
@@ -58,7 +58,7 @@ abstract contract Worker is AccessControl, Pausable, IWorker {
|
|
|
58
58
|
|
|
59
59
|
modifier onlyAcl(address _sender) {
|
|
60
60
|
if (!hasAcl(_sender)) {
|
|
61
|
-
revert
|
|
61
|
+
revert Worker_NotAllowed();
|
|
62
62
|
}
|
|
63
63
|
_;
|
|
64
64
|
}
|
|
@@ -115,7 +115,7 @@ abstract contract Worker is AccessControl, Pausable, IWorker {
|
|
|
115
115
|
/// @param _to address to withdraw fee to
|
|
116
116
|
/// @param _amount amount to withdraw
|
|
117
117
|
function withdrawFee(address _lib, address _to, uint256 _amount) external onlyRole(ADMIN_ROLE) {
|
|
118
|
-
if (!hasRole(MESSAGE_LIB_ROLE, _lib)) revert
|
|
118
|
+
if (!hasRole(MESSAGE_LIB_ROLE, _lib)) revert Worker_OnlyMessageLib();
|
|
119
119
|
ISendLib(_lib).withdrawFee(_to, _amount);
|
|
120
120
|
emit Withdraw(_lib, _to, _amount);
|
|
121
121
|
}
|
|
@@ -162,6 +162,6 @@ abstract contract Worker is AccessControl, Pausable, IWorker {
|
|
|
162
162
|
|
|
163
163
|
/// @dev overrides AccessControl to disable renouncing of roles
|
|
164
164
|
function renounceRole(bytes32 /*role*/, address /*account*/) public pure override {
|
|
165
|
-
revert
|
|
165
|
+
revert Worker_RoleRenouncingDisabled();
|
|
166
166
|
}
|
|
167
167
|
}
|
|
@@ -13,10 +13,10 @@ interface IExecutorFeeLib {
|
|
|
13
13
|
uint16 defaultMultiplierBps;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
error
|
|
17
|
-
error
|
|
18
|
-
error
|
|
19
|
-
error
|
|
16
|
+
error Executor_NoOptions();
|
|
17
|
+
error Executor_NativeAmountExceedsCap(uint256 amount, uint256 cap);
|
|
18
|
+
error Executor_UnsupportedOptionType(uint8 optionType);
|
|
19
|
+
error Executor_InvalidExecutorOptions(uint256 cursor);
|
|
20
20
|
|
|
21
21
|
function getFeeOnSend(
|
|
22
22
|
FeeParams calldata _params,
|
|
@@ -35,9 +35,9 @@ interface ILayerZeroPriceFeed {
|
|
|
35
35
|
ArbitrumPriceExt extend;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
error
|
|
39
|
-
error
|
|
40
|
-
error
|
|
38
|
+
error LZ_PriceFeed_OnlyPriceUpdater();
|
|
39
|
+
error LZ_PriceFeed_InsufficientFee(uint256 provided, uint256 required);
|
|
40
|
+
error LZ_PriceFeed_UnknownL2Eid(uint32 l2Eid);
|
|
41
41
|
|
|
42
42
|
function nativeTokenPriceUSD() external view returns (uint128);
|
|
43
43
|
|
|
@@ -9,9 +9,9 @@ interface IWorker {
|
|
|
9
9
|
event SetSupportedOptionTypes(uint32 dstEid, uint8[] optionTypes);
|
|
10
10
|
event Withdraw(address lib, address to, uint256 amount);
|
|
11
11
|
|
|
12
|
-
error
|
|
13
|
-
error
|
|
14
|
-
error
|
|
12
|
+
error Worker_NotAllowed();
|
|
13
|
+
error Worker_OnlyMessageLib();
|
|
14
|
+
error Worker_RoleRenouncingDisabled();
|
|
15
15
|
|
|
16
16
|
function setPriceFeed(address _priceFeed) external;
|
|
17
17
|
|
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
pragma solidity ^0.8.20;
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
6
|
+
import { Proxied } from "hardhat-deploy/solc_0.8/proxy/Proxied.sol";
|
|
6
7
|
|
|
7
8
|
import { IReceiveUlnE2 } from "./interfaces/IReceiveUlnE2.sol";
|
|
8
|
-
import { ILayerZeroEndpointV2,
|
|
9
|
+
import { ILayerZeroEndpointV2, Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
|
|
9
10
|
import { Transfer } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/Transfer.sol";
|
|
10
11
|
|
|
11
|
-
import {
|
|
12
|
+
import { ExecutionState, EndpointV2ViewUpgradeable } from "@layerzerolabs/lz-evm-protocol-v2/contracts/EndpointV2ViewUpgradeable.sol";
|
|
13
|
+
|
|
14
|
+
import { VerificationState } from "./uln302/ReceiveUln302View.sol";
|
|
12
15
|
|
|
13
16
|
struct LzReceiveParam {
|
|
14
17
|
Origin origin;
|
|
@@ -25,20 +28,50 @@ struct NativeDropParam {
|
|
|
25
28
|
uint256 _amount;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
interface IReceiveUlnView {
|
|
32
|
+
function verifiable(bytes calldata _packetHeader, bytes32 _payloadHash) external view returns (VerificationState);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
contract LzExecutor is OwnableUpgradeable, EndpointV2ViewUpgradeable, Proxied {
|
|
36
|
+
error LzExecutor_Executed();
|
|
37
|
+
error LzExecutor_Verifying();
|
|
38
|
+
error LzExecutor_ReceiveLibViewNotSet();
|
|
39
|
+
|
|
40
|
+
event NativeWithdrawn(address _to, uint256 _amount);
|
|
41
|
+
event ReceiveLibViewSet(address _receiveLib, address _receiveLibView);
|
|
42
|
+
|
|
43
|
+
address public receiveUln302;
|
|
44
|
+
uint32 public localEid;
|
|
32
45
|
|
|
33
|
-
|
|
34
|
-
|
|
46
|
+
mapping(address receiveLib => address receiveLibView) public receiveLibToView;
|
|
47
|
+
|
|
48
|
+
function initialize(
|
|
49
|
+
address _receiveUln302,
|
|
50
|
+
address _receiveUln302View,
|
|
51
|
+
address _endpoint
|
|
52
|
+
) external proxied initializer {
|
|
53
|
+
__Ownable_init();
|
|
54
|
+
__EndpointV2View_init(_endpoint);
|
|
35
55
|
|
|
36
|
-
constructor(address _receiveUln302, address _endpoint) {
|
|
37
56
|
receiveUln302 = _receiveUln302;
|
|
38
|
-
endpoint = ILayerZeroEndpointV2(_endpoint);
|
|
39
57
|
localEid = endpoint.eid();
|
|
58
|
+
receiveLibToView[_receiveUln302] = _receiveUln302View;
|
|
40
59
|
}
|
|
41
60
|
|
|
61
|
+
// ============================ OnlyOwner ===================================
|
|
62
|
+
|
|
63
|
+
function withdrawNative(address _to, uint256 _amount) external onlyOwner {
|
|
64
|
+
Transfer.native(_to, _amount);
|
|
65
|
+
emit NativeWithdrawn(_to, _amount);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function setReceiveLibView(address _receiveLib, address _receiveLibView) external onlyOwner {
|
|
69
|
+
receiveLibToView[_receiveLib] = _receiveLibView;
|
|
70
|
+
emit ReceiveLibViewSet(_receiveLib, _receiveLibView);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ============================ External ===================================
|
|
74
|
+
|
|
42
75
|
/// @notice process for commit and execute
|
|
43
76
|
/// 1. check if executable, revert if executed, execute if executable
|
|
44
77
|
/// 2. check if verifiable, revert if verifying, commit if verifiable
|
|
@@ -50,8 +83,8 @@ contract LzExecutor is Ownable {
|
|
|
50
83
|
NativeDropParam[] calldata _nativeDropParams
|
|
51
84
|
) external payable {
|
|
52
85
|
/// 1. check if executable, revert if executed
|
|
53
|
-
ExecutionState executionState =
|
|
54
|
-
if (executionState == ExecutionState.Executed) revert
|
|
86
|
+
ExecutionState executionState = executable(_lzReceiveParam.origin, _lzReceiveParam.receiver);
|
|
87
|
+
if (executionState == ExecutionState.Executed) revert LzExecutor_Executed();
|
|
55
88
|
|
|
56
89
|
/// 2. if not executable, check if verifiable, revert if verifying, commit if verifiable
|
|
57
90
|
if (executionState != ExecutionState.Executable) {
|
|
@@ -66,12 +99,15 @@ contract LzExecutor is Ownable {
|
|
|
66
99
|
);
|
|
67
100
|
bytes32 payloadHash = keccak256(abi.encodePacked(_lzReceiveParam.guid, _lzReceiveParam.message));
|
|
68
101
|
|
|
69
|
-
|
|
102
|
+
address receiveLibView = receiveLibToView[receiveLib];
|
|
103
|
+
if (receiveLibView == address(0x0)) revert LzExecutor_ReceiveLibViewNotSet();
|
|
104
|
+
|
|
105
|
+
VerificationState verificationState = IReceiveUlnView(receiveLibView).verifiable(packetHeader, payloadHash);
|
|
70
106
|
if (verificationState == VerificationState.Verifiable) {
|
|
71
107
|
// verification required
|
|
72
108
|
IReceiveUlnE2(receiveLib).commitVerification(packetHeader, payloadHash);
|
|
73
109
|
} else if (verificationState == VerificationState.Verifying) {
|
|
74
|
-
revert
|
|
110
|
+
revert LzExecutor_Verifying();
|
|
75
111
|
}
|
|
76
112
|
}
|
|
77
113
|
|
|
@@ -90,8 +126,4 @@ contract LzExecutor is Ownable {
|
|
|
90
126
|
_lzReceiveParam.extraData
|
|
91
127
|
);
|
|
92
128
|
}
|
|
93
|
-
|
|
94
|
-
function withdrawNative(address _to, uint256 _amount) external onlyOwner {
|
|
95
|
-
Transfer.native(_to, _amount);
|
|
96
|
-
}
|
|
97
129
|
}
|
|
@@ -6,12 +6,6 @@ import { PacketV1Codec } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messa
|
|
|
6
6
|
|
|
7
7
|
import { UlnBase, UlnConfig } from "./UlnBase.sol";
|
|
8
8
|
|
|
9
|
-
enum VerificationState {
|
|
10
|
-
Verifying,
|
|
11
|
-
Verifiable,
|
|
12
|
-
Verified
|
|
13
|
-
}
|
|
14
|
-
|
|
15
9
|
struct Verification {
|
|
16
10
|
bool submitted;
|
|
17
11
|
uint64 confirmations;
|
|
@@ -26,10 +20,23 @@ abstract contract ReceiveUlnBase is UlnBase {
|
|
|
26
20
|
|
|
27
21
|
event PayloadVerified(address dvn, bytes header, uint256 confirmations, bytes32 proofHash);
|
|
28
22
|
|
|
29
|
-
error
|
|
30
|
-
error
|
|
31
|
-
error
|
|
32
|
-
error
|
|
23
|
+
error LZ_ULN_InvalidPacketHeader();
|
|
24
|
+
error LZ_ULN_InvalidPacketVersion();
|
|
25
|
+
error LZ_ULN_InvalidEid();
|
|
26
|
+
error LZ_ULN_Verifying();
|
|
27
|
+
|
|
28
|
+
// ============================ External ===================================
|
|
29
|
+
function verifiable(
|
|
30
|
+
UlnConfig memory _config,
|
|
31
|
+
bytes32 _headerHash,
|
|
32
|
+
bytes32 _payloadHash
|
|
33
|
+
) external view returns (bool) {
|
|
34
|
+
return _checkVerifiable(_config, _headerHash, _payloadHash);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function assertHeader(bytes calldata _packetHeader, uint32 _localEid) external pure {
|
|
38
|
+
_assertHeader(_packetHeader, _localEid);
|
|
39
|
+
}
|
|
33
40
|
|
|
34
41
|
// ============================ Internal ===================================
|
|
35
42
|
/// @dev per DVN signing function
|
|
@@ -51,7 +58,7 @@ abstract contract ReceiveUlnBase is UlnBase {
|
|
|
51
58
|
|
|
52
59
|
function _verifyAndReclaimStorage(UlnConfig memory _config, bytes32 _headerHash, bytes32 _payloadHash) internal {
|
|
53
60
|
if (!_checkVerifiable(_config, _headerHash, _payloadHash)) {
|
|
54
|
-
revert
|
|
61
|
+
revert LZ_ULN_Verifying();
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
// iterate the required DVNs
|
|
@@ -71,11 +78,11 @@ abstract contract ReceiveUlnBase is UlnBase {
|
|
|
71
78
|
|
|
72
79
|
function _assertHeader(bytes calldata _packetHeader, uint32 _localEid) internal pure {
|
|
73
80
|
// assert packet header is of right size 81
|
|
74
|
-
if (_packetHeader.length != 81) revert
|
|
81
|
+
if (_packetHeader.length != 81) revert LZ_ULN_InvalidPacketHeader();
|
|
75
82
|
// assert packet header version is the same as ULN
|
|
76
|
-
if (_packetHeader.version() != PacketV1Codec.PACKET_VERSION) revert
|
|
83
|
+
if (_packetHeader.version() != PacketV1Codec.PACKET_VERSION) revert LZ_ULN_InvalidPacketVersion();
|
|
77
84
|
// assert the packet is for this endpoint
|
|
78
|
-
if (_packetHeader.dstEid() != _localEid) revert
|
|
85
|
+
if (_packetHeader.dstEid() != _localEid) revert LZ_ULN_InvalidEid();
|
|
79
86
|
}
|
|
80
87
|
|
|
81
88
|
/// @dev for verifiable view function
|
|
@@ -33,13 +33,13 @@ abstract contract UlnBase is Ownable {
|
|
|
33
33
|
|
|
34
34
|
mapping(address oapp => mapping(uint32 eid => UlnConfig)) internal ulnConfigs;
|
|
35
35
|
|
|
36
|
-
error
|
|
37
|
-
error
|
|
38
|
-
error
|
|
39
|
-
error
|
|
40
|
-
error
|
|
41
|
-
error
|
|
42
|
-
error
|
|
36
|
+
error LZ_ULN_Unsorted();
|
|
37
|
+
error LZ_ULN_InvalidRequiredDVNCount();
|
|
38
|
+
error LZ_ULN_InvalidOptionalDVNCount();
|
|
39
|
+
error LZ_ULN_AtLeastOneDVN();
|
|
40
|
+
error LZ_ULN_InvalidOptionalDVNThreshold();
|
|
41
|
+
error LZ_ULN_InvalidConfirmations();
|
|
42
|
+
error LZ_ULN_UnsupportedEid(uint32 eid);
|
|
43
43
|
|
|
44
44
|
event DefaultUlnConfigsSet(SetDefaultUlnConfigParam[] params);
|
|
45
45
|
event UlnConfigSet(address oapp, uint32 eid, UlnConfig config);
|
|
@@ -57,9 +57,9 @@ abstract contract UlnBase is Ownable {
|
|
|
57
57
|
SetDefaultUlnConfigParam calldata param = _params[i];
|
|
58
58
|
|
|
59
59
|
// 2.a must not use NIL
|
|
60
|
-
if (param.config.requiredDVNCount == NIL_DVN_COUNT) revert
|
|
61
|
-
if (param.config.optionalDVNCount == NIL_DVN_COUNT) revert
|
|
62
|
-
if (param.config.confirmations == NIL_CONFIRMATIONS) revert
|
|
60
|
+
if (param.config.requiredDVNCount == NIL_DVN_COUNT) revert LZ_ULN_InvalidRequiredDVNCount();
|
|
61
|
+
if (param.config.optionalDVNCount == NIL_DVN_COUNT) revert LZ_ULN_InvalidOptionalDVNCount();
|
|
62
|
+
if (param.config.confirmations == NIL_CONFIRMATIONS) revert LZ_ULN_InvalidConfirmations();
|
|
63
63
|
|
|
64
64
|
// 2.b must have at least one dvn
|
|
65
65
|
_assertAtLeastOneDVN(param.config);
|
|
@@ -138,13 +138,13 @@ abstract contract UlnBase is Ownable {
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
function _assertSupportedEid(uint32 _remoteEid) internal view {
|
|
141
|
-
if (!_isSupportedEid(_remoteEid)) revert
|
|
141
|
+
if (!_isSupportedEid(_remoteEid)) revert LZ_ULN_UnsupportedEid(_remoteEid);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
// ============================ Private ===================================
|
|
145
145
|
|
|
146
146
|
function _assertAtLeastOneDVN(UlnConfig memory _config) private pure {
|
|
147
|
-
if (_config.requiredDVNCount == 0 && _config.optionalDVNThreshold == 0) revert
|
|
147
|
+
if (_config.requiredDVNCount == 0 && _config.optionalDVNThreshold == 0) revert LZ_ULN_AtLeastOneDVN();
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
/// @dev this private function is used in both setDefaultUlnConfigs and setUlnConfig
|
|
@@ -154,10 +154,10 @@ abstract contract UlnBase is Ownable {
|
|
|
154
154
|
// if dvnCount == DEFAULT, dvn list must be empty
|
|
155
155
|
// otherwise, dvnList.length == dvnCount and assert the list is valid
|
|
156
156
|
if (_param.requiredDVNCount == NIL_DVN_COUNT || _param.requiredDVNCount == DEFAULT) {
|
|
157
|
-
if (_param.requiredDVNs.length != 0) revert
|
|
157
|
+
if (_param.requiredDVNs.length != 0) revert LZ_ULN_InvalidRequiredDVNCount();
|
|
158
158
|
} else {
|
|
159
159
|
if (_param.requiredDVNs.length != _param.requiredDVNCount || _param.requiredDVNCount > MAX_COUNT)
|
|
160
|
-
revert
|
|
160
|
+
revert LZ_ULN_InvalidRequiredDVNCount();
|
|
161
161
|
_assertNoDuplicates(_param.requiredDVNs);
|
|
162
162
|
}
|
|
163
163
|
|
|
@@ -170,13 +170,13 @@ abstract contract UlnBase is Ownable {
|
|
|
170
170
|
// a) use a custom 1/1 dvn (practically a required dvn), or
|
|
171
171
|
// b) use a custom 2/3 dvn
|
|
172
172
|
if (_param.optionalDVNCount == NIL_DVN_COUNT || _param.optionalDVNCount == DEFAULT) {
|
|
173
|
-
if (_param.optionalDVNs.length != 0) revert
|
|
174
|
-
if (_param.optionalDVNThreshold != 0) revert
|
|
173
|
+
if (_param.optionalDVNs.length != 0) revert LZ_ULN_InvalidOptionalDVNCount();
|
|
174
|
+
if (_param.optionalDVNThreshold != 0) revert LZ_ULN_InvalidOptionalDVNThreshold();
|
|
175
175
|
} else {
|
|
176
176
|
if (_param.optionalDVNs.length != _param.optionalDVNCount || _param.optionalDVNCount > MAX_COUNT)
|
|
177
|
-
revert
|
|
177
|
+
revert LZ_ULN_InvalidOptionalDVNCount();
|
|
178
178
|
if (_param.optionalDVNThreshold == 0 || _param.optionalDVNThreshold > _param.optionalDVNCount)
|
|
179
|
-
revert
|
|
179
|
+
revert LZ_ULN_InvalidOptionalDVNThreshold();
|
|
180
180
|
_assertNoDuplicates(_param.optionalDVNs);
|
|
181
181
|
}
|
|
182
182
|
// don't assert valid count here, as it needs to be validated along side default config
|
|
@@ -188,7 +188,7 @@ abstract contract UlnBase is Ownable {
|
|
|
188
188
|
address lastDVN = address(0);
|
|
189
189
|
for (uint256 i = 0; i < _dvns.length; i++) {
|
|
190
190
|
address dvn = _dvns[i];
|
|
191
|
-
if (dvn <= lastDVN) revert
|
|
191
|
+
if (dvn <= lastDVN) revert LZ_ULN_Unsorted(); // to ensure no duplicates
|
|
192
192
|
lastDVN = dvn;
|
|
193
193
|
}
|
|
194
194
|
}
|