@layerzerolabs/oapp-upgradeable-evm-contracts 1.2.18 → 1.2.20

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.
@@ -9,6 +9,14 @@ contracts/oapp/alt/OAppAltUpgradeable.sol
9
9
  29:5 warning Missing @notice tag in function '<anonymous>' use-natspec
10
10
  41:5 warning Missing @notice tag in function '_payNative' use-natspec
11
11
 
12
+ contracts/oapp/messaging-channel/OAppMessagingChannelBaseUpgradeable.sol
13
+ 20:74 warning Code contains empty blocks no-empty-blocks
14
+ 26:84 warning Code contains empty blocks no-empty-blocks
15
+
16
+ contracts/oapp/messaging-channel/OAppMessagingChannelRBACUpgradeable.sol
17
+ 35:74 warning Code contains empty blocks no-empty-blocks
18
+ 41:84 warning Code contains empty blocks no-empty-blocks
19
+
12
20
  contracts/oapp/msg-inspection/OAppMsgInspectionBaseUpgradeable.sol
13
21
  29:5 warning Mismatch in @return names for function '_getOAppMsgInspectionStorage'. Expected: [$], Found: [] use-natspec
14
22
  39:71 warning Code contains empty blocks no-empty-blocks
@@ -151,6 +159,107 @@ test/OAppCoreRBACUpgradeable.t.sol
151
159
  107:5 warning Missing @param tag in function 'test_acceptDefaultAdminTransfer_Fuzz' use-natspec
152
160
  107:5 warning Mismatch in @param names for function 'test_acceptDefaultAdminTransfer_Fuzz'. Expected: [_newAdmin], Found: [] use-natspec
153
161
 
162
+ test/OAppMessagingChannelBaseUpgradeable.t.sol
163
+ 2:1 warning Found more than One contract per file. 2 contracts found! one-contract-per-file
164
+ 12:1 warning Missing @title tag in contract 'OAppMessagingChannelBaseHarness' use-natspec
165
+ 12:1 warning Missing @author tag in contract 'OAppMessagingChannelBaseHarness' use-natspec
166
+ 12:1 warning Missing @notice tag in contract 'OAppMessagingChannelBaseHarness' use-natspec
167
+ 13:5 warning Missing @notice tag in function '<anonymous>' use-natspec
168
+ 13:5 warning Missing @param tag in function '<anonymous>' use-natspec
169
+ 13:5 warning Mismatch in @param names for function '<anonymous>'. Expected: [_endpoint], Found: [] use-natspec
170
+ 17:5 warning Missing @notice tag in function 'initialize' use-natspec
171
+ 17:5 warning Missing @param tag in function 'initialize' use-natspec
172
+ 17:5 warning Mismatch in @param names for function 'initialize'. Expected: [_delegate], Found: [] use-natspec
173
+ 21:5 warning Missing @notice tag in function 'oAppVersion' use-natspec
174
+ 21:5 warning Missing @return tag in function 'oAppVersion' use-natspec
175
+ 21:5 warning Mismatch in @return names for function 'oAppVersion'. Expected: [senderVersion, receiverVersion], Found: [] use-natspec
176
+ 25:5 warning Missing @notice tag in function 'allowInitializePath' use-natspec
177
+ 25:5 warning Missing @param tag in function 'allowInitializePath' use-natspec
178
+ 25:5 warning Mismatch in @param names for function 'allowInitializePath'. Expected: [_origin], Found: [] use-natspec
179
+ 25:5 warning Missing @return tag in function 'allowInitializePath' use-natspec
180
+ 25:5 warning Mismatch in @return names for function 'allowInitializePath'. Expected: [isAllowed], Found: [] use-natspec
181
+ 29:5 warning Missing @notice tag in function 'setPeer' use-natspec
182
+ 29:5 warning Missing @param tag in function 'setPeer' use-natspec
183
+ 29:5 warning Mismatch in @param names for function 'setPeer'. Expected: [_eid, _peer], Found: [] use-natspec
184
+ 33:5 warning Missing @notice tag in function 'setDelegate' use-natspec
185
+ 33:5 warning Missing @param tag in function 'setDelegate' use-natspec
186
+ 33:5 warning Mismatch in @param names for function 'setDelegate'. Expected: [_delegate], Found: [] use-natspec
187
+ 37:5 warning Missing @notice tag in function 'clear' use-natspec
188
+ 37:5 warning Missing @param tag in function 'clear' use-natspec
189
+ 37:5 warning Mismatch in @param names for function 'clear'. Expected: [_origin, _guid, _message], Found: [] use-natspec
190
+ 41:5 warning Missing @notice tag in function 'skip' use-natspec
191
+ 41:5 warning Missing @param tag in function 'skip' use-natspec
192
+ 41:5 warning Mismatch in @param names for function 'skip'. Expected: [_srcEid, _sender, _nonce], Found: [] use-natspec
193
+ 45:5 warning Missing @notice tag in function 'burn' use-natspec
194
+ 45:5 warning Missing @param tag in function 'burn' use-natspec
195
+ 45:5 warning Mismatch in @param names for function 'burn'. Expected: [_srcEid, _sender, _nonce, _payloadHash], Found: [] use-natspec
196
+ 49:5 warning Missing @notice tag in function 'nilify' use-natspec
197
+ 49:5 warning Missing @param tag in function 'nilify' use-natspec
198
+ 49:5 warning Mismatch in @param names for function 'nilify'. Expected: [_srcEid, _sender, _nonce, _payloadHash], Found: [] use-natspec
199
+ 54:1 warning Missing @title tag in contract 'OAppMessagingChannelBaseUpgradeableTest' use-natspec
200
+ 54:1 warning Missing @author tag in contract 'OAppMessagingChannelBaseUpgradeableTest' use-natspec
201
+ 54:1 warning Missing @notice tag in contract 'OAppMessagingChannelBaseUpgradeableTest' use-natspec
202
+ 55:5 warning Explicitly mark visibility of state state-visibility
203
+ 56:5 warning Explicitly mark visibility of state state-visibility
204
+ 64:5 warning Missing @notice tag in function '_deployOApp' use-natspec
205
+ 64:5 warning Missing @return tag in function '_deployOApp' use-natspec
206
+ 64:5 warning Mismatch in @return count for function '_deployOApp'. Expected: 1, Found: 0 use-natspec
207
+ 74:5 warning Missing @notice tag in function '_setPeer' use-natspec
208
+ 74:5 warning Missing @param tag in function '_setPeer' use-natspec
209
+ 74:5 warning Mismatch in @param names for function '_setPeer'. Expected: [_eid, _peer], Found: [] use-natspec
210
+ 78:5 warning Missing @notice tag in function 'setUp' use-natspec
211
+ 85:5 warning Missing @notice tag in function '_origin' use-natspec
212
+ 85:5 warning Missing @param tag in function '_origin' use-natspec
213
+ 85:5 warning Mismatch in @param names for function '_origin'. Expected: [_nonce], Found: [] use-natspec
214
+ 85:5 warning Missing @return tag in function '_origin' use-natspec
215
+ 85:5 warning Mismatch in @return names for function '_origin'. Expected: [origin], Found: [] use-natspec
216
+ 89:5 warning Missing @notice tag in function '_verify' use-natspec
217
+ 89:5 warning Missing @param tag in function '_verify' use-natspec
218
+ 89:5 warning Mismatch in @param names for function '_verify'. Expected: [_nonce, _payloadHash], Found: [] use-natspec
219
+ 97:5 warning Missing @notice tag in function 'test_clear' use-natspec
220
+ 109:5 warning Missing @notice tag in function 'test_skip' use-natspec
221
+ 120:5 warning Missing @notice tag in function 'test_burn' use-natspec
222
+ 136:5 warning Missing @notice tag in function 'test_nilify' use-natspec
223
+ 147:5 warning Missing @notice tag in function 'test_nilify_Unverified' use-natspec
224
+
225
+ test/OAppMessagingChannelRBACUpgradeable.t.sol
226
+ 2:1 warning Found more than One contract per file. 2 contracts found! one-contract-per-file
227
+ 16:1 warning Missing @title tag in contract 'OAppMessagingChannelRBACHarness' use-natspec
228
+ 16:1 warning Missing @author tag in contract 'OAppMessagingChannelRBACHarness' use-natspec
229
+ 16:1 warning Missing @notice tag in contract 'OAppMessagingChannelRBACHarness' use-natspec
230
+ 17:5 warning Missing @notice tag in function '<anonymous>' use-natspec
231
+ 17:5 warning Missing @param tag in function '<anonymous>' use-natspec
232
+ 17:5 warning Mismatch in @param names for function '<anonymous>'. Expected: [_endpoint], Found: [] use-natspec
233
+ 21:5 warning Missing @notice tag in function 'initialize' use-natspec
234
+ 21:5 warning Missing @param tag in function 'initialize' use-natspec
235
+ 21:5 warning Mismatch in @param names for function 'initialize'. Expected: [_initialAdmin], Found: [] use-natspec
236
+ 26:5 warning Missing @notice tag in function 'oAppVersion' use-natspec
237
+ 26:5 warning Missing @return tag in function 'oAppVersion' use-natspec
238
+ 26:5 warning Mismatch in @return names for function 'oAppVersion'. Expected: [senderVersion, receiverVersion], Found: [] use-natspec
239
+ 30:5 warning Missing @notice tag in function 'allowInitializePath' use-natspec
240
+ 30:5 warning Missing @param tag in function 'allowInitializePath' use-natspec
241
+ 30:5 warning Mismatch in @param names for function 'allowInitializePath'. Expected: [_origin], Found: [] use-natspec
242
+ 30:5 warning Missing @return tag in function 'allowInitializePath' use-natspec
243
+ 30:5 warning Mismatch in @return names for function 'allowInitializePath'. Expected: [isAllowed], Found: [] use-natspec
244
+ 34:5 warning Missing @notice tag in function 'acceptDefaultAdminTransfer' use-natspec
245
+ 43:1 warning Missing @title tag in contract 'OAppMessagingChannelRBACUpgradeableTest' use-natspec
246
+ 43:1 warning Missing @author tag in contract 'OAppMessagingChannelRBACUpgradeableTest' use-natspec
247
+ 43:1 warning Missing @notice tag in contract 'OAppMessagingChannelRBACUpgradeableTest' use-natspec
248
+ 44:5 warning Explicitly mark visibility of state state-visibility
249
+ 45:5 warning Explicitly mark visibility of state state-visibility
250
+ 46:5 warning Explicitly mark visibility of state state-visibility
251
+ 47:5 warning Explicitly mark visibility of state state-visibility
252
+ 49:5 warning Missing @notice tag in function '_deployOApp' use-natspec
253
+ 49:5 warning Missing @return tag in function '_deployOApp' use-natspec
254
+ 49:5 warning Mismatch in @return count for function '_deployOApp'. Expected: 1, Found: 0 use-natspec
255
+ 60:5 warning Missing @notice tag in function 'setUp' use-natspec
256
+ 72:5 warning Missing @notice tag in function 'test_clear_Revert_Unauthorized' use-natspec
257
+ 84:5 warning Missing @notice tag in function 'test_clear_Revert_NilifierUnauthorized' use-natspec
258
+ 98:5 warning Missing @notice tag in function 'test_skip_Revert_Unauthorized' use-natspec
259
+ 112:5 warning Missing @notice tag in function 'test_burn_Revert_Unauthorized' use-natspec
260
+ 126:5 warning Missing @notice tag in function 'test_nilify_Revert_Unauthorized' use-natspec
261
+ 138:5 warning Missing @notice tag in function 'test_nilify_Revert_ManagerUnauthorized' use-natspec
262
+
154
263
  test/OAppOptionsType3BaseUpgradeable.t.sol
