Skip to content

test, doc: fix subsidy unit tests and halving comments for FIP-102 - #22

Open
Avecci-Claussen wants to merge 1 commit into
fractal-bitcoin:fractal-29.xfrom
Avecci-Claussen:fix/subsidy-tests-fip102
Open

Avecci-Claussen wants to merge 1 commit into
fractal-bitcoin:fractal-29.xfrom
Avecci-Claussen:fix/subsidy-tests-fip102

Conversation

@Avecci-Claussen

Copy link
Copy Markdown

FIP-102 activates the first and second halvings together at the first
interval boundary (block 2,100,000 on mainnet), so the subsidy quarters
there and halves at every later boundary. Three places in the tree were
never updated for this:

  • TestBlockSubsidyHalvings in src/test/validation_tests.cpp asserted
    a 50% reduction at every boundary, so block_subsidy_test failed on
    the very first halving check.
  • subsidy_limit_test expected the upstream Bitcoin total
    (83,996,874.977 FB sampled) instead of the FIP-102 schedule
    (78,203,125 FB sampled), and never exercised the height-1 premine.
  • The GetBlockSubsidy comment in src/validation.cpp still described
    the upstream "halves every 210,000 blocks" behavior.
  • Two comments in src/kernel/chainparams.cpp claimed the testnet3 and
    regtest indexer cold keys are "same as mainnet for testing"; the keys
    are in fact distinct per network, and the comment is dangerously
    misleading for anyone reasoning about indexer authorization.

This change updates the tests to assert the actual consensus behavior
(FIP-102 quartering at the first boundary, halving thereafter, premine
at height 1, supply cap reached one boundary earlier than upstream) and
corrects the comments. No consensus, P2P, or RPC behavior changes.

Test plan: build/bin/test_bitcoin --run_test=validation_tests/block_subsidy_test
and --run_test=validation_tests/subsidy_limit_test now pass.

GetBlockSubsidy implements FIP-102's brought-forward second halving via
an extra halvings++ (validation.cpp), so the first interval boundary
quarters the subsidy (25 -> 6.25 FB) and only later boundaries halve.
The subsidy tests still encoded upstream Bitcoin's pure-halving schedule
and failed at the first boundary; subsidy_limit_test still expected
Bitcoin's 21M-budget constant.

Update the tests to encode the actual schedule, cover the height-1
premine, and recompute the sampled issuance total (78,203,125 FB over
heights 0..14M step 1000). Also correct the stale subsidy comment
(wrong interval, and the first boundary is not a plain halving) and the
misleading "same as mainnet" comments on the testnet3/regtest indexer
cold keys, which are in fact distinct per-network keys.
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