Skip to content
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

Drop CAutoFile #28904

Merged
merged 5 commits into from
Nov 22, 2023
Merged

Drop CAutoFile #28904

merged 5 commits into from
Nov 22, 2023

Conversation

ajtowns
Copy link
Contributor

@ajtowns ajtowns commented Nov 17, 2023

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

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 17, 2023

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.

@@ -30,7 +30,6 @@
#include <vector>

class BlockValidationState;
class CAutoFile;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: in e25bb16: 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@@ -55,7 +55,7 @@ static void LoadExternalBlockFile(benchmark::Bench& bench)
bench.run([&] {
// "rb" is "binary, O_RDONLY", positioned to the start of the file.
// The file will be closed by LoadExternalBlockFile().
CAutoFile file{fsbridge::fopen(blkfile, "rb"), CLIENT_VERSION};
AutoFile file{fsbridge::fopen(blkfile, "rb")};
testing_setup->m_node.chainman->LoadExternalBlockFile(file, &pos, &blocks_with_unknown_parent);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

ACK 6b70cf7 🚾

Show signature

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==

@maflcko
Copy link
Member

maflcko commented Nov 17, 2023

re-ACK 4eb2a9e 🖼

Show signature

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==

Copy link
Contributor

@TheCharlatan TheCharlatan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 4eb2a9e

Copy link
Contributor

@stickies-v stickies-v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 4eb2a9e

@maflcko maflcko added this to the 27.0 milestone Nov 20, 2023
@Sjors
Copy link
Member

Sjors commented Nov 21, 2023

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.

@maflcko
Copy link
Member

maflcko commented Nov 21, 2023

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.

@fanquake fanquake merged commit ca041fc into bitcoin:master Nov 22, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants