[DAO] sessions._submitted leaves Anchor rows unwritten until worker.job_sessions, causing false anchor_overdue health degradation and unbounded rescans
Report
Summary
In dao/services/sessions.py, _ended (L502-506) deletes an Anchor row inside the same transaction whenever an anchor session ends failed or cancelled. By contrast, _submitted (L394-401) — the single helper called by submit (L426), _refused (L448), rebuild (L295), and cancel (L494) whenever a session's block has landed on the state chain — sets SigningSession.status = "submitted", submitted_index, and submitted_hash without updating Anchor.statechain_index or Anchor.statechain_hash.
This produces two concrete defects:
- False
anchor_overduehealth degradation and stale public anchor surfaces after API submission:- Every member API path that lands an anchor block (
POST /v1/members/sessions/{sid}/sign,/rebuild,/cancel) commitsSigningSession.status = "submitted"while leavingAnchor.statechain_index = NoneandAnchor.statechain_hash = "". - In
dao/worker.py:289-303(Worker.scheduler),"health"is ordered before"sessions"injob_table. On any scheduler pass where bothjob_healthandjob_sessionsare due after an overdue anchor has just been signed and submitted via the API (or whenGET /v1/health/dao healthruns before the next 120-secondjob_sessionstick, or while the worker is not yet caught up),records.health(dao/services/records.py:282) querieslatest_anchor(db, written=True)(Anchor.statechain_index.isnot(None)), misses the already-landed anchor, setsanchor_overdue = Trueandok = False, degrades 30-day uptime (HealthCheck(ok=False)), and appends a publichealth.degradedevent toEventLog. - Over the same window,
GET /v1/legal/anchors,GET /v1/log/head, and/recordsreportstatechain_index: null(pending) while/membersalready shows the anchor sessionWritten at state-chain #N.
- Every member API path that lands an anchor block (
- Unbounded full-history anchor scan every 120 seconds in
worker.job_sessions:- To compensate for
_submittednot updatingAnchor,dao/worker.py:195-197runsselect(SigningSession).where(SigningSession.status == "submitted", SigningSession.kind == "anchor")on every two-minutejob_sessionspass with noAnchor.statechain_index.is_(None)filter, reloading every submitted anchor session since genesis and issuingSELECT ... FROM anchors+ ORM updates for each one.
- To compensate for
Impact
Submitting an overdue anchor via the member API still triggers false anchor_overdue health failure, permanent health.degraded log entries, 30-day uptime loss when job_health runs ahead of job_sessions, temporary disagreement between /members and /records + /v1/legal/anchors + /v1/log/head, and an O(total historical anchors) database scan every 120 seconds.
Thread
Fix proposed in xeprotocol/dao#4.
Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-13355 and says what differs; it is read like any other.