Skip to content

Conversation

kiminuo
Copy link
Contributor

@kiminuo kiminuo commented Sep 9, 2021

This is a follow-up PR to #22183 and is related to #21005 issue.

@fanquake fanquake added the Wallet label Sep 9, 2021
@kiminuo kiminuo changed the title Remove gArgs from wallet.h and wallet.cpp (2) refactor: Remove gArgs from wallet.h and wallet.cpp (2) Sep 9, 2021
@kiminuo kiminuo marked this pull request as ready for review September 9, 2021 10:52
@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 9, 2021

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #22372 (Support multiple -*notify commands by luke-jr)
  • #21206 (refactor: Make CWalletTx sync state type-safe by ryanofsky)
  • #19461 (multiprocess: Add bitcoin-gui -ipcconnect option by ryanofsky)
  • #19460 (multiprocess: Add bitcoin-wallet -ipcconnect option 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.

Copy link
Contributor

@ryanofsky ryanofsky 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 d7b9045, but I left two review comments below that would be good to address.

Also it would be good if PR description linked to issue #21005 as the true motivation for this PR, instead of saying that I suggested this. I think the current description which says the PR "follows the suggestion by ryanofsky" is a misleading, even though it is technically true, because I don't have any opinion on whether gArgs should be removed from wallet code, and I didn't suggest doing that. My suggestions have only been about how to pass ArgsManager references if you did decide it was important to get rid of gArgs.

@@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// P2PK compressed
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", gArgs, CreateDummyWalletDatabase());
Copy link
Contributor

Choose a reason for hiding this comment

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

In commit "Remove gArgs from wallet.h and wallet.cpp" (d7b9045)

I think it's mistake to be adding gArgs references so many places when the goal is to not use gArgs. Most of these uses can be replaced by m_args. Would suggest the following change:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the feedback! My approach overall is to progress from the bottom up. I find the way I did it here very conservative so that we are sure that nothing breaks. You are right that m_args can be used here, I wanted to do that later but if you find it better use m_args right away, then great.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! Normally I'd agree with being incremental and conservative, but if it is important to do this transition away from gArgs I think it is also important to try to make transition painless as possible to reviewers, and to other PR authors working on conflicting PRs by avoiding changing the same code multiple times in multiple PRs.

Maybe changing the same code in different PRs makes sense if one change is a bulk change and the second change is a manual change. But if two changes are both bulk changes, then splitting into conservative and non-conservative PRs just delays the inevitable non-conservative part of the change and prolongs the transition for no benefit. Also, these are changes to test code so there is basically no need to be conservative because it will be obvious if the tests are broken.

Copy link
Contributor

Choose a reason for hiding this comment

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

In general it would be great to be to see a consolidated final PR with all the future changes in one place. Or if that is too much work, it would be good to have a roadmap describing what the future changes will be. At very least if a PR has changes that are known to be temporary, it would be good to identify which parts of the PR are temporary, and which parts are permanent in the PR description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I'll see what I can do.

@kiminuo kiminuo force-pushed the feature/2021-09-wallet-gArgs branch from d7b9045 to 8762663 Compare September 15, 2021 18:33
@kiminuo
Copy link
Contributor Author

kiminuo commented Sep 15, 2021

Also it would be good if PR description linked to issue #21005 as the true motivation for this PR, instead of saying that I suggested this. I think the current description which says the PR "follows the suggestion by ryanofsky" is a misleading, even though it is technically true, because I don't have any opinion on whether gArgs should be removed from wallet code, and I didn't suggest doing that. My suggestions have only been about how to pass ArgsManager references if you did decide it was important to get rid of gArgs.

Sorry for putting words to your mouth 😐

Copy link
Contributor

@ryanofsky ryanofsky 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 8762663. Only changes since previous review were removing gArgs usages in tests and simplifying AttachChain arguments.

Sorry for putting words to your mouth

Sorry that was my fault. You referenced the post correctly. I just didn't make the context clear that it was an "if you need to do this" change suggestion, not a change request!

Copy link
Contributor

@ryanofsky ryanofsky 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 d815b50. No changes since last review other than rebase

@kiminuo kiminuo force-pushed the feature/2021-09-wallet-gArgs branch from d815b50 to 29554af Compare October 29, 2021 18:04
Copy link
Contributor

@ryanofsky ryanofsky 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 29554af. No changes since last review other than rebase

@kiminuo
Copy link
Contributor Author

kiminuo commented Nov 8, 2021

🙏

@@ -2732,11 +2732,11 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
walletInstance->m_default_max_tx_fee = max_fee.value();
}

if (gArgs.IsArgSet("-consolidatefeerate")) {
if (std::optional<CAmount> consolidate_feerate = ParseMoney(gArgs.GetArg("-consolidatefeerate", ""))) {
if (args.IsArgSet("-consolidatefeerate")) {
Copy link
Member

Choose a reason for hiding this comment

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

This hunk can be removed via a rebase

Copy link
Contributor Author

@kiminuo kiminuo Nov 9, 2021

Choose a reason for hiding this comment

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

You are right. I have rebased the PR. Thanks.

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
@kiminuo kiminuo force-pushed the feature/2021-09-wallet-gArgs branch from 29554af to 2ec38bd Compare November 9, 2021 10:38
Copy link
Contributor

@ryanofsky ryanofsky 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 2ec38bd. No changes since last review, just rebase

@maflcko maflcko merged commit f63bf05 into bitcoin:master Nov 10, 2021
@@ -32,7 +32,7 @@ static void CoinSelection(benchmark::Bench& bench)
{
NodeContext node;
auto chain = interfaces::MakeChain(node);
CWallet wallet(chain.get(), "", CreateDummyWalletDatabase());
CWallet wallet(chain.get(), "", gArgs, CreateDummyWalletDatabase());
Copy link
Member

Choose a reason for hiding this comment

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

Can't this use node.args directly? (Same for all instances below)

@kiminuo kiminuo deleted the feature/2021-09-wallet-gArgs branch November 10, 2021 18:50
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Nov 10, 2021
@bitcoin bitcoin locked and limited conversation to collaborators Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants