You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Testing and verification](#testing-and-verification)
23
22
@@ -40,9 +39,7 @@ _How are ratings determined?_ While the process for assigning ratings can vary d
40
39
41
40
## Arithmetic
42
41
43
-
<!-- omit from toc -->
44
-
45
-
### Weak
42
+
### Weak <!-- omit from toc -->
46
43
47
44
A weak arithmetic maturity reflects the lack of a systematic approach toward ensuring the correctness of the operations and reducing the risks of arithmetic-related flaws such as overflow, rounding, precision loss, and trapping. Specific criteria include, but are not limited to, the following:
48
45
@@ -52,9 +49,7 @@ A weak arithmetic maturity reflects the lack of a systematic approach toward ens
52
49
- No explicit testing strategy has been identified to increase confidence in the system’s arithmetic.
53
50
- The testing does not cover critical—or several—arithmetic edge cases.
54
51
55
-
<!-- omit from toc -->
56
-
57
-
### Moderate
52
+
### Moderate <!-- omit from toc -->
58
53
59
54
This rating indicates that the codebase follows best practices, but lacks a systematic approach toward ensuring the correctness of the arithmetic operations. The code is well structured to facilitate the testing of operations, and multiple testing techniques are used. Specific criteria include, but are not limited to, the following:
60
55
@@ -67,9 +62,7 @@ This rating indicates that the codebase follows best practices, but lacks a syst
67
62
- Arithmetic operations are structured through stateless functions to facilitate their testing.
68
63
- System parameters are bounded, the ranges are explained, and their impacts are propagated through the documentation/specification.
69
64
70
-
<!-- omit from toc -->
71
-
72
-
### Satisfactory
65
+
### Satisfactory <!-- omit from toc -->
73
66
74
67
Arithmetic-related risks are clearly identified and understood. A theoretical analysis ensures that the code is consistent with the specification. Specific criteria include, but are not limited to, the following:
75
68
The system meets all moderate criteria.
@@ -83,19 +76,15 @@ The system meets all moderate criteria.
83
76
84
77
“Auditing” refers to the proper use of events and monitoring procedures within the system.
85
78
86
-
<!-- omit from toc -->
87
-
88
-
### Weak
79
+
### Weak <!-- omit from toc -->
89
80
90
81
The system has no strategy towards emitting or using events. Specific criteria include, but are not limited to, the following:
91
82
92
83
- Events are missing for critical components updates.
93
84
- There are no clear or consistent guidelines for event-emitting functions.
94
85
- The same events are reused for different purposes.
95
86
96
-
<!-- omit from toc -->
97
-
98
-
### Moderate
87
+
### Moderate <!-- omit from toc -->
99
88
100
89
The system is built to be monitored. An off-chain infrastructure for detecting unexpected behavior is in place, and the team can be notified about events. Clear documentation highlights how the events should be used by third parties. Specific criteria include, but are not limited to, the following:
101
90
@@ -106,9 +95,7 @@ The system is built to be monitored. An off-chain infrastructure for detecting u
106
95
- The monitoring documentation describes how to review logs in order to audit a failure.
107
96
- An [incident response plan](https://github.com/crytic/building-secure-contracts/blob/master/development-guidelines/incident_response.md) describes how the protocol’s actors must react in case of failure.
108
97
109
-
<!-- omit from toc -->
110
-
111
-
### Satisfactory
98
+
### Satisfactory <!-- omit from toc -->
112
99
113
100
The system is well monitored, and processes are in place to react in case of defect or failure. Specific criteria include, but are not limited to, the following:
114
101
The system meets all moderate criteria.
@@ -121,34 +108,28 @@ The system meets all moderate criteria.
121
108
122
109
“Authentication / access controls” refers to the use of robust access controls to handle identification and authorization and to ensure safe interactions with the system.
123
110
124
-
<!-- omit from toc -->
125
-
126
-
### Weak
111
+
### Weak <!-- omit from toc -->
127
112
128
113
The expected access controls are unclear or inconsistent; one address may be in control of the entire system, and there is no indication of additional safeguards for this account. Specific criteria include, but are not limited to, the following:
129
114
No access controls are in place for privileged functions, or some privileged functions lack access controls.
130
115
131
116
- There are no differentiated privileged actors or roles.
132
117
- All privileged functions are callable by one address, and there is no indication that this address will have further access controls (e.g., multisig).
133
118
134
-
<!-- omit from toc -->
135
-
136
-
### Moderate
119
+
### Moderate <!-- omit from toc -->
137
120
138
121
The system adheres to best practices, the major actors are documented and tested, and risks are limited through a clear separation of privileges. Specific criteria include, but are not limited to, the following:
139
122
None of the weak criteria apply to the codebase.
140
123
141
124
- All privileged functions have some form of access control.
142
-
- The principle of least privilege is followed for all components.
125
+
- The principle of [least privilege](https://en.wikipedia.org/wiki/Principle_of_least_privilege) is followed for all components.
143
126
- There are different roles in the system, and privileges for different roles do not overlap.
144
127
- There is clear documentation about the actors and their respective privileges in the system.
145
128
- Tests cover every actor-specific privilege.
146
129
- Roles can be revoked (if applicable).
147
130
- Two-step processes are used for privileged operations performed by Externally Owned Accounts (EOA).
148
131
149
-
<!-- omit from toc -->
150
-
151
-
### Satisfactory
132
+
### Satisfactory <!-- omit from toc -->
152
133
153
134
All actors and roles are clearly documented, including their expected privileges, and the implementation is consistent with all expected behavior and thoroughly tested. All known risks are highlighted and visible to users. Specific criteria include, but are not limited to, the following:
154
135
@@ -162,9 +143,7 @@ All actors and roles are clearly documented, including their expected privileges
162
143
163
144
“Complexity management” refers to the separation of logic into functions with a clear purpose. The presence of clear structures designed to manage system complexity, including the separation of system logic into clearly defined functions, is the central focus when evaluating the system with respect to this category.
164
145
165
-
<!-- omit from toc -->
166
-
167
-
### Weak
146
+
### Weak <!-- omit from toc -->
168
147
169
148
The code has unnecessary complexity (e.g., failure to adhere to well-established software development practices) that hinders automated and/or manual review. Specific criteria include, but are not limited to, the following:
170
149
@@ -173,23 +152,19 @@ The code has unnecessary complexity (e.g., failure to adhere to well-established
173
152
- Functions have unnecessary redundant code/code duplication.
174
153
- Contracts have a complex inheritance tree.
175
154
176
-
<!-- omit from toc -->
177
-
178
-
### Moderate
155
+
### Moderate <!-- omit from toc -->
179
156
180
157
The most complex parts of the codebase are well identified, and their complexity is reduced as much as possible. Specific criteria include, but are not limited to, the following:
181
158
None of the weak criteria apply to the codebase.
182
159
183
-
- Functions have a high cyclomatic complexity (≥11).
160
+
- Functions have a high cyclomatic complexity ([≥11](https://en.wikipedia.org/wiki/Cyclomatic_complexity#Interpretation)).
184
161
- Critical functions are well scoped, making them easy to understand and test.
185
162
- Redundant code in the system is limited and justified.
186
163
- Inputs and their expected values are clear, and validation is performed where necessary.
187
164
- A clear and documented naming convention is in place for functions, variables, and other identifiers, and the codebase clearly adheres to the convention.
188
165
- Types are not used to enforce correctness.
189
166
190
-
<!-- omit from toc -->
191
-
192
-
## Satisfactory
167
+
## Satisfactory <!-- omit from toc -->
193
168
194
169
The code has little or no unnecessary complexity, any necessary complexity is well documented, and all code is easy to test. Specific criteria include, but are not limited to, the following:
195
170
@@ -204,9 +179,7 @@ The code has little or no unnecessary complexity, any necessary complexity is we
204
179
205
180
> A note on upgradeability: Upgradeability is often an important feature to consider when reviewing the decentralization of a system. While upgradeability is not, at a fundamental or theoretical level, incompatible with decentralization, it is, in practice, an obstacle in realizing robust system decentralization. Upgradeable systems that aim to be decentralized have additional requirements to demonstrate that their upgradeable components do not impact their decentralization.
206
181
207
-
<!-- omit from toc -->
208
-
209
-
## Weak
182
+
## Weak <!-- omit from toc -->
210
183
211
184
The system has several points of centrality that may not be clearly visible to the users. Specific criteria include, but are not limited to, the following:
212
185
@@ -216,9 +189,7 @@ The system has several points of centrality that may not be clearly visible to t
216
189
- System parameters can be changed at any time by a single entity.
217
190
- Permission/authorization by a centralized actor is required to use the contracts.
218
191
219
-
<!-- omit from toc -->
220
-
221
-
## Moderate
192
+
## Moderate <!-- omit from toc -->
222
193
223
194
Centralization risks are identified, justified and documented, and users might choose to not follow an upgrade. Specific criteria include, but are not limited to, the following:
224
195
@@ -228,9 +199,7 @@ Centralization risks are identified, justified and documented, and users might c
228
199
- Privileged actors are not able to unilaterally move funds out of, or trap funds in, the protocol.
229
200
- All privileges are documented.
230
201
231
-
<!-- omit from toc -->
232
-
233
-
## Satisfactory
202
+
## Satisfactory <!-- omit from toc -->
234
203
235
204
The system provides clear justification to demonstrate its path toward decentralization. Specific criteria include, but are not limited to the following:
236
205
@@ -240,13 +209,11 @@ The system provides clear justification to demonstrate its path toward decentral
240
209
- Risks related to external contract interactions are documented.
241
210
- The critical configuration parameters are immutable once deployed, or the users have a documented path to opt out of the changes or exit the system if they are updated.
242
211
243
-
# Documentation
212
+
##Documentation
244
213
245
214
“Documentation” refers to the presence of comprehensive and readable codebase documentation, including inline code comments, the roles and responsibilities of system entities, system invariants, use cases, expected system behavior, and data flow diagrams.
246
215
247
-
<!-- omit from toc -->
248
-
249
-
### Weak
216
+
### Weak <!-- omit from toc -->
250
217
251
218
Minimal documentation is present, or documentation is clearly incomplete or outdated. Specific criteria include, but are not limited to, the following:
252
219
@@ -255,9 +222,7 @@ Minimal documentation is present, or documentation is clearly incomplete or outd
255
222
- Documentation is not publicly available. (Note that this applies only to codebases meant for general public usage.)
256
223
- Documentation depends directly on a set of artificial terms or words that are not clearly explained.
257
224
258
-
<!-- omit from toc -->
259
-
260
-
### Moderate
225
+
### Moderate <!-- omit from toc -->
261
226
262
227
The documentation adheres to best practices. Important components are documented; the documentation exists at different levels (such as inline code comments, NatSpec, and system documentation); and there is consistency across all documentation. Specific criteria include, but are not limited to, the following:
263
228
@@ -272,9 +237,7 @@ The documentation adheres to best practices. Important components are documented
272
237
- All critical code blocks are documented.
273
238
- Known risks and system limitations are documented.
274
239
275
-
<!-- omit from toc -->
276
-
277
-
### Satisfactory
240
+
### Satisfactory <!-- omit from toc -->
278
241
279
242
Thorough documentation exists spanning all of the areas required for a moderate rating, as well as system corner cases, detailed aspects of users stories, and all features. The documentation matches the code. Specific criteria include, but are not limited to, the following:
280
243
@@ -290,9 +253,7 @@ Thorough documentation exists spanning all of the areas required for a moderate
290
253
291
254
“Transaction ordering risks” refers to the resilience against malicious ordering of the transactions. This includes toxic forms of Miner Extractable Value (MEV), such as front-running, sandwiching, forced liquidations, and oracle attacks.
292
255
293
-
<!-- omit from toc -->
294
-
295
-
### Weak
256
+
### Weak <!-- omit from toc -->
296
257
297
258
There are unexpected/undocumented risks that arise due to the ordering of transactions. Specific criteria include, but are not limited to, the following:
298
259
@@ -301,9 +262,7 @@ There are unexpected/undocumented risks that arise due to the ordering of transa
301
262
- The system relies on unjustified constraints to prevent MEV extraction.
302
263
- The system makes unproven assumptions about which attributes may or may not be manipulatable by an MEV extractor.
303
264
304
-
<!-- omit from toc -->
305
-
306
-
### Moderate
265
+
### Moderate <!-- omit from toc -->
307
266
308
267
Risks related to transaction ordering are identified and, when applicable, limited through on-chain mitigations. Specific criteria include, but are not limited to, the following:
309
268
@@ -313,9 +272,7 @@ Risks related to transaction ordering are identified and, when applicable, limit
313
272
- The testing strategy emphasizes transaction ordering risks.
314
273
- The system uses tamper-resistant oracles.
315
274
316
-
<!-- omit from toc -->
317
-
318
-
### Satisfactory
275
+
### Satisfactory <!-- omit from toc -->
319
276
320
277
All transaction ordering risks are documented and clearly justified. The known risks are highlighted through documentation and tests and are visible to the users. Specific criteria include, but are not limited to, the following:
321
278
@@ -328,17 +285,13 @@ All transaction ordering risks are documented and clearly justified. The known r
328
285
329
286
“Low-level manipulation” refers to the usage of low-level operations (e.g., assembly code, bitwise operations, low-level calls) and relevant justification within the codebase.
330
287
331
-
<!-- omit from toc -->
332
-
333
-
### Weak
288
+
### Weak <!-- omit from toc -->
334
289
335
290
The code uses unjustified low-level manipulations. Specific criteria include, but are not limited to, the following:
336
291
337
292
- Usage of assembly code or low-level manipulation is not justified; most can likely be replaced by high-level code.
338
293
339
-
<!-- omit from toc -->
340
-
341
-
### Moderate
294
+
### Moderate <!-- omit from toc -->
342
295
343
296
Low level operations are justified and limited. Extra documentation and testing is provided for them. Specific criteria include, but are not limited to, the following:
344
297
@@ -348,9 +301,7 @@ Low level operations are justified and limited. Extra documentation and testing
348
301
- The code does not re-implement well-established, low-level library functionality without justification (e.g., OZ’s SafeERC20).
349
302
- A high-level implementation reference exists for each function with complex assembly code.
350
303
351
-
<!-- omit from toc -->
352
-
353
-
### Satisfactory
304
+
### Satisfactory <!-- omit from toc -->
354
305
355
306
Thorough documentation, justification, and testing exists to increase confidence in all usage of assembly code and low-level manipulation. Implementations are validated with automated testing against a reference implementation. Specific criteria include, but are not limited to, the following:
356
307
@@ -362,19 +313,15 @@ Thorough documentation, justification, and testing exists to increase confidence
362
313
363
314
“Testing and verification” refers to the robustness of testing procedures of techniques (including unit tests, integration tests, fuzzing, and symbolic execution) as well as the amount of test coverage.
364
315
365
-
<!-- omit from toc -->
366
-
367
-
### Weak
316
+
### Weak <!-- omit from toc -->
368
317
369
318
Testing is limited and covers only some of the “happy paths.” Specific criteria include, but are not limited to, the following:
370
319
371
320
- Common or expected use cases are not fully tested.
372
321
- Provided tests fail for the codebase.
373
322
- There is insufficient or non-existent documentation to run the test suite “out of the box.”
374
323
375
-
<!-- omit from toc -->
376
-
377
-
### Moderate
324
+
### Moderate <!-- omit from toc -->
378
325
379
326
Testing adheres to best practices and covers a large majority of the code. An automated testing technique is used to increase the confidence of the most critical components. Specific criteria include, but are not limited to, the following:
380
327
@@ -387,9 +334,7 @@ Testing adheres to best practices and covers a large majority of the code. An au
387
334
- Integration tests are implemented, if applicable.
388
335
- Test code follows best practices and does not trigger warnings by the compiler or static analysis tools.
389
336
390
-
<!-- omit from toc -->
391
-
392
-
### Satisfactory
337
+
### Satisfactory <!-- omit from toc -->
393
338
394
339
Testing is clearly an important part of codebase development. Tests include unit tests and end-to-end testing. Code properties are clearly identified and validated with an automated testing technique. Specific criteria include, but are not limited to, the following:
0 commit comments