Skip to content

api: top-attesters / top-schema-owners / top-attestor-sets leaderboards#67

Merged
proofmancer merged 2 commits into
mainfrom
api/leaderboards-top-attesters-schemas-sets
May 22, 2026
Merged

api: top-attesters / top-schema-owners / top-attestor-sets leaderboards#67
proofmancer merged 2 commits into
mainfrom
api/leaderboards-top-attesters-schemas-sets

Conversation

@proofmancer
Copy link
Copy Markdown
Member

Why

Grafana wants "who's using the chain most" panels — top attesters, top schema owners, top attestor sets — alongside the existing ops + cost + economy dashboards (chain v0.2.11). Prometheus is wrong for this (address labels = unbounded cardinality), so the data needs to live in the api with Grafana pointing at it via the Infinity HTTP-JSON datasource. Filed during the 2026-05-22 session as part of Track 4 "full cost metrics" closeout — leaderboards were the second half of that ask.

What

Three new endpoints, all read-only, all sourced from existing indexer tables:

Endpoint Source Cost
GET /v1/stats/top-attesters?n=10 attestations GROUP BY submitter one indexed scan; attestations is small (devnet: ~20 rows)
GET /v1/stats/top-schema-owners?n=10 schemas GROUP BY owner one indexed scan; schemas is tiny (devnet: ~8 rows)
GET /v1/stats/top-attestor-sets?n=10 attestor_sets ORDER BY schema_count DESC single index scan — schema_count is denormalised by ingest, no GROUP BY

All three return the same LeaderboardResponse shape:

{
  "window": "all-time",
  "rows": [
    {"rank": 1, "address": "lig1…", "count": 7},
    {"rank": 2, "address": "lig1…", "count": 5},
    
  ]
}

Same {rank, address, count} row shape across all three means Grafana table panels can use one template per leaderboard. address is lig1... for the first two (rollup addresses) and las1... for top-attestor-sets (attestor-set ids) — same column, different identifier space, documented in the endpoint help.

Query params: n defaults to 10, capped at 100. 30s in-process cache + Cache-Control: public, max-age=30 matching the rest of /v1/stats/*.

Followup

  • File a chain issue to add an "Activity leaders" row to ops/grafana/ligate-node.json once the Grafana Infinity datasource is provisioned. Three table panels, one per leaderboard.
  • Future: time-windowed variant (?since=24h / ?since=7d) that JOINs on transactions.indexed_at for "who's been most active this week." Response shape stays the same; window field changes from "all-time" to the requested interval.

Net diff

3 files (crates/api/src/stats.rs +204, crates/api/src/main.rs +5, CHANGELOG.md +5).

@proofmancer proofmancer merged commit 03274d0 into main May 22, 2026
7 checks passed
@proofmancer proofmancer deleted the api/leaderboards-top-attesters-schemas-sets branch May 22, 2026 13:05
@github-actions github-actions Bot locked and limited conversation to collaborators May 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant