Skip to content

Conversation

Empact
Copy link
Contributor

@Empact Empact commented Mar 1, 2022

By splitting ArgsManager and related functions out of the grab-bag util/system file, this enables more specific includes, referencing ArgsManager without pulling in gArgs, and eliminate a circular dependency between chainparamsbase and utils/system.

The proposed new modules are:

  • util/args_manager - ArgsManager and related functions
  • util/args - gArgs only - separate to support the goal of limiting the scope of gArgs
  • util/system - a variety of file system and sytem-related functions

Other notable points:

  • I find it a bit concerning that ArgsManager::ReadConfigFiles calls ClearPathCache and CheckDataDirOption on gArgs rather than the current ArgsManager instance in the status quo.

The new files are nearly unchanged from their sources, so git diff master --color-moved=dimmed-zebra could be helpful.

Copy link
Contributor

@dongcarl dongcarl left a comment

Choose a reason for hiding this comment

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

Concept ACK!

In fact I did almost the exact same thing here 😆: dongcarl@81d1857

Happy to use your changes though if you're planning on proactively rebasing over master when merge conflicts arise!

One thing: the only difference I can spot between your changes and mine is that you didn't move BITCOIN_CONF_FILENAME and BITCOIN_SETTINGS_FILENAME out of util/system.h, I think doing that makes the split even better? Lmk!

@ryanofsky
Copy link
Contributor

This is pretty reasonable. I know we don't generally like to move code around, but this move was probably inevitable.

One suggestion would be to rename "util/args_manager" to "util/args". I think "_manager" suffix does not contribute or clarify much, and will make it awkward to add other argument-handling functions and classes to the same file without attaching them to the ArgsManager class. ArgsManager class is already monolithic and it should be possible to break up or extend without putting everything inside.

Related to this, I don't necessarily see a need to put the gArgs variable in its own file, but if this is needed to get rid of circular dependencies, or if it just seems like a good idea, I'd suggest putting it in "util/gargs" or "util/args_global" instead of "util/args"

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 2, 2022

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #24922 (Isolate the storage abstraction layer from the application/serialization layer by TheQuantumPhysicist)
  • #24915 (lint: Convert lint-circular-dependencies.sh to Python by Smlep)
  • #24914 (wallet: Load database records in a particular order by achow101)
  • #24845 (wallet: createTransaction, return proper error description for "too-long-mempool-chain" + introduce generic Result classes by furszy)
  • #24831 (tidy: add include-what-you-use by fanquake)
  • #24830 (init: Allow -proxy="" setting values by ryanofsky)
  • #24812 (util/check: Add CHECK_NONFATAL identity function and NONFATAL_UNREACHABLE macro by aureleoules)
  • #24764 (Modernize util/strencodings and util/string: string_view and optional by sipa)
  • #24757 (build, ci: add DEBUG_LOCKCONTENTION to --enable-debug and CI by jonatack)
  • #24742 ([POC] build: prune Boost headers in depends by fanquake)
  • #24676 ([WIP] [kernelheaders 1/n] Cleave LevelDB headers from our header tree by dongcarl)
  • #24675 (util: Use ArgsManager::GetPathArg more widely by hebasto)
  • #24479 (Bugfix: util: Correctly handle Number value types in GetArg/GetBoolArg by luke-jr)
  • #24232 (assumeutxo: add init and completion logic by jamesob)
  • #24230 (indexes: Stop using node internal types and locking cs_main, improve sync logic by ryanofsky)
  • #23561 (BIP324: Handshake prerequisites by dhruv)
  • #23444 (fuzz: Add regression test for wallet crash by MarcoFalke)
  • #23233 (BIP324: Add encrypted p2p transport {de}serializer by dhruv)
  • #22953 (refactor: introduce single-separator split helper (boost::split replacement) by theStack)
  • #20205 (wallet: Properly support a wallet id by achow101)
  • #19792 (rpc: Add dumpcoinstats by fjahr)
  • #17786 (refactor: Nuke policy/fees->mempool circular dependencies by hebasto)
  • #16673 (Relog configuration args on debug.log rotation by LarryRuane)
  • #15936 (Unify bitcoin-qt and bitcoind persistent settings 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.

Empact added 4 commits April 22, 2022 13:55
These were introduced in bitcoin#22950, but they're not used in the header,
rather equivalent includes in addrman.cpp do the work.
This file is not required for the dbwrapper interfaces provided, but several other files were getting their necessary includes indirectly via this header.

Removing results in more minimal includes throughout.
This is the more minimal include, and the only used therein.
@Empact Empact force-pushed the 2022-03-util-args-manager branch 5 times, most recently from f3a7954 to 9f8fe54 Compare April 22, 2022 21:50
@Empact Empact force-pushed the 2022-03-util-args-manager branch from 9f8fe54 to bfcbe09 Compare April 23, 2022 06:44
@Empact Empact marked this pull request as ready for review April 23, 2022 22:48
@Empact
Copy link
Contributor Author

Empact commented Apr 23, 2022

See #24811 for the setup commits of this PR.

@Empact
Copy link
Contributor Author

Empact commented Apr 23, 2022

This PR impacting the need for util/system includes led me to audit those, and the necessity of them. I could perhaps reorder the commits or do a follow up to shrink it down further.

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@dongcarl
Copy link
Contributor

dongcarl commented May 9, 2022

@Empact I'm wondering if you'd be open to splitting off the last two commits off to their own PR (or just this PR) not based on #24811?

I think "removing references to gArgs and header tree cleanup" (which is what #24811 is doing) probably stands on its own merit and can be done either before or after the "split util/args and util/system" work here.


Selfishly, I also want to get the last 2 commits reviewed and merged ASAP since it'll soon become a blocker for libbitcoinkernel work.

@Empact
Copy link
Contributor Author

Empact commented May 9, 2022

@Empact I'm wondering if you'd be open to splitting off the last two commits off to their own PR (or just this PR) not based on #24811?

Sure, I'll be happy to try that, but I think some of the prior work is necessary to enable the separation. I'll let you know what I find.

@Empact
Copy link
Contributor Author

Empact commented May 17, 2022

Closing in favor of my next attempt: #25152

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: Done or Closed or Rethinking
Development

Successfully merging this pull request may close these issues.

6 participants