Skip to content

dash: MSVC-portable coinbase PPLNS payout muldiv (fixes c2pool-dash Windows v0.2.1)#709

Merged
frstrtr merged 1 commit into
masterfrom
dash/coinbase-muldiv-msvc-portable
Jul 15, 2026
Merged

dash: MSVC-portable coinbase PPLNS payout muldiv (fixes c2pool-dash Windows v0.2.1)#709
frstrtr merged 1 commit into
masterfrom
dash/coinbase-muldiv-msvc-portable

Conversation

@frstrtr

@frstrtr frstrtr commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Problem

DASH is the only coin whose Windows binary fails to compile in the v0.2.1 release build (Linux + macOS DASH are green) -- the last DASH gap for the all-5-coin v0.2.1. Root cause (MSVC run 29383023622):

```
src/impl/dash/coinbase_builder.hpp(131): error C2065: __uint128_t: undeclared identifier
```

The PPLNS per-script coinbase payout proportion was evaluated in a native `unsigned __int128` intermediate (`worker_payout * weight / total_weight`, and the pre-v36 `49 / (total50)` arm). `__int128` is a GCC/Clang extension MSVC does not provide.

Fix (mirrors BCH abla #688 / DGB arith256 #690)

  1. Extracted the 128-bit muldiv into `dash::payout::payout_share` (new `src/impl/dash/payout_muldiv.hpp`), guarded by `#if defined(SIZEOF_INT128)`:
    • Native (GCC/Clang): `__uint128_t` path kept BYTE-EXACT -- the shipping Linux/macOS packages are unchanged.
    • MSVC: `boost::multiprecision::uint128_t` (header-only, already a c2pool dependency) -- bit-identical result.
  2. Rewired `coinbase_builder.hpp:131-138` through it. No payout amount changes on any platform.
  3. Byte-parity KAT (`test_dash_coinbase_muldiv`, the required guard for consensus payout math):
    • Layer A -- cross-platform known answers (incl. products > 2^64) that MSVC can run with no native to diff against.
    • Layer B (`#if __int128`) -- `native == portable` across the DASH payout operand grid + a 200k-vector deterministic fuzz, over both v36 and pre-v36 branches.

Wired into `test/CMakeLists.txt` and both `build.yml` `--target` allowlists.

Local verification

  • `test_dash_coinbase_muldiv`: 5/5 PASS (native==portable over 200000 fuzz vectors)
  • `test_dash_coinbase_parity`: 10/10 unchanged (byte-exact refactor)

Consensus surface: payout arithmetic is bit-identical to what merged; the only behavioural change is that MSVC now compiles.

…ash Windows)

coinbase_builder.hpp evaluated the PPLNS per-script payout proportion
(worker_payout * weight / total_weight, and the pre-v36 *49/(50*total) arm)
in a native unsigned __int128 intermediate. __int128 is a GCC/Clang extension
MSVC does not provide (error C2065: __uint128_t undeclared identifier), so the
c2pool-dash Windows binary failed to compile in the v0.2.1 release build while
Linux/macOS DASH passed -- the last DASH gap for the all-5-coin v0.2.1.

Same class of fix already shipped for BCH abla (#688) and DGB arith256 (#690):
extract the 128-bit muldiv into dash::payout::payout_share (payout_muldiv.hpp)
and guard it with #if defined(__SIZEOF_INT128__). The native path keeps the
__uint128_t arithmetic BYTE-EXACT for the shipping Linux/macOS packages; MSVC
falls back to boost::multiprecision::uint128_t (header-only, already a c2pool
dependency) which yields bit-identical results. coinbase_builder.hpp:131-138 is
rewired through it; no payout amount changes on any platform.

This is CONSENSUS PAYOUT math -- a one-satoshi divergence forks payouts -- so
test_dash_coinbase_muldiv is the required guard: layer A pins cross-platform
known answers (incl. products > 2^64) that MSVC can run without a native to diff
against; layer B (#if __int128) proves native == portable across the DASH payout
operand grid plus a 200k-vector deterministic fuzz, over both the v36 and pre-v36
branches. Wired into test/CMakeLists.txt and both build.yml --target allowlists.

Verified locally: test_dash_coinbase_muldiv 5/5 PASS (native==portable over
200000 fuzz vectors); test_dash_coinbase_parity 10/10 unchanged.
@frstrtr
frstrtr merged commit 9945019 into master Jul 15, 2026
22 of 26 checks passed
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