Skip to content

Route the project slice through the switching controller #3701

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. This is the feature itself: sending a slice of each cycle to the project endpoint. AlgoService is the only writer of the proxy's pool list, and any second writer would race it (both do GET, modify, PUT on /1/config, dashboard/mining_dashboard/client/xmrig_proxy_client.py:120-184). Today it knows two pools:

  • switch_miners builds a P2Pool pool and an XvB pool, puts the enabled one first, and sends both (dashboard/mining_dashboard/service/xvb/algo_service.py:75-115); only the XvB pool carries socks5 (:89-91).
  • run executes P2POOL, XVB or SPLIT with inline sleeps (:483-558). With XvB off, get_decision returns P2POOL at once (:142-143) and the loop still runs, so a project slice must work with XvB off.
  • The mode label is read by substring: "XVB" in current_mode decides hashrate attribution (service/data_service.py:188-190, :508-510) and the chart palette checks Split and XVB (web/views/series_views.py:193-200).

Wire the planner ({{A3}}), the constants loader ({{A2}}), the config ({{A1}}) and the store ({{A4}}) into the controller:

  • A third pool object for the project: url is the constants endpoint, user is one fixed non-identifying label (never the wallet, the XvB donor id or a rig name; printable ASCII without . or +, because upstream P2Pool splits the login on those characters, src/stratum_server.cpp:204-262), pass x, coin monero, socks5 set only when DONATION_TOR_ENABLED; the local P2Pool pool never gets socks5.
  • run asks the planner for segments (XvB slice, P2Pool remainder, project slice), sleeps each segment's length, and switches to the project pool for the last one. The project slice uses a plain sleep like the XvB slice (:539), the P2Pool remainder keeps _smart_sleep.
  • max_fraction comes from the same _max_donation_fraction helper (:286-294, steering_projection.py:35-53), computed in run because get_decision returns before computing it when XvB is off.
  • While workers are rejected (:495) nothing is switched and the debt is untouched.
  • The project mode label contains neither XVB nor Split.
  • Every cycle the controller records a donation_history row and the state record from {{A4}}, so a dashboard restart resumes the debt.
  • algo_service.py is at its 558-line ceiling in docs/dev/file-budget.tsv. Move the pool-building and the segment executor into new files under service/donation/ (for example pools.py, executor.py) first, so the net change to algo_service.py is zero or negative.

What it impacts

The proxy's upstream route for every opted-in operator, and the XvB controller's path (shared run loop). With the feature disabled or unavailable the payloads must not change.

How I found it

Read-only scan of origin/develop-v2.1.0 at 02852bd on 2026-10-27 from the paths above and dashboard/tests/service/xvb/test_algo_service_switch_miners.py:1-52 (the existing pool tests). Nothing was executed. Unknown: whether xmrig-proxy honours socks5 for an onion upstream (the e2e phase proves it), and whether a project slice should be skipped while the donor has no share in the PPLNS window (algo_service.py:153-157 forces P2Pool for XvB then). This issue does not skip it; an owner ruling would be a small follow-up.

How important is it

High inside this lane. It touches real hashpower routing, so default-off and fail-safe behavior carry the weight.

Acceptance criteria

  • With the feature disabled or donation.json empty, switch_miners sends byte-identical payloads to today for P2POOL, XVB and SPLIT, and the existing tests in test_algo_service_switch_miners.py pass unchanged. A new parity test pins the two-pool payloads.
  • Enabled and available: the pool list has three entries and exactly one is enabled; the project pool matches the shape above; a test asserts the serialized payload contains neither MONERO_WALLET_ADDRESS nor XVB_DONOR_ID in the project entry and that the label has no . or +; socks5 appears only on the XvB pool (when xvb.tor) and the project pool (when donation.tor), mirroring test_algo_service_switch_miners.py:20-52.
  • With a fake clock: XvB off gives P2Pool then project; SPLIT gives XvB slice, P2Pool remainder, project slice; the sleep lengths equal the planner's segments; the XvB slice length is identical with and without the donation enabled.
  • A planner trim sets status: reduced and reduced_percent in the state record, and a slice start sets slice_ends_at (cleared when it ends); workers_rejected blocks switching and keeps the debt; the project label contains neither XVB nor Split, and the attribution and palette tests keep passing.
  • One donation_history row per cycle, and a restarted controller resumes the stored debt.
  • algo_service.py has no more lines than before; new logic is under service/donation/.
  • make test, make test-patch-coverage (90 % of changed lines) and make lint-file-budget pass. No new explanatory code comments.
  • This PR changes no docker-compose.yml, build/ or os/ path, so no tier4 job is required to merge. The live proof is the --donation-routing-smoke phase ({{A12}}), which must pass against this change before the setting is ever shown to users.

Possible solutions

  • Planner-driven loop in a new executor module with run calling it only when the feature is active (recommended: the old path stays byte-identical).
  • Make the existing three-way decision a list of segments for every user: one code path, but every XvB user's behavior changes and needs re-proving.
  • Skip the project slice while no PPLNS share is in the window, as XvB does: protects share finding for tiny miners, and a tiny miner may then never donate.

Part of #2476. Depends on {{A1}}, {{A2}}, {{A3}} and {{A4}}.

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 #3695.
    Blocked on #3697.

    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.

  5. pithead-architect commented on Nov 20, 2026

    @pithead-architect

    Owner ruling, 2026-11-20: "we can dark release it ahead so we can spot issues in logs before making a proper ui for it".

    The backend ships in v2.0.7 and v2.0.8 with no UI, so the logs are the only way to see it working. One acceptance criterion is added to this issue:

    • While the feature is dark, every donation decision is logged at info level with a stable prefix (donation:): slice start and end, the route chosen (tor or direct), fallback to P2Pool, endpoint errors and the cost estimate. These lines appear in the dashboard log and in the support bundle, with addresses redacted by the existing redactors. No UI is required.
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