155
264
  2:1 warning Found more than One contract per file. 2 contracts found! one-contract-per-file
156
265
  8:1 warning Import in test/OAppOptionsType3BaseUpgradeable.t.sol doesn't exist in: forge-std/Test.sol import-path-check
@@ -213,7 +322,7 @@ test/OAppOptionsType3RBACUpgradeable.t.sol
213
322
  45:5 warning Missing @notice tag in function 'test_initialize_Revert_AlreadyInitialized' use-natspec
214
323
  52:5 warning Missing @notice tag in function 'test_setEnforcedOptions_Revert_Unauthorized' use-natspec
215
324
 
216
- 180 problems (0 errors, 180 warnings)
325
+ 281 problems (0 errors, 281 warnings)
217
326
 
218
327
  --------------------------------------------------------------------------
219
328
  ===> Join SOLHINT Community at: https://discord.com/invite/4TYGq3zpjs <===
@@ -4,15 +4,15 @@
4
4
 
5
5
  ✅ forge-1.3.6-hardhat-2.26.3
6
6
  🔧 forge version: 1.3.6
7
- 📦 Using scoped workspace: /tmp/lz-scoped-workspace-ufTjtA
7
+ 📦 Using scoped workspace: /tmp/lz-scoped-workspace-pJTU6M
8
8
  📦 Copied 11 workspace package source(s)
9
9
  📦 No scoped-workspace pruner configured; using unpruned package-level source copy fallback.
10
- (node:62746) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/monorepo-internal/monorepo-internal/configs/vm-tooling/values/docker-image-repo.ts is not specified and it doesn't parse as CommonJS.
10
+ (node:61713) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/monorepo-internal/monorepo-internal/configs/vm-tooling/values/docker-image-repo.ts is not specified and it doesn't parse as CommonJS.
11
11
  Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
12
12
  To eliminate this warning, add "type": "module" to /home/runner/work/monorepo-internal/monorepo-internal/package.json.
13
13
  (Use `node --trace-warnings ...` to show where the warning was created)
14
14
  📦 Docker volumes:
15
- -v /tmp/lz-scoped-workspace-ufTjtA:/workspace
15
+ -v /tmp/lz-scoped-workspace-pJTU6M:/workspace
16
16
  -v /home/runner/work/monorepo-internal/monorepo-internal/apps/oapp-app/contracts/evm/upgradeable:/workspace/apps/oapp-app/contracts/evm/upgradeable
