Skip to content

bch(share): canonical 60% work-weighted version-switch boundary (drop 95% flat-count punish) - #326

Merged
frstrtr merged 1 commit into
masterfrom
bch/autoratchet-canonical-60pct-weighted
Jun 22, 2026
Merged

bch(share): canonical 60% work-weighted version-switch boundary (drop 95% flat-count punish)#326
frstrtr merged 1 commit into
masterfrom
bch/autoratchet-canonical-60pct-weighted

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 22, 2026

Copy link
Copy Markdown
Owner

What

Ports the canonical AutoRatchet version-switch boundary rule into BCH share validation, replacing the non-canonical 95%-flat-count should_punish_version gate.

  • share_check.hpp: version BOUNDARY (share.version != parent.version) is valid only when the new version holds >= 60% of PPLNS work-weighted desired-version support in window [CHAIN_LENGTH*9/10, CHAIN_LENGTH] behind the parent. One-step downgrade allowed (AutoRatchet deactivation); larger jumps rejected; insufficient history rejected.
  • share_tracker.hpp: add get_desired_version_weights — per-desired-version WORK tally (idx->work = target_to_average_attempts), mirroring p2pool get_desired_version_counts (data.py:2651). NOT a flat count.

Why

BCH still called the 95%-flat-count should_punish_version (no BCH tracker even defined it — survived only as an uninstantiated dependent template expr). LTC/DGB removed it; BTC replaced it with the canonical 60% work-weighted switch (F10/(b), #290). This brings BCH to parity — v36-native bucket-2 standardization toward the v37 unified shape. Couples the accept gate to the work-weighted mint guard so an activated node cannot mint a boundary share its peers reject.

Conformance

  • Oracle: p2pool-merged-v36 data.py check() 1396-1414 + get_desired_version_counts 2651. No v36 wire-surface change — same accept semantics as BTC/LTC/DGB.
  • Per-coin isolation: src/impl/bch/ ONLY. No shared bitcoin_family/ or peer-coin trees touched.

Verify

  • Both BCH headers -fsyntax-only clean (rc=0).
  • No should_punish_version call remains (only the F10/(b) explanatory comment).

GPG-signed. Merge operator-gated (I author/review; integrator merges on push approved).

… drop 95% flat-count punish

Replace the non-canonical 95%-flat-count should_punish_version gate in
share_check with the canonical 60% PPLNS-work-weighted boundary switch
(p2pool data.py check() 1396-1414), matching the BTC F10/(b) port and the
LTC/DGB removals. Add ShareTracker::get_desired_version_weights — per-
desired-version WORK tally (idx->work), mirroring get_desired_version_counts
(data.py:2651) — NOT a flat share count.

A version BOUNDARY (share.version != parent.version) is valid only when the
new version holds >= 60% of weighted desired-version support in the window
[CHAIN_LENGTH*9/10, CHAIN_LENGTH] behind the parent; one-step downgrade is
allowed (AutoRatchet deactivation), larger jumps rejected. Couples the accept
gate to the work-weighted mint guard so an activated node cannot mint a
boundary share its peers reject. BCH-fenced (src/impl/bch only); standalone
SHA256d parent, no aux dimension. v36-native bucket-2 standardization.
@frstrtr
frstrtr merged commit d5ddb71 into master Jun 22, 2026
20 checks passed
frstrtr added a commit that referenced this pull request Jun 23, 2026
… drop 95% flat-count punish (#326)

Replace the non-canonical 95%-flat-count should_punish_version gate in
share_check with the canonical 60% PPLNS-work-weighted boundary switch
(p2pool data.py check() 1396-1414), matching the BTC F10/(b) port and the
LTC/DGB removals. Add ShareTracker::get_desired_version_weights — per-
desired-version WORK tally (idx->work), mirroring get_desired_version_counts
(data.py:2651) — NOT a flat share count.

A version BOUNDARY (share.version != parent.version) is valid only when the
new version holds >= 60% of weighted desired-version support in the window
[CHAIN_LENGTH*9/10, CHAIN_LENGTH] behind the parent; one-step downgrade is
allowed (AutoRatchet deactivation), larger jumps rejected. Couples the accept
gate to the work-weighted mint guard so an activated node cannot mint a
boundary share its peers reject. BCH-fenced (src/impl/bch only); standalone
SHA256d parent, no aux dimension. v36-native bucket-2 standardization.

Co-authored-by: frstrtr <frstrtr@users.noreply.github.com>
frstrtr added a commit that referenced this pull request Jun 27, 2026
…577)

Fenced, additive, rig-free known-answer test for the BCH G2 staged 1-by-1
miner-migration gate. Pins the canonical 60%-by-WORK version-switch ACCEPT
gate that bch::check_share enforces inline (src/impl/bch/share_check.hpp:1774):

    if (new_ver_weight * 100 < total_weight * 60)
        throw "switch without enough hash power upgraded";

via a verbatim replica of the live tail-guard (same non-circular localisation
btc/DGB use; guard stays inline, no lifted SSOT). Arms the staged-migration
rows without a SHA256d bitaxe rig.

Properties pinned (15 asserts, all green):
  - 60%-by-WORK boundary at the exact crossing (59 hold / 60-100 pass / 0 hold)
  - mint-cannot-outrun-accept (#288): 95%-by-COUNT under heterogeneous hashrate
    can NOT outrun the 60%-by-work gate -> a minted V36 boundary share its peers
    would reject is prevented
  - work-weighted NOT flat-count (#290/#326 regression guard): gate diverges
    from a head-count in both directions; #326 dropped the 95%-flat-count punish
  - monotonic staged migration: 5 equal-work miners, tally advances monotone,
    accept gate crosses at stage 3/5 (60%) and stays on
  - downgrade asymmetry: V35-after-V36 (AutoRatchet deactivation) is un-gated

Test-only, bch-tree-local: pure int main()+assert over <core/pack_types.hpp>
uint288, no consensus / shared-base / CMake-shared surface. Registered in the
bch test CMakeLists foreach and BOTH build.yml COIN_BCH --target allowlists.

Co-authored-by: frstrtr <frstrtr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant