Repository navigation
Description
What's the problem
Part of #4431, the Event log. The dashboard has no store for system events with a label and a severity, and no single read path:
- The
eventstable (ts, type, detail, no id) is a chart-marker store. It is held in memory and fed tochart.events, so it cannot hold error episodes that need updating, and it should not grow with non-chart entries. - Payouts, shares, blocks, raffle wins and settings changes live in their own tables.
- On
develop-v2.1.0,build_mining_activity(dashboard/mining_dashboard/web/views/overview_views.py:72, called atweb/views/views.py:305) merges some of them for Overview, with a browser fallback inweb/static/sovereign/overview-model.mjs:200.
What it impacts
Every later Event log piece (#4433, #4434, #4435) and #3735's donation entries need this store and endpoint first.
How I found it
A read-only read of develop-v2.1.0 at bfd061f:
storage_schema.py: theeventstable;service/storage_service.py:309:add_event;overview_views.py:72:build_mining_activity;config/config.py:535:HISTORY_RETENTION_SEC, 30 days.
How important is it
Medium. It is the first piece of #4431, and the other three wait for it.
Acceptance criteria
Store
-
A new
event_logtable, separate fromevents, with these columns: id, ts, end_ts, count, kind, subject, label, severity (info, warning or error) and text. -
Producers call one helper,
record_event(kind, subject, label, severity, text_template, slots). -
add_eventkeeps feeding the chart unchanged. The legacyhashrate_lossandhashrate_recoveredrows are shown under the System label at read time. -
Error episodes are keyed by (kind, subject):
- the first failure opens an episode;
- each repeat increments its count and updates its last time;
- the episode closes at the first success of that check, or after 30 minutes with no repeat, whichever comes first.
- Fake-clock tests cover open, repeat, close by success, close by timeout, and a re-open after close.
-
Retention is 30 days (
HISTORY_RETENTION_SEC) or 5,000 rows, whichever comes first, oldest first, with at most one new entry per (kind, subject) per minute. A test inserts 20,000 events in one minute, then asserts there are at most 5,000 rows and that the last hour's error entries are still present. -
Entry text comes from fixed sentence templates, never from free text. It never contains:
- a wallet or onion address, view key, password or token;
- a transaction id, IP address, user name or rig hostname;
- a raw exception class name, raw config key or URL.
Payout text may state the chain and the amount. A test feeds each forbidden kind of value through
record_eventand asserts none of them appears in the stored text or in the response.
Read endpoint
-
GET /api/events?range=day|week|month|all&label=<l>[&label=<l>]&severity=errorreturns{entries, counts}:rangeis the only time control, with no from/to;- at most 500 entries, newest first, each with id, ts, end_ts, count, label, severity and text;
countshas one figure per label for the selected range.
- Existing rows appear through the read merge, with their labels and the same templates. They are not copied into
event_log, so one payout gives exactly one entry, and a test proves it:payouts: one entry per saved payout, "Payout received: XMR reached your wallet" (or XTM), label Payouts;sharesandblocks: label Shares and blocks;raffle_wins: label XvB;audit_events: label Settings, in plain words with no raw keys.
- Settings entries are returned only where and to whom
/api/auditis available today. A test covers both cases. -
/api/eventsreplacesbuild_mining_activityand its browser fallback as the single source for the Overview Activity list. - Endpoint tests cover each label, several labels at once,
severity=error, each range, an empty result and the 500 cap. -
docs/dashboard.mddocuments the endpoint and the labels. -
make test,make test-patch-coverageandmake lint-file-budgetpass.
Possible solutions
- A new
event_logtable and a read merge over the existing tables (recommended). Nothing is written twice, and history from before the upgrade shows up. - Extend
eventswith label and severity. It has no id, so episodes cannot be updated in place. It is also loaded into memory and into the chart payload, so non-chart rows would bloat both.
Activity