-
Notifications
You must be signed in to change notification settings - Fork 296
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
blockchain: Correct total subsidy snapshot. #3112
Merged
davecgh
merged 3 commits into
decred:master
from
davecgh:blockchain_correct_subsidy_snapshot
May 25, 2023
Merged
blockchain: Correct total subsidy snapshot. #3112
davecgh
merged 3 commits into
decred:master
from
davecgh:blockchain_correct_subsidy_snapshot
May 25, 2023
Conversation
This file contains 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
davecgh
added
the
database upgrade
Issues and/or pull requests that involve a new database version.
label
May 17, 2023
davecgh
force-pushed
the
blockchain_correct_subsidy_snapshot
branch
from
May 22, 2023 05:06
92cc25f
to
46a675b
Compare
jrick
approved these changes
May 22, 2023
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.
upgrade ran fine, and don't spot any issues in this code except the trivial bits regarding the error messages
This removes the error return from the TipGeneration method since it is no longer used due to previous updates. It also updates all callers accordingly.
This modifies calculateAddedSubsidy to also include the subsidy generated by treasurybases to ensure the total reported coin supply is the expected value. It should be noted that this commit only corrects the function and the issue does not affect consensus in any way since the calculated value is only used when providing the information via RPC. However, it does mean the database has an incorrect value stored. That will be corrected via a database migration in a separate commit.
This adds code to correct the total subsidy entry in the database due to the issue in calculateAddedSubsidy described by the previous commit. It involves loading and iterating through all of the main chain blocks and to recalculate the total subsidy and then updating the best chain state that houses the stored value. The process can be interrupted at any point and future invocations will resume from the point it was interrupted. Also, this takes advantage of the database version bump to only check and remove the legacy spend consumer dependencies bucket once during the upgrade instead of at every startup.
davecgh
force-pushed
the
blockchain_correct_subsidy_snapshot
branch
from
May 23, 2023 01:56
46a675b
to
14a80d5
Compare
dajohi
approved these changes
May 23, 2023
matheusd
approved these changes
May 24, 2023
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.
Testing Notes
As of this PR, the expected behavior is that there is a single migration that takes around 2 to 3 minutes to complete after which it will no longer be possible to downgrade.
As the warning above notes, if you try to run an older software version after this migration has completed, you will get an error message similar to
Unable to start server: the current blockchain database is no longer compatible with this version of the software (14 > 13)
This modifies
calculateAddedSubsidy
to also include the subsidy generated by treasurybases to ensure the total reported coin supply is the expected value.It should be noted that this commit only corrects the function and the issue does not affect consensus in any way since the calculated value is only used when providing the information via RPC.
However, it does mean the database has an incorrect value stored and therefore requires a database migration to correct.
The migration involves loading and iterating through all of the main chain blocks and to recalculate the total subsidy and then updating the best chain state that houses the stored value. The process can be interrupted at any point and future invocations will resume from the point it was interrupted.
Also, this takes advantage of the database version bump to only check and remove the legacy spend consumer dependencies bucket once during the upgrade instead of at every startup.
Fixes #3111.