Skip to content

feat: add functions to build attestations and blocks - #30

Merged
MegaRedHand merged 3 commits into
mainfrom
produce-attestation-and-block
Jan 16, 2026
Merged

MegaRedHand merged 3 commits into
mainfrom
produce-attestation-and-block

Conversation

@MegaRedHand

Copy link
Copy Markdown
Collaborator

No description provided.

@MegaRedHand
MegaRedHand marked this pull request as ready for review January 16, 2026 15:06
@MegaRedHand
MegaRedHand merged commit fdf6d92 into main Jan 16, 2026
@MegaRedHand
MegaRedHand deleted the produce-attestation-and-block branch January 16, 2026 15:07
MegaRedHand pushed a commit that referenced this pull request Apr 21, 2026
… PR #30 (#312)

## Motivation

Implements the `lean_attestations_production_time_seconds` histogram
defined in

[leanEthereum/leanMetrics#30](leanEthereum/leanMetrics#30),
which measures the end-to-end time a node spends producing attestations
for all its validators in a given slot.

## Description

### New Metric

| Metric | Type | Buckets | Sample collection event |
|--------|------|---------|-------------------------|
| `lean_attestations_production_time_seconds` | Histogram | 0.01, 0.025,
0.05, 0.1, 0.25, 0.5, 0.75, 1 | On attestation production |

### Implementation

- **`crates/blockchain/src/metrics.rs`**: registers the histogram under
the
`Validator Metrics` family and exposes `time_attestations_production()`,
which returns a `TimingGuard` that observes the duration on drop. Added
  to the `init()` eager-registration list so the metric appears on
  `/metrics` from process start.
- **`crates/blockchain/src/lib.rs`**: instruments
`produce_attestations()`
with `let _timing = metrics::time_attestations_production();` at the top
  of the function, capturing the full flow:
  1. Attestation data construction (`store::produce_attestation_data`)
  2. Per-validator signing
  3. Self-delivery via `on_gossip_attestation`
  4. Gossip publish

### Documentation

- **`docs/metrics.md`**: adds a `Buckets` column to the Validator
Metrics
  table (consistent with the other tables in the doc) and lists the new
  metric alongside `lean_validators_count` and `lean_is_aggregator`.

## How to Test

1. `make fmt` - passes
2. `make lint` - passes (clippy clean)
3. `make test` - passes
4. Run a local devnet and verify the metric appears on the `/metrics`
   endpoint (port 5054):
   ```
curl -s localhost:5054/metrics | grep
lean_attestations_production_time_seconds
   ```
   You should see the histogram buckets populate as the node produces
   attestations each slot.

## Related

- leanMetrics spec: leanEthereum/leanMetrics#30
- Previous metrics PR: #289 (Devnet-4 metrics from leanMetrics PR #29)
tcoratger pushed a commit to tcoratger/ethlambda that referenced this pull request Oct 30, 2026
The smoke step sat in `Test (node)` on the assumption that the test build
had already linked the binary. It had not: `cargo test` never links the
plain `ethlambda` binary, and it unifies dev-dependency features in
(`bin/ethlambda` enables tokio's `test-util`), which `cargo run` leaves
out. tokio is the only crate whose features differ, but everything above
it is rebuilt with it: libp2p, hyper, axum, the ethrex crates and the
node crates, six minutes of compilation into a target dir the test build
leaves at about 1.8 GB free.

That pushes the runner to a full disk, so whether `Test (node)` passes
comes down to whether the rust-cache post step still finds room to write
its log. It fails with `No space left on device` after every test has
passed, as on PR lambdaclass#24 and feat/validator-client.

A dedicated job builds only the binary's own graph on a fresh runner.
It needs no leanSpec fixtures: with `--mock-crypto` the synthetic
benchmark generates its own chain and reads no files.
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.

1 participant