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
- Retrieves payloads from local execution layer or external block builders
85
96
- Handles payload validation and builder integration
86
97
87
98
**Slasher** (`slasher/`)
99
+
88
100
- Optional slashing detection service
89
101
- Supports LMDB, MDBX, and REDB database backends
90
102
- Can be enabled with `--slasher` flag
@@ -120,67 +132,79 @@ Lighthouse is a modular Ethereum consensus client with two main components:
120
132
## Common Review Standards
121
133
122
134
### CI/Testing Requirements
135
+
123
136
- All checks must pass before merge
124
137
- Test coverage expected for significant changes
125
138
- Flaky tests are actively addressed and fixed
126
139
- New features often require corresponding tests
127
140
-`beacon_chain` and `http_api` tests support fork-specific testing using `FORK_NAME` env var when `beacon_chain/fork_from_env` feature is enabled
128
141
129
142
### Code Quality Standards
143
+
130
144
- Clippy warnings must be fixed promptly (multiple PRs show this pattern)
131
145
- Code formatting with `cargo fmt` enforced
132
146
- Must run `cargo sort` when adding dependencies - dependency order is enforced on CI
133
147
- Performance considerations for hot paths
134
148
135
149
### Documentation and Context
150
+
136
151
- PRs require clear descriptions of what and why
137
152
- Breaking changes need migration documentation
138
153
- API changes require documentation updates
139
154
- When CLI is updated, run `make cli-local` to generate updated help text in lighthouse book
140
155
- Comments appreciated for complex logic
141
156
142
157
### Security and Safety
158
+
143
159
- Careful review of consensus-critical code paths
144
160
- Error handling patterns must be comprehensive
145
161
- Input validation for external data
146
162
147
163
## Development Patterns and Best Practices
148
164
149
165
### Panics and Error Handling
166
+
150
167
-**Panics should be avoided at all costs**
151
168
- Always prefer returning a `Result` or `Option` over causing a panic (e.g., prefer `array.get(1)?` over `array[1]`)
152
169
- Avoid `expect` or `unwrap` at runtime - only acceptable during startup when validating CLI flags or configurations
153
170
- If you must make assumptions about panics, use `.expect("Helpful message")` instead of `.unwrap()` and provide detailed reasoning in nearby comments
154
171
- Use proper error handling with `Result` types and graceful error propagation
155
172
156
173
### Rayon Usage
174
+
157
175
- Avoid using the rayon global thread pool as it results in CPU oversubscription when the beacon processor has fully allocated all CPUs to workers
158
176
- Use scoped rayon pools started by beacon processor for computational intensive tasks
159
177
160
178
### Locks
179
+
161
180
- Take great care to avoid deadlocks when working with fork choice locks - seek detailed review ([reference](beacon_node/beacon_chain/src/canonical_head.rs:9))
162
181
- Keep lock scopes as narrow as possible to avoid blocking fast-responding functions like the networking stack
163
182
164
183
### Async Patterns
184
+
165
185
- Avoid blocking computations in async tasks
166
186
- Spawn a blocking task instead for CPU-intensive work
167
187
168
188
### Tracing
189
+
169
190
- Design spans carefully and avoid overuse of spans just to add context data to events
170
191
- Avoid using spans on simple getter methods as it can result in performance overhead
171
192
- Be cautious of span explosion with recursive functions
172
193
- Use spans per meaningful step or computationally critical step
173
194
- Avoid using `span.enter()` or `span.entered()` in async tasks
174
195
175
196
### Database
197
+
176
198
- Maintain schema continuity on `unstable` branch
177
199
- Database migrations must be backward compatible
178
200
179
201
### Consensus Crate
202
+
180
203
- Use safe math methods like `saturating_xxx` or `checked_xxx`
181
204
- Critical that this crate behaves deterministically and MUST not have undefined behavior
182
205
183
206
### Testing Patterns
207
+
184
208
-**Use appropriate test types for the right scenarios**:
185
209
-**Unit tests** for single component edge cases and isolated logic
186
210
-**Integration tests** using [`BeaconChainHarness`](beacon_node/beacon_chain/src/test_utils.rs:668) for end-to-end workflows
@@ -204,14 +228,17 @@ Lighthouse is a modular Ethereum consensus client with two main components:
204
228
- See [`scripts/local_testnet/README.md`](scripts/local_testnet/README.md) for setup instructions
205
229
206
230
### TODOs and Comments
231
+
207
232
- All `TODO` statements must be accompanied by a GitHub issue link
208
233
- Prefer line (`//`) comments to block comments (`/* ... */`)
209
234
- Use doc comments (`///`) before attributes for public items
210
235
- Keep documentation concise and clear - avoid verbose explanations
211
236
- Provide examples in doc comments for public APIs when helpful
212
237
213
238
## Logging Guidelines
239
+
214
240
Use appropriate log levels for different scenarios:
241
+
215
242
-**`crit`**: Critical issues with major impact to Lighthouse functionality - Lighthouse may not function correctly without resolving. Needs immediate attention.
216
243
-**`error`**: Error cases that may have moderate impact to Lighthouse functionality. Expect to receive reports from users for this level.
217
244
-**`warn`**: Unexpected code paths that don't have major impact - fully recoverable. Expect user reports if excessive warning logs occur.
@@ -221,6 +248,7 @@ Use appropriate log levels for different scenarios:
221
248
## Code Examples
222
249
223
250
### Safe Math in Consensus Crate
251
+
224
252
```rust
225
253
// ❌ Avoid - could panic
226
254
letresult=a+b;
@@ -234,6 +262,7 @@ let result = a.safe_add(b)?;
234
262
```
235
263
236
264
### Panics and Error Handling
265
+
237
266
```rust
238
267
// ❌ Avoid - could panic at runtime
239
268
letvalue=some_result.unwrap();
@@ -253,6 +282,7 @@ let item = array.get(1).expect("Array always has at least 2 elements due to vali
0 commit comments