-
Notifications
You must be signed in to change notification settings - Fork 37.8k
refactor: Remove confusing BlockIndex global #19413
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
Conversation
The |
Nice change, good to get rid of an valdiation global, and it's surprisingly low impact. ACK fa82d84 |
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.
Light code review ACK fa82d84 I agree that that this is a nice change
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. |
Concept ACK |
fa82d84
to
fa0dfdf
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.
Code review ACK fa0dfdf.
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.
re-ACK fa0dfdf
Some Namecoin code is still broken by the upstream change in bitcoin/bitcoin#19413, which will be fixed in a separate follow-up commit.
Properly pass down a ChainstateManager to the parts of the Namecoin code that need it (mostly validation of the coin database and the mempool, which is partly based on block heights). This fixes the breakages introduced by the upstream removal of the global BlockIndex in bitcoin/bitcoin#19413.
Properly pass down a ChainstateManager to the parts of the Namecoin code that need it (mostly validation of the coin database and the mempool, which is partly based on block heights). This fixes the breakages introduced by the upstream removal of the global BlockIndex in bitcoin/bitcoin#19413.
Summary: > The global ::BlockIndex() is problematic for several reasons: > - It returns a mutable reference to the block tree, without the appropriate lock annotation (m_block_index is guarded by cs_main). The current code is fine, but in the future this might lead to accidental races and data corruption. > - The rpc server shouldn't rely on node globals, but rather a context that is passed in to the RPC method. > - Tests might want to spin up their own block tree, and thus should also not rely on a single global. > > Fix all issues by removing the global This is a backport of [[bitcoin/bitcoin#19413 | core#19413]] Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D9581
The global
::BlockIndex()
is problematic for several reasons:m_block_index
is guarded bycs_main
). The current code is fine, but in the future this might lead to accidental races and data corruption.Fix all issues by removing the global