-
-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tokenomics update #1478
Tokenomics update #1478
Conversation
WalkthroughThe changes involve significant modifications to the consensus parameters and subsidy distribution mechanisms across various classes. Key parameters related to subsidy halving have been removed, while new parameters for a fourth funding stage have been introduced. The logic for block subsidy calculations and payout distributions has been refined, enhancing the clarity and efficiency of the reward mechanism. Additionally, updates to test cases ensure alignment with the new consensus structure. Changes
Sequence Diagram(s)sequenceDiagram
participant Miner
participant ConsensusParams
participant Block
participant PayoutSystem
Miner->>ConsensusParams: Request subsidy parameters
ConsensusParams->>Miner: Return updated parameters
Miner->>Block: Create block with subsidy
Block->>PayoutSystem: Calculate payouts
PayoutSystem->>Block: Distribute rewards
Tip We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range, codebase verification and nitpick comments (2)
src/test/firsthalving_tests.cpp (1)
272-273
: Update the comment to match the 5% miner reward allocation.The assertion correctly checks for the 1.25 coins miner reward, which is 5% of the total block subsidy. However, the comment mentions a 10% miner reward allocation.
Update the comment to match the 5% miner reward allocation mentioned in the PR objective:
-// miner's reward should be 1.25 (10%) +// miner's reward should be 1.25 (5%)src/consensus/params.h (1)
164-172
: Inconsistencies in Stage 4 ParametersThe
stage4StartBlock
and fund share percentages for stage 4 are inconsistent across the codebase:
stage4StartBlock
is set to different values in various files:
consensus.nSubsidyHalvingSecond
167500
consensus.nSubsidyHalvingSecond + 500
Fund Share Percentages:
- In most cases,
stage4CommunityFundShare
is 10%,stage4DevelopmentFundShare
is 15%, andstage4MasternodeShare
is 70%, totaling 95%.- In one instance, they are set to 15%, 25%, and 50%, totaling 90%.
These discrepancies suggest a need for further verification or clarification to ensure the parameters align with the intended design for stage 4. Please review and confirm the correct values.
Analysis chain
New parameters for stage 4 coinbase payment distribution.
The code changes introduce new parameters for stage 4 of the coinbase payment distribution, including:
stage4StartBlock
: The starting block for stage 4.stage4DevelopmentFundShare
: The percentage share for the development fund.stage4CommunityFundShare
: The percentage share for the community fund.stage4MasternodeShare
: The percentage share for masternodes.Please verify that the
stage4StartBlock
and the fund share percentages align with the intended design for stage 4. Consider running the following script to confirm the values:Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify stage 4 parameters are set as intended. # Test: Check if stage4StartBlock is set correctly. Expect: Correct block number. rg --type cpp -A 5 $'stage4StartBlock' # Test: Check if fund share percentages add up to 100%. Expect: Sum of percentages is 100. rg --type cpp -A 5 $'stage4\w+Share'Length of output: 9942
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (7)
- src/chainparams.cpp (6 hunks)
- src/consensus/params.h (2 hunks)
- src/miner.cpp (2 hunks)
- src/test/firsthalving_tests.cpp (4 hunks)
- src/test/main_tests.cpp (2 hunks)
- src/test/mtp_halving_tests.cpp (2 hunks)
- src/validation.cpp (4 hunks)
Additional comments not posted (24)
src/test/mtp_halving_tests.cpp (3)
45-46
: LGTM!The addition of the new member variables
mutableParams
andoldParams
to theMtpHalvingTestingSetup
struct is approved.
48-54
: LGTM!The changes to the constructor of the
MtpHalvingTestingSetup
struct are approved. The initialization of the new member variables and disabling of stage 3 functionality during the test setup is correct.
78-80
: LGTM!The addition of the destructor to the
MtpHalvingTestingSetup
struct is approved. Restoring the original consensus parameters in the destructor is a good practice to ensure that modifications made during the test do not persist.src/test/firsthalving_tests.cpp (7)
157-157
: LGTM!The change aligns the second subsidy halving with the start of stage 4 at block 620, which is consistent with the PR objective.
228-228
: LGTM!Assigning the current chain height to
consensusParams.stage3StartBlock
enhances the tracking of block stages by capturing when stage 3 begins.
264-265
: LGTM!The comment and assertion are consistent with the PR objective of keeping the block subsidy unchanged in stage 4 instead of implementing a second halving.
275-286
: LGTM!The assertions correctly verify the payment amounts to the development and community funds based on the new allocation percentages mentioned in the PR objective.
289-296
: LGTM!The comment and assertion are consistent with the PR objective of transitioning to a tail emission phase with a 1 FIRO block subsidy at block 1798655.
308-308
: LGTM!Setting
consensusParams.stage3StartTime
toINT_MAX
effectively disables stage 3 for the test case, allowing the focus to be on testing the behavior of other stages.
Line range hint
309-343
:
The remaining code segments are part of thedevpayoutverification
test case and do not have any alterations. Skipping the review.src/consensus/params.h (2)
Line range hint
1-1
: Removal ofnSubsidyHalvingStopBlock
parameter.The code changes involve the removal of the
nSubsidyHalvingStopBlock
parameter from theParams
struct.Please verify that the removal of
nSubsidyHalvingStopBlock
is intentional and doesn't introduce any unintended consequences or inconsistencies in the codebase. Consider running the following script to check for any remaining references tonSubsidyHalvingStopBlock
:Verification successful
Removal of
nSubsidyHalvingStopBlock
verified.The removal of the
nSubsidyHalvingStopBlock
parameter from theParams
struct has been verified. There are no remaining references to this parameter in the codebase, indicating that the removal was complete and did not introduce any inconsistencies.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the removal of nSubsidyHalvingStopBlock doesn't introduce inconsistencies. # Test: Search for any remaining references to nSubsidyHalvingStopBlock. Expect: No occurrences. rg --type cpp $'nSubsidyHalvingStopBlock'Length of output: 40
174-175
: New parameter for tail emission block subsidy.The code changes introduce a new parameter
tailEmissionBlockSubsidy
to define the block subsidy value during the tail emission phase.Please verify that the
tailEmissionBlockSubsidy
value is set as intended for the tail emission phase. Consider running the following script to confirm the value:Verification successful
Tail emission block subsidy is set as intended.
The
tailEmissionBlockSubsidy
is consistently set to4 * COIN
across different configurations, with a comment explaining that the effective value is1 FIRO
due to halvings. This setup appears intentional and aligns with the expected behavior for the tail emission phase.
src/chainparams.cpp
:consensus.tailEmissionBlockSubsidy = 4 * COIN; // real value would be 1 FIRO
src/validation.cpp
: UtilizestailEmissionBlockSubsidy
for subsidy calculations.src/test/main_tests.cpp
: Includes tests involvingtailEmissionBlockSubsidy
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify tail emission block subsidy is set as intended. # Test: Check if tailEmissionBlockSubsidy is set correctly. Expect: Correct subsidy value. rg --type cpp -A 5 $'tailEmissionBlockSubsidy'Length of output: 2941
src/miner.cpp (5)
195-195
: LGTM!Deriving
fShorterBlockDistance
fromnHeight
compared toparams.stage3StartBlock
makes the block reward logic more consistent and predictable.
838-841
: LGTM!The expanded conditional logic and introduction of
fStage3
andfStage4
boolean flags improve the clarity and maintainability of the block reward calculations for different stages.
846-852
: LGTM!Calculating the development and community fund payouts based on the appropriate share percentages for the current stage ensures alignment with the consensus rules.
854-857
: LGTM!Skipping the development fund payout when the value is zero enhances the efficiency of the reward distribution mechanism.
859-862
: LGTM!Skipping the community fund payout when the value is zero enhances the efficiency of the reward distribution mechanism.
src/chainparams.cpp (6)
208-212
: LGTM!The changes introduce the stage 4 funding parameters as per the PR description:
stage4StartBlock
is set tonSubsidyHalvingSecond
block number.- Fund share percentages are defined for community fund, development fund, and masternodes.
tailEmissionBlockSubsidy
is set to 4 FIRO.
535-539
: LGTM!The stage 4 funding parameters are correctly added for testnet, mirroring the changes made in
CMainParams
:
stage4StartBlock
is explicitly set to 167500.- Fund share percentages are defined.
tailEmissionBlockSubsidy
is set to 4 FIRO.
802-803
: LGTM!The subsidy halving schedule for devnet is adjusted:
nSubsidyHalvingSecond
is set to block 3000.nSubsidyHalvingInterval
is set to 10000 blocks.
810-817
: Verify thestage3StartBlock
value for devnet.The comment indicates that the
stage3StartBlock
value of 1514 is incorrect for devnet but will be retained for now.Please confirm if the
stage3StartBlock
value needs to be updated. If it's intentionally kept as 1514 for some reason, consider removing the comment to avoid confusion.
817-821
: LGTM!The stage 4 funding parameters are correctly added for devnet:
stage4StartBlock
is set tonSubsidyHalvingSecond
.- Fund share percentages are defined.
tailEmissionBlockSubsidy
is set to 4 FIRO.
1055-1067
: LGTM!The changes for regtest params look good:
stage3StartTime
is set to 0.stage3StartBlock
is set to 1500.- Stage 4 funding parameters are added:
stage4StartBlock
is set to 500 blocks afternSubsidyHalvingSecond
.- Fund share percentages are defined.
tailEmissionBlockSubsidy
is set to 4 FIRO.src/validation.cpp (1)
1921-1933
: Update to the block subsidy calculation logicThe changes to the
GetBlockSubsidyWithMTPFlag
function modify the block subsidy calculation:
- The initial subsidy remains at 50 coins until the first halving (
nSubsidyHalvingFirst
).- Between the first and second halvings, the subsidy is 25 coins.
- After the
stage4StartBlock
, the subsidy is set to a fixed 25 coins.- After
stage4StartBlock + nSubsidyHalvingInterval
, the subsidy switches to a fixed tail emission of 1 coin.Verify that the fixed subsidy values (25 coins, 1 coin) and the block height thresholds (
stage4StartBlock
,stage4StartBlock + nSubsidyHalvingInterval
) match the intended emission schedule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/chainparams.cpp (6 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/chainparams.cpp
PR intention
Change of emission rules. According to the new rules instead of second halving at block 958655 block subsidy remains the same and the split of funds are: development fund - 15%, community fund - 10%, masternode reward - 70%, miner's reward - 5%.
Instead of the third halving (block 1798655) blockchain enters the tail emission phase and block subsidy becomes 1 FIRO. Split remains the same as above.
Code changes brief
Multiple changes in generation and verification functions as well as chain parameters and tests.