Commit cdbca48
authored
## 🗒️ Description / Motivation
- Removes the `log_tree` boolean parameter from
`accept_new_attestations` (and `update_head`), which threaded a UI
concern through the fork-choice code path.
- `crates/blockchain/src/store.rs` is meant to mirror the spec's
architecture, and the `log_tree` flag was inconsistent with that goal —
logging is a caller-side concern, not part of the fork-choice update.
- Moves the fork choice tree logging to the call site (`on_tick`,
end-of-slot) so the update functions stay purely about fork-choice
computation.
## What Changed
- **`crates/blockchain/src/store.rs`**
- Dropped the `log_tree: bool` parameter from `accept_new_attestations`
and `update_head`.
- Added a standalone `log_fork_choice_tree(store, &HeadUpdate)` helper
that renders the ASCII tree; called from `on_tick` at
`SlotInterval::EndOfSlot`.
- `update_head` now returns a `HeadUpdate { blocks, weights, head }` so
the tree renders from already-computed data instead of recomputing LMD
GHOST.
- Updated the (previously stale) `update_head` doc comment.
- **`crates/blockchain/src/spec_test_runner.rs`**
- Updated the `update_head` call to the new no-bool signature.
## Correctness / Behavior Guarantees
- **No behavior change.** The tree is still logged only at end-of-slot,
and `log_fork_choice_tree` still reads
`latest_justified`/`latest_finalized` *after* the checkpoint update — so
the rendered tree is byte-for-byte equivalent to before.
- **Efficiency improvement:** end-of-slot previously computed LMD GHOST
twice (once in `update_head`, once for the tree). It now computes once
and reuses the result via `HeadUpdate`, eliminating a redundant
`get_live_chain()` + `compute_lmd_ghost_head()` per slot.
- All other call sites (`BlockPublication`, `on_block_core`,
`get_proposal_head`) simply drop the `false` argument — no functional
difference.
## Tests Added / Run
- No new tests — this is a behavior-preserving refactor covered by
existing fork-choice spec tests.
- Ran:
- `cargo clippy -p ethlambda-blockchain --all-targets -- -D warnings` —
clean
- `cargo fmt --all --check` — clean
- `cargo test -p ethlambda-blockchain --test forkchoice_spectests` —
compiled and ran; requires `make leanSpec/fixtures` locally to execute
assertions.
## Related Issues / PRs
- Closes lambdaclass#520
## ✅ Verification Checklist
- [x] Ran `make fmt` — clean
- [x] Ran `make lint` (clippy with `-D warnings`) — clean
- [x] Ran `cargo test --workspace --release`
1 parent 15d40a4 commit cdbca48
2 files changed
Lines changed: 41 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
28 | 53 | | |
29 | | - | |
| 54 | + | |
30 | 55 | | |
31 | 56 | | |
32 | 57 | | |
33 | | - | |
| 58 | + | |
34 | 59 | | |
35 | 60 | | |
36 | 61 | | |
37 | 62 | | |
38 | | - | |
39 | | - | |
40 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
41 | 66 | | |
42 | 67 | | |
43 | 68 | | |
| |||
104 | 129 | | |
105 | 130 | | |
106 | 131 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
120 | 136 | | |
121 | 137 | | |
122 | 138 | | |
| |||
350 | 366 | | |
351 | 367 | | |
352 | 368 | | |
353 | | - | |
| 369 | + | |
354 | 370 | | |
355 | 371 | | |
356 | 372 | | |
| |||
365 | 381 | | |
366 | 382 | | |
367 | 383 | | |
368 | | - | |
| 384 | + | |
| 385 | + | |
369 | 386 | | |
370 | 387 | | |
371 | 388 | | |
| |||
690 | 707 | | |
691 | 708 | | |
692 | 709 | | |
693 | | - | |
| 710 | + | |
694 | 711 | | |
695 | 712 | | |
696 | 713 | | |
| |||
872 | 889 | | |
873 | 890 | | |
874 | 891 | | |
875 | | - | |
| 892 | + | |
876 | 893 | | |
877 | 894 | | |
878 | 895 | | |
| |||
0 commit comments