17
17
  -v /home/runner/work/monorepo-internal/monorepo-internal/node_modules/.pnpm:/workspace/node_modules/.pnpm:ro
18
18
  $ docker image inspect --format {{.Architecture}} 438003944538.dkr.ecr.us-east-1.amazonaws.com/layerzerolabs/evm-tooling:forge-1.3.6-hardhat-2.26.3-patch-4
@@ -26,7 +26,7 @@ bbd7db620433: Already exists
26
26
  dd8d0adb78c1: Already exists
27
27
  e2082273f6a6: Already exists
28
28
  6aca5ecbfbf0: Already exists
29
- 57cfa89d22f0: Already exists
29
+ 57cfa89d22f0: Pulling fs layer
30
30
  95f21f1a21d0: Pulling fs layer
31
31
  796d60317d4d: Pulling fs layer
32
32
  c35d7f83b6fc: Pulling fs layer
@@ -36,14 +36,21 @@ c8e19a2c627e: Pulling fs layer
36
36
  b79abc894e87: Pulling fs layer
37
37
  63ec365deef1: Pulling fs layer
38
38
  36a7bdc86737: Pulling fs layer
39
- 36a7bdc86737: Download complete
40
- 8f1cde221fc4: Download complete
39
+ 36a7bdc86737: Waiting
41
40
  796d60317d4d: Download complete
42
41
  c35d7f83b6fc: Download complete
43
- b79abc894e87: Download complete
42
+ 8f1cde221fc4: Download complete
44
43
  bcbb9eb73fb5: Download complete
45
- 63ec365deef1: Download complete
46
44
  c8e19a2c627e: Download complete
45
+ 57cfa89d22f0: Pull complete
46
+ 95f21f1a21d0: Verifying Checksum
47
+ 95f21f1a21d0: Download complete
48
+ 36a7bdc86737: Verifying Checksum
49
+ 36a7bdc86737: Download complete
50
+ 63ec365deef1: Verifying Checksum
51
+ 63ec365deef1: Download complete
52
+ b79abc894e87: Verifying Checksum
53
+ b79abc894e87: Download complete
47
54
  95f21f1a21d0: Pull complete
48
55
  796d60317d4d: Pull complete
49
56
  c35d7f83b6fc: Pull complete
@@ -58,63 +65,85 @@ Status: Image is up to date for 438003944538.dkr.ecr.us-east-1.amazonaws.com/lay
58
65
  438003944538.dkr.ecr.us-east-1.amazonaws.com/layerzerolabs/evm-tooling:forge-1.3.6-hardhat-2.26.3-patch-4
59
66
  ✅ Successfully pulled: 438003944538.dkr.ecr.us-east-1.amazonaws.com/layerzerolabs/evm-tooling:forge-1.3.6-hardhat-2.26.3-patch-4
60
67
  👤 Running container as UID:GID 1001:1001
61
- $ docker run --rm --add-host=host.docker.internal:host-gateway -e LOCAL_UID=1001 -e LOCAL_GID=1001 -v /tmp/lz-scoped-workspace-ufTjtA:/workspace -v /home/runner/work/monorepo-internal/monorepo-internal/apps/oapp-app/contracts/evm/upgradeable:/workspace/apps/oapp-app/contracts/evm/upgradeable -v /home/runner/work/monorepo-internal/monorepo-internal/node_modules/.pnpm:/workspace/node_modules/.pnpm:ro -w /workspace/apps/oapp-app/contracts/evm/upgradeable 438003944538.dkr.ecr.us-east-1.amazonaws.com/layerzerolabs/evm-tooling:forge-1.3.6-hardhat-2.26.3-patch-4 forge test
62
- Compiling 150 files with Solc 0.8.22
63
- Solc 0.8.22 finished in 12.95s
68
+ $ docker run --rm --add-host=host.docker.internal:host-gateway -e LOCAL_UID=1001 -e LOCAL_GID=1001 -v /tmp/lz-scoped-workspace-pJTU6M:/workspace -v /home/runner/work/monorepo-internal/monorepo-internal/apps/oapp-app/contracts/evm/upgradeable:/workspace/apps/oapp-app/contracts/evm/upgradeable -v /home/runner/work/monorepo-internal/monorepo-internal/node_modules/.pnpm:/workspace/node_modules/.pnpm:ro -w /workspace/apps/oapp-app/contracts/evm/upgradeable 438003944538.dkr.ecr.us-east-1.amazonaws.com/layerzerolabs/evm-tooling:forge-1.3.6-hardhat-2.26.3-patch-4 forge test
69
+ Compiling 157 files with Solc 0.8.26
70
+ Solc 0.8.26 finished in 11.97s
64
71
  Compiler run successful!
65
72
 
66
- Ran 6 tests for test/OAppCoreRBACUpgradeable.t.sol:OAppCoreRBACUpgradeableTest
67
- [PASS] test_acceptDefaultAdminTransfer() (gas: 107512)
68
- [PASS] test_acceptDefaultAdminTransfer_ChainedTransfers() (gas: 175705)
69
- [PASS] test_acceptDefaultAdminTransfer_Fuzz(address) (runs: 1000, μ: 108498, ~: 108498)
70
- [PASS] test_initialize_SetsDelegate() (gas: 15127)
71
- [PASS] test_setDelegate_Revert_CannotDirectlySetDelegate_Admin() (gas: 15597)
72
- [PASS] test_setDelegate_Revert_CannotDirectlySetDelegate_NonAdmin() (gas: 16016)
73
- Suite result: ok. 6 passed; 0 failed; 0 skipped; finished in 137.03ms (117.42ms CPU time)
73
+ Ran 11 tests for test/OAppMessagingChannelRBACUpgradeable.t.sol:OAppMessagingChannelRBACUpgradeableTest
74
+ [PASS] test_burn() (gas: 80979)
75
+ [PASS] test_burn_Revert_Unauthorized() (gas: 22064)
76
+ [PASS] test_clear() (gas: 74460)
77
+ [PASS] test_clear_Revert_NilifierUnauthorized() (gas: 22574)
78
+ [PASS] test_clear_Revert_Unauthorized() (gas: 22583)
79
+ [PASS] test_nilify() (gas: 72463)
80
+ [PASS] test_nilify_Revert_ManagerUnauthorized() (gas: 22123)
81
+ [PASS] test_nilify_Revert_Unauthorized() (gas: 22090)
82
+ [PASS] test_nilify_Unverified() (gas: 53369)
83
+ [PASS] test_skip() (gas: 52715)
84
+ [PASS] test_skip_Revert_Unauthorized() (gas: 21976)
85
+ Suite result: ok. 11 passed; 0 failed; 0 skipped; finished in 6.03ms (1.75ms CPU time)
74
86
 
