Skip to content

Commit 55dd21a

Browse files
committed
Merge remote-tracking branch 'origin/unstable' into blob-backfill
2 parents 1f3d1da + 521be2b commit 55dd21a

File tree

99 files changed

+1815
-952
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1815
-952
lines changed

.github/mergify.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ queue_rules:
105105
106106
107107
{{ body | get_section("## Proposed Changes", "") }}
108+
109+
{% for commit in commits | unique(attribute='email_author') %}
110+
Co-Authored-By: {{ commit.author }} <{{ commit.email_author }}>
111+
{% endfor %}
108112
queue_conditions:
109113
- "#approved-reviews-by >= 1"
110114
- "check-success=license/cla"

.github/workflows/test-suite.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
with:
103103
version: nightly-ca67d15f4abd46394b324c50e21e66f306a1162d
104104
- name: Run tests in release
105-
run: make nextest-release
105+
run: make test-release
106106
- name: Show cache stats
107107
if: env.SELF_HOSTED_RUNNERS == 'true'
108108
continue-on-error: true
@@ -134,7 +134,7 @@ jobs:
134134
- name: Set LIBCLANG_PATH
135135
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
136136
- name: Run tests in release
137-
run: make nextest-release
137+
run: make test-release
138138
- name: Show cache stats
139139
if: env.SELF_HOSTED_RUNNERS == 'true'
140140
continue-on-error: true
@@ -269,7 +269,7 @@ jobs:
269269
with:
270270
version: nightly-ca67d15f4abd46394b324c50e21e66f306a1162d
271271
- name: Run tests in debug
272-
run: make nextest-debug
272+
run: make test-debug
273273
- name: Show cache stats
274274
if: env.SELF_HOSTED_RUNNERS == 'true'
275275
continue-on-error: true
@@ -306,7 +306,7 @@ jobs:
306306
cache-target: release
307307
bins: cargo-nextest
308308
- name: Run consensus-spec-tests with blst and fake_crypto
309-
run: make nextest-ef
309+
run: make test-ef
310310
- name: Show cache stats
311311
if: env.SELF_HOSTED_RUNNERS == 'true'
312312
continue-on-error: true

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ perf.data*
99
*.tar.gz
1010
/bin
1111
genesis.ssz
12-
/clippy.toml
1312
/.cargo
1413

1514
# IntelliJ

CLAUDE.md

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,38 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
77
**Important**: Always branch from `unstable` and target `unstable` when creating pull requests.
88

99
### Building and Installation
10+
1011
- `make install` - Build and install the main Lighthouse binary in release mode
1112
- `make install-lcli` - Build and install the `lcli` utility binary
1213
- `cargo build --release` - Standard Rust release build
1314
- `cargo build --bin lighthouse --features "gnosis,slasher-lmdb"` - Build with specific features
1415

1516
### Testing
17+
1618
- `make test` - Run the full test suite in release mode (excludes EF tests, beacon_chain, slasher, network, http_api)
17-
- `make nextest-release` - Run tests using nextest (faster parallel test runner)
19+
- `make test-release` - Run tests using nextest (faster parallel test runner)
1820
- `make test-beacon-chain` - Run beacon chain tests for all supported forks
1921
- `make test-slasher` - Run slasher tests with all database backend combinations
2022
- `make test-ef` - Download and run Ethereum Foundation test vectors
2123
- `make test-full` - Complete test suite including linting, EF tests, and execution engine tests
22-
- `cargo test -p <package_name>` - Run tests for a specific package
23-
- `cargo test -p <package_name> <test_name>` - Run individual test (preferred during development iteration)
24+
- `cargo nextest run -p <package_name>` - Run tests for a specific package
25+
- `cargo nextest run -p <package_name> <test_name>` - Run individual test (preferred during development iteration)
2426
- `FORK_NAME=electra cargo nextest run -p beacon_chain` - Run tests for specific fork
2527

2628
**Note**: Full test suite takes ~20 minutes. When iterating, prefer running individual tests.
2729

28-
### Linting and Code Quality
30+
### Linting and Code Quality
31+
2932
- `make lint` - Run Clippy linter with project-specific rules
3033
- `make lint-full` - Run comprehensive linting including tests (recommended for thorough checking)
3134
- `make cargo-fmt` - Check code formatting with rustfmt
3235
- `make check-benches` - Typecheck benchmark code
3336
- `make audit` - Run security audit on dependencies
3437

3538
### Cross-compilation
39+
3640
- `make build-x86_64` - Cross-compile for x86_64 Linux
37-
- `make build-aarch64` - Cross-compile for ARM64 Linux
41+
- `make build-aarch64` - Cross-compile for ARM64 Linux
3842
- `make build-riscv64` - Cross-compile for RISC-V 64-bit Linux
3943

