Skip to content

Commit 92bc80c

Browse files
committed
Minor
1 parent 3f244c7 commit 92bc80c

File tree

1 file changed

+31
-86
lines changed

1 file changed

+31
-86
lines changed

development-guidelines/code_maturity.md

Lines changed: 31 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ As technologies and tooling improve, standards and best practices evolve, and th
1515
- [Authentication / access controls](#authentication--access-controls)
1616
- [Complexity management](#complexity-management)
1717
- [Decentralization](#decentralization)
18-
- [Documentation](#documentation)
18+
- [Documentation](#documentation)
1919
- [Transaction ordering risks](#transaction-ordering-risks)
20-
- [Weak](#weak-6)
2120
- [Low-level manipulation](#low-level-manipulation)
2221
- [Testing and verification](#testing-and-verification)
2322

@@ -40,9 +39,7 @@ _How are ratings determined?_ While the process for assigning ratings can vary d
4039

4140
## Arithmetic
4241

43-
<!-- omit from toc -->
44-
45-
### Weak
42+
### Weak <!-- omit from toc -->
4643

4744
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:
4845

@@ -52,9 +49,7 @@ A weak arithmetic maturity reflects the lack of a systematic approach toward ens
5249
- No explicit testing strategy has been identified to increase confidence in the system’s arithmetic.
5350
- The testing does not cover critical—or several—arithmetic edge cases.
5451

55-
<!-- omit from toc -->
56-
57-
### Moderate
52+
### Moderate <!-- omit from toc -->
5853

5954
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:
6055

@@ -67,9 +62,7 @@ This rating indicates that the codebase follows best practices, but lacks a syst
6762
- Arithmetic operations are structured through stateless functions to facilitate their testing.
6863
- System parameters are bounded, the ranges are explained, and their impacts are propagated through the documentation/specification.
6964

70-
<!-- omit from toc -->
71-
72-
### Satisfactory
65+
### Satisfactory <!-- omit from toc -->
7366

7467
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:
7568
The system meets all moderate criteria.
@@ -83,19 +76,15 @@ The system meets all moderate criteria.
8376

8477
“Auditing” refers to the proper use of events and monitoring procedures within the system.
8578

86-
<!-- omit from toc -->
87-
88-
### Weak
79+
### Weak <!-- omit from toc -->
8980

9081
The system has no strategy towards emitting or using events. Specific criteria include, but are not limited to, the following:
9182

9283
- Events are missing for critical components updates.
9384
- There are no clear or consistent guidelines for event-emitting functions.
9485
- The same events are reused for different purposes.
9586

96-
<!-- omit from toc -->
97-
98-
### Moderate
87+
### Moderate <!-- omit from toc -->
9988

10089
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:
10190

@@ -106,9 +95,7 @@ The system is built to be monitored. An off-chain infrastructure for detecting u
10695
- The monitoring documentation describes how to review logs in order to audit a failure.
10796
- 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.
10897

109-
<!-- omit from toc -->
110-
111-
### Satisfactory
98+
### Satisfactory <!-- omit from toc -->
11299

113100
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:
114101
The system meets all moderate criteria.
@@ -121,34 +108,28 @@ The system meets all moderate criteria.
121108

122109
“Authentication / access controls” refers to the use of robust access controls to handle identification and authorization and to ensure safe interactions with the system.
123110

124-
<!-- omit from toc -->
125-
126-
### Weak
111+
### Weak <!-- omit from toc -->
127112

128113
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:
129114
No access controls are in place for privileged functions, or some privileged functions lack access controls.
130115

131116
- There are no differentiated privileged actors or roles.
132117
- All privileged functions are callable by one address, and there is no indication that this address will have further access controls (e.g., multisig).
133118

134-
<!-- omit from toc -->
135-
136-
### Moderate
119+
### Moderate <!-- omit from toc -->
137120

138121
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:
139122
None of the weak criteria apply to the codebase.
140123

141124
- 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.
143126
- There are different roles in the system, and privileges for different roles do not overlap.
144127
- There is clear documentation about the actors and their respective privileges in the system.
145128
- Tests cover every actor-specific privilege.
146129
- Roles can be revoked (if applicable).
147130
- Two-step processes are used for privileged operations performed by Externally Owned Accounts (EOA).
148131

149-
<!-- omit from toc -->
150-
151-
### Satisfactory
132+
### Satisfactory <!-- omit from toc -->
152133

153134
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:
154135

@@ -162,9 +143,7 @@ All actors and roles are clearly documented, including their expected privileges
162143

163144
“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.
164145

165-
<!-- omit from toc -->
166-
167-
### Weak
146+
### Weak <!-- omit from toc -->
168147

169148
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:
170149

@@ -173,23 +152,19 @@ The code has unnecessary complexity (e.g., failure to adhere to well-established
173152
- Functions have unnecessary redundant code/code duplication.
174153
- Contracts have a complex inheritance tree.
175154

176-
<!-- omit from toc -->
177-
178-
### Moderate
155+
### Moderate <!-- omit from toc -->
179156

180157
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:
181158
None of the weak criteria apply to the codebase.
182159

183-
- Functions have a high cyclomatic complexity (≥11).
160+
- Functions have a high cyclomatic complexity ([≥11](https://en.wikipedia.org/wiki/Cyclomatic_complexity#Interpretation)).
184161
- Critical functions are well scoped, making them easy to understand and test.
185162
- Redundant code in the system is limited and justified.
186163
- Inputs and their expected values are clear, and validation is performed where necessary.
187164
- A clear and documented naming convention is in place for functions, variables, and other identifiers, and the codebase clearly adheres to the convention.
188165
- Types are not used to enforce correctness.
189166

190-
<!-- omit from toc -->
191-
192-
## Satisfactory
167+
## Satisfactory <!-- omit from toc -->
193168

194169
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:
195170

@@ -204,9 +179,7 @@ The code has little or no unnecessary complexity, any necessary complexity is we
204179

205180
> 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.
206181
207-
<!-- omit from toc -->
208-
209-
## Weak
182+
## Weak <!-- omit from toc -->
210183

211184
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:
212185

@@ -216,9 +189,7 @@ The system has several points of centrality that may not be clearly visible to t
216189
- System parameters can be changed at any time by a single entity.
217190
- Permission/authorization by a centralized actor is required to use the contracts.
218191

219-
<!-- omit from toc -->
220-
221-
## Moderate
192+
## Moderate <!-- omit from toc -->
222193

223194
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:
224195

@@ -228,9 +199,7 @@ Centralization risks are identified, justified and documented, and users might c
228199
- Privileged actors are not able to unilaterally move funds out of, or trap funds in, the protocol.
229200
- All privileges are documented.
230201

231-
<!-- omit from toc -->
232-
233-
## Satisfactory
202+
## Satisfactory <!-- omit from toc -->
234203

235204
The system provides clear justification to demonstrate its path toward decentralization. Specific criteria include, but are not limited to the following:
236205

@@ -240,13 +209,11 @@ The system provides clear justification to demonstrate its path toward decentral
240209
- Risks related to external contract interactions are documented.
241210
- 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.
242211

243-
# Documentation
212+
## Documentation
244213

245214
“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.
246215

247-
<!-- omit from toc -->
248-
249-
### Weak
216+
### Weak <!-- omit from toc -->
250217

251218
Minimal documentation is present, or documentation is clearly incomplete or outdated. Specific criteria include, but are not limited to, the following:
252219

@@ -255,9 +222,7 @@ Minimal documentation is present, or documentation is clearly incomplete or outd
255222
- Documentation is not publicly available. (Note that this applies only to codebases meant for general public usage.)
256223
- Documentation depends directly on a set of artificial terms or words that are not clearly explained.
257224

258-
<!-- omit from toc -->
259-
260-
### Moderate
225+
### Moderate <!-- omit from toc -->
261226

262227
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:
263228

@@ -272,9 +237,7 @@ The documentation adheres to best practices. Important components are documented
272237
- All critical code blocks are documented.
273238
- Known risks and system limitations are documented.
274239

275-
<!-- omit from toc -->
276-
277-
### Satisfactory
240+
### Satisfactory <!-- omit from toc -->
278241

279242
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:
280243

@@ -290,9 +253,7 @@ Thorough documentation exists spanning all of the areas required for a moderate
290253

291254
“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.
292255

293-
<!-- omit from toc -->
294-
295-
### Weak
256+
### Weak <!-- omit from toc -->
296257

297258
There are unexpected/undocumented risks that arise due to the ordering of transactions. Specific criteria include, but are not limited to, the following:
298259

@@ -301,9 +262,7 @@ There are unexpected/undocumented risks that arise due to the ordering of transa
301262
- The system relies on unjustified constraints to prevent MEV extraction.
302263
- The system makes unproven assumptions about which attributes may or may not be manipulatable by an MEV extractor.
303264

304-
<!-- omit from toc -->
305-
306-
### Moderate
265+
### Moderate <!-- omit from toc -->
307266

308267
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:
309268

@@ -313,9 +272,7 @@ Risks related to transaction ordering are identified and, when applicable, limit
313272
- The testing strategy emphasizes transaction ordering risks.
314273
- The system uses tamper-resistant oracles.
315274

316-
<!-- omit from toc -->
317-
318-
### Satisfactory
275+
### Satisfactory <!-- omit from toc -->
319276

320277
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:
321278

@@ -328,17 +285,13 @@ All transaction ordering risks are documented and clearly justified. The known r
328285

329286
“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.
330287

331-
<!-- omit from toc -->
332-
333-
### Weak
288+
### Weak <!-- omit from toc -->
334289

335290
The code uses unjustified low-level manipulations. Specific criteria include, but are not limited to, the following:
336291

337292
- Usage of assembly code or low-level manipulation is not justified; most can likely be replaced by high-level code.
338293

339-
<!-- omit from toc -->
340-
341-
### Moderate
294+
### Moderate <!-- omit from toc -->
342295

343296
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:
344297

@@ -348,9 +301,7 @@ Low level operations are justified and limited. Extra documentation and testing
348301
- The code does not re-implement well-established, low-level library functionality without justification (e.g., OZ’s SafeERC20).
349302
- A high-level implementation reference exists for each function with complex assembly code.
350303

351-
<!-- omit from toc -->
352-
353-
### Satisfactory
304+
### Satisfactory <!-- omit from toc -->
354305

355306
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:
356307

@@ -362,19 +313,15 @@ Thorough documentation, justification, and testing exists to increase confidence
362313

363314
“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.
364315

365-
<!-- omit from toc -->
366-
367-
### Weak
316+
### Weak <!-- omit from toc -->
368317

369318
Testing is limited and covers only some of the “happy paths.” Specific criteria include, but are not limited to, the following:
370319

371320
- Common or expected use cases are not fully tested.
372321
- Provided tests fail for the codebase.
373322
- There is insufficient or non-existent documentation to run the test suite “out of the box.”
374323

375-
<!-- omit from toc -->
376-
377-
### Moderate
324+
### Moderate <!-- omit from toc -->
378325

379326
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:
380327

@@ -387,9 +334,7 @@ Testing adheres to best practices and covers a large majority of the code. An au
387334
- Integration tests are implemented, if applicable.
388335
- Test code follows best practices and does not trigger warnings by the compiler or static analysis tools.
389336

390-
<!-- omit from toc -->
391-
392-
### Satisfactory
337+
### Satisfactory <!-- omit from toc -->
393338

394339
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:
395340

0 commit comments

Comments
 (0)