75
- Ran 6 tests for test/OAppAltUpgradeable.t.sol:OAppAltUpgradeableTest
76
- [PASS] test_constructor() (gas: 15583)
77
- [PASS] test_constructor_Revert_InvalidNativeToken() (gas: 4353096)
78
- [PASS] test_payNative() (gas: 97285)
79
- [PASS] test_payNative_Fuzz(uint96) (runs: 1000, μ: 99264, ~: 99198)
80
- [PASS] test_payNative_Revert_OnlyAltToken() (gas: 101951)
81
- [PASS] test_payNative_ZeroFee() (gas: 18992)
82
- Suite result: ok. 6 passed; 0 failed; 0 skipped; finished in 137.05ms (134.06ms CPU time)
87
+ Ran 5 tests for test/OAppMessagingChannelBaseUpgradeable.t.sol:OAppMessagingChannelBaseUpgradeableTest
88
+ [PASS] test_burn() (gas: 78214)
89
+ [PASS] test_clear() (gas: 72050)
90
+ [PASS] test_nilify() (gas: 70075)
91
+ [PASS] test_nilify_Unverified() (gas: 50992)
92
+ [PASS] test_skip() (gas: 50360)
93
+ Suite result: ok. 5 passed; 0 failed; 0 skipped; finished in 7.87ms (980.82µs CPU time)
83
94
 
84
- Ran 15 tests for test/OAppOptionsType3RBACUpgradeable.t.sol:OAppOptionsType3RBACUpgradeableTest
85
- [PASS] test_combineOptions_CombinesType3Options() (gas: 58123)
86
- [PASS] test_combineOptions_Fuzz(uint32,uint16,uint128,uint128) (runs: 1000, μ: 60854, ~: 60846)
87
- [PASS] test_combineOptions_Fuzz_Revert_InvalidExtraOptionsType(uint16) (runs: 1000, μ: 53270, ~: 53270)
88
- [PASS] test_combineOptions_NoEnforcedOptions() (gas: 19929)
89
- [PASS] test_combineOptions_NoExtraOptions() (gas: 97207)
90
- [PASS] test_combineOptions_PassthroughAfterReset() (gas: 82507)
91
- [PASS] test_combineOptions_Revert_SingleByteExtraOptions() (gas: 51909)
92
- [PASS] test_enforcedOptions() (gas: 49830)
93
- [PASS] test_enforcedOptions_Empty() (gas: 17366)
94
- [PASS] test_initialize_Revert_AlreadyInitialized() (gas: 17887)
95
- [PASS] test_setEnforcedOptions() (gas: 135089)
96
- [PASS] test_setEnforcedOptions_EmptyOptionsResetsEnforced() (gas: 44862)
97
- [PASS] test_setEnforcedOptions_Fuzz(uint32,uint16,uint128) (runs: 1000, μ: 53638, ~: 53634)
98
- [PASS] test_setEnforcedOptions_Fuzz_Revert_InvalidOptionsType(uint16) (runs: 1000, μ: 20171, ~: 20171)
99
- [PASS] test_setEnforcedOptions_Revert_Unauthorized() (gas: 24948)
100
- Suite result: ok. 15 passed; 0 failed; 0 skipped; finished in 196.38ms (508.68ms CPU time)
95
+ Ran 6 tests for test/OAppAltUpgradeable.t.sol:OAppAltUpgradeableTest
96
+ [PASS] test_constructor() (gas: 15503)
97
+ [PASS] test_constructor_Revert_InvalidNativeToken() (gas: 5016117)
98
+ [PASS] test_payNative() (gas: 96297)
99
+ [PASS] test_payNative_Fuzz(uint96) (runs: 1000, μ: 98429, ~: 98362)
100
+ [PASS] test_payNative_Revert_OnlyAltToken() (gas: 101530)
101
+ [PASS] test_payNative_ZeroFee() (gas: 18704)
102
+ Suite result: ok. 6 passed; 0 failed; 0 skipped; finished in 132.03ms (124.57ms CPU time)
101
103
 
102
104
  Ran 14 tests for test/OAppOptionsType3BaseUpgradeable.t.sol:OAppOptionsType3BaseUpgradeableTest
103
- [PASS] test_combineOptions_CombinesType3Options() (gas: 55506)
104
- [PASS] test_combineOptions_Fuzz(uint32,uint16,uint128,uint128) (runs: 1000, μ: 58345, ~: 58337)
105
- [PASS] test_combineOptions_Fuzz_Revert_InvalidExtraOptionsType(uint16) (runs: 1000, μ: 50697, ~: 50697)
106
- [PASS] test_combineOptions_NoEnforcedOptions() (gas: 19825)
107
- [PASS] test_combineOptions_NoExtraOptions() (gas: 94671)
108
- [PASS] test_combineOptions_PassthroughAfterReset() (gas: 80107)
109
- [PASS] test_combineOptions_Revert_SingleByteExtraOptions() (gas: 49368)
110
- [PASS] test_enforcedOptions() (gas: 47289)
111
- [PASS] test_enforcedOptions_Empty() (gas: 17289)
112
- [PASS] test_initialize_Revert_AlreadyInitialized() (gas: 15583)
113
- [PASS] test_setEnforcedOptions() (gas: 132440)
114
- [PASS] test_setEnforcedOptions_EmptyOptionsResetsEnforced() (gas: 42400)
115
- [PASS] test_setEnforcedOptions_Fuzz(uint32,uint16,uint128) (runs: 1000, μ: 51095, ~: 51093)
116
- [PASS] test_setEnforcedOptions_Fuzz_Revert_InvalidOptionsType(uint16) (runs: 1000, μ: 17649, ~: 17649)
117
- Suite result: ok. 14 passed; 0 failed; 0 skipped; finished in 196.42ms (415.21ms CPU time)
105
+ [PASS] test_combineOptions_CombinesType3Options() (gas: 52612)
106
+ [PASS] test_combineOptions_Fuzz(uint32,uint16,uint128,uint128) (runs: 1000, μ: 55764, ~: 55747)
107
+ [PASS] test_combineOptions_Fuzz_Revert_InvalidExtraOptionsType(uint16) (runs: 1000, μ: 49369, ~: 49369)
108
+ [PASS] test_combineOptions_NoEnforcedOptions() (gas: 19002)
109
+ [PASS] test_combineOptions_NoExtraOptions() (gas: 92961)
110
+ [PASS] test_combineOptions_PassthroughAfterReset() (gas: 78119)
111
+ [PASS] test_combineOptions_Revert_SingleByteExtraOptions() (gas: 48364)
112
+ [PASS] test_enforcedOptions() (gas: 46261)
113
+ [PASS] test_enforcedOptions_Empty() (gas: 17056)
114
+ [PASS] test_initialize_Revert_AlreadyInitialized() (gas: 15511)
115
+ [PASS] test_setEnforcedOptions() (gas: 129551)
116
+ [PASS] test_setEnforcedOptions_EmptyOptionsResetsEnforced() (gas: 41253)
117
+ [PASS] test_setEnforcedOptions_Fuzz(uint32,uint16,uint128) (runs: 1000, μ: 49907, ~: 49900)
118
+ [PASS] test_setEnforcedOptions_Fuzz_Revert_InvalidOptionsType(uint16) (runs: 1000, μ: 16895, ~: 16895)
119
+ Suite result: ok. 14 passed; 0 failed; 0 skipped; finished in 138.57ms (404.06ms CPU time)
120
+
121
+ Ran 6 tests for test/OAppCoreRBACUpgradeable.t.sol:OAppCoreRBACUpgradeableTest
122
+ [PASS] test_acceptDefaultAdminTransfer() (gas: 106631)
123
+ [PASS] test_acceptDefaultAdminTransfer_ChainedTransfers() (gas: 174083)
124
+ [PASS] test_acceptDefaultAdminTransfer_Fuzz(address) (runs: 1000, μ: 107394, ~: 107380)
125
+ [PASS] test_initialize_SetsDelegate() (gas: 15106)
126
+ [PASS] test_setDelegate_Revert_CannotDirectlySetDelegate_Admin() (gas: 15484)
127
+ [PASS] test_setDelegate_Revert_CannotDirectlySetDelegate_NonAdmin() (gas: 15909)
128
+ Suite result: ok. 6 passed; 0 failed; 0 skipped; finished in 141.53ms (137.85ms CPU time)
129
+
130
+ Ran 15 tests for test/OAppOptionsType3RBACUpgradeable.t.sol:OAppOptionsType3RBACUpgradeableTest
131
+ [PASS] test_combineOptions_CombinesType3Options() (gas: 55050)
132
+ [PASS] test_combineOptions_Fuzz(uint32,uint16,uint128,uint128) (runs: 1000, μ: 58200, ~: 58185)
133
+ [PASS] test_combineOptions_Fuzz_Revert_InvalidExtraOptionsType(uint16) (runs: 1000, μ: 51795, ~: 51795)
134
+ [PASS] test_combineOptions_NoEnforcedOptions() (gas: 19051)
135
+ [PASS] test_combineOptions_NoExtraOptions() (gas: 95387)
136
+ [PASS] test_combineOptions_PassthroughAfterReset() (gas: 80364)
137
+ [PASS] test_combineOptions_Revert_SingleByteExtraOptions() (gas: 50790)
138
+ [PASS] test_enforcedOptions() (gas: 48710)
139
+ [PASS] test_enforcedOptions_Empty() (gas: 17124)
140
+ [PASS] test_initialize_Revert_AlreadyInitialized() (gas: 17800)
141
+ [PASS] test_setEnforcedOptions() (gas: 132072)
142
+ [PASS] test_setEnforcedOptions_EmptyOptionsResetsEnforced() (gas: 43568)
143
+ [PASS] test_setEnforcedOptions_Fuzz(uint32,uint16,uint128) (runs: 1000, μ: 52353, ~: 52349)
144
+ [PASS] test_setEnforcedOptions_Fuzz_Revert_InvalidOptionsType(uint16) (runs: 1000, μ: 19270, ~: 19270)
145
+ [PASS] test_setEnforcedOptions_Revert_Unauthorized() (gas: 24036)
146
+ Suite result: ok. 15 passed; 0 failed; 0 skipped; finished in 142.72ms (390.13ms CPU time)
118
147
 