4044
## Architecture Overview
@@ -44,13 +48,15 @@ Lighthouse is a modular Ethereum consensus client with two main components:
4448
### Core Components
4549

4650
**Beacon Node** (`beacon_node/`)
51+
4752
- Main consensus client that syncs with the Ethereum network
4853
- Contains the beacon chain state transition logic (`beacon_node/beacon_chain/`)
4954
- Handles networking, storage, and P2P communication
5055
- Provides HTTP API for validator clients and external tools
5156
- Entry point: `beacon_node/src/lib.rs`
5257

53-
**Validator Client** (`validator_client/`)
58+
**Validator Client** (`validator_client/`)
59+
5460
- Manages validator keystores and performs validator duties
5561
- Connects to beacon nodes via HTTP API
5662
- Handles block proposals, attestations, and sync committee duties
@@ -60,31 +66,37 @@ Lighthouse is a modular Ethereum consensus client with two main components:
6066
### Key Subsystems
6167

6268
**Consensus Types** (`consensus/types/`)
69+
6370
- Core Ethereum consensus data structures (BeaconState, BeaconBlock, etc.)
6471
- Ethereum specification implementations for different networks (mainnet, gnosis)
6572
- SSZ encoding/decoding and state transition primitives
6673

6774
**Storage** (`beacon_node/store/`)
75+
6876
- Hot/cold database architecture for efficient beacon chain storage
6977
- Supports multiple backends (LevelDB, RocksDB, REDB)
7078
- Handles state pruning and historical data management
7179

7280
**Networking** (`beacon_node/lighthouse_network/`, `beacon_node/network/`)
81+
7382
- Libp2p-based P2P networking stack
7483
- Gossipsub for message propagation
7584
- Discovery v5 for peer discovery
7685
- Request/response protocols for sync
7786

7887
**Fork Choice** (`consensus/fork_choice/`, `consensus/proto_array/`)
88+
7989
- Implements Ethereum's fork choice algorithm (proto-array)
8090
- Manages chain reorganizations and finality
8191

8292
**Execution Layer Integration** (`beacon_node/execution_layer/`)
93+
8394
- Interfaces with execution clients
8495
- Retrieves payloads from local execution layer or external block builders
8596
- Handles payload validation and builder integration
8697

8798
**Slasher** (`slasher/`)
99+
88100
- Optional slashing detection service
89101
- Supports LMDB, MDBX, and REDB database backends
90102
- Can be enabled with `--slasher` flag
@@ -120,67 +132,79 @@ Lighthouse is a modular Ethereum consensus client with two main components:
120132
## Common Review Standards
121133

122134
### CI/Testing Requirements
135+
123136
- All checks must pass before merge
124137
- Test coverage expected for significant changes
125138
- Flaky tests are actively addressed and fixed
126139
- New features often require corresponding tests
127140
- `beacon_chain` and `http_api` tests support fork-specific testing using `FORK_NAME` env var when `beacon_chain/fork_from_env` feature is enabled
128141

129142
### Code Quality Standards
143+
130144
- Clippy warnings must be fixed promptly (multiple PRs show this pattern)
131145
- Code formatting with `cargo fmt` enforced
132146
- Must run `cargo sort` when adding dependencies - dependency order is enforced on CI
133147
- Performance considerations for hot paths
134148

135149
### Documentation and Context
150+
136151
- PRs require clear descriptions of what and why
137152
- Breaking changes need migration documentation
138153
- API changes require documentation updates
139154
- When CLI is updated, run `make cli-local` to generate updated help text in lighthouse book
140155
- Comments appreciated for complex logic
141156

142157
### Security and Safety
158+
143159
- Careful review of consensus-critical code paths
144160
- Error handling patterns must be comprehensive
145161
- Input validation for external data
146162

147163
## Development Patterns and Best Practices
148164

149165
### Panics and Error Handling
166+
150167
- **Panics should be avoided at all costs**
151168
- Always prefer returning a `Result` or `Option` over causing a panic (e.g., prefer `array.get(1)?` over `array[1]`)
152169
- Avoid `expect` or `unwrap` at runtime - only acceptable during startup when validating CLI flags or configurations
153170
- If you must make assumptions about panics, use `.expect("Helpful message")` instead of `.unwrap()` and provide detailed reasoning in nearby comments
154171
- Use proper error handling with `Result` types and graceful error propagation
155172

156173
### Rayon Usage
174+
157175
- Avoid using the rayon global thread pool as it results in CPU oversubscription when the beacon processor has fully allocated all CPUs to workers
158176
- Use scoped rayon pools started by beacon processor for computational intensive tasks
159177

