Skip to content
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

multi: Implement DCP0012 subsidy consensus vote. #3092

Merged
merged 3 commits into from
Apr 30, 2023

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Apr 12, 2023

This requires #3090.

This implements the agenda for voting on the round 2 modified subsidy split defined in DCP0012 along with consensus tests.

In particular, once the vote has passed and is active, the PoW subsidy will be 1% of the block reward and the PoS subsidy will be 89%. The Treasury subsidy will remain at 10%.

In terms of the overall effects, this includes updates to:

  • The validation logic for votes, coinbases, and overall block subsidy
  • Enforcement when considering candidate votes for acceptance to the mempool, relaying, and inclusion into block templates
  • Mining template generation
  • The output of the getblocksubsidy RPC

Also note that this does not implement the block version bump that will ultimately be needed by the mining code since there are multiple consensus votes gated behind it and will therefore be done separately.

The following is an overview of the changes:

  • Introduce a convenience function for determining if the vote passed and is now active
  • Add new methods to blockchain/standalone for calculating the work and stake vote subsidies according to a subsidy split variant flag:
    • The original subsidy split used at launch (standalone.SSVOriginal)
    • The modified subsidy split defined by DCP0010 (standalone.SSVDCP0010)
    • The modified subsidy split defined by DCP0012 (standalone..SSVDCP0012)
  • Modify vote validation to enforce the new stake vote subsidy in accordance with the state of the vote
  • Modify coinbase validation to enforce the new work subsidy in accordance with the state of the vote
  • Modify block validation logic to enforce the total overall subsidy in accordance with the state of the vote
  • Add tests for determining if the agenda is active for both mainnet and testnet
  • Add tests for getblocksubsidy RPC
  • Add tests to ensure proper behavior for the modified subsidy splits as follows:
    • Ensure new blockchain validation semantics are enforced once the agenda is active
    • Ensure mempool correctly accepts and rejects votes in accordance with the state of the vote

@davecgh davecgh added the consensus changes Changes that involve modifying the consensus rules and thus are required to be gated behind a vote. label Apr 12, 2023
@davecgh davecgh added this to the 1.8.0 milestone Apr 12, 2023
@davecgh davecgh force-pushed the multi_dcp0012_subsidy_split branch from c7b5762 to 138127e Compare April 12, 2023 06:29
@davecgh
Copy link
Member Author

davecgh commented Apr 12, 2023

Note that I've disabled the RPC integration test (TestTreasury) for this PR because the separate framework that it uses needs to be updated to the code this PR itself introduces in order to work properly with the resulting modified version of simnet. Rather than having to constantly play musical chairs with replacements to changing commits, I've opened #3093 as a reminder to re-enable it once this PR has been merged and the separate framework is updated to use the published code accordingly.

@davecgh davecgh force-pushed the multi_dcp0012_subsidy_split branch from 138127e to 1e60037 Compare April 12, 2023 16:47
Copy link
Member

@matheusd matheusd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While DCP0012 isn't actually published as of this comment, the code in the PR implements the approved proposal (1/89/10 split).

I haven't done manual tests on simnet yet, so that I can perform them with the upcoming pow algo change as well.

Comment on lines +667 to +670
wantFull: 1896827356,
wantWork: 11380963,
wantVote: 337635269,
wantTreasury: 113809641,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually verified the numbers in the tests.

// at the time of this writing. For testing purposes, the activation height
// is estimated to be 782208 on mainnet.
const dcp0010ActivationHeight = 657280
const estimatedDCP0012ActivationHeight = 782208
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤞

Copy link
Member

@matheusd matheusd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First commit message has calculate calculate typo

@davecgh davecgh force-pushed the multi_dcp0012_subsidy_split branch from 1e60037 to b3fd35c Compare April 13, 2023 21:48
@davecgh
Copy link
Member Author

davecgh commented Apr 13, 2023

First commit message has calculate calculate typo

Fixed.

@davecgh davecgh force-pushed the multi_dcp0012_subsidy_split branch 2 times, most recently from 837403d to 032295a Compare April 16, 2023 07:11
This adds two new exported functions to the subsidy cache in
blockchain/standalone to calculate the work and stake vote subsidies
according to a provided subsidy split variant flag along with tests to
ensure expected behavior.

The available variants are:

- The original subsidy split used at launch
- The modified subsidy split defined by DCP0010
- The modified subsidy split defined by DCP0012

It should be noted that the values for the modified split are hard coded
as opposed to using the subsidy cache params in order to avoid the need
for a major module bump that would be required if the subsidy params
interface were changed.  The values are the same for all networks, so no
additional logic is necessary on a per-network basis.
This implements the agenda for voting on the round 2 modified subsidy
split defined in DCP0012 along with consensus tests.

In particular, once the vote has passed and is active, the PoW subsidy
will be 1% of the block reward and the PoS subsidy will be 89%.  The
Treasury subsidy will remain at 10%.

In terms of the overall effects, this includes updates to:
- The validation logic for votes, coinbases, and overall block subsidy
- Enforcement when considering candidate votes for acceptance to the
  mempool, relaying, and inclusion into block templates
- Mining template generation
- The output of the getblocksubsidy RPC

Also note that this does not implement the block version bump that will
ultimately be needed by the mining code since there are multiple
consensus votes gated behind it and will therefore be done separately.

The following is an overview of the changes:

- Introduce a convenience function for determining if the vote passed
  and is now active
- Modify vote validation to enforce the new stake vote subsidy in
  accordance with the state of the vote
- Modify coinbase validation to enforce the new work subsidy in
  accordance with the state of the vote
- Modify block validation logic to enforce the total overall subsidy in
  accordance with the state of the vote
- Add tests for determining if the agenda is active for both mainnet and
  testnet
- Add tests for getblocksubsidy RPC
- Add tests to ensure proper behavior for the modified subsidy splits as
  follows:
  - Ensure new blockchain validation semantics are enforced once the
    agenda is active
  - Ensure mempool correctly accepts and rejects votes in accordance
    with the state of the vote
This updates the simnet environment documentation to account for the
different expected initial balances due to the subsidy split round 2
agenda since it is always active on simnet.
@davecgh davecgh force-pushed the multi_dcp0012_subsidy_split branch from 032295a to 8f3e249 Compare April 30, 2023 21:35
@davecgh davecgh merged commit 8f3e249 into decred:master Apr 30, 2023
@davecgh davecgh deleted the multi_dcp0012_subsidy_split branch April 30, 2023 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus changes Changes that involve modifying the consensus rules and thus are required to be gated behind a vote.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants