Skip to content

Conversation

Empact
Copy link
Contributor

@Empact Empact commented Aug 24, 2018

By making BaseParams() responsible for holding the current chain name, and layering
ArgsManager atop it.

Without this both m_network of ArgsManager and globalChainBaseParams track the current chain, leading to circular dependencies between them.

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 24, 2018

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #16508 (Disallow double negation syntax (-nofoo=0) for options by hebasto)
  • #16411 (Signet support by kallewoof)
  • #16097 (Refactor: Add Flags enum to ArgsManager class by hebasto)
  • #16060 (Bury bip9 deployments by jnewbery)
  • #15934 (Separate settings merging from parsing by ryanofsky)
  • #8994 (Testchains: Introduce custom chain whose constructor... by jtimon)

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 Empact force-pushed the chain-params-base-circ branch from b77e9ba to d1e653c Compare August 24, 2018 08:59
@Empact Empact changed the title Break the chainparamsbase -> util circular dependency refactor: Fix the chainparamsbase -> util circular dependency Aug 24, 2018
@practicalswift
Copy link
Contributor

Concept ACK

Let’s get rid of all circular dependencies! :-)

Copy link
Contributor

@domob1812 domob1812 left a comment

Choose a reason for hiding this comment

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

utACK d1e653c2e028c3342cdae4be81e423f96db89214 with a few style nits.

@Empact Empact force-pushed the chain-params-base-circ branch 4 times, most recently from d5c2ab0 to 10652ff Compare August 24, 2018 23:54
@Empact
Copy link
Contributor Author

Empact commented Aug 24, 2018

Fixed tests. Note I had to guard ArgsManagerHelper::NetworkArg calls with a test for a
leading - as NetworkArg asserts against the absence, while values without
- are tested for in util_tests. Could drop those tests instead, but this seems coherent.

@Empact Empact force-pushed the chain-params-base-circ branch 2 times, most recently from 27f8ab9 to eca5a9f Compare August 25, 2018 00:57
@Empact
Copy link
Contributor Author

Empact commented Aug 25, 2018

On second thought, removed the --less test and asserted against --less options in the relevant calls. Note that --less options are skipped over in ParseParameters.

@Empact Empact changed the title refactor: Fix the chainparamsbase -> util circular dependency WIP: refactor: Fix the chainparamsbase -> util circular dependency Nov 12, 2018
@Empact Empact force-pushed the chain-params-base-circ branch from 55c3b8c to 8f3b025 Compare December 13, 2018 02:03
@Empact Empact force-pushed the chain-params-base-circ branch from 8f3b025 to 60ee8a4 Compare December 14, 2018 09:08
@Empact Empact changed the title WIP: refactor: Fix the chainparamsbase -> util circular dependency refactor: Fix the chainparamsbase -> util circular dependency Dec 14, 2018
@Empact Empact force-pushed the chain-params-base-circ branch 3 times, most recently from 91f62a7 to fa190c6 Compare December 18, 2018 03:38
@Empact Empact force-pushed the chain-params-base-circ branch from fa190c6 to 0c0f506 Compare January 7, 2019 19:39
@Empact Empact force-pushed the chain-params-base-circ branch from 0c0f506 to 7588c1b Compare March 4, 2019 09:37
@Empact Empact force-pushed the chain-params-base-circ branch 2 times, most recently from 96b2d9b to ab5b67e Compare March 9, 2019 16:23
Empact added 2 commits June 5, 2019 12:55
These options are intimately tied to ArgsManager, so their
presence here makes sense, and moving them removes a final cause for a
circular dependency between util and chainparamsbase.
And call into BaseParams from ArgsManager. Introduce BaseParamsSelected
as it's necessary to prevent access to BaseParams prior to selection.

This eliminates the chainparamsbase -> util -> chainparamsbase
circular dependency.

Note I had to guard ArgsManagerHelper::NetworkArg calls with a test for a
leading '-' as NetworkArg asserts against the alternative, while values without
- are tested for in the util_tests.
@Empact Empact force-pushed the chain-params-base-circ branch from ab5b67e to 764106e Compare June 5, 2019 11:57
@Empact
Copy link
Contributor Author

Empact commented Jun 5, 2019

Rebased

@@ -774,7 +780,7 @@ BOOST_FIXTURE_TEST_CASE(util_ArgsMerge, ArgsMergeTestingSetup)
// Results file is formatted like:
//
// <input> || <IsArgSet/IsArgNegated/GetArg output> | <GetArgs output> | <GetUnsuitable output>
BOOST_CHECK_EQUAL(out_sha_hex, "b835eef5977d69114eb039a976201f8c7121f34fe2b7ea2b73cafb516e5c9dc8");
BOOST_CHECK_EQUAL(out_sha_hex, "6e84c6b6a1702f5c2247d175e7e1ad76c342be58b95bf2b7ed7e271d38197a14");
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the changes here expected? I don't think they look right. It looks like wallet settings in the top-level of the config file (not in the test section) are now no longer ignored when testnet is enabled.

DIfferences in results.txt before and after this change look like:

-net=test wallet=c1 wallet=c2 || unset | ignored -wallet
+net=test wallet=c1 wallet=c2 || c1 | c1 c2
...
-net=test wallet=c1 wallet=c2 || unset | ignored -wallet
+net=test wallet=c1 wallet=c2 || c1 | c1 c2
...

If this is not intended, it might just be a bug in the test setup, like the parser.m_network = network; line above no longer having an effect, instead of a real bug.

@maflcko
Copy link
Member

maflcko commented Jun 6, 2019

I wrote a feedback a few months ago, not sure if it still applies:

Base params are always selected when the program is running. Only very early in the init sequence (when the chain was not selected) we'd have to (and should) skip the steps that involve the chain name. Imo this is better solved by passing a bool into IsArg*(..., bool net_specific=true), that is set to true by default but only in the few calls during init set to false. E.g. would have to pass it down in HelpRequested...

No strong opinion, though

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 2, 2019

Needs rebase

@DrahtBot
Copy link
Contributor

There hasn't been much activity lately and the patch still needs rebase, so I am closing this for now. Please let me know when you want to continue working on this, so the pull request can be re-opened.

@DrahtBot DrahtBot closed this Jul 14, 2020
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants