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

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

    Code Coverage

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

    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.

    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:

    0+#include "flatfile.h"
    1+#include "streams.h"
    2+#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):

     0The full include-list for node/blockstorage.h:
     1#include <attributes.h>                // for LIFETIMEBOUND
     2#include <chain.h>                     // for CBlockFileInfo, CBlockIndex
     3#include <dbwrapper.h>                 // for CDBWrapper
     4#include <kernel/blockmanager_opts.h>  // for BlockManagerOpts
     5#include <kernel/chainparams.h>        // for CChainParams
     6#include <kernel/cs_main.h>            // for cs_main
     7#include <kernel/messagestartchars.h>  // for MessageStartChars
     8#include <stddef.h>                    // for size_t
     9#include <sync.h>                      // for EXCLUSIVE_LOCKS_REQUIRED, GUARDED_BY, RecursiveMutex
    10#include <util/fs.h>                   // for path
    11#include <util/hasher.h>               // for BlockHasher
    12#include <algorithm>                   // for max
    13#include <array>                       // for array, tuple_size_v
    14#include <atomic>                      // for atomic, atomic_bool
    15#include <cstdint>                     // for uint64_t, uint8_t
    16#include <functional>                  // for function
    17#include <iosfwd>                      // for ostream
    18#include <limits>                      // for numeric_limits
    19#include <map>                         // for multimap
    20#include <memory>                      // for unique_ptr
    21#include <optional>                    // for optional, nullopt
    22#include <set>                         // for set
    23#include <string>                      // for string, hash
    24#include <unordered_map>               // for unordered_map
    25#include <utility>                     // for move, pair
    26#include <vector>                      // for vector
    27#include "flatfile.h"                  // for FlatFilePos (ptr only), FlatFileSeq
    28#include "uint256.h"                   // for uint256, operator==
    29class BlockValidationState;  // lines 32-32
    30class CAutoFile;  // lines 33-33
    31class CBlock;  // lines 34-34
    32class CBlockHeader;
    33class CBlockUndo;  // lines 35-35
    34class Chainstate;  // lines 37-37
    35class ChainstateManager;  // lines 38-38
    36namespace Consensus { struct Params; }  // lines 42-42
    37namespace 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 🚾

    Signature:

    0untrusted 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}"
    1RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
    2trusted comment: ACK 6b70cf77b5beda5bd25246aefed2633410d4126f 🚾
    39vtH9miHsZeyTpMvrJOhEJfjd/q6MlP9nJvViqeqkdhzvUvH5m1DR9I/+rVIopqsS4/EIsnuNZognM5WPJ0ODw==
    
  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 🖼

    Signature:

    0untrusted 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}"
    1RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
    2trusted comment: re-ACK 4eb2a9ea4b6262bec0bc7c20cb3e684ea75caf42 🖼
    3ANC6hAaguhTkX0Yz+0EjG+ghzH3/DQZEXpJT5Nr6Ld8sHHSeLVAxdgc2S+cEUYIPfS4uqwL1HOY2fFVWlwKUDw==
    
  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


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-09-28 22:12 UTC

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