Skip to content

feat: implement Store::get_attestation_target function#29

Merged
MegaRedHand merged 3 commits into
mainfrom
get-attestation-target
Jan 15, 2026
Merged

feat: implement Store::get_attestation_target function#29
MegaRedHand merged 3 commits into
mainfrom
get-attestation-target

Conversation

@MegaRedHand
Copy link
Copy Markdown
Collaborator

No description provided.

@MegaRedHand MegaRedHand marked this pull request as ready for review January 15, 2026 18:52
@MegaRedHand MegaRedHand merged commit 1010712 into main Jan 15, 2026
@MegaRedHand MegaRedHand deleted the get-attestation-target branch January 15, 2026 18:52
pablodeymo added a commit that referenced this pull request Apr 14, 2026
…d bucket update (leanMetrics PR #29)

  - Block production: building time, payload aggregation time, aggregated payload count,
    success/failure counters
  - Gossip message sizes: block, attestation, and aggregation compressed bytes
  - Sync status gauge with idle/syncing/synced labels (wiring deferred to PR #246)
  - Update committee_signatures_aggregation buckets from [0.005..1s] to [0.05..4s]
pablodeymo added a commit that referenced this pull request Apr 15, 2026
  Add block production metrics (building time, payload aggregation time,
  aggregated payload count, success/failure counters), gossip message size
  histograms (block, attestation, aggregation), node sync status gauge
  (idle/syncing/synced), and update committee signature aggregation
  histogram buckets to wider range.
MegaRedHand pushed a commit that referenced this pull request Apr 15, 2026
## Motivation

Implements the metrics defined in
[leanEthereum/leanMetrics#29](leanEthereum/leanMetrics#29)
for Devnet-4 monitoring: block production, gossip message sizes, sync
status, and updated histogram buckets.

## Description

### Block Production Metrics (`blockchain/metrics.rs` → instrumented in
`lib.rs` + `store.rs`)

| Metric | Type | Buckets |
|--------|------|---------|
| `lean_block_building_time_seconds` | Histogram | 0.01, 0.025, 0.05,
0.1, 0.25, 0.5, 0.75, 1 |
| `lean_block_building_payload_aggregation_time_seconds` | Histogram |
0.1, 0.25, 0.5, 0.75, 1, 2, 3, 4 |
| `lean_block_aggregated_payloads` | Histogram | 1, 2, 4, 8, 16, 32, 64,
128 |
| `lean_block_building_success_total` | Counter | — |
| `lean_block_building_failures_total` | Counter | — |

- `propose_block()` is wrapped with a timing guard for total block
building time, and increments success/failure counters on each exit
path.
- `produce_block_with_signatures()` times the `build_block()` call
specifically for payload aggregation, and observes the aggregated
payload count.

### Sync Status (`blockchain/metrics.rs` → tracked in `lib.rs`)

| Metric | Type | Labels |
|--------|------|--------|
| `lean_node_sync_status` | Gauge | status=idle,syncing,synced |

- Set to `idle` at startup (before first tick).
- Updated to `syncing` or `synced` after every block, by comparing
`head_slot` against the wall clock slot.

### Gossip Message Size Metrics (`p2p/metrics.rs` → instrumented in
`gossipsub/handler.rs`)

| Metric | Type | Buckets |
|--------|------|---------|
| `lean_gossip_block_size_bytes` | Histogram | 10K, 50K, 100K, 250K,
500K, 1M, 2M, 5M |
| `lean_gossip_attestation_size_bytes` | Histogram | 512, 1K, 2K, 4K,
8K, 16K |
| `lean_gossip_aggregation_size_bytes` | Histogram | 1K, 4K, 16K, 64K,
128K, 256K, 512K, 1M |

- Observed on the **uncompressed** message after snappy decompression,
for each gossip message type.

### Modified Existing Metric

- `lean_committee_signatures_aggregation_time_seconds`: buckets updated
from `[0.005..1.0]` to `[0.05..4.0]` to capture longer aggregation times
in Devnet-4.

## How to Test

1. `make fmt` — passes
2. `make lint` — passes (clippy clean)
3. `make test` — spec test failures are pre-existing (fixture format
mismatch, unrelated to this PR)
4. Run a local devnet and verify new metrics appear on the `/metrics`
endpoint (port 5054)
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)
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