Skip to content

metrics, node: lean_block_proposal attestation build metrics#914

Merged
anshalshukla merged 5 commits into
mainfrom
metrics/block-proposal-attestation-build
May 22, 2026
Merged

metrics, node: lean_block_proposal attestation build metrics#914
anshalshukla merged 5 commits into
mainfrom
metrics/block-proposal-attestation-build

Conversation

@ch4r10t33r

Copy link
Copy Markdown
Contributor

Summary

Adds cross-client lean_block_proposal_* metrics for block-proposal attestation selection in getProposalAttestationsUnlocked, aligned with leanSpec #753:

  • lean_block_proposal_attestation_build_phase_seconds{phase}select_payloads, compact_ffi, stf_simulate
  • lean_block_proposal_attestation_builds_total
  • lean_block_proposal_child_payloads_consumed_total
  • lean_block_proposal_attestation_data_selected
  • lean_block_proposal_aggregates_selected

These are not the same as zeam_compact_attestations_* (per-compactAttestations FFI time and attestation row in/out only). lean_block_building_payload_aggregation_time_seconds remains the wall-clock total for the whole call.

Test plan

  • zig build test
  • CI green

Instrument getProposalAttestations with cross-client lean_* phase timing,
build/child-payload counters, and attestation-data/aggregate histograms.
Distinct from zeam_compact_attestations_* (compactAttestations FFI only).
Align phase label with leanSpec #753; compact is spec-level recursive
merge, not an FFI-specific step name.
anshalshukla
anshalshukla previously approved these changes May 21, 2026
CI stalled finalization at slot 12 so node3 never emitted its own
new_finalization within 480s. Accept head-event progress after the
delayed node3 start (original #484 approach) while still honoring
node3 finalization or a later global finalization when they occur.
Remove the per-event SUCCESS log that fired before assertions.
ch4r10t33r and others added 2 commits May 21, 2026 21:29
CI records ~25 new_head events by first finalization and only one more
before the chain stalls; requiring +5 never tripped got_node3_sync.
Use strictly-more-than baseline and re-check at timeout exit.
@ch4r10t33r ch4r10t33r requested a review from anshalshukla May 21, 2026 22:20
@anshalshukla anshalshukla merged commit 9602ba3 into main May 22, 2026
13 checks passed
@anshalshukla anshalshukla deleted the metrics/block-proposal-attestation-build branch May 22, 2026 08:19
MegaRedHand pushed a commit to lambdaclass/ethlambda that referenced this pull request Jun 3, 2026
…ction (#414)

## 🗒️ Description / Motivation

Ports the five `lean_block_proposal_*` observability metrics from
[leanSpec PR #753](leanEthereum/leanSpec#753)
into the ethlambda block builder.

These metrics give cross-client visibility into the block-proposal
attestation-selection path (`build_block`): how long each phase takes,
how many proposal builds run, how many child payloads are greedily
consumed, and how many distinct `AttestationData` / aggregated proofs
end up in the proposed block. They align with [zeam
#914](blockblaz/zeam#914
`getProposalAttestations` instrumentation and the leanSpec naming so the
[leanMetrics](https://github.com/leanEthereum/leanMetrics) dashboards
work across clients.

## What Changed

**`crates/blockchain/src/metrics.rs`** — five new metrics registered
with the existing `LazyLock` + `register_*!` pattern, a
`BLOCK_PROPOSAL_ATTESTATION_BUILD_PHASES` label constant, registration
in `init()`, public API functions, and a unit test:

| Metric | Type | Buckets / Labels |
|--------|------|------------------|
| `lean_block_proposal_attestation_build_phase_seconds` | HistogramVec |
`phase` = `select_payloads`, `compact`, `stf_simulate`; buckets
`0.001…8` |
| `lean_block_proposal_attestation_builds_total` | Counter | one per
proposal attempt |
| `lean_block_proposal_child_payloads_consumed_total` | Counter |
greedily-picked proofs before compaction |
| `lean_block_proposal_attestation_data_selected` | Histogram | buckets
`0, 1, 2, 4, 8, 16, 32` |
| `lean_block_proposal_aggregates_selected` | Histogram | buckets `0, 1,
2, 4, 8, 16, 32, 64, 128` |

**`crates/blockchain/src/block_builder.rs`** — instruments
`build_block`: times the `select_attestations`, `compact_attestations`,
and STF (`process_slots` + `process_block`) phases, and emits the
counters/histograms after a successful build.

**`docs/metrics.md`** — documents all five in the Block Production
Metrics table.

## Correctness / Behavior Guarantees

- **No behavior change.** Only metric observations were added around
existing logic; block contents, selection order, and the
state-transition path are untouched.
- **Architectural divergence from leanSpec, documented.** leanSpec
re-runs the STF inside a fixed-point loop and observes `stf_simulate`
per round. ethlambda projects justification/finalization incrementally
during selection and runs the STF exactly **once** at the end, so its
`stf_simulate` is a single observation per build. This is noted on the
`BLOCK_PROPOSAL_ATTESTATION_BUILD_PHASES` doc comment, consistent with
the upstream PR's own caveat that phase timings are not directly
comparable across clients.
- `attestation_data_selected` and `aggregates_selected` are observed
from the post-compaction body (one merged proof per distinct
`AttestationData`), matching the spec's intent.
- Metrics are only emitted on a **successful** build; a build that
errors out in the STF is already counted by the existing
`lean_block_building_failures_total`.

## Tests Added / Run

- New unit test
`metrics::tests::block_proposal_attestation_build_metrics_are_usable` —
verifies the phase metric registers and accepts every label in
`BLOCK_PROPOSAL_ATTESTATION_BUILD_PHASES`, and that the companion
counters/histograms are callable. Guards against drift between the label
constant and the strings passed at the `build_block` call sites.
- Existing `block_builder` tests (`build_block_*`,
`compact_attestations_*`, `extend_proofs_greedily_*`) now exercise the
new metric paths and pass unchanged.

Commands run:
- `make fmt` — clean
- `cargo clippy -p ethlambda-blockchain --all-targets -- -D warnings` —
clean
- `cargo test -p ethlambda-blockchain --lib` — 23 passing

## Related Issues / PRs

- Ports
[leanEthereum/leanSpec#753](leanEthereum/leanSpec#753)
- Related to
[blockblaz/zeam#914](blockblaz/zeam#914)
- Follows the metrics pattern from #406 (per-subnet attestation
aggregate coverage)

## ✅ Verification Checklist

- [x] Ran `make fmt` — clean
- [x] Ran `make lint` (clippy with `-D warnings`) — clean
- [ ] Ran `cargo test --workspace --release` — only
`ethlambda-blockchain` lib suite run (23 passing); full workspace
release run not yet executed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants