refactor: Create blockstorage module #21575

pull MarcoFalke wants to merge 6 commits into bitcoin:master from MarcoFalke:2104-blockstorage changing 19 files +330 −258
  1. MarcoFalke commented at 6:26 pm on April 2, 2021: member

    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:

    • Breaking down the massive files init.cpp and validation.cpp into logical units
    • Creating a standalone-module to reduce the mental complexity
    • Pave the way to fix validation related circular dependencies
    • Pave the way to mock disk access for testing, especially where it is performance critical (like fuzzing)
  2. refactor: Move load block thread into ChainstateManager faf843c07f
  3. MarcoFalke added the label Block storage on Apr 2, 2021
  4. MarcoFalke added the label Refactoring on Apr 2, 2021
  5. MarcoFalke marked this as ready for review on Apr 2, 2021
  6. MarcoFalke force-pushed on Apr 2, 2021
  7. DrahtBot commented at 1:24 am on April 3, 2021: member

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #20331 (allow -loadblock blocks to be unsorted by LarryRuane)
    • #20295 (rpc: getblockfrompeer by Sjors)
    • #19521 (Coinstats Index by fjahr)
    • #10443 (Add fee_est tool for debugging fee estimation code by ryanofsky)

    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.

  8. MarcoFalke force-pushed on Apr 4, 2021
  9. move-only: Move ThreadImport to blockstorage
    Can be reviewed with the git options
    --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
    fa413f07a1
  10. move-only: Move AbortNode to shutdown
    Can be reviewed with the git option
    --color-moved=dimmed-zebra
    fa91b2b2b3
  11. MarcoFalke force-pushed on Apr 4, 2021
  12. jnewbery commented at 6:13 pm on April 5, 2021: member

    Concept ACK.

    The include sorting is a bit off in some files.

  13. practicalswift commented at 6:18 pm on April 5, 2021: contributor

    Concept ACK

    Pave the way to mock disk access for testing, especially where it is performance critical (like fuzzing)

    That’s great! :)

  14. move-only: Move *Disk functions to blockstorage
    Can be reviewed with the git options
    --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
    fa0c7d9ad2
  15. blockstorage: [refactor] Use chainman reference where possible
    Also, add missing { } for style.
    
    Can be reviewed with `--word-diff-regex=.`
    fa121b628d
  16. MarcoFalke force-pushed on Apr 5, 2021
  17. MarcoFalke commented at 6:29 pm on April 5, 2021: member
    force pushed to clang-format the include sorting
  18. jamesob commented at 6:38 pm on April 5, 2021: member
    Concept ACK. This paves the way to at some point make lock-splitting BlockManager away from cs_main a little bit more straightforward, at least syntactically.
  19. doc: Remove irrelevant link to GitHub
    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
    fadcd3f78e
  20. MarcoFalke force-pushed on Apr 6, 2021
  21. promag commented at 7:55 am on April 7, 2021: member

    Code review ACK fadcd3f78e, 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.

  22. MarcoFalke commented at 8:04 am on April 7, 2021: member

    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 ./src/ changes only.

  23. in src/node/blockstorage.h:31 in fa0c7d9ad2 outdated
    26 static constexpr bool DEFAULT_STOPAFTERBLOCKIMPORT{false};
    27 
    28+/** Functions for disk access for blocks */
    29+bool ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos, const Consensus::Params& consensusParams);
    30+bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams);
    31+bool ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatFilePos& pos, const CMessageHeader::MessageStartChars& message_start);
    


    jamesob commented at 2:02 pm on April 7, 2021:

    https://github.com/bitcoin/bitcoin/pull/21575/commits/fa0c7d9ad24d3c9515d3f9c136af4071cbd79055

    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.


    MarcoFalke commented at 6:12 am on April 19, 2021:
    I’ll keep this one public for symmetry with the other read* functions
  24. jamesob approved
  25. jamesob commented at 2:20 pm on April 7, 2021: member

    ACK fadcd3f78e1dd1acd7a774f8fad68dc471ff9e1f (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.

    • faf843c07f refactor: Move load block thread into ChainstateManager Would be nice to document the new m_load_block thread.

    • fa413f07a1 move-only: Move ThreadImport to blockstorage

    • fa91b2b2b3 move-only: Move AbortNode to shutdown Seems unrelated, but maybe isn’t? ACK anyway.

    • fa0c7d9ad2 move-only: Move *Disk functions to blockstorage

    • fa121b628d blockstorage: [refactor] Use chainman reference where possible

    • fadcd3f78e doc: Remove irrelevant link to GitHub Unrelated and I don’t see why we should remove historical links to PRs from docs.

     0-----BEGIN PGP SIGNED MESSAGE-----
     1Hash: SHA512
     2
     3ACK fadcd3f78e1dd1acd7a774f8fad68dc471ff9e1f ([`jamesob/ackr/21575.1.MarcoFalke.refactor_create_blocksto`](https://github.com/jamesob/bitcoin/tree/ackr/21575.1.MarcoFalke.refactor_create_blocksto))
     4
     5Good change, mostly just moves. Though I think the last commit should maybe be amended or reviewing in its own PR.
     6[@MarcoFalke](/bitcoin-bitcoin/contributor/marcofalke/) I assume that the circular deps introduced here are thought to be temporary?
     7
     8Built locally and ran unittest suite.
     9
    10
    11- - [x] faf843c07f refactor: Move load block thread into ChainstateManager
    12Would be nice to document the new `m_load_block` thread.
    13
    14- - [x] fa413f07a1 move-only: Move ThreadImport to blockstorage
    15- - [x] fa91b2b2b3 move-only: Move AbortNode to shutdown
    16Seems unrelated, but maybe isn't? ACK anyway.
    17
    18- - [x] fa0c7d9ad2 move-only: Move *Disk functions to blockstorage
    19- - [x] fa121b628d blockstorage: [refactor] Use chainman reference where possible
    20- - [x] fadcd3f78e doc: Remove irrelevant link to GitHub
    21Unrelated and I don't see why we should remove historical links to PRs from docs.
    22
    23-----BEGIN PGP SIGNATURE-----
    24
    25iQIzBAEBCgAdFiEEGNRVI1NPYuZCSIrGepNdrbLETwUFAmBtv1sACgkQepNdrbLE
    26TwX76RAAj9pVUi6OkydJS/FoBFxIM4kC2Z/ayMhFZDrhzMhCepKU8ZAV6zJal5Bo
    27BFz8wkW34GCFpfSwOOPy6Wq7CNS8K5cVkgXWdZRdV7tbzJmtxSlVXVNyR3PoehD6
    28CJnRJ2Bcqm3S1a1DGFqGaT2dpQLdnIhpB3UQ3b+egcUE9Fw85uhdHL9N9gasKxB6
    29OFsvLJ7W49+2J6m94fo5Pgmt/LhdcuSBFcJOVdh70MYa80gZKVOOAdzzFLiirikf
    30NX7f8A3fPZCeeWLYKZ8A2Z43XxYKq6OSHtyHzr1Be5m62ZY3zCOz3dkmqzZica3E
    31ikGK48fMzWQBq+f0V6Rjcyt0F8aK7mzKi67aqEkuobEWfp1y57iIxNV3tFnzH0IT
    32IZxPScoRislqRIFj+V0/YpjvkFCYu5ODFYLukpvE6rsoHMnKAXhqXrHNxPX7K0vz
    334snv1TomXlWMzG6raf0xF23p8xMGN3/2N6b+XltpGVI/oXbthZNMaNcuIQHCLwIc
    34glydl0koJ9QW5Erj3OX8nHOLT73DIFWlB19E228DdI0fYKmXCWhsn5lfSho7U939
    356Ol+gi16tQVkmEm7eNhjjWovADS6LAb96aUKlm03Kch7L3K52Icw6585C/cY54ur
    36marlDQj5LN5nfyCpyU/1kTfBBsENtTcotuz1yaQHbrzGoz0YcEA=
    37=aS2w
    38-----END PGP SIGNATURE-----
    
    0Tested on Linux-4.19.0-10-amd64-x86_64-with-glibc2.28
    1
    2Configured 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
    3
    4Compiled 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
    5
    6Compiler version: clang version 7.0.1-8 (tags/RELEASE_701/final)
    
  26. fanquake deleted a comment on Apr 7, 2021
  27. fanquake deleted a comment on Apr 7, 2021
  28. fanquake deleted a comment on Apr 7, 2021
  29. ryanofsky approved
  30. ryanofsky commented at 8:08 pm on April 10, 2021: member
    Code review ACK fadcd3f78e1dd1acd7a774f8fad68dc471ff9e1f. New organization makes sense, moves extraneous things outside of validation.cpp. PR is also easy to review with helpfully split up moveonly commits.
  31. fanquake commented at 2:00 pm on April 13, 2021: member
    Concept ACK. Looking forward to a follow up to address the new circular dependencies, TODO comments & review comments.
  32. fanquake merged this on Apr 13, 2021
  33. fanquake closed this on Apr 13, 2021

  34. MarcoFalke deleted the branch on Apr 13, 2021
  35. sidhujag referenced this in commit 099efbefa1 on Apr 13, 2021
  36. MarcoFalke commented at 6:09 am on April 19, 2021: member

    @MarcoFalke I assume that the circular deps introduced here are thought to be temporary?

    Yes, one of them is being solved in #21726

  37. LarryRuane referenced this in commit 04f28a70bb on Apr 23, 2021
  38. LarryRuane referenced this in commit 8c3c00637f on Apr 24, 2021
  39. laanwj referenced this in commit 3275c6e578 on May 5, 2021
  40. rebroad commented at 8:50 am on May 11, 2021: contributor
    @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.
  41. Fabcien referenced this in commit 57f0e173dd on Apr 27, 2022
  42. Fabcien referenced this in commit ce7eaa4a7e on Apr 27, 2022
  43. Fabcien referenced this in commit d4ff766e57 on Apr 27, 2022
  44. Fabcien referenced this in commit b46af778f1 on Apr 27, 2022
  45. Fabcien referenced this in commit 1ee3cb4fdc on Apr 27, 2022
  46. DrahtBot locked this on Aug 18, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-23 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me