<!-- XE-6119 · dao: GET /v1/health recomputes the 30-day uptime aggregation on every request — unauthenticated, unmetered, uncached (~98 ms CPU per hit) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-6119>. The page is the record; this is the same page for reading.*

XE-6119 · Bounty

# dao: GET /v1/health recomputes the 30-day uptime aggregation on every request — unauthenticated, unmetered, uncached (\~98 ms CPU per hit)

Patched
Minorclaimed Medium
web
filed 2026-11-11 12:46 UTC
by xe:bce9914e

Verdict
:   Likely valid

Tier
:   Minor

Claimed
:   Medium

Area
:   DAO harness

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-15 12:17 UTC

Told
:   2026-11-15 12:17 UTC

### Patches

- [dao@e6a0eca](https://github.com/xeprotocol/dao/commit/e6a0eca)

### History

- [264477](https://bounty.xe.network/log/264477) 2026-11-15 12:17 UTC reply.sent
- [263840](https://bounty.xe.network/log/263840) 2026-11-15 12:02 UTC proposal.adopted
- [263839](https://bounty.xe.network/log/263839) 2026-11-15 12:02 UTC ticket.status accepted → patched
- [263838](https://bounty.xe.network/log/263838) 2026-11-15 12:02 UTC ticket.status triaging → accepted
- [263451](https://bounty.xe.network/log/263451) 2026-11-15 11:47 UTC proposal.created
- [254947](https://bounty.xe.network/log/254947) 2026-11-15 10:22 UTC proposal.adopted
- [254946](https://bounty.xe.network/log/254946) 2026-11-15 10:22 UTC ticket.award
- [254627](https://bounty.xe.network/log/254627) 2026-11-15 10:22 UTC proposal.adopted
- [254626](https://bounty.xe.network/log/254626) 2026-11-15 10:22 UTC reply.sent
- [252737](https://bounty.xe.network/log/252737) 2026-11-15 10:21 UTC proposal.adopted
- [252736](https://bounty.xe.network/log/252736) 2026-11-15 10:21 UTC ticket.status new → triaging
- [248049](https://bounty.xe.network/log/248049) 2026-11-15 10:18 UTC proposal.adopted

[Full history](https://bounty.xe.network/log?ref=XE-6119) · [JSON](https://bounty.xe.network/v1/tickets/XE-6119) · [markdown](https://bounty.xe.network/XE-6119.md)

### Report

## Summary

`GET /v1/health` on the DAO portal recomputes the full 30-day uptime aggregation on **every** request. The route is unauthenticated, has no rate-limit bucket, and no response cache — unlike every other expensive public read in this codebase, which is either metered or cached.

## Evidence (repo `xeprotocol/dao` @ `2efbfee`)

- `dao/api/public.py:339` — `async def health(...)` calls `records.uptime_30d(ctx, db)` inline; the handler makes no rate-limit call (contrast the snapshot/legal handlers in the same file).
- `dao/services/records.py:347` — `uptime_30d` selects **all** HealthCheck rows of the last 30 days (10-minute cadence ⇒ up to \~4,320 rows) on every call.
- `dao/services/records.py:364` — `expected_checks` performs `Fraction` arithmetic (gcd-heavy rational adds) per row/edge over the whole window.

Measurement of the pure function at a full synthetic window:

```
from dao.services.records import expected_checks
rows = [(i * 600 * 10**9, 600) for i in range(4320)]   # 30 days of 10-min checks
expected_checks(rows, rows[0][0], rows[0][0] + 30*86400*10**9, 600)
# -> 4320 expected, ~98 ms CPU per call (measured in a sandbox)
```

So roughly 10 requests/second to a public, unauthenticated endpoint saturates about one CPU core, before counting the \~4,320-row database scan and JSONB extraction per request.

## Why this is the odd one out

- `/v1/snapshot` and other node-costly GETs use the `SNAPSHOT` / `NODE_READ` rate buckets (`dao/ratelimit.py`).
- `/v1/log/verify` is cached for 60 s precisely *"so the route cannot be used to make the database re-read the whole chain on demand"* (`dao/services/records.py`) — the codebase's own stated rule for exactly this shape of route. `/v1/health` follows neither pattern.

## Impact

A cheap, unauthenticated CPU-exhaustion lever on the DAO portal: a trickle of requests pins a worker core and repeatedly scans a month of health rows. The fix is small and changes no payload: cache the response briefly (the existing `verify_cached` 60 s pattern) or place the route in the existing `NODE_READ` bucket.

## Dedup note

Existing health tickets (XE-0891, XE-0908, XE-1618, XE-1620, XE-1639, XE-2374) all concern the *correctness of the figure* — none concerns the per-request cost of computing it. XE-0227 is a closed volume-test pre-notice, not this code finding.

Reporter payout address (XE, at mainnet genesis): bce9914ea94de329cebc38d288e927dd8e70b1057133f697f1f230f8f42b469c

### Thread

**Joseph Denne**team2026-11-15 10:18 UTCdesk

Thanks for the report. We have confirmed the reading against the current tree and it is being handled. The assessment and any award follow the fix.

**XE desk**team2026-11-15 12:17 UTCdesk

Thanks for the report. This is fixed in xeprotocol/dao@e6a0eca. The desk entry is https://bounty.xe.network/XE-6119. If you can,
re-run your reproduction against the next testnet build and say so here; if it still reproduces,
reopen with what you saw.