119
- Ran 4 test suites in 206.65ms (666.87ms CPU time): 41 tests passed, 0 failed, 0 skipped (41 total tests)
120
- ⏳ forge test: 16.217s
148
+ Ran 6 test suites in 149.00ms (568.75ms CPU time): 57 tests passed, 0 failed, 0 skipped (57 total tests)
149
+ ⏳ forge test: 15.805s
@@ -0,0 +1,77 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.22;
3
+
4
+ import { Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
5
+ import { OAppCoreBaseUpgradeable } from "./../OAppCoreBaseUpgradeable.sol";
6
+
7
+ /**
8
+ * @title OAppMessagingChannelBaseUpgradeable
9
+ * @author LayerZero Labs (tinom.eth)
10
+ * @custom:version 1.0.0
11
+ * @notice Abstract upgradeable contract that wraps endpoint messaging channel operations.
12
+ * @dev No public management functions are exposed by this contract, wrappers should be used with access control.
13
+ * Alternatively, refer to `OAppMessagingChannelRBACUpgradeable` for a permissioned implementation.
14
+ */
15
+ abstract contract OAppMessagingChannelBaseUpgradeable is OAppCoreBaseUpgradeable {
16
+ /**
17
+ * @notice Initializes the contract.
18
+ * @dev This function is empty on purpose, as no custom logic is needed.
19
+ */
20
+ function __OAppMessagingChannelBase_init() internal onlyInitializing {}
21
+
22
+ /**
23
+ * @notice Unchained initialization function for the contract.
24
+ * @dev This function is empty on purpose, as no custom logic is needed.
25
+ */
26
+ function __OAppMessagingChannelBase_init_unchained() internal onlyInitializing {}
27
+
28
+ // ============ Internal Functions to Wrap with Access Control ============
29
+
30
+ /**
31
+ * @notice Internal function to permanently consume a verified inbound message without the `lzReceive` callback.
32
+ * @dev To be wrapped with access control.
33
+ * @param _origin Origin of the message
34
+ * @param _guid GUID of the message
35
+ * @param _message Message payload
36
+ */
37
+ function _clear(Origin calldata _origin, bytes32 _guid, bytes calldata _message) internal virtual {
38
+ endpoint.clear(address(this), _origin, _guid, _message);
39
+ }
40
+
41
+ /**
42
+ * @notice Internal function to permanently skip the next inbound nonce for a path.
43
+ * @dev To be wrapped with access control.
44
+ * @param _srcEid Source endpoint ID
45
+ * @param _sender Sender address on the source chain
46
+ * @param _nonce Nonce to skip, must equal `inboundNonce + 1`
47
+ */
48
+ function _skip(uint32 _srcEid, bytes32 _sender, uint64 _nonce) internal virtual {
49
+ endpoint.skip(address(this), _srcEid, _sender, _nonce);
50
+ }
51
+
52
+ /**
53
+ * @notice Internal function to permanently burn a verified or nilified inbound nonce so it can never be executed or
54
+ * re-verified.
55
+ * @dev To be wrapped with access control.
56
+ * @param _srcEid Source endpoint ID
57
+ * @param _sender Sender address on the source chain
58
+ * @param _nonce Nonce to burn, must be `<= lazyInboundNonce`
59
+ * @param _payloadHash Expected payload hash for the nonce
60
+ */
61
+ function _burn(uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) internal virtual {
62
+ endpoint.burn(address(this), _srcEid, _sender, _nonce, _payloadHash);
63
+ }
64
+
65
+ /**
66
+ * @notice Internal function to nilify an inbound nonce, preventing execution until it is re-verified.
67
+ * @dev To be wrapped with access control.
68
+ * @dev An unverified nonce can be nilified by passing `bytes32(0)` for `_payloadHash`.
69
+ * @param _srcEid Source endpoint ID
70
+ * @param _sender Sender address on the source chain
71
+ * @param _nonce Nonce to nilify
72
+ * @param _payloadHash Expected payload hash for the nonce
73
+ */
74
+ function _nilify(uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) internal virtual {
75
+ endpoint.nilify(address(this), _srcEid, _sender, _nonce, _payloadHash);
76
+ }
77
+ }
@@ -0,0 +1,88 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.22;
3
+
4
+ import { Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
5
+ import { IOAppMessagingChannel } from "@layerzerolabs/oapp-evm-contracts/contracts/interfaces/IOAppMessagingChannel.sol";
6
+ import { AccessControl2StepUpgradeable } from "@layerzerolabs/utils-upgradeable-evm-contracts/contracts/access/AccessControl2StepUpgradeable.sol";
7
+ import { OAppMessagingChannelBaseUpgradeable } from "./OAppMessagingChannelBaseUpgradeable.sol";
8
+
9
+ /**
10
+ * @title OAppMessagingChannelRBACUpgradeable
11
+ * @author LayerZero Labs (tinom.eth)
12
+ * @custom:version 1.0.0
13
+ * @notice Abstract upgradeable contract that wraps endpoint messaging channel operations with RBAC.
14
+ * @dev Exposes public management functions through `AccessControl2StepUpgradeable`.
15
+ * @dev `MESSAGING_CHANNEL_MANAGER_ROLE` gates non-reversible operations (`clear`, `skip`, `burn`).
16
+ * `MESSAGE_NILIFIER_ROLE` gates the reversible `nilify` operation.
17
+ * @dev `IOAppMessagingChannel` must precede `OAppMessagingChannelBaseUpgradeable` for C3 linearization compatibility
18
+ * with other OApp extensions that place their interfaces before `Initializable`.
19
+ */
20
+ abstract contract OAppMessagingChannelRBACUpgradeable is
21
+ IOAppMessagingChannel,
22
+ OAppMessagingChannelBaseUpgradeable,
23
+ AccessControl2StepUpgradeable
24
+ {
25
+ /// @notice Role for non-reversible messaging channel operations (`clear`, `skip`, `burn`).
26
+ bytes32 public constant MESSAGING_CHANNEL_MANAGER_ROLE = keccak256("MESSAGING_CHANNEL_MANAGER_ROLE");
27
+
28
+ /// @notice Role for the reversible messaging channel operation (`nilify`).
29
+ bytes32 public constant MESSAGE_NILIFIER_ROLE = keccak256("MESSAGE_NILIFIER_ROLE");
30
+
31
+ /**
32
+ * @notice Initializes the contract.
33
+ * @dev This function is empty on purpose, as no custom logic is needed.
34
+ */
35
+ function __OAppMessagingChannelRBAC_init() internal onlyInitializing {}
36
+
37
+ /**
38
+ * @notice Unchained initialization function for the contract.
39
+ * @dev This function is empty on purpose, as no custom logic is needed.
40
+ */
41
+ function __OAppMessagingChannelRBAC_init_unchained() internal onlyInitializing {}
42
+
43
+ /**
44
+ * @inheritdoc IOAppMessagingChannel
45
+ */
46
+ function clear(
47
+ Origin calldata _origin,
48
+ bytes32 _guid,
49
+ bytes calldata _message
50
+ ) public virtual onlyRole(MESSAGING_CHANNEL_MANAGER_ROLE) {
51
+ _clear(_origin, _guid, _message);
52
+ }
53
+
54
+ /**
55
+ * @inheritdoc IOAppMessagingChannel
56
+ */
57
+ function skip(
58
+ uint32 _srcEid,
59
+ bytes32 _sender,
60
+ uint64 _nonce
61
+ ) public virtual onlyRole(MESSAGING_CHANNEL_MANAGER_ROLE) {
62
+ _skip(_srcEid, _sender, _nonce);
63
+ }
64
+
65
+ /**
66
+ * @inheritdoc IOAppMessagingChannel
67
+ */
68
+ function burn(
69
+ uint32 _srcEid,
70
+ bytes32 _sender,
71
+ uint64 _nonce,
72
+ bytes32 _payloadHash
73
+ ) public virtual onlyRole(MESSAGING_CHANNEL_MANAGER_ROLE) {
74
+ _burn(_srcEid, _sender, _nonce, _payloadHash);
75
+ }
76
+
77
+ /**
78
+ * @inheritdoc IOAppMessagingChannel
79
+ */
80
+ function nilify(
81
+ uint32 _srcEid,
82
+ bytes32 _sender,
83
+ uint64 _nonce,
84
+ bytes32 _payloadHash
85
+ ) public virtual onlyRole(MESSAGE_NILIFIER_ROLE) {
86
+ _nilify(_srcEid, _sender, _nonce, _payloadHash);
87
+ }
88
+ }
package/foundry.toml CHANGED
@@ -1,5 +1,5 @@
1
1
  [profile.default]
2
- solc = '0.8.22'
2
+ solc = '0.8.26'
3
3
  verbosity = 3
4
4
  src = "contracts"
5
5
  test = "test"
@@ -7,7 +7,7 @@ out = "out"
7
7
  cache_path = "cache"
8
8
  libs = ['node_modules', 'node_modules/@layerzerolabs/toolbox-foundry/lib']
9
9
  optimizer = true
10
- optimizer_runs = 200
10
+ optimizer_runs = 20_000
11
11
 
12
12
  remappings = [
13
13
  'ds-test/=node_modules/@layerzerolabs/toolbox-foundry/lib/ds-test/',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layerzerolabs/oapp-upgradeable-evm-contracts",
3
- "version": "1.2.18",
3
+ "version": "1.2.20",
4
4
  "private": false,
5
5
  "description": "LayerZero Labs reference EVM upgradeable OApp implementation",
6
6
  "license": "MIT",
@@ -10,17 +10,17 @@
10
10
  "@layerzerolabs/lz-evm-v1-0.7": "3.0.168",
11
11
  "@layerzerolabs/test-devtools-evm-foundry": "8.0.1",
12
12
  "@layerzerolabs/toolbox-foundry": "^0.1.13",
13
- "@openzeppelin/contracts": ">=5.0.2 <5.5.0",
14
- "@openzeppelin/contracts-upgradeable": ">=5.0.2 <5.5.0",
13
+ "@openzeppelin/contracts": "^5.0.2",
14
+ "@openzeppelin/contracts-upgradeable": "^5.0.2",
15
15
  "ethers": "^5.8.0",
16
16
  "solhint": "^6.0.1",
17
17
  "solidity-bytes-utils": "^0.8.4",
18
- "@layerzerolabs/oapp-evm-contracts": "1.2.18",
19
- "@layerzerolabs/test-utils-evm-contracts": "1.2.18",
20
- "@layerzerolabs/solhint-configuration": "1.2.18",
21
- "@layerzerolabs/utils-evm-contracts": "1.2.18",
22
- "@layerzerolabs/utils-upgradeable-evm-contracts": "1.2.18",
23
- "@layerzerolabs/vm-tooling-evm": "1.2.18"
18
+ "@layerzerolabs/oapp-evm-contracts": "1.2.20",
19
+ "@layerzerolabs/utils-evm-contracts": "1.2.20",
20
+ "@layerzerolabs/test-utils-evm-contracts": "1.2.20",
21
+ "@layerzerolabs/utils-upgradeable-evm-contracts": "1.2.20",
22
+ "@layerzerolabs/solhint-configuration": "1.2.20",
23
+ "@layerzerolabs/vm-tooling-evm": "1.2.20"
24
24
  },
25
25
  "publishConfig": {
26
26
  "access": "public",
@@ -0,0 +1,155 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.22;
3
+
4
+ import { Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
5
+ import { IMessagingChannel } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessagingChannel.sol";
6
+ import { EndpointV2Mock } from "@layerzerolabs/test-devtools-evm-foundry/contracts/mocks/EndpointV2Mock.sol";
7
+ import { TestHelperOz5 } from "@layerzerolabs/test-devtools-evm-foundry/contracts/TestHelperOz5.sol";
8
+ import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
9
+ import { OAppMessagingChannelBaseUpgradeable } from "./../contracts/oapp/messaging-channel/OAppMessagingChannelBaseUpgradeable.sol";
10
+ import { OAppCoreBaseUpgradeable } from "./../contracts/oapp/OAppCoreBaseUpgradeable.sol";
11
+
12
+ contract OAppMessagingChannelBaseHarness is OAppMessagingChannelBaseUpgradeable {
13
+ constructor(address _endpoint) OAppCoreBaseUpgradeable(_endpoint) {
14
+ _disableInitializers();
15
+ }
16
+
17
+ function initialize(address _delegate) public initializer {
18
+ __OAppCoreBase_init(_delegate);
19
+ }
20
+
21
+ function oAppVersion() public pure returns (uint64 senderVersion, uint64 receiverVersion) {
22
+ return (1, 1);
23
+ }
24
+
25
+ function allowInitializePath(Origin calldata _origin) public view returns (bool isAllowed) {
26
+ return peers(_origin.srcEid) == _origin.sender;
27
+ }
28
+
29
+ function setPeer(uint32 _eid, bytes32 _peer) public {
30
+ _setPeer(_eid, _peer);
31
+ }
32
+
33
+ function setDelegate(address _delegate) public {
34
+ _setDelegate(_delegate);
35
+ }
36
+
37
+ function clear(Origin calldata _origin, bytes32 _guid, bytes calldata _message) public {
38
+ _clear(_origin, _guid, _message);
39
+ }
40
+
41
+ function skip(uint32 _srcEid, bytes32 _sender, uint64 _nonce) public {
42
+ _skip(_srcEid, _sender, _nonce);
43
+ }
44
+
45
+ function burn(uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) public {
46
+ _burn(_srcEid, _sender, _nonce, _payloadHash);
47
+ }
48
+
49
+ function nilify(uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) public {
50
+ _nilify(_srcEid, _sender, _nonce, _payloadHash);
51
+ }
52
+ }
53
+
54
+ contract OAppMessagingChannelBaseUpgradeableTest is TestHelperOz5 {
55
+ OAppMessagingChannelBaseHarness oapp;
56
+ EndpointV2Mock endpoint;
57
+
58
+ uint32 internal constant SRC_EID = 2;
59
+ bytes32 internal constant SENDER = bytes32(uint256(uint160(address(0xBEEF))));
60
+ bytes32 internal constant PAYLOAD_HASH = keccak256("payload");
61
+ bytes32 internal constant GUID = keccak256("guid");
62
+ bytes internal constant MESSAGE = hex"01";
63
+
64
+ function _deployOApp() internal virtual returns (OAppMessagingChannelBaseHarness) {
65
+ OAppMessagingChannelBaseHarness impl = new OAppMessagingChannelBaseHarness(address(endpoint));
66
+ TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(
67
+ address(impl),
68
+ address(this),
69
+ abi.encodeWithSelector(OAppMessagingChannelBaseHarness.initialize.selector, address(this))
70
+ );
71
+ return OAppMessagingChannelBaseHarness(address(proxy));
72
+ }
73
+
74
+ function _setPeer(uint32 _eid, bytes32 _peer) internal virtual {
75
+ oapp.setPeer(_eid, _peer);
76
+ }
77
+
78
+ function setUp() public virtual override {
79
+ setUpEndpoints(2, LibraryType.UltraLightNode);
80
+ endpoint = endpointSetup.endpointList[0];
81
+ oapp = _deployOApp();
82
+ _setPeer(SRC_EID, SENDER);
83
+ }
84
+
85
+ function _origin(uint64 _nonce) internal pure returns (Origin memory origin) {
86
+ return Origin({ srcEid: SRC_EID, sender: SENDER, nonce: _nonce });
87
+ }
88
+
89
+ function _verify(uint64 _nonce, bytes32 _payloadHash) internal {
90
+ Origin memory origin = _origin(_nonce);
91
+ vm.prank(address(endpointSetup.receiveLibs[0]));
92
+ endpoint.verify(origin, address(oapp), _payloadHash);
93
+ }
94
+
95
+ // ============ clear ============
96
+
97
+ function test_clear() public {
98
+ bytes32 payloadHash = keccak256(abi.encodePacked(GUID, MESSAGE));
99
+ _verify(1, payloadHash);
100
+
101
+ oapp.clear(_origin(1), GUID, MESSAGE);
102
+
103
+ assertEq(endpoint.inboundPayloadHash(address(oapp), SRC_EID, SENDER, 1), bytes32(0));
104
+ assertEq(endpoint.lazyInboundNonce(address(oapp), SRC_EID, SENDER), 1);
105
+ }
106
+
107
+ // ============ skip ============
108
+
109
+ function test_skip() public {
110
+ vm.expectEmit(true, true, true, true, address(endpoint));
111
+ emit IMessagingChannel.InboundNonceSkipped(SRC_EID, SENDER, address(oapp), 1);
112
+
113
+ oapp.skip(SRC_EID, SENDER, 1);
114
+
115
+ assertEq(endpoint.lazyInboundNonce(address(oapp), SRC_EID, SENDER), 1);
116
+ }
117
+
118
+ // ============ burn ============
119
+
120
+ function test_burn() public {
121
+ _verify(1, PAYLOAD_HASH);
122
+
123
+ /// @dev Advance `lazyInboundNonce` past the verified nonce without consuming its payload hash.
124
+ oapp.skip(SRC_EID, SENDER, 2);
125
+
126
+ vm.expectEmit(true, true, true, true, address(endpoint));
127
+ emit IMessagingChannel.PacketBurnt(SRC_EID, SENDER, address(oapp), 1, PAYLOAD_HASH);
128
+
129
+ oapp.burn(SRC_EID, SENDER, 1, PAYLOAD_HASH);
130
+
131
+ assertEq(endpoint.inboundPayloadHash(address(oapp), SRC_EID, SENDER, 1), bytes32(0));
132
+ }
133
+
134
+ // ============ nilify ============
135
+
136
+ function test_nilify() public {
137
+ _verify(1, PAYLOAD_HASH);
138
+
139
+ vm.expectEmit(true, true, true, true, address(endpoint));
140
+ emit IMessagingChannel.PacketNilified(SRC_EID, SENDER, address(oapp), 1, PAYLOAD_HASH);
141
+
142
+ oapp.nilify(SRC_EID, SENDER, 1, PAYLOAD_HASH);
143
+
144
+ assertEq(endpoint.inboundPayloadHash(address(oapp), SRC_EID, SENDER, 1), bytes32(type(uint256).max));
145
+ }
146
+
147
+ function test_nilify_Unverified() public {
148
+ vm.expectEmit(true, true, true, true, address(endpoint));
149
+ emit IMessagingChannel.PacketNilified(SRC_EID, SENDER, address(oapp), 1, bytes32(0));
150
+
151
+ oapp.nilify(SRC_EID, SENDER, 1, bytes32(0));
152
+
153
+ assertEq(endpoint.inboundPayloadHash(address(oapp), SRC_EID, SENDER, 1), bytes32(type(uint256).max));
154
+ }
155
+ }
@@ -0,0 +1,149 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.22;
3
+
4
+ import { Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
5
+ import { AccessControl2StepUpgradeable } from "@layerzerolabs/utils-upgradeable-evm-contracts/contracts/access/AccessControl2StepUpgradeable.sol";
6
+ import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol";
7
+ import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
8
+ import { OAppMessagingChannelRBACUpgradeable } from "./../contracts/oapp/messaging-channel/OAppMessagingChannelRBACUpgradeable.sol";
9
+ import { OAppCoreBaseUpgradeable } from "./../contracts/oapp/OAppCoreBaseUpgradeable.sol";
10
+ import { OAppCoreRBACUpgradeable } from "./../contracts/oapp/OAppCoreRBACUpgradeable.sol";
11
+ import {
12
+ OAppMessagingChannelBaseUpgradeableTest,
13
+ OAppMessagingChannelBaseHarness
14
+ } from "./OAppMessagingChannelBaseUpgradeable.t.sol";
15
+
16
+ contract OAppMessagingChannelRBACHarness is OAppCoreRBACUpgradeable, OAppMessagingChannelRBACUpgradeable {
17
+ constructor(address _endpoint) OAppCoreBaseUpgradeable(_endpoint) {
18
+ _disableInitializers();
19
+ }
20
+
21
+ function initialize(address _initialAdmin) public initializer {
22
+ __OAppCoreBase_init(_initialAdmin);
23
+ __AccessControl2Step_init(_initialAdmin);
24
+ }
25
+
26
+ function oAppVersion() public pure returns (uint64 senderVersion, uint64 receiverVersion) {
27
+ return (1, 1);
28
+ }
29
+
30
+ function allowInitializePath(Origin calldata _origin) public view returns (bool isAllowed) {
31
+ return peers(_origin.srcEid) == _origin.sender;
32
+ }
33
+
34
+ function acceptDefaultAdminTransfer()
35
+ public
36
+ virtual
37
+ override(OAppCoreRBACUpgradeable, AccessControl2StepUpgradeable)
38
+ {
39
+ super.acceptDefaultAdminTransfer();
40
+ }
41
+ }
42
+
43
+ contract OAppMessagingChannelRBACUpgradeableTest is OAppMessagingChannelBaseUpgradeableTest {
44
+ address alice = makeAddr("alice");
45
+ address bob = makeAddr("bob");
46
+ address charlie = makeAddr("charlie");
47
+ OAppMessagingChannelRBACHarness oappRbac;
48
+
49
+ function _deployOApp() internal virtual override returns (OAppMessagingChannelBaseHarness) {
50
+ OAppMessagingChannelRBACHarness impl = new OAppMessagingChannelRBACHarness(address(endpoint));
51
+ TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(
52
+ address(impl),
53
+ address(this),
54
+ abi.encodeWithSelector(OAppMessagingChannelRBACHarness.initialize.selector, address(this))
55
+ );
56
+ oappRbac = OAppMessagingChannelRBACHarness(address(proxy));
57
+ return OAppMessagingChannelBaseHarness(address(proxy));
58
+ }
59
+
60
+ function setUp() public override {
61
+ super.setUp();
62
+
63
+ /// @dev Grant roles to this contract so inherited base tests can call the gated functions.
64
+ oappRbac.grantRole(oappRbac.MESSAGING_CHANNEL_MANAGER_ROLE(), address(this));
65
+ oappRbac.grantRole(oappRbac.MESSAGE_NILIFIER_ROLE(), address(this));
66
+ oappRbac.grantRole(oappRbac.MESSAGING_CHANNEL_MANAGER_ROLE(), bob);
67
+ oappRbac.grantRole(oappRbac.MESSAGE_NILIFIER_ROLE(), charlie);
68
+ }
69
+
70
+ // ============ clear ============
71
+
72
+ function test_clear_Revert_Unauthorized() public {
73
+ vm.expectRevert(
74
+ abi.encodeWithSelector(
75
+ IAccessControl.AccessControlUnauthorizedAccount.selector,
76
+ alice,
77
+ oappRbac.MESSAGING_CHANNEL_MANAGER_ROLE()
78
+ )
79
+ );
80
+ vm.prank(alice);
81
+ oapp.clear(_origin(1), GUID, MESSAGE);
82
+ }
83
+
84
+ function test_clear_Revert_NilifierUnauthorized() public {
85
+ vm.expectRevert(
86
+ abi.encodeWithSelector(
87
+ IAccessControl.AccessControlUnauthorizedAccount.selector,
88
+ charlie,
89
+ oappRbac.MESSAGING_CHANNEL_MANAGER_ROLE()
90
+ )
91
+ );
92
+ vm.prank(charlie);
93
+ oapp.clear(_origin(1), GUID, MESSAGE);
94
+ }
95
+
96
+ // ============ skip ============
97
+
98
+ function test_skip_Revert_Unauthorized() public {
99
+ vm.expectRevert(
100
+ abi.encodeWithSelector(
101
+ IAccessControl.AccessControlUnauthorizedAccount.selector,
102
+ alice,
103
+ oappRbac.MESSAGING_CHANNEL_MANAGER_ROLE()
104
+ )
105
+ );
106
+ vm.prank(alice);
107
+ oapp.skip(SRC_EID, SENDER, 1);
108
+ }
109
+
110
+ // ============ burn ============
111
+
112
+ function test_burn_Revert_Unauthorized() public {
113
+ vm.expectRevert(
114
+ abi.encodeWithSelector(
115
+ IAccessControl.AccessControlUnauthorizedAccount.selector,
116
+ alice,
117
+ oappRbac.MESSAGING_CHANNEL_MANAGER_ROLE()
118
+ )
119
+ );
120
+ vm.prank(alice);
121
+ oapp.burn(SRC_EID, SENDER, 1, PAYLOAD_HASH);
122
+ }
123
+
124
+ // ============ nilify ============
125
+
126
+ function test_nilify_Revert_Unauthorized() public {
127
+ vm.expectRevert(
128
+ abi.encodeWithSelector(
129
+ IAccessControl.AccessControlUnauthorizedAccount.selector,
130
+ alice,
131
+ oappRbac.MESSAGE_NILIFIER_ROLE()
132
+ )
133
+ );
134
+ vm.prank(alice);
135
+ oapp.nilify(SRC_EID, SENDER, 1, PAYLOAD_HASH);
136
+ }
137
+
138
+ function test_nilify_Revert_ManagerUnauthorized() public {
139
+ vm.expectRevert(
140
+ abi.encodeWithSelector(
141
+ IAccessControl.AccessControlUnauthorizedAccount.selector,
142
+ bob,
143
+ oappRbac.MESSAGE_NILIFIER_ROLE()
144
+ )
145
+ );
146
+ vm.prank(bob);
147
+ oapp.nilify(SRC_EID, SENDER, 1, PAYLOAD_HASH);
148
+ }
149
+ }