Repository navigation
Description
What's the problem
Part of #2476. Owner priority (2026-10-27): build the opt-in donation feature now, shipping dark. The switching controller thinks in one cycle of two destinations: an XvB slice, then a P2Pool remainder (dashboard/mining_dashboard/service/xvb/algo_service.py:543-554), inside a 600 s cycle (config/config.py:144) with a 15 s minimum dwell (:147) and 5 s switch overhead (:608). A project slice of 1 % of the cycle is 6 s, shorter than the dwell, so a plain percentage cannot be used. There is also no rule for how a third slice interacts with the XvB tier: the project slice must come out of the P2Pool remainder, never out of the XvB slice, and must yield first to the reserve that keeps P2Pool finding shares (service/xvb/steering_projection.py:35-53).
Add a pure function, with no I/O, in a new package dashboard/mining_dashboard/service/donation/ (__init__.py, planner.py):
plan_cycle(xvb_ms, debt_ms, percent, max_fraction, *, cycle_ms=XVB_TIME_ALGO_MS, min_slice_ms=60000, min_dwell_ms=XVB_MIN_TIME_SEND_MS, overhead_ms=XVB_SWITCH_OVERHEAD_MS) returning the ordered segments [("xvb", ms), ("p2pool", ms), ("project", ms)] and the new debt.
- Each cycle credits
percent / 100 * cycle_msto the debt. A project slice is spent only when the debt reachesmin_slice_ms(60 s is a suggestion, owner decision), and carried debt is capped at 3 cycles. - The slice is taken from the P2Pool remainder. If
xvb_msplus the slice would exceedcycle_ms * max_fraction, the project slice is trimmed and the unspent debt carries over (subject to the cap). A full-cycle XvB decision leaves no remainder, so the slice is 0 and the debt keeps accruing. - Every returned segment is at least
min_dwell_ms; a P2Pool remainder under 30 s is merged into a neighbour asalgo_service.py:222-225does. Segment lengths sum tocycle_ms. - Long-run share converges on
percent: 1, 2 and 5 percent give about 14.4, 28.8 and 72 minutes a day.
Add the simulation to a new file, dashboard/mining_dashboard/sim/project_slice_model.py. The existing sim/donation_model.py is at its 539-line ceiling in docs/dev/file-budget.tsv, so it must not be edited.
What it impacts
Only the new modules and tests. No behavior changes until the controller child ({{A8}}) calls the planner. It fixes the contract the controller, the store and the fake-clock tests build on.
How I found it
Read-only scan of origin/develop-v2.1.0 at 02852bd on 2026-10-27 from the paths above and the existing simulator (dashboard/mining_dashboard/sim/donation_model.py, property-test pattern in dashboard/tests/sim/test_donation_model_properties.py:10-46). Nothing was executed. Unknown: the right debt cap and minimum slice for good share behaviour (both are parameters, so changing them is a one-line change), and whether a 60 s slice is long enough for a fresh upstream connection to submit a share (a bench question for the e2e child).
How important is it
Medium. It isolates the hardest logic in a testable module before the run loop is touched, and is small enough for one session.
Acceptance criteria
plan_cycleis pure: same inputs give the same outputs, no clock, no environment, no logging side effects.- New
dashboard/tests/service/donation/test_planner.py(examples) andtest_planner_properties.py(hypothesis, patterntest_donation_model_properties.py:10-46) assert, over randomxvb_ms,percent1 to 10,max_fraction0 to 0.85, and starting debt:- segment lengths sum to
cycle_ms, and no segment is longer than 0 and shorter thanmin_dwell_ms; - the XvB segment equals the input
xvb_msexactly (the project slice never reduces it); xvb_msplus the project segment never exceedscycle_ms * max_fractionunlessxvb_msalone does;- the debt stays between 0 and 3 cycles;
- over 144 cycles with room to spare, the project share is within 5 % (relative) of
percent; - a full-cycle XvB decision yields no project segment and a larger debt.
- segment lengths sum to
- A table test for 1, 2 and 5 percent states the minutes per day the planner delivers over 144 cycles.
sim/project_slice_model.pyruns the planner for N cycles with an XvB schedule and reports the donated share and the number of switches per hour; one test uses it.algo_service.pyis not touched.make test,make test-patch-coverage(90 % of changed lines) andmake lint-file-budgetpass. No new explanatory code comments.
Possible solutions
- A debt accumulator as described (recommended): exact long-run share, bounded switching.
- Probabilistic slicing (spend the slice with probability
percent): simpler, but variance is high and the share is only right on average. - A fixed longer cycle for the project slice only: breaks the shared 10-minute cadence the XvB controller assumes.
Part of #2476.
Activity
pithead-developer commentedon Oct 27, 2026
Questions before work continues (answer here, then remove the
questionlabel):pithead-architect commentedon Oct 27, 2026
Escalated to the human operator; the ruling lands in the runner's private question file and the worker resumes from it.
pithead-developer commentedon Oct 27, 2026
Owner, 2026-10-27: shares as low as 0.1 percent are offered. At 0.1 percent the debt takes about 17 hours to reach the 60-second trigger. Unspent debt must therefore persist across restarts and config reloads (keep it with the slice ledger, #3697), or the delivered share falls short. Add a test that 0.1 percent over a simulated week delivers 0.1 percent within one slice.
pithead-developer commentedon Oct 30, 2026
Merged in #3732.
Forward-port the donation planner (#3696) and fake stratum endpoint (#…