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

refactor: pull libbitcoin_server code out of wallet code 3/N #5743

Merged
merged 9 commits into from
Dec 17, 2023

Conversation

knst
Copy link
Collaborator

@knst knst commented Nov 29, 2023

Issue being fixed or feature implemented

Wallet library should not depends on server code (libbitcoin_server).

Untie this library will help to finish backport bitcoin#15639 and will unblock multiprocess: bitcoin#18677

Prior work:

What was done?

  • using havePruned from interface instead direct fPrune
  • removed dependency scriptpubkeyman on uiInterface
  • removed usage fShutdown from scriptpubkeyman
  • usages llmq::quorumInstantSendManager/llmq::chainLocksHandler are wrapper in interface
  • dropped direct usages of deterministicMNManager from wallet code

How Has This Been Tested?

Amount of linkage errors is decreased from 196 to 141 if libbitcoin_server is excluded during linkage:

diff --git a/src/Makefile.am b/src/Makefile.am
index fb4850429f..c9c9c331a7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -865,9 +865,7 @@ endif
 # https://eli.thegreenplace.net/2013/07/09/library-order-in-static-linking#circular-dependency)
 dash_wallet_LDADD = \
   $(LIBBITCOIN_WALLET_TOOL) \
-  $(LIBBITCOIN_SERVER) \
   $(LIBBITCOIN_WALLET) \
-  $(LIBBITCOIN_SERVER) \
   $(LIBBITCOIN_COMMON) \
   $(LIBBITCOIN_CONSENSUS) \
   $(LIBBITCOIN_UTIL) \

Breaking Changes

N/A

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@knst knst added this to the 20.1 milestone Nov 29, 2023
@UdjinM6
Copy link

UdjinM6 commented Nov 30, 2023

tool_wallet.py is crashing... 🙈 this should help

diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 206ff59f54..81ac0b7edb 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -5517,7 +5517,7 @@ bool CWallet::GenerateNewHDChainEncrypted(const SecureString& secureMnemonic, co
 
 bool CWallet::ShutdownRequested()
 {
-    return chain().shutdownRequested();
+    return HaveChain() && chain().shutdownRequested();
 }
 
 void CWallet::UpdateProgress(const std::string& title, int nProgress)

UdjinM6
UdjinM6 previously approved these changes Nov 30, 2023
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

LGTM, light ACK 👍

Copy link

github-actions bot commented Dec 4, 2023

This pull request has conflicts, please rebase.

UdjinM6
UdjinM6 previously approved these changes Dec 5, 2023
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

re-utACK

knst added a commit to knst/dash that referenced this pull request Dec 11, 2023
@UdjinM6
Copy link

UdjinM6 commented Dec 11, 2023

ping @PastaPastaPasta

@@ -855,6 +855,8 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
bool IsLocked(bool fForMixing = false) const override;
bool Lock(bool fForMixing = false);

void UpdateProgress(const std::string& title, int nProgress) override;
Copy link
Member

Choose a reason for hiding this comment

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

it'd be nice to use string_view here but I think ShowProgress probably wants a std::string

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, ShowProgress indeed uses std::string even in the latest version of bitcoin core:

    boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress;

The strMsg that is used in scriptpubkeyman.cpp is also std::string, so, using string_view will add a new allocation here, I will keep it as it is.

@@ -135,6 +135,9 @@ class Chain
//! Check if transaction will be final given chain height current time.
virtual bool checkFinalTx(const CTransaction& tx) = 0;

//! Check if transaction is locked as the instant tx.
Copy link
Member

Choose a reason for hiding this comment

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

please rework this comment; doesn't make sense

for (const auto& output : group.m_outputs) {
if (!chain.isInstantSendLockedTx(output.outpoint.hash)) return false;
}
return true;
}
Copy link
Member

Choose a reason for hiding this comment

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

refactor to use std::all_of, std::any_of or std::none_of ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that's not new code, I just moved a function to a new place. Anyway, I provided a refactoring in an extra commit

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

re-utACK

knst added a commit to knst/dash that referenced this pull request Dec 15, 2023
knst added a commit to knst/dash that referenced this pull request Dec 15, 2023
@knst knst changed the title refactor: Pull wallet code out of libbitcoin_server 3/N refactor: pull libbitcoin_server code out of wallet code 3/N Dec 15, 2023
knst added a commit to knst/dash that referenced this pull request Dec 16, 2023
Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

utACK for merging via merge commit

@PastaPastaPasta PastaPastaPasta merged commit 714be63 into dashpay:develop Dec 17, 2023
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants