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 DCP0010 subsidy consensus vote. #2848
Conversation
db87955
to
b249403
Compare
999c545
to
923bc6a
Compare
} | ||
|
||
// Ensure the total calculated subsidy is the expected value. | ||
const expectedTotalSubsidy = 2100000000015952 |
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.
So the net result is an increase in total issuance of 215k atoms.
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.
Estimated. Yes. The reason is that fewer atoms are lost due to truncation.
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.
Going to do more testing and another thorough review, but so far, everything is looking good to me.
// Subsidy aligns with the height being voting on, not with the | ||
// height of the current block. | ||
voteSubsidy := b.subsidyCache.CalcStakeVoteSubsidyV2(node.height-1, | ||
isSubsidySplitEnabled) |
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.
I double-checked and confirmed that there are no other locations using the CalcWorkSubsidy
or CalcStakeVoteSubsidy
versions of these functions (other than tests and internally to the subsidy code).
923bc6a
to
01cd66f
Compare
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.
Will run some simnet tests later, looking good overall.
01cd66f
to
ba03567
Compare
Can't mine past SVH on simnet so far. Getting this error from the wallet. 2021-12-15 08:59:00.823 [ERR] WLLT: Failed to send one or more votes: dcrd.PublishTransactions: rejected transaction ef0e9658ef997c1ec41c2781a52281b45124f038a1be325dbdc6795bbb70fb90: vote subsidy input value of 2970297029 is not 7920792079 |
Yes, that is expected because the agenda is active and your wallet isn't updated to calculate the new required vote subsidy. You'll either have to wait for wallet to be updated or just modify it yourself to call the new methods with the agenda active. |
Thought as much, thanks. Will update the wallet. |
ba03567
to
5351006
Compare
I updated the first commit to include a few more tests so it includes all of the test vectors that are in the DCP. |
deploymentVer, ok := b.deploymentVers[deploymentID] | ||
if !ok { | ||
return true, nil |
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.
This looks like boilerplate from the other methods, but I'm not clear what this implies. Not found means it was not in chaincfg.Params.Deployments
, which means:
- "voting is not enabled for this network" as described in
isLNFeaturesAgendaActive
. Like simnet where it is always active? - This deployment is ancient history, removed from
Params.Deployments
, and thus passed? Presumably the plan is if an agenda fails then all the related code that would look for it would also be removed if it is also removed fromParams.Deployments
.
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.
Yes on number 1. For number 2, in the case of failure, yes, that's correct. In the case of success though, the idea is that the code would be changed so that the historical activation points for mainnet
/testnet
are added and then these methods would turn into "if that historical activation point is an ancestor of a given block, it's active, otherwise, it's not".
EDIT: I should also note that Matheus and I have discussed previously that it would probably be nicer to add a flag to the deployments for specifying whether or not it should always be considered active instead of the current approach of "active if voting is not enabled for this network due to lack of a definition for the deployment". I am planning to do that at some point.
This adds two new exported functions to the subsidy cache in blockchain/standalone to calculate calculate the work and stake vote subsidies according to either the original or modified values defined in DCP0010 per a provided flag along with tests to ensure expected behavior. It should be noted that the values for the modified split are hard coded as opposed to using the subsidy 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 adds a new munger to the test chain generator named ReplaceVoteSubsidies which modifies a block by replacing the subsidy of all votes contained in the block to a given value.
a858c16
to
ec0736c
Compare
Updated to remove the replace for |
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.
In addition to giving this another thorough review, I also tested the following scenarios in simnet (with dcrd
updated to activate the agenda at a particular height and dcrwallet
updated to use CalcStakeVoteSubsidyV2
):
- When the agenda is NOT active
- Votes are accepted with the original vote subsidy
- Votes are NOT accepted with the new vote subsidy (and therefore, blocks can't be mined)
- Blocks are NOT accepted with the new work subsidy (modified the
mining
code to test) - Blocks are accepted with the original vote and work subsidy
- When the agenda is active
- Votes are NOT accepted with the original vote subsidy (and therefore, blocks can't be mined)
- Votes are accepted with the new vote subsidy
- Blocks are NOT accepted with the original work subsidy (modified the
mining
code to test) - Blocks are accepted with the new vote and work subsidy
- Validated that disconnecting and reconnecting blocks across the agenda activation height works as expected
Looks good to me!
This implements the agenda for voting on the modified subsidy split defined in DCP0010 along with consensus tests. In particular, once the vote has passed and is active, the PoW subsidy will be 10% of the block reward and the PoS subsidy will be 80%. 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 either the original or modified values per a provided flag - 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 agenda since it is always active on simnet.
ec0736c
to
259b51b
Compare
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.
Tested on simnet. Woop!
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.
Simnet testing looks good.
This requires #2847.
This implements the agenda for voting on the modified subsidy split defined in DCP0010 along with consensus tests.
In particular, once the vote has passed and is active, the PoW subsidy will be 10% of the block reward and the PoS subsidy will be 80%. The Treasury subsidy will remain at 10%.
In terms of the overall effects, this includes updates to:
mempool
, relaying, and inclusion into block templatesgetblocksubsidy
RPCAlso 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:
blockchain/standalone
for calculating the work and stake vote subsidies according to either the original or modified values per a provided flagmainnet
andtestnet
getblocksubsidy
RPCmempool
correctly accepts and rejects votes in accordance with the state of the vote