btc(stratum): integer-exact unconditional v35 finder fee in mined-block coinbase (D2)#737
Merged
Merged
Conversation
…ck coinbase (D2) The mined-block coinbase computed the block-finder fee as a float (coinbasevalue/200.0) and applied it only when the donation output could cover the full amount (all-or-nothing skip). Both diverge from the p2pool reference (data.py generate_transaction: amounts[finder] += subsidy//200, integer floor, unconditional) and were a latent satoshi-rounding divergence on the money path of a won block. The consensus share gentx was already integer-exact; this makes the block-coinbase path identical. Extract v35_finder_fee_split() (finder_fee.hpp SSOT): floor(cbv/200), capped at the donation available so the coinbase stays balanced (total == subsidy) and no output goes negative. No float in the split. Base stays coinbasevalue, matching core/web_server.cpp:1888 (p2pool subsidy = template coinbasevalue incl. fees). KAT finder_fee_integer_exact_test.cpp (btc_share_test): pins the split vs the jtoomim subsidy//200 formula at round and odd coinbase values, the sub-200 zero edge, the donation cap, and a float-vs-integer divergence witness. 4/4 green; full btc_share_test 50/50.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
D2 — integer-exact, unconditional v35 finder fee in the mined-block coinbase
Closes the June-audit D2 residual. The audit cited
coin/work_source.cpp ~421-433; the actual live code issrc/impl/btc/stratum/work_source.cpp(path moved), where the block-coinbase finder fee still computed as floatcoinbasevalue/200.0and applied all-or-nothing (skipped entirely when the donation output could not cover the full fee).Both diverge from the p2pool reference —
data.py generate_transaction, verified against~/p2pool-jtoomim@ece15b0:The consensus share gentx was already integer-exact; this is only the block-coinbase path, but it is a latent satoshi-rounding divergence on the money path of a won block.
Change
src/impl/btc/stratum/finder_fee.hpp—v35_finder_fee_split(coinbasevalue, donation_sats)=floor(coinbasevalue/200)(integer,subsidy//200), capped at the donation available so the coinbase stays balanced (total == subsidy) and no output goes negative. No float in the split.work_source.cppcalls the SSOT; fee is now applied unconditionally (never all-or-nothing skipped — the cap only binds in a pathological rounding edge).coinbasevalue, matchingcore/web_server.cpp:1888(in p2poolsubsidy= templatecoinbasevalue, incl. fees).Test
finder_fee_integer_exact_test.cpp, compiled into the existing allowlistedbtc_share_testtarget. Pins the split vs thesubsidy//200formula at round + odd coinbase values, the sub-200 zero edge, the donation cap, and a float-vs-integer divergence witness (atcbv=312500199the old float rounds to a different satoshi than the integer floor).Results: D2 KAT 4/4 green; full
btc_share_test50/50 (no regression).Review -> integrator. No self-merge.