Commit 318923c
authored
Add timing logs for block processing and XMSS signature verification (#225)
## Summary
- Instruments `on_block_core()` with per-phase timing breakdown of full
block processing
- Instruments `verify_signatures()` with per-phase timing breakdown of
XMSS signature verification
- Helps diagnose #197 where
`lean_fork_choice_block_processing_time_seconds` shows constant ~1s on
devnet dashboards
## Context
Issue #197 reports that block processing time on the devnet Grafana
dashboard is always approximately 1 second. Investigation revealed that:
1. The `lean_fork_choice_block_processing_time_seconds` histogram has a
bucket gap between `0.1s` and `1.0s`, which could cause Grafana's
`histogram_quantile` to interpolate misleadingly
2. The actual bottleneck is likely in XMSS signature verification
(post-quantum crypto), but there's no visibility into how long each
phase takes
This PR adds structured timing logs at two levels to pinpoint exactly
where time is spent, without changing any behavior.
## Example output
Each block produces two log lines — first the signature detail, then the
block summary:
```
2026-03-13T15:30:42.123456Z INFO ethlambda_blockchain::store: Signature verification timing slot=42 attestation_count=3 aggregated_sigs_ms=450 proposer_sig_ms=120 total_ms=572
2026-03-13T15:30:42.140123Z INFO ethlambda_blockchain::store: Processed new block slot=42 block_root=0xabcd1234 state_root=0xef567890 sig_verification_ms=572 state_transition_ms=15 block_total_ms=590
```
In this example you can see:
- **Signature verification dominates** — `sig_verification_ms=572` out
of `block_total_ms=590`
- **Aggregated sigs are the bottleneck** — `aggregated_sigs_ms=450` vs
`proposer_sig_ms=120`
- **State transition is fast** — `state_transition_ms=15`
- **Minimal overhead** — `590 - 572 - 15 = 3ms` for storage, fork
choice, etc.
## Logged fields
### Block processing breakdown (`on_block_core`)
| Field | Description |
|-------|-------------|
| `sig_verification_ms` | Time spent in `verify_signatures()` (0 when
verification is skipped) |
| `state_transition_ms` | Time spent in `state_transition()`
(process_slots + process_block) |
| `block_total_ms` | Wall-clock time for the entire `on_block_core()`
function |
### Signature verification breakdown (`verify_signatures`)
| Field | Description |
|-------|-------------|
| `attestation_count` | Number of aggregated attestation signatures
verified |
| `aggregated_sigs_ms` | Total time verifying all aggregated attestation
proofs (leanVM calls) |
| `proposer_sig_ms` | Time verifying the proposer's individual XMSS
signature |
| `total_ms` | Wall-clock time for the entire `verify_signatures()`
function |
## How to use
```bash
# Full block processing breakdown
grep "Processed new block" node.log
# Signature verification detail
grep "Signature verification timing" node.log
# Key questions these logs answer:
# - Is sig verification the bottleneck? (sig_verification_ms ≈ block_total_ms)
# - Is state transition the bottleneck? (state_transition_ms >> sig_verification_ms)
# - Within sigs, is it aggregated or proposer? (aggregated_sigs_ms vs proposer_sig_ms)
# - Is there overhead outside both phases? (block_total_ms >> sig + state_transition)
```
## Test plan
- [x] `cargo check -p ethlambda-blockchain` passes
- [x] `cargo fmt --all -- --check` passes
- [x] `cargo clippy -p ethlambda-blockchain -- -D warnings` passes
- [ ] Deploy to devnet and observe log output during block production
- [ ] Compare timing fields to identify the dominant bottleneck
Closes #197 (diagnostic step — may need follow-up based on findings)1 parent f8acb93 commit 318923c
1 file changed
+33
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
| 535 | + | |
535 | 536 | | |
536 | 537 | | |
537 | 538 | | |
| |||
553 | 554 | | |
554 | 555 | | |
555 | 556 | | |
| 557 | + | |
556 | 558 | | |
557 | 559 | | |
558 | 560 | | |
559 | 561 | | |
| 562 | + | |
560 | 563 | | |
561 | 564 | | |
562 | 565 | | |
563 | 566 | | |
564 | 567 | | |
| 568 | + | |
565 | 569 | | |
566 | 570 | | |
| 571 | + | |
567 | 572 | | |
568 | 573 | | |
569 | 574 | | |
| |||
647 | 652 | | |
648 | 653 | | |
649 | 654 | | |
650 | | - | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
651 | 665 | | |
652 | 666 | | |
653 | 667 | | |
| |||
1175 | 1189 | | |
1176 | 1190 | | |
1177 | 1191 | | |
| 1192 | + | |
| 1193 | + | |
1178 | 1194 | | |
1179 | 1195 | | |
1180 | 1196 | | |
| |||
1189 | 1205 | | |
1190 | 1206 | | |
1191 | 1207 | | |
| 1208 | + | |
1192 | 1209 | | |
1193 | 1210 | | |
1194 | 1211 | | |
| |||
1224 | 1241 | | |
1225 | 1242 | | |
1226 | 1243 | | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
1227 | 1247 | | |
1228 | 1248 | | |
1229 | 1249 | | |
| |||
1256 | 1276 | | |
1257 | 1277 | | |
1258 | 1278 | | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
1259 | 1291 | | |
1260 | 1292 | | |
1261 | 1293 | | |
| |||
0 commit comments