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

Remove almost all blockstorage globals #25781

Merged
merged 5 commits into from Mar 15, 2023

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Aug 4, 2022

It seems preferable to assign globals to a class (in this case BlockManager), than to leave them dangling. This should clarify scope for code-readers, as well as clarifying unit test behaviour.

@maflcko maflcko force-pushed the 2208-block-globals- branch 3 times, most recently from 24a984a to a63ccbc Compare August 4, 2022 15:40
@maflcko maflcko changed the title Remove all blockstorage globals Remove almost all blockstorage globals Aug 4, 2022
@maflcko maflcko marked this pull request as ready for review August 4, 2022 17:12
@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 5, 2022

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

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK TheCharlatan, dergoegge, achow101
Concept ACK fanquake
Stale ACK w0xlt

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:

  • #27254 (refactor: Extract util/fs from util/system by TheCharlatan)
  • #27125 (refactor, kernel: Decouple ArgsManager from blockstorage by TheCharlatan)
  • #27050 (p2p, validation: Don't download witnesses for assumed-valid blocks when running in prune mode by dergoegge)
  • #25386 (refactor: Extract MIB_BYTES constant for init.cpp by Empact)
  • #25193 (indexes: Read the locator's top block during init, allow interaction with reindex-chainstate by mzumsande)
  • #15606 (assumeutxo by jamesob)

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.

maflcko pushed a commit to bitcoin-core/gui that referenced this pull request Aug 11, 2022
2e79fb6 validation tests: Use existing {Chainstate,Block}Man (Carl Dong)

Pull request description:

  This is split up because it is needed for two changes:
  * bitcoin/bitcoin#25781
  * bitcoin/bitcoin#25623

ACKs for top commit:
  adam2k:
    ACK tested 2e79fb6
  aureleoules:
    ACK 2e79fb6.

Tree-SHA512: 2cd6a2fec19545f8ffc77e37ccb793aa6cb5815bb1b5e560c0345af6e0f890fd500ae3297b044d3f6f613b8dd7fd4553f5fc2824013342b9e25af1fe2b624967
Copy link
Contributor

@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

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

ACK faf14c6

@fanquake fanquake requested review from TheCharlatan and removed request for w0xlt March 14, 2023 18:46
@maflcko
Copy link
Member Author

maflcko commented Mar 15, 2023

I've added a new commit, because all of this was reworked anyway.

@TheCharlatan
Copy link
Contributor

Code review ACK fadf8b8

@DrahtBot DrahtBot requested a review from w0xlt March 15, 2023 16:51
Copy link
Member

@dergoegge dergoegge left a comment

Choose a reason for hiding this comment

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

Code review ACK fadf8b8

: m_prune_mode{opts.prune_target > 0},
m_opts{std::move(opts)} {};

std::atomic<bool> m_importing{false};
Copy link
Member

Choose a reason for hiding this comment

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

nit: I think it would be nice if access to this was wrapped in a getter/setter, e.g. Importing(), {Start,Stop}Importing().

My thinking is that we might (in the future) want to mock the BlockManager to avoid expensive i/o in the fuzz tests for example. Having a clear interface defined would make that easier. A simple member like this is not a huge blocker for that so feel free to ignore.

Copy link
Member Author

Choose a reason for hiding this comment

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

This shouldn't be exposed at all, so I think making it private and ImportingNow a friend or so might be better?

@DrahtBot DrahtBot requested review from w0xlt and removed request for w0xlt March 15, 2023 17:05
@achow101
Copy link
Member

ACK fadf8b8

@DrahtBot DrahtBot requested review from w0xlt and removed request for w0xlt March 15, 2023 22:38
@achow101 achow101 merged commit cbfbf46 into bitcoin:master Mar 15, 2023
16 checks passed
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Mar 16, 2023
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Mar 16, 2023
@maflcko maflcko deleted the 2208-block-globals-🙅 branch March 16, 2023 09:10
fanquake added a commit to bitcoin-core/gui that referenced this pull request May 11, 2023
…rom blockstorage

5ff63a0 refactor, blockstorage: Replace stopafterblockimport arg (TheCharlatan)
18e5ba7 refactor, blockstorage: Replace blocksdir arg (TheCharlatan)
02a0899 refactor, BlockManager: Replace fastprune from arg with options (TheCharlatan)
a498d69 refactor/iwyu: Complete includes for blockmanager_args (TheCharlatan)
f0bb102 refactor: Move functions to BlockManager methods (TheCharlatan)
cfbb212 zmq: Pass lambda to zmq's ZMQPublishRawBlockNotifier (TheCharlatan)
8ed4ff8 refactor: Declare g_zmq_notification_interface as unique_ptr (TheCharlatan)

Pull request description:

  The libbitcoin_kernel library should not rely on the `ArgsManager`, but rather use option structs that can be passed to the various classes it uses. This PR removes reliance on the `ArgsManager` from the `blockstorage.*` files. Like similar prior work, it uses the options struct in the `BlockManager` that can be populated with `ArgsManager` values.

  Some related prior work: bitcoin/bitcoin#26889 bitcoin/bitcoin#25862 bitcoin/bitcoin#25527 bitcoin/bitcoin#25487

  Related PR removing blockstorage globals: bitcoin/bitcoin#25781

ACKs for top commit:
  ryanofsky:
    Code review ACK 5ff63a0. Since last ACK just added std::move and fixed commit title. Sorry for the noise!
  mzumsande:
    Code Review ACK 5ff63a0

Tree-SHA512: 4bde8fd140a40b97eca923e9016d85dcea6fad6fd199731f158376294af59c3e8b163a0725aa47b4be3519b61828044e0a042deea005e0c28de21d8b6c3e1ea7
@bitcoin bitcoin locked and limited conversation to collaborators Mar 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants