Repository navigation
Description
What's the problem
P2Pool's PPLNS window is dynamic: it ends at 2160 blocks or at shares worth 2x the Monero network difficulty, whichever comes first (about one hour on Main per the repo's XvB delivery study, not six). In the pinned P2Pool v4.18, pool/stats pplnsWindowSize is that effective window, and local/stratum block_reward_share_percent is P2Pool's own signal that the wallet holds a share in it.
The dashboard already receives both but does not use them to decide membership. It turns the block count into a wall-clock cutoff (pplns_window x nominal block time), stamps each share with the poll time instead of a sidechain height (the shares table is ts and difficulty only), falls back to 2160, and hard-codes 2160 and a 6 h horizon in the XvB simulator. A share P2Pool has already aged out can therefore still count here. Re-checked on develop-v2.1.0 on 2026-10-27: all of this is still in place.
Unknown: how far the dashboard and P2Pool diverge in practice. Nothing has been measured on a bench.
What it impacts
- XvB: the controller's share gate and auto-register eligibility share one wall-clock helper, so the raffle gate can read Yes for a share P2Pool no longer counts and a win is skipped.
- Luck, expected shares and own PPLNS weight use the wrong horizon, off by the ratio of the two windows; simulator tier recommendations assume a 6 h window on Main.
- Earnings: the estimate on the Earnings page (Sovereign: build estimates with explicit mining assumptions #2525) and the Overview earnings tile (v2.1.0 lean UI spec: four pages, one profile control, an Advanced drawer #3566) cannot ship correct until this lands; the spec ships no estimate otherwise.
- This issue has no UI of its own (operator, 2026-10-21) and does not need the configuration model.
How I found it
- Operator observation on 2026-09-20 that the window looks dynamic, confirmed by reading the v4.18 tag of upstream P2Pool: the share walk stops at 2160 blocks or at 2x network difficulty,
pplnsWindowSizeis tip height minus bottom height plus one, andblock_reward_share_percentis the wallet's reward share times 100. The delivery study in the repo records the same ~1 h on Main. - An investigator read of develop on 2026-09-23 matched the dashboard-side claims above.
- Rulings on 2026-10-21 (comments): counts and weights from observed poll heights are labelled estimates, never verified per-share heights; legacy heightless shares stay in history and are not counted in height-based membership; absent, invalid or stale reward-share data means unknown and fails the gate, not zero shares; the 24 h live validation is retained.
- Not run: bench-ci#2141 (open) tracks the missing queued P2Pool observation method, so no baseline exists.
How important is it
Medium. P2-correctness in v2.1.0, not a release blocker (no data loss, no security exposure, not the Tari path), but it gates a correct Earnings estimate and steers real XvB routing.
Acceptance criteria
Behaviour, unit tests in every PR:
- Each new share row records the sidechain height seen at record time, through a schema migration; existing rows are kept, get no invented height and are excluded from height-based membership.
- Membership is
tip height - share height < pplnsWindowSize. With window 360, a share 361 blocks old is out and one 359 old is in. The output marks counts and weights as estimates so Earnings (Sovereign: build estimates with explicit mining assumptions #2525) can label them. - XvB eligibility (controller share gate and auto-register) requires a valid, fresh, positive
block_reward_share_percent: 0.0 with a fresh-looking local share gives false, positive gives true, and absent, invalid or stale data gives false. - Window duration is
pplnsWeight / hashRate. Luck, expected shares, own PPLNS weight and eligibility no longer usepplns_window x block_time;expected_sharesand luck differ between window 360 and 2160 on identical inputs; identical shares with the reported window shrinking from 2160 to 360 drop out of the count and the weight. - The XvB simulator takes the effective window as an input with 2160 as the ceiling only;
min_expected_sharesat window 360 is one sixth of its value at 2160. - One shared helper serves every consumer (metrics, XvB sync, auto-register, simulator, tests), and no
DEFAULT_PPLNS_WINDOW x block_timemembership horizon remains. The collector still carriespplnsWindowSizewhen present and leaves the key absent when not (the Dashboard: stratum-file read race replays the whole cumulative counter as fresh PPLNS shares (+ pplns_window reads 0) #547 test stays). - Changed lines clear
make test-patch-coverage. No explanatory code comments are added. The current dashboard UI is not edited; existing metric keys keep their names.
Contract, every PR:
- One sanitized real v4.18
pool/statsandlocal/stratumsample is added to the contract fixtures, and the contract test asserts the collector mapspplnsWindowSize,sidechainHeight,pplnsWeightandhashRateand readsblock_reward_share_percentfrom the real wire shape.
Live, through bench-ci#2141:
- One run of at most 24 h on the pre-fix head and one on the PR head, each on P2Pool Main and on Mini or Nano; no longer runs and no repeats.
- Per poll:
pplnsWindowSize,pplnsWeight / hashRate, the dashboard's own window figure, whether its membership answer is above zero, andblock_reward_share_percent. A P2Poolstatusreadout at the start and end of each run (bench-only compose override withstdin_openandtty, never shipped) confirms the JSON matches P2Pool. - The PR reports the window ratio and its spread per tier and the count of polls where membership disagrees with
block_reward_share_percent > 0. That count is 0 after the fix on the same box. Unavailable or stale samples and coverage gaps are disclosed, not counted as agreement. - The evidence carries the exact head SHA and P2Pool version, passes through
scripts/sanitize-test-log.sh, and raw logs stay private. A missing run is stated; a smoke test or a shorter run is not presented as the 24 h comparison.
Possible solutions
- Persist the
sidechainHeightthe collector already reads and discards, count membership by height, gate on the reward-share signal, showpplnsWeight / hashRate, and pass the effective window into the simulator. - Poll the data API files, not the console
statuscommand: the shipped stack gives P2Pool no stdin or TTY, and every window figurestatusprints is already inpool/stats. Usestatuson the bench only as the independent witness. - Split the work: runner support for the observation lives in bench-ci#2141, product instrumentation stays in this repo's harness. The migration, helper, gates and tier 1 and 2 tests can be built and reviewed while the baseline waits, but the pre-fix baseline must be captured on the current head before the fix merges.
- Open: per-share heights cannot be rebuilt from the current API inputs, which is why heights from polls are estimates and the reward-share signal is the authority.
Earlier scope, kept as evidence only (superseded 2026-10-27; do not implement from it)
What's the problem
Operator observation (2026-09-20): the P2Pool PPLNS window looks dynamic, not a fixed length. Upstream P2Pool at the version we pin agrees. The dashboard already receives the effective window size from P2Pool, but it turns that block count into a wall-clock cutoff and stamps shares with poll time, so its membership answer can disagree with P2Pool's. This issue establishes how far they diverge, what it costs, and how the fix is proven.
What P2Pool does (v4.18, the pinned binary; upstream checked 2026-09-20)
Read from the v4.18 tag of SChernykh/p2pool. The latest release is v4.18 (2026-08-05); master differs from the tag in side_chain.cpp only outside the regions cited here, and p2pool.cpp / stratum_server.cpp are identical.
get_shareswalks back from the tip and stops when either 2160 blocks are included (src/side_chain.cpp:445) or the cumulative PPLNS weight exceeds 2 × the Monero network difficulty (:387-389,:440). Uncles that would push past the cap are dropped (:419).- So the effective window is
min(2160 blocks, shares worth 2 × network difficulty). On P2Pool main that came to about one hour during the delivery study, not six (docs/research/xvb-delivery-study/PAPER.md:236). On mini and nano the block cap is more likely to bind. pool/stats→pplnsWindowSizeis the effective window:tip height − bottom height + 1(src/p2pool.cpp:1949-1950, written at:1985). This answers the question the first draft of this issue left open.local/stratum→block_reward_share_percentisget_reward_share(our wallet) × 100(src/stratum_server.cpp:1710,:1726;side_chain.cpp:1139). It is P2Pool's own authoritative "you hold a share in the current window" signal, and it is already on disk for us.
What the dashboard does today
| Consumer | What it uses | Where |
|---|---|---|
| Collector | reads pplnsWindowSize from the pool/stats file when present, else leaves the key absent |
dashboard/mining_dashboard/collector/pools.py:98-102 |
| Share records | one row per delta of the cumulative shares_found counter, stamped with the poll time; schema is shares (ts, difficulty), no sidechain height |
service/data_service.py:223-227, :562; service/storage_schema.py:148 |
| Window helpers | count and weight shares by wall clock: ts >= now − pplns_window × block_time, block time 10 s (main, mini) or 30 s (nano) |
helper/utils.py:191-225 |
| Fallback | DEFAULT_PPLNS_WINDOW = 2160 |
helper/utils.py:194 |
| Shares in Window, Luck, expected shares, own PPLNS weight | pplns_window × block_time as the horizon |
service/metrics.py:191-206 |
| XvB controller share gate, auto-register eligibility | same helper | service/data_xvb_sync.py:160-165, service/data_service.py:355-357 |
| Donation simulator | hard-coded _PPLNS_WINDOW = 2160 and a 6 h horizon |
sim/donation_model.py:54, :269 |
| Display only | block_reward_share_percent is rendered, used by no gate |
web/views/views.py:157 |
So the block count is right at the source. The gaps are downstream:
- Blocks to seconds at the nominal block time, from
now. P2Pool measures the window in sidechain heights, not time. Sidechain block times vary, and the window can shrink between two polls, so a share P2Pool has already aged out can still be inside our cutoff. - Share timestamps are poll timestamps. A share is dated up to one poll interval late, and nothing records the sidechain height it landed at, so we cannot ask the question P2Pool asks (
tip − share height < window). - The 2160 constant survives as the fallback and in the simulator.
Reading the window from P2Pool: the status console command versus the data API
P2Pool's console status command (src/console_commands.cpp:176, handler :205-219) prints, via SideChain::print_status (src/side_chain.cpp:1122-1135):
PPLNS window = N blocks (+U uncles, O orphans)
PPLNS window duration = <pplns_weight / pool_hashrate>
Your shares = n blocks (+u uncles, o orphans)
Block reward share = X% (amount)
That is the operator's eyes-on readout and the right cross-check on the bench. It is not the right thing for the stack to poll:
- The console reads stdin and needs a TTY or a named pipe (
console_commands.cpp:46-49). Our compose opens neither forp2pool(nostdin_openorttyanywhere indocker-compose.yml), sostatuscannot be issued in the shipped stack without adding one and attaching, and its output is free text in the log. - Everything
statussays about the window is already in the data API files the collector reads today (--data-apiand--local-apiare in the p2pool command):pool/statscarriespplnsWindowSize,pplnsWeight,hashRate,sidechainHeight(src/p2pool.cpp:1976-1985), andlocal/stratumcarriesblock_reward_share_percent.status'sPPLNS window durationis literallypplnsWeight / hashRate, so the honest duration is one division on fields we already have, with no block-time assumption. The only thingsstatusadds are the uncle and orphan breakdown, which no consumer needs.
So: poll the JSON (the better way for the stack), and use status on the bench to confirm the JSON and the dashboard agree with P2Pool's own words.
Investigation deliverables
Confirm whetherAnswered above: effective.pplnsWindowSizeis the effective window or the cap.- On the bench, on P2Pool main (where the cap binds) and on mini or nano (where it likely does not), log every poll for 24 h:
pool/stats→pplnsWindowSizeandpplnsWeight / hashRatebeside the dashboard'spplns_window × block_time, and astatusreadout at the start and end of the run (a bench-only compose override withstdin_openandtty, thendocker attach) to confirm the JSON matches P2Pool's own words. Report the ratio and its spread per tier. - Over the same 24 h, count polls where
shares_in_pplns_window > 0disagrees withblock_reward_share_percent > 0. Each disagreement is a poll where the raffle gate was wrong. - List every consumer of the
utils.pyhelpers (the table above plus tests), so the fix lands once, per the "never drift" comment atutils.py:188-190.
Testing strategy
Per docs/dev/testing-strategy.md: each behaviour proven once, at the lowest honest tier. P2Pool's own window algorithm is upstream's to test; we stop at its API.
Tier 1, unit (dashboard/tests/, every PR). These fail today or would fail on a regression, and they carry the fix.
helper/test_utils.py(extendtest_counts_only_shares_inside_the_window,:59): withpplns_window=360and the same share list, a share aged 361 blocks is out and one aged 359 is in. Proves the helpers honour the dynamic value rather than 2160.collector/test_pools.py:pplnsWindowSizepresent →pplns_windowcarries it; absent → key absent (the Dashboard: stratum-file read race replays the whole cumulative counter as fresh PPLNS shares (+ pplns_window reads 0) #547 test, keep it).service/test_metrics.py:expected_sharesand luck differ betweenpplns_window=360and2160on identical inputs. Guards against any hidden 2160 on the path.service/test_data_service_xvb_auto_register.pyand the XvB sync gate: two consecutive polls with the same share list andpplns_windowshrinking from 2160 to 360 flip the gate from eligible to not. This is the raffle-skip regression test.- After the fix: stratum
block_reward_share_percent = 0.0with a fresh-looking local share → gate false;> 0→ true. A share recorded at height H counts ifftip − H < pplnsWindowSize. The simulator'smin_expected_sharesat window 360 is one sixth of its value at 2160. - Coverage: the changed lines must clear
make test-patch-coverage(90 %).
Tier 2, contract (tests/integration/fakes/test_contract.py, every PR). Capture one real v4.18 pool/stats and local/stratum file from the bench into tests/integration/fakes/contract/v1/ beside the existing control-status.json and feed.json, and assert the collector maps pplnsWindowSize → pplns_window and reads block_reward_share_percent from the real wire shape. Nothing in the fakes serves P2Pool's stats files today, so this is new, and it is what catches an upstream field rename.
Tier 3, mini-stack (tests/integration/mini-stack/). Only if tier 1 cannot prove the controller wiring. The collector reads P2Pool's JSON from disk, so the fake would have to write pool/stats with a shrinking pplnsWindowSize and local/stratum with block_reward_share_percent dropping to 0, then the run asserts the real controller releases the XvB slice. Expect to skip this: the gate is decision logic, which tier 1 owns.
Tier 4, live (bench, on the PR's head). Deliverables 2 and 3 above are the tier-4 evidence, with status as the independent witness that the data API and the dashboard both agree with P2Pool, run once to size the defect and once after the fix on the same box: the disagreement count in deliverable 3 must read 0 after. Raw logs stay private; the PR carries the ratio table and the disagreement count, produced through scripts/sanitize-test-log.sh, plus the exact head SHA and P2Pool version.
Related: #547 (pplns_window read 0), #129 (share undercount), #84 (luck panel), #263 (shared window math), #158 (VIP status).
🤖 Generated with Claude Code
what it impacts
Impact is not separately established in the existing report; confirm the affected users or behavior.
How I found it
Discovery details are not separately established in the existing report; preserve and verify the evidence already recorded.
how important is it
What it costs if the divergence is real
- Shares in Window overcounts when the effective window is shorter than the wall-clock one. The XvB gate then reads a share that P2Pool no longer counts,
Raffle Eligiblesays Yes, and a win is skipped (the VIP gate,docs/dashboard.md). This is the expensive one: the controller keeps donating for a raffle it cannot collect. - Luck and expected shares use the wrong horizon, so the percentage is off by the ratio of the two windows.
- Own PPLNS weight and the payout-slice framing that rests on it are off the same way.
- Simulator tier recommendations assume a 6 h window on main.
acceptance criteria
Acceptance is not isolated in the existing report; the agent must identify a testable outcome before implementation.
possible solutions
Likely fix direction (a guess until 2–4 are done)
Stop recomputing membership from time. Gate on block_reward_share_percent > 0. Record the sidechainHeight the collector already reads (pools.py:88) on each share row and count membership as tip − height < pplnsWindowSize. Show the window duration as pplnsWeight / hashRate from pool/stats, the same figure status prints, and drop pplns_window × block_time entirely. The simulator takes the effective window as an input with 2160 as the ceiling, not the value.
Activity
pithead-developer commentedon Sep 24, 2026
Investigation brief (operator pre-read, 2026-09-23)
Verified against current develop head (296c860): the issue is accurate and unfixed. The dashboard converts P2Pool's block-count PPLNS window into a wall-clock cutoff and stamps shares with poll time rather than sidechain height, so its window-membership answer can disagree with P2Pool's.
helper/utils.py:191-225—shares_in_pplns_window/pplns_weight_in_windowusets >= now - pplns_window*block_time;DEFAULT_PPLNS_WINDOW = 2160at:194. Unchanged since the issue was filed.collector/pools.py:88already readssidechainHeightoffpool/statsbut discards it — never persisted.:98-102correctly passes throughpplnsWindowSizewhen present (the Dashboard: stratum-file read race replays the whole cumulative counter as fresh PPLNS shares (+ pplns_window reads 0) #547 fix holds).service/storage_schema.py:148—shares (ts, difficulty), no height column, sotip - height < pplnsWindowSize(what P2Pool actually asks) can't be computed today.metrics.py:191-206(luck, expected shares),data_xvb_sync.py:160-165(donation-gate eligibility — the expensive one, per the issue),data_service.py:352-360(alerter), andsim/donation_model.py:54,269(hard-coded 2160/6h).views.py:157already displaysblock_reward_share_percent(the correct authoritative signal) but nothing gates on it.Root cause: confirmed, file:line above matches the issue's claims exactly — no drift since filing.
Fix shape: as the issue proposes — add a height column to the shares table (schema migration), persist
sidechain_heightat record time, switch membership math totip - height < pplnsWindowSize, gate XvB eligibility onblock_reward_share_percent > 0, show duration aspplnsWeight/hashRate, and make the simulator take the effective window as an input (2160 as ceiling only). One shared helper + 6 call sites; not a one-liner but each site is mechanical once the height column exists. The issue itself argues for landing it as one PR (the "never drift" rule atutils.py:188-190).Evidence tier: tier4-live (bench), per the issue's own testing-strategy section — this steers real donation-controller behavior, not just display. Tier1 (5 named unit tests) carries the fix; the issue also specifies a new tier2 contract fixture (no fake currently serves P2Pool's
pool/stats/local/stratum).Duplicates/blockers: #547 (closed, adjacent — fixed the
pplns_windowreads 0 the collector relies on); #129, #84, #263, #158 are related consumers of the same helper, not blockers.Rulings needed:
Triage recommendation: MOVE-sovereign-ui — already correctly milestoned; P2-correctness, not release-blocking, fully specified and ready for a worker once bench capacity opens post-GA.
Verify against the code before relying on this; it was written by an investigator, not the implementer.
pithead-developer commentedon Oct 21, 2026
Questions before work continues (answer here, then remove the
questionlabel):pithead-architect commentedon Oct 21, 2026
Ruling: Take both defaults as evidence-honesty decisions. Label counts and weights derived from observed poll heights as estimates; never describe those heights as verified per-share heights. Keep legacy heightless shares in history without inventing heights or counting them in height-based membership. In the shared helpers and XvB gates, require a valid, fresh positive P2Pool reward-share signal for authoritative eligibility; absent, invalid or stale data means unknown and fails the gate, not zero shares. Prove boundary changes, migration and unavailable-data behavior, retaining the issue's current-head live validation requirements. Keep presentation work within the revised v2.1.0 UI and respect its lane exclusion.
pithead-developer commentedon Oct 21, 2026
Blocked on p2pool-starter-stack/bench-ci#2141: the retained acceptance requires a queued 24-hour before/after PPLNS comparison on Main and Mini or Nano, but the exact-commit CI catalogue has no supported P2Pool observation method. Its existing XvB smoke cannot establish that baseline, and the long observation capability is Tari-specific. No manual bench work or substitute smoke run was performed.
The operator's defaults are recorded: observed heights yield estimates, legacy heightless records remain history only, and absent/invalid/stale reward-share data means unknown and fails eligibility. Read-only code, migration, consumer and freshness reconnaissance is complete; no product source changes or PR exist. The current live routing enables v2.1.0 and maps it to develop-v2.1.0, superseding the README's earlier exclusion description; presentation remains restricted to the revised UI.
The bench-ci maintainer must provide or identify the supported queued observation/admission/artifact method in p2pool-starter-stack/bench-ci#2141. Once that prerequisite lands and is deployed, this session can submit the pre-fix baseline, then implement the shared fix and tests and obtain the required current-head proof. The catalogue was checked at a10dbf0; no job was submitted, and no passing or failing live result is claimed.
pithead-developer commentedon Oct 21, 2026
Blocked on p2pool-starter-stack/bench-ci#2141. Blocked on p2pool-starter-stack/bench-ci#2141: the required 24-hour PPLNS baseline has no supported queued CI method. Reconnaissance is complete and the blocker is documented on #2479; the bench-ci maintainer must provide that method before baseline collection and implementation proceed. No product source changes, PR or bench job exists.
The runner resumes this issue when that one closes.
pithead-developer commentedon Oct 21, 2026
Rescoped to the lean UI spec #3566 (operator, 2026-10-21): Stays as the correctness prerequisite for the Earnings page and the Overview earnings tile: P2Pool's PPLNS window is dynamic, so the estimate in #2525 must use the real window before it is simplified into one number. No UI of its own. Does not need the configuration model.
pithead-developer commentedon Nov 1, 2026
Operator: Moved from v2.1.0 to v2.0.4. The dashboard's wall-clock PPLNS horizon (pplns_window x block time, shares stamped at poll time) ships in 2.0.2, so this is a bug in shipped code and, under the 10-31 patch-placement ruling, 2.1.0 is for new features only; the validated correction goes on the patch line and reaches 2.1.0 by forward merge. v2.0.4 is a triage slot, not a promise: the issue stays blocked on bench-ci#2141, the 24 h before/after live validation is still required before the fix merges, the 10-21 rulings and acceptance criteria are unchanged, and the lean Earnings estimate in 2.1.0 stays gated by this result.
pithead-developer commentedon Nov 13, 2026
Moved to v2.0.5 (owner-approved backlog groom, 2026-11-13): blocked on bench-ci#2141 and needs a 24 h live validation.