Make blockstorage globals private members of BlockManager#23974
Merged
fanquake merged 7 commits intobitcoin:masterfrom Jan 7, 2022
Merged
Make blockstorage globals private members of BlockManager#23974fanquake merged 7 commits intobitcoin:masterfrom
fanquake merged 7 commits intobitcoin:masterfrom
Conversation
Contributor
|
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. |
added 2 commits
January 5, 2022 15:07
Needed for a later commit
Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
faaecfe to
fad81b7
Compare
ryanofsky
reviewed
Jan 5, 2022
added 5 commits
January 5, 2022 16:15
This is a refactor and safe to do because: * UnloadBlockIndex calls ChainstateManager::Unload, which calls BlockManager::Unload * Only unit tests call Unload directly
This is needed to turn globals into member variables. Otherwise, this
will lead to issues:
runtime error: reference binding to null pointer of type 'CBlockFileInfo'
#0 in std::vector<CBlockFileInfo, std::allocator<CBlockFileInfo> >::operator[](unsigned long) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_vector.h:1046:2
#1 in BlockManager::FlushBlockFile(bool, bool) src/node/blockstorage.cpp:540:47
#2 in CChainState::FlushStateToDisk(BlockValidationState&, FlushStateMode, int) src/validation.cpp:2262:28
bitcoin#3 in CChainState::ResizeCoinsCaches(unsigned long, unsigned long) src/validation.cpp:4414:15
#4 in validation_chainstate_tests::validation_chainstate_resize_caches::test_method() src/test/validation_chainstate_tests.cpp:66:12
-BEGIN VERIFY SCRIPT-
ren() { sed -i "s/\<$1\>/$2/g" $( git grep -l "$1" ./src/ ) ; }
ren vinfoBlockFile m_blockfile_info
ren nLastBlockFile m_last_blockfile
ren fCheckForPruning m_check_for_pruning
ren setDirtyBlockIndex m_dirty_blockindex
ren setDirtyFileInfo m_dirty_fileinfo
-END VERIFY SCRIPT-
e339654 to
fa68a6c
Compare
This was referenced Jan 6, 2022
Closed
Member
|
ACK fa68a6c |
jonatack
reviewed
Jan 7, 2022
| } | ||
|
|
||
| bool BlockManager::WriteBlockIndexDB() | ||
| { |
Member
jonatack
reviewed
Jan 7, 2022
|
|
||
| CBlockIndex* LookupBlockIndex(const uint256& hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||
|
|
||
| /** Get block file info entry for one block file */ |
Member
There was a problem hiding this comment.
Would be it worth mentioning that this function is only used by the unit tests? If yes, can add to #24002.
- /** Get block file info entry for one block file */
+ /** Get block file info entry for one block file. Currently only used for unit tests. */
Member
Author
There was a problem hiding this comment.
It might be better to move the function to the test, if it is only used there.
sidhujag
pushed a commit
to syscoin/syscoin
that referenced
this pull request
Jan 7, 2022
maflcko
pushed a commit
that referenced
this pull request
Jan 8, 2022
…kIndexDB() 1823766 refactor: add thread safety lock assertion to WriteBlockIndexDB() (Jon Atack) Pull request description: New helper function `BlockManager::WriteBlockIndexDB()` added in #23974 has a thread safety lock annotation in its declaration but is missing the corresponding run-time lock assertion in its definition. Per doc/developer-notes.md: "Combine annotations in function declarations with run-time asserts in function definitions." ACKs for top commit: MarcoFalke: cr ACK 1823766 Tree-SHA512: b915e6b105c38b8bbe04ad810aefa68e940a13b8dd265e79563a2aaefc93ffa031d56a7f3c481a5ada90de7c2ddd3b419dcfa46c22fa26c22f95eda15cd243bc
sidhujag
pushed a commit
to syscoin/syscoin
that referenced
this pull request
Jan 9, 2022
…iteBlockIndexDB() 1823766 refactor: add thread safety lock assertion to WriteBlockIndexDB() (Jon Atack) Pull request description: New helper function `BlockManager::WriteBlockIndexDB()` added in bitcoin#23974 has a thread safety lock annotation in its declaration but is missing the corresponding run-time lock assertion in its definition. Per doc/developer-notes.md: "Combine annotations in function declarations with run-time asserts in function definitions." ACKs for top commit: MarcoFalke: cr ACK 1823766 Tree-SHA512: b915e6b105c38b8bbe04ad810aefa68e940a13b8dd265e79563a2aaefc93ffa031d56a7f3c481a5ada90de7c2ddd3b419dcfa46c22fa26c22f95eda15cd243bc
Fabcien
pushed a commit
to Bitcoin-ABC/bitcoin-abc
that referenced
this pull request
Nov 17, 2022
Summary: Needed for a later commit This is a partial backport of [[bitcoin/bitcoin#23974 | core#23974]] bitcoin/bitcoin@fa88cfd Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, sdulfari Reviewed By: #bitcoin_abc, sdulfari Differential Revision: https://reviews.bitcoinabc.org/D12510
Fabcien
pushed a commit
to Bitcoin-ABC/bitcoin-abc
that referenced
this pull request
Nov 17, 2022
Summary: Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space This is a partial backport of [[bitcoin/bitcoin#23974 | core#23974]] bitcoin/bitcoin@fa467f3 Depends on D12510 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, sdulfari Reviewed By: #bitcoin_abc, sdulfari Differential Revision: https://reviews.bitcoinabc.org/D12511
Fabcien
pushed a commit
to Bitcoin-ABC/bitcoin-abc
that referenced
this pull request
Nov 17, 2022
Summary: This is a refactor and safe to do because: * UnloadBlockIndex calls ChainstateManager::Unload, which calls BlockManager::Unload * Only unit tests call Unload directly This is a partial backport of [[bitcoin/bitcoin#23974 | core#23974]] bitcoin/bitcoin@fab2621 Depends on D12511 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, sdulfari Reviewed By: #bitcoin_abc, sdulfari Differential Revision: https://reviews.bitcoinabc.org/D12512
Fabcien
pushed a commit
to Bitcoin-ABC/bitcoin-abc
that referenced
this pull request
Nov 17, 2022
Summary:
This is needed to turn globals into member variables. Otherwise, this
will lead to issues:
```
runtime error: reference binding to null pointer of type 'CBlockFileInfo'
#0 in std::vector<CBlockFileInfo, std::allocator<CBlockFileInfo> >::operator[](unsigned long) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_vector.h:1046:2
#1 in BlockManager::FlushBlockFile(bool, bool) src/node/blockstorage.cpp:540:47
#2 in CChainState::FlushStateToDisk(BlockValidationState&, FlushStateMode, int) src/validation.cpp:2262:28
#3 in CChainState::ResizeCoinsCaches(unsigned long, unsigned long) src/validation.cpp:4414:15
#4 in validation_chainstate_tests::validation_chainstate_resize_caches::test_method() src/test/validation_chainstate_tests.cpp:66:12
```
This is a partial backport of [[bitcoin/bitcoin#23974 | core#23974]]
bitcoin/bitcoin@fad381b
Depends on D12512
Test Plan: `ninja check`
Reviewers: #bitcoin_abc, sdulfari
Reviewed By: #bitcoin_abc, sdulfari
Differential Revision: https://reviews.bitcoinabc.org/D12513
Fabcien
pushed a commit
to Bitcoin-ABC/bitcoin-abc
that referenced
this pull request
Nov 17, 2022
Summary: This is a partial backport of [[bitcoin/bitcoin#23974 | core#23974]] bitcoin/bitcoin@faa8c2d Depends on D12513 Test Plan: proofreading Reviewers: #bitcoin_abc, sdulfari Reviewed By: #bitcoin_abc, sdulfari Differential Revision: https://reviews.bitcoinabc.org/D12514
Fabcien
pushed a commit
to Bitcoin-ABC/bitcoin-abc
that referenced
this pull request
Nov 17, 2022
Summary: This is a partial backport of [[bitcoin/bitcoin#23974 | core#23974]] bitcoin/bitcoin@facd3df Depends on D12514 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D12517
Fabcien
pushed a commit
to Bitcoin-ABC/bitcoin-abc
that referenced
this pull request
Nov 17, 2022
Summary:
```
-BEGIN VERIFY SCRIPT-
ren() { sed -i "s/\<$1\>/$2/g" $( git grep -l "$1" ./src/ ) ; }
ren vinfoBlockFile m_blockfile_info
ren nLastBlockFile m_last_blockfile
ren fCheckForPruning m_check_for_pruning
ren setDirtyBlockIndex m_dirty_blockindex
ren setDirtyFileInfo m_dirty_fileinfo
-END VERIFY SCRIPT-
```
This concludes backport of [[bitcoin/bitcoin#23974 | core#23974]]
bitcoin/bitcoin@fa68a6c
Depends on D12517
Test Plan: `ninja all check-all`
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D12518
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Globals aren't too nice because they hide dependencies, also they make testing harder.
Fix that by removing some.