-
Notifications
You must be signed in to change notification settings - Fork 36.6k
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: Create blockstorage module #21575
Conversation
b2c4d6f
to
fab062c
Compare
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. |
fab062c
to
555529c
Compare
Can be reviewed with the git options --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
Can be reviewed with the git option --color-moved=dimmed-zebra
555529c
to
fa0248a
Compare
Concept ACK. The include sorting is a bit off in some files. |
Concept ACK
That's great! :) |
Can be reviewed with the git options --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
Also, add missing { } for style. Can be reviewed with `--word-diff-regex=.`
fa0248a
to
fa3e883
Compare
force pushed to clang-format the include sorting |
Concept ACK. This paves the way to at some point make lock-splitting |
The doc nicely explains why the directory exists and it is irrelevant when it was introduced. Even if it was relevant, it could be trivially found out via `git log ./src/node/ | tail` without visiting GitHub
fa3e883
to
fadcd3f
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 fadcd3f, checked (almost) moved only changes. This is a nice tidy up change and doesn't change behavior. Easily reviewed commit by commit.
nit, could update doc/productivity.md to mention --color-moved-ws=ignore-all-space
.
Good suggestion. Happy to review another pr, to keep this one focused on |
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.
ACK fadcd3f (jamesob/ackr/21575.1.MarcoFalke.refactor_create_blocksto
)
Good change, mostly just moves. Though I think the last commit should maybe be amended or reviewed in its own PR.
@MarcoFalke I assume that the circular deps introduced here are thought to be temporary?
Built locally and ran unittest suite.
-
faf843c refactor: Move load block thread into ChainstateManager
Would be nice to document the newm_load_block
thread. -
fa413f0 move-only: Move ThreadImport to blockstorage
-
fa91b2b move-only: Move AbortNode to shutdown
Seems unrelated, but maybe isn't? ACK anyway. -
fa0c7d9 move-only: Move *Disk functions to blockstorage
-
fa121b6 blockstorage: [refactor] Use chainman reference where possible
-
fadcd3f doc: Remove irrelevant link to GitHub
Unrelated and I don't see why we should remove historical links to PRs from docs.
Show signature data
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
ACK fadcd3f78e1dd1acd7a774f8fad68dc471ff9e1f ([`jamesob/ackr/21575.1.MarcoFalke.refactor_create_blocksto`](https://github.com/jamesob/bitcoin/tree/ackr/21575.1.MarcoFalke.refactor_create_blocksto))
Good change, mostly just moves. Though I think the last commit should maybe be amended or reviewing in its own PR.
@MarcoFalke I assume that the circular deps introduced here are thought to be temporary?
Built locally and ran unittest suite.
- - [x] faf843c07f refactor: Move load block thread into ChainstateManager
Would be nice to document the new `m_load_block` thread.
- - [x] fa413f07a1 move-only: Move ThreadImport to blockstorage
- - [x] fa91b2b2b3 move-only: Move AbortNode to shutdown
Seems unrelated, but maybe isn't? ACK anyway.
- - [x] fa0c7d9ad2 move-only: Move *Disk functions to blockstorage
- - [x] fa121b628d blockstorage: [refactor] Use chainman reference where possible
- - [x] fadcd3f78e doc: Remove irrelevant link to GitHub
Unrelated and I don't see why we should remove historical links to PRs from docs.
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCgAdFiEEGNRVI1NPYuZCSIrGepNdrbLETwUFAmBtv1sACgkQepNdrbLE
TwX76RAAj9pVUi6OkydJS/FoBFxIM4kC2Z/ayMhFZDrhzMhCepKU8ZAV6zJal5Bo
BFz8wkW34GCFpfSwOOPy6Wq7CNS8K5cVkgXWdZRdV7tbzJmtxSlVXVNyR3PoehD6
CJnRJ2Bcqm3S1a1DGFqGaT2dpQLdnIhpB3UQ3b+egcUE9Fw85uhdHL9N9gasKxB6
OFsvLJ7W49+2J6m94fo5Pgmt/LhdcuSBFcJOVdh70MYa80gZKVOOAdzzFLiirikf
NX7f8A3fPZCeeWLYKZ8A2Z43XxYKq6OSHtyHzr1Be5m62ZY3zCOz3dkmqzZica3E
ikGK48fMzWQBq+f0V6Rjcyt0F8aK7mzKi67aqEkuobEWfp1y57iIxNV3tFnzH0IT
IZxPScoRislqRIFj+V0/YpjvkFCYu5ODFYLukpvE6rsoHMnKAXhqXrHNxPX7K0vz
4snv1TomXlWMzG6raf0xF23p8xMGN3/2N6b+XltpGVI/oXbthZNMaNcuIQHCLwIc
glydl0koJ9QW5Erj3OX8nHOLT73DIFWlB19E228DdI0fYKmXCWhsn5lfSho7U939
6Ol+gi16tQVkmEm7eNhjjWovADS6LAb96aUKlm03Kch7L3K52Icw6585C/cY54ur
marlDQj5LN5nfyCpyU/1kTfBBsENtTcotuz1yaQHbrzGoz0YcEA=
=aS2w
-----END PGP SIGNATURE-----
Show platform data
Tested on Linux-4.19.0-10-amd64-x86_64-with-glibc2.28
Configured with ./configure LDFLAGS=-L/home/james/src/bitcoin/db4/lib/ -L/home/james/.local/lib CPPFLAGS=-I/home/james/src/bitcoin/db4/include/ -I/home/james/.local/include CXXFLAGS=-fPIE -pipe -O2 -g -Wthread-safety-analysis -Wall -Werror=sign-compare -Wsign-compare -Werror=thread-safety-analysis --enable-wallet --enable-debug --with-daemon --enable-natpmp-default --enable-multiprocess PKG_CONFIG_PATH=/home/james/.local/lib/pkgconfig CXX=/usr/bin/clang++ CC=/usr/bin/clang PYTHONPATH= --disable-shared --with-pic --enable-benchmark=no --with-bignum=no --enable-module-recovery --enable-module-schnorrsig --enable-experimental --disable-shared --with-pic --enable-benchmark=no --with-bignum=no --enable-module-recovery --enable-module-schnorrsig --enable-experimental --no-create --no-recursion
Compiled with /usr/bin/ccache /usr/bin/clang++ -std=c++17 -mavx -mavx2 -fPIE -pipe -O2 -g -Wthread-safety-analysis -Wall -Werror=sign-compare -Wsign-compare -Werror=thread-safety-analysis -O0 -g3 -ftrapv -Wstack-protector -fstack-protector-all -msse4 -msha -msse4.1 -msse4.2 i
Compiler version: clang version 7.0.1-8 (tags/RELEASE_701/final)
/** Functions for disk access for blocks */ | ||
bool ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos, const Consensus::Params& consensusParams); | ||
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams); | ||
bool ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatFilePos& pos, const CMessageHeader::MessageStartChars& message_start); |
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.
It looks like this is unused outside of the src/node/blockstorage.cpp
unit, so you could make it internal to that if you wanted to.
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'll keep this one public for symmetry with the other read* functions
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 fadcd3f. New organization makes sense, moves extraneous things outside of validation.cpp. PR is also easy to review with helpfully split up moveonly commits.
Concept ACK. Looking forward to a follow up to address the new circular dependencies, TODO comments & review comments. |
Yes, one of them is being solved in #21726 |
Continue moving some of the low-level block file functions from validation to node/blockstorage (see bitcoin#21575), needed in the next commit. Also adds a version of ReadBlockFromDisk() that takes a path and seek offset, unused but also needed in the next commit.
Continue moving some of the low-level block file functions from validation to node/blockstorage (see bitcoin#21575), needed in the next commit. Also adds a version of ReadBlockFromDisk() that takes a path and seek offset, unused but also needed in the next commit.
fa09a9e style: Add { } to multi-line if (MarcoFalke) fadafab move-only: Move functions to blockstorage (MarcoFalke) fa7e64d move-only: Move constants to blockstorage (MarcoFalke) fa247a3 refactor: Move block storage globals to blockstorage (MarcoFalke) fa81c30 refactor: Move pruning/reindex/importing globals to blockstorage (MarcoFalke) Pull request description: See #21575 ACKs for top commit: Sjors: ACK fa09a9e kiminuo: ACK fa09a9e laanwj: Code review ACK fa09a9e promag: Code review ACK fa09a9e. Since last review Tree-SHA512: 2eb6962ff44da6b77f3058fc02ec66ab742e25ae8dcc8ec62b062896571910d43ca7c4bb16fb3ccb5e5245195b8dec6384b6c8d442fa97ca28d93bdff347d677
@MarcoFalke I notice that LoadMempool() is now done from blockstorage.cpp - somehow seems an inappropriate place now for this to be called from - it made more sense as part of an import thread in init.cpp. |
Summary: This is a backport of [[bitcoin/bitcoin#21575 | core#21575]] [1/6] bitcoin/bitcoin@faf843c Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D11347
Summary: Can be reviewed with the git options `--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space` This is a backport of [[bitcoin/bitcoin#21575 | core#21575]] [2/6] bitcoin/bitcoin@fa413f0 Depends on D11347 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D11348
Summary: Can be reviewed with the git option `--color-moved=dimmed-zebra` Also fix a `if (user_message.empty())` clause which was previously negated by mistake (introduced in D8649). This caused the specific user message to be overwritten by a more generic and less useful message. This is a backport of [[bitcoin/bitcoin#21575 | core#21575]] [3/6] bitcoin/bitcoin@fa91b2b Depends on D11348 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D11349
Summary: Can be reviewed with the git options `--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space` This is a backport of [[bitcoin/bitcoin#21575 | core#21575]] [4/6] bitcoin/bitcoin@fa0c7d9 Depends on D11349 and D11355 Notes: - we don't have the `ReadRawBlockFromDisk` functions, which are related to segwit - some functions were in `blockdb.{h|cpp}` rather than `validation.{h|cpp}` in Bitcoin ABC. `blockdb.{h|cpp}` will most likely be unnecessary and deleted as a result of this series of backports. Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D11350
Summary: This is a backport of [[bitcoin/bitcoin#21575 | core#21575]] [5/6] bitcoin/bitcoin@fa121b6 Depends on D11350 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D11351
This picks up the closed pull request #21030 and is the first step toward fixing #21220.
The basic idea is to move all disk access into a separate module with benefits: