test, doc: fix subsidy unit tests and halving comments for FIP-102 - #22
Open
Avecci-Claussen wants to merge 1 commit into
Open
Avecci-Claussen wants to merge 1 commit into
Avecci-Claussen wants to merge 1 commit into
Conversation
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.
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.
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:
TestBlockSubsidyHalvingsinsrc/test/validation_tests.cppasserteda 50% reduction at every boundary, so
block_subsidy_testfailed onthe very first halving check.
subsidy_limit_testexpected 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.
GetBlockSubsidycomment insrc/validation.cppstill describedthe upstream "halves every 210,000 blocks" behavior.
src/kernel/chainparams.cppclaimed the testnet3 andregtest 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_testand
--run_test=validation_tests/subsidy_limit_testnow pass.