Drop CAutoFile #28904

pull ajtowns wants to merge 5 commits into bitcoin:master from ajtowns:202311-autofile changing 11 files +43 −65
  1. ajtowns commented at 2:20 PM on November 17, 2023: contributor

    Continuing the move away from GetVersion(), replace uses of CAutoFile with AutoFile.

  2. streams: Base BufferedFile on AutoFile instead of CAutoFile e63f643079
  3. streams: Remove unused CAutoFile::GetVersion c72ddf04db
  4. DrahtBot commented at 2:20 PM on November 17, 2023: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK maflcko, TheCharlatan, stickies-v

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #28687 ([POC][WIP] C++20 std::views::reverse by stickies-v)
    • #28052 (blockstorage: XOR blocksdir *.dat files by maflcko)

    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.

  5. ajtowns added the label Refactoring on Nov 17, 2023
  6. in src/node/blockstorage.h:33 in e25bb1698f outdated
      29 | @@ -30,7 +30,6 @@
      30 |  #include <vector>
      31 |  
      32 |  class BlockValidationState;
      33 | -class CAutoFile;
    


    maflcko commented at 2:50 PM on November 17, 2023:

    nit: in e25bb1698f3a0f2ce095832202b3b4354ab3a08d: I don't think deleting this is correct, according to iwyu? My understanding is that it may be fine to have a return type in C++ forward declared without including the full header, as long as the function whose return type is forward declared is never called without having the full header. But I could be wrong?


    ajtowns commented at 3:57 PM on November 17, 2023:

    It's not buggy, because blockstorage.h includes dbwrapper.h which includes streams.h; but I think it should just be including streams.h directly, and that seems to be what iwyu is recommending?


    maflcko commented at 4:01 PM on November 17, 2023:

    I know it isn't buggy, but it seems fragile to rely on dbwrapper having the include. iwyu used to be happy with a fwd decl, so maybe just keep it as-is?


    maflcko commented at 4:03 PM on November 17, 2023:

    A fwd decl should be enough, see also https://godbolt.org/z/7Txqjrh8e, unless I am missing something?


    ajtowns commented at 5:02 PM on November 17, 2023:

    I don't think you're missing anything; but I don't really see the point of including a fwd declaration when that's not enough to be able to use the function, especially when the full header's already included indirectly? The tidy job says:

    +#include "flatfile.h"
    +#include "streams.h"
    +#include "uint256.h"
    

    which seems reasonable to me? When I run iwyu locally, it also seems to suggest primitives/block.h (rather than class CBlock), which is already included via chain.h anyway, so seems fine.

    I've just pushed an update that gets closer to what iwyu suggests.


    maflcko commented at 5:29 PM on November 17, 2023:

    The tidy job says:

    For reference, on master it doesn't say that. See for example https://cirrus-ci.com/task/5754375344226304 (https://api.cirrus-ci.com/v1/task/5754375344226304/logs/ci.log):

    The full include-list for node/blockstorage.h:
    #include <attributes.h>                // for LIFETIMEBOUND
    #include <chain.h>                     // for CBlockFileInfo, CBlockIndex
    #include <dbwrapper.h>                 // for CDBWrapper
    #include <kernel/blockmanager_opts.h>  // for BlockManagerOpts
    #include <kernel/chainparams.h>        // for CChainParams
    #include <kernel/cs_main.h>            // for cs_main
    #include <kernel/messagestartchars.h>  // for MessageStartChars
    #include <stddef.h>                    // for size_t
    #include <sync.h>                      // for EXCLUSIVE_LOCKS_REQUIRED, GUARDED_BY, RecursiveMutex
    #include <util/fs.h>                   // for path
    #include <util/hasher.h>               // for BlockHasher
    #include <algorithm>                   // for max
    #include <array>                       // for array, tuple_size_v
    #include <atomic>                      // for atomic, atomic_bool
    #include <cstdint>                     // for uint64_t, uint8_t
    #include <functional>                  // for function
    #include <iosfwd>                      // for ostream
    #include <limits>                      // for numeric_limits
    #include <map>                         // for multimap
    #include <memory>                      // for unique_ptr
    #include <optional>                    // for optional, nullopt
    #include <set>                         // for set
    #include <string>                      // for string, hash
    #include <unordered_map>               // for unordered_map
    #include <utility>                     // for move, pair
    #include <vector>                      // for vector
    #include "flatfile.h"                  // for FlatFilePos (ptr only), FlatFileSeq
    #include "uint256.h"                   // for uint256, operator==
    class BlockValidationState;  // lines 32-32
    class CAutoFile;  // lines 33-33
    class CBlock;  // lines 34-34
    class CBlockHeader;
    class CBlockUndo;  // lines 35-35
    class Chainstate;  // lines 37-37
    class ChainstateManager;  // lines 38-38
    namespace Consensus { struct Params; }  // lines 42-42
    namespace util { class SignalInterrupt; }  // lines 45-45
    

    Anyway, it is just a style nit and anything that compiles should be fine here.

  7. in src/bench/load_external.cpp:59 in 8a8d9d0a6a outdated
      54 | @@ -55,7 +55,7 @@ static void LoadExternalBlockFile(benchmark::Bench& bench)
      55 |      bench.run([&] {
      56 |          // "rb" is "binary, O_RDONLY", positioned to the start of the file.
      57 |          // The file will be closed by LoadExternalBlockFile().
      58 | -        CAutoFile file{fsbridge::fopen(blkfile, "rb"), CLIENT_VERSION};
      59 | +        AutoFile file{fsbridge::fopen(blkfile, "rb")};
      60 |          testing_setup->m_node.chainman->LoadExternalBlockFile(file, &pos, &blocks_with_unknown_parent);
    


    maflcko commented at 2:51 PM on November 17, 2023:

    nit: This is related to the blockmanager commit, so could just squash 8a8d9d0a6ac6378b06c57911cf5a3c2b48a19610 into the previous commit?

  8. maflcko approved
  9. maflcko commented at 2:52 PM on November 17, 2023: member

    Nice

    ACK 6b70cf77b5beda5bd25246aefed2633410d4126f 🚾

    <details><summary>Show signature</summary>

    Signature:

    untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
    RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
    trusted comment: ACK 6b70cf77b5beda5bd25246aefed2633410d4126f 🚾
    9vtH9miHsZeyTpMvrJOhEJfjd/q6MlP9nJvViqeqkdhzvUvH5m1DR9I/+rVIopqsS4/EIsnuNZognM5WPJ0ODw==
    

    </details>

  10. blockstorage: switch from CAutoFile to AutoFile
    Also bump includes per suggestions from iwyu.
    bbd4646a2e
  11. refactor: switch from CAutoFile to AutoFile cde9a4b137
  12. streams: Drop unused CAutoFile 4eb2a9ea4b
  13. ajtowns force-pushed on Nov 17, 2023
  14. maflcko commented at 5:30 PM on November 17, 2023: member

    re-ACK 4eb2a9ea4b6262bec0bc7c20cb3e684ea75caf42 🖼

    <details><summary>Show signature</summary>

    Signature:

    untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
    RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
    trusted comment: re-ACK 4eb2a9ea4b6262bec0bc7c20cb3e684ea75caf42 🖼
    ANC6hAaguhTkX0Yz+0EjG+ghzH3/DQZEXpJT5Nr6Ld8sHHSeLVAxdgc2S+cEUYIPfS4uqwL1HOY2fFVWlwKUDw==
    

    </details>

  15. TheCharlatan approved
  16. TheCharlatan commented at 6:16 PM on November 18, 2023: contributor

    ACK 4eb2a9ea4b6262bec0bc7c20cb3e684ea75caf42

  17. stickies-v approved
  18. stickies-v commented at 3:27 PM on November 20, 2023: contributor

    ACK 4eb2a9ea4b6262bec0bc7c20cb3e684ea75caf42

  19. maflcko added this to the milestone 27.0 on Nov 20, 2023
  20. Sjors commented at 9:57 AM on November 21, 2023: member

    Looks like a nice cleanup, but I'm not familiar with the history of CAutoFile -> AutoFile. I did check that tests pass for all intermediate commits.

  21. maflcko commented at 10:11 AM on November 21, 2023: member

    Looks like a nice cleanup, but I'm not familiar with the history of CAutoFile -> AutoFile.

    serialization flags embedded in the version-integer and type-integer are gone, serialization now uses params-serialization, so the ser-version and ser-type code can be deleted.

  22. maflcko assigned achow101 on Nov 22, 2023
  23. maflcko assigned ryanofsky on Nov 22, 2023
  24. fanquake merged this on Nov 22, 2023
  25. fanquake closed this on Nov 22, 2023

  26. bitcoin locked this on Nov 21, 2024

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: 2026-04-26 09:14 UTC

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