160178
### Locks
179+
161180
- 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))
162181
- Keep lock scopes as narrow as possible to avoid blocking fast-responding functions like the networking stack
163182

164183
### Async Patterns
184+
165185
- Avoid blocking computations in async tasks
166186
- Spawn a blocking task instead for CPU-intensive work
167187

168188
### Tracing
189+
169190
- Design spans carefully and avoid overuse of spans just to add context data to events
170191
- Avoid using spans on simple getter methods as it can result in performance overhead
171192
- Be cautious of span explosion with recursive functions
172193
- Use spans per meaningful step or computationally critical step
173194
- Avoid using `span.enter()` or `span.entered()` in async tasks
174195

175196
### Database
197+
176198
- Maintain schema continuity on `unstable` branch
177199
- Database migrations must be backward compatible
178200

179201
### Consensus Crate
202+
180203
- Use safe math methods like `saturating_xxx` or `checked_xxx`
181204
- Critical that this crate behaves deterministically and MUST not have undefined behavior
182205

183206
### Testing Patterns
207+
184208
- **Use appropriate test types for the right scenarios**:
185209
- **Unit tests** for single component edge cases and isolated logic
186210
- **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:
204228
- See [`scripts/local_testnet/README.md`](scripts/local_testnet/README.md) for setup instructions
205229

206230
### TODOs and Comments
231+
207232
- All `TODO` statements must be accompanied by a GitHub issue link
208233
- Prefer line (`//`) comments to block comments (`/* ... */`)
209234
- Use doc comments (`///`) before attributes for public items
210235
- Keep documentation concise and clear - avoid verbose explanations
211236
- Provide examples in doc comments for public APIs when helpful
212237

213238
## Logging Guidelines
239+
214240
Use appropriate log levels for different scenarios:
241+
215242
- **`crit`**: Critical issues with major impact to Lighthouse functionality - Lighthouse may not function correctly without resolving. Needs immediate attention.
216243
- **`error`**: Error cases that may have moderate impact to Lighthouse functionality. Expect to receive reports from users for this level.
217244
- **`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:
221248
## Code Examples
222249

223250
### Safe Math in Consensus Crate
251+
224252
```rust
225253
// ❌ Avoid - could panic
226254
let result = a + b;
@@ -234,6 +262,7 @@ let result = a.safe_add(b)?;
234262
```
235263

236264
### Panics and Error Handling
265+
237266
```rust
238267
// ❌ Avoid - could panic at runtime
239268
let value = some_result.unwrap();
@@ -253,6 +282,7 @@ let item = array.get(1).expect("Array always has at least 2 elements due to vali
253282
```
254283

255284
### TODO Format
285+
256286
```rust
257287
pub fn my_function(&mut self, _something: &[u8]) -> Result<String, Error> {
258288
// TODO: Implement proper validation here
@@ -261,6 +291,7 @@ pub fn my_function(&mut self, _something: &[u8]) -> Result<String, Error> {
261291
```
262292

263293
### Async Task Spawning for Blocking Work
294+
264295
```rust
265296
// ❌ Avoid - blocking in async context
266297
async fn some_handler() {
@@ -276,6 +307,7 @@ async fn some_handler() {
276307
```
277308

278309
### Tracing Span Usage
310+
279311
```rust
280312
// ❌ Avoid - span on simple getter
281313
#[instrument]
@@ -291,9 +323,10 @@ async fn process_block(&self, block: Block) -> Result<(), Error> {
291323
```
292324

293325
## Build and Development Notes
294-
- Full builds and tests take 5+ minutes - use large timeouts (300s+) for any `cargo build`, `cargo test`, or `make` commands
326+
327+
- Full builds and tests take 5+ minutes - use large timeouts (300s+) for any `cargo build`, `cargo nextest`, or `make` commands
295328
- Use `cargo check` for faster iteration during development and always run after code changes
329+
- Prefer targeted package tests (`cargo nextest run -p <package>`) and individual tests over full test suite when debugging specific issues
296330
- Use `cargo fmt --all && make lint-fix` to format code and fix linting issues once a task is complete
297-
- Prefer targeted package tests (`cargo test -p <package>`) and individual tests over full test suite when debugging specific issues
298331
- Always understand the broader codebase patterns before making changes
299-
- Minimum Supported Rust Version (MSRV) is documented in `lighthouse/Cargo.toml` - ensure Rust version meets or exceeds this requirement
332+
- Minimum Supported Rust Version (MSRV) is documented in `lighthouse/Cargo.toml` - ensure Rust version meets or exceeds this requirement

0 commit comments

Comments
 (0)