Skip to content

End a project slice early and restore the P2Pool route when the endpoint or dashboard fails #3704

Open

Description

@pithead-developer

What's the problem

Part of #2476. Owner priority (2026-10-27): build the opt-in donation feature now, shipping dark. A project slice must never leave rigs mining nowhere or mining for the project longer than planned. Three failure modes are not covered by the controller as it will be after {{A8}}:

  • The endpoint stops accepting. In -m simple (docker-compose.yml:547-548) a rig whose upstream is dead mines nothing. The signal is in the proxy summary: XMRigProxyClient.get_summary() documents upstreams: {active, total} (dashboard/mining_dashboard/client/xmrig_proxy_client.py:42-80, shape at :67). Nothing reads it during a slice.
  • The dashboard dies mid-slice. The proxy keeps the last pool list pushed through PUT /1/config (:158-184) until the dashboard returns; it reverts to the P2Pool boot pool only when the proxy itself restarts, because its config is re-rendered from the compose command on every start (docker-compose.yml:507-510, :539-546). The dashboard has restart: unless-stopped (:630), so the exposure is the time it stays down. XvB has the same latent behavior today; here the beneficiary is the project.
  • The dashboard restarts. AlgoService.run waits 5 s and then enters its loop (dashboard/mining_dashboard/service/xvb/algo_service.py:488-489). The first thing it does must be a route push to P2Pool, never a project slice.

Add, in new files under service/donation/ (algo_service.py is at its 558-line ceiling):

  • During a project slice, poll the proxy summary at most every XVB_MIN_TIME_SEND_MS (15 s, config/config.py:147). If upstreams.active is 0 for two consecutive polls after the dwell, end the slice, push the P2Pool route, set status fallback and record endpoint_down_since in the state record from {{A4}}.
  • Back off after a failure: skip project slices for one cycle, doubling per consecutive failure up to 6 cycles; debt is zeroed during backoff (the gift is lost, rigs are never stranded) and a successful slice clears the state.
  • On controller start, read the proxy config; if the first enabled pool is the project pool, push the P2Pool route before anything else. If it is not, send nothing.
  • Keep the worst case bounded: the planner's debt cap ({{A3}}) limits one slice to at most 3 cycles of credit (180 s at the 10 % cap, 90 s at 5 %), and a test asserts it.

What it impacts

Operators who opt in, on the days an endpoint or the dashboard misbehaves. Nothing when the feature is off.

How I found it

Read-only scan of origin/develop-v2.1.0 at 02852bd on 2026-10-27 from the paths above. Nothing was executed. Unknown: whether upstreams.active reflects only the currently enabled pool in simple mode (the e2e child proves it on a bench with a stub that refuses connections), and the right poll and backoff constants. A host-side pithead doctor row for "proxy on the project route while the dashboard is down" is not in this issue: lib/pithead/21-doctor-stack-checks.sh and 05-doctor-checks.sh have no reader of the proxy pool list today, so it is a separate piece of work if wanted.

How important is it

High inside this lane. It is what makes "fail open" true, and it is the difference between a harmless dead endpoint and idle rigs.

Acceptance criteria

  • Kill-mid-slice test (new dashboard/tests/service/donation/test_recovery.py, fake proxy client with a recorded config): a config whose first enabled pool is the project pool at start makes the controller's first update_config put P2Pool first and the project pool disabled, before any planner segment; a config already on P2Pool produces no update_config at start.
  • Early end: with upstreams.active 0 on two polls, the controller ends the slice within one poll interval of the second, pushes the P2Pool route, sets fallback and endpoint_down_since; with one zero poll followed by a non-zero poll it keeps the slice.
  • Backoff and recovery follow the schedule above under a fake clock; the debt is zero after a failure; the next successful slice returns the status to idle and clears endpoint_down_since.
  • No planned segment exceeds the debt cap in a property test over the planner and executor together.
  • Disabled or unavailable: none of these code paths runs and get_summary is not called by the donation code.
  • make test, make test-patch-coverage (90 % of changed lines) and make lint-file-budget pass; algo_service.py does not grow. No new explanatory code comments.

Possible solutions

  • Poll the proxy summary from the executor (recommended: one reader, no new thread).
  • Poll from the dashboard's existing data loop and flag the controller: spreads one decision across two services and races the single writer.
  • A host-side watchdog that restores the P2Pool route when the dashboard is down: closes the dashboard-dead gap fully, and is new host machinery; worth a separate issue only if the exposure is judged too long.

Part of #2476. Depends on {{A4}} and {{A8}}.

Activity

  1. added this to the v2.1.0 milestone on Oct 27, 2026
  2. added
    enhancement
    dashboard
    p2pool
    on Oct 27, 2026
  3. added
    blocked
    on Oct 27, 2026
  4. pithead-developer commented on Nov 16, 2026

    @pithead-developer
    ContributorAuthor

    Blocked on #3697.
    Blocked on #3701.

    Dependency marker for the dashboard. The native blocked-by links on this issue already name these open blockers, and the tick removes blocked when every one of them closes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockeddashboardenhancementp2pool

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions