-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
refactor: Remove nChainTx from consensus #29349
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
src/chain.h
Outdated
*/ | ||
BLOCK_VALID_TRANSACTIONS = 3, | ||
BLOCK_VALID_TRANSACTIONS = 2, |
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'm trying to understand if it's safe to modify these values -- I believe we write the nStatus field to disk and load it on restart, so wouldn't changing these values require a block-index-upgrade mechanism to be created, in order to avoid problems on restart?
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.
Good catch. It should be possible to keep the persisted format by using a serialize helper that translates nStatus both ways losslessly and then recover BLOCK_VALID_TRANSACTIONS_TREE
in LoadBlockIndex
as a memory-only value.
Though, I wonder if this pull request is still worth it, if more code changes are needed.
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.
Fixed. (Implemented my suggestion)
facca8f
to
6670123
Compare
Closing for now, but happy to reopen if someone thinks this is useful. |
nChainTx
is returned by RPCs and is used to estimate (sync and rescan) progress.However, it is also used for consensus and P2P logic to denote that a block and all its parents have
BLOCK_VALID_TRANSACTIONS
set.This is confusing, because:
BlockStatus
enum for this as well.nChainTx
values.nChainTx
completely, or limit it to code that needs it (estimate sync and scan progress and report it on RPC).Fix it by introducing a new
BLOCK_VALID_TRANSACTIONS_TREE
level and use it where possible.