Skip to content

Conversation

xdustinface
Copy link

@xdustinface xdustinface commented Aug 30, 2020

This is mainly the backport of bitcoin#10244 (replaces #3638) which is actually more than enough for one PR but i added bitcoin#18123 because it fixes a bug introduced in bitcoin#10244 and its just a simple diff.

I added the dash related changes into the related commits of the original PR where it made sense.. if i would do this PR again i would separate them probably lol.. but well, its done like this now..hope its not too hard to review 🙈

352e7d3 unfortunately ended up being a bit too much imo.. besides removing the direct calls it also contains some refactoring.. should have done it in multiple steps but didn't expect it to become that big in the beginning.. i hope you can still get the reasonings for the changes.. if not, just ask :)

Based on #3680

@xdustinface xdustinface force-pushed the backport-10244-18123 branch 3 times, most recently from d875e09 to 564302c Compare August 31, 2020 08:45
@xdustinface xdustinface marked this pull request as draft September 1, 2020 17:34
@PastaPastaPasta
Copy link
Member

Can you rebase/provide guidance on if this is ready for review?

@xdustinface
Copy link
Author

Based on #3680

^^^ waiting for that to get your review before i rebase here.

@PastaPastaPasta PastaPastaPasta mentioned this pull request Sep 27, 2020
24 tasks
@xdustinface xdustinface force-pushed the backport-10244-18123 branch 2 times, most recently from 7143863 to 63840e1 Compare September 29, 2020 23:20
@xdustinface
Copy link
Author

Ok i guess this one is ready now! Happy reviewing 🙈

@xdustinface xdustinface marked this pull request as ready for review September 29, 2020 23:24
@UdjinM6
Copy link

UdjinM6 commented Oct 1, 2020

should revert/drop 9a07ca7 and backport bitcoin#12906 instead

@xdustinface xdustinface changed the title backport: bitcoin#10244 and bitcoin#18123 backport: bitcoin#10244, bitcoin#18123 and bitcoin#12906 Oct 1, 2020
@xdustinface xdustinface force-pushed the backport-10244-18123 branch from 63840e1 to 3a8a0e1 Compare October 1, 2020 13:34
@xdustinface
Copy link
Author

should revert/drop 9a07ca7 and backport bitcoin#12906 instead

Done 👍

@UdjinM6
Copy link

UdjinM6 commented Oct 1, 2020

hmm.. would prefer it backported as a scripted-diff commit tbh

@xdustinface xdustinface force-pushed the backport-10244-18123 branch from 3a8a0e1 to bf15977 Compare October 1, 2020 14:09
};

//! Interface for the src/masternode part of a dash node (dashd process).
class Masternode
Copy link

Choose a reason for hiding this comment

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

This is confusing imo. Would probably make sense to make Masternode a namespace and introduce Sync class inside of it or smth like that and then Masternode& masternode() -> Masternode::Sync& masternodeSync() etc. And tbh, the whole "masternode sync" name which comes from old non-DML times doesn't make sense anymore because we simply don't sync mn registrations/pings since ages 🙈 it's just governance and sporks now. We should probably refactor this in some future PR into smth like "extended sync" or whatever and move it out of masternode/.

Copy link
Author

Choose a reason for hiding this comment

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

I totally agree, this "masternode sync" related stuff needs to be refactored 😄 Thoughts about just moving

    virtual bool isBlockchainSynced() = 0;
    virtual bool isSynced() = 0;
    virtual std::string getSyncStatus() =  0;

into interfaces::Node ? Like having calls like node.isSynced()

Kind of breaks with my initial idea i.e. having an interface for each subdirectory stuff but it somehow sounds more reasonable to have those methods in the Node interface..

Copy link
Author

Choose a reason for hiding this comment

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

If there are any concerns about moving it into Node i would probably just do the Masternode::Sync thing for now and revisit this in a future PR.

Copy link
Author

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

I'd say Masternode::Sync is the way to go.

@xdustinface xdustinface force-pushed the backport-10244-18123 branch 2 times, most recently from ddc841a to 05720a6 Compare October 2, 2020 01:05
@@ -241,9 +241,7 @@ void AddressBookPage::on_showAddressQRCode_clicked()

Copy link
Member

Choose a reason for hiding this comment

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

changes in 4374d05 in this file aren't in the bitcoin commit. Stuff like this should be minimized (the changes in say optionsmodel.cpp are okay since they are all of the same kind as upstream commit as well as in the same file) and should instead imo be in a different commit to make review easier

Please explain these additional changes a bit

Copy link
Author

Choose a reason for hiding this comment

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

Hmm long time ago 🙈 but looks like its just because QDialog doesn't need it for anything, OptionsModel's constructor changed, so i just dropped the related stuff it seems. Also a7024cf now.

@@ -5120,12 +5118,23 @@ CWallet* CWallet::CreateWalletFromFile(const std::string& name, const fs::path&
// wallet creation fails.
auto temp_wallet = MakeUnique<CWallet>(name, WalletDatabase::Create(path));
CWallet *walletInstance = temp_wallet.get();
DBErrors nLoadWalletRet = walletInstance->LoadWallet(fFirstRun);
AddWallet(walletInstance);
Copy link
Member

Choose a reason for hiding this comment

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

and below

@@ -8,7 +8,7 @@
#include <qt/guiutil.h>
#include <qt/walletmodel.h>

#include <interfaces/node.h>
#include <interfaces/wallet.h>
Copy link
Member

Choose a reason for hiding this comment

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

why?

Copy link
Author

@xdustinface xdustinface Oct 2, 2020

Choose a reason for hiding this comment

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

Not sure where this came from but Seems like that was a suggestion but it does not longer exist this way

@xdustinface xdustinface force-pushed the backport-10244-18123 branch 3 times, most recently from 2399dc2 to e9d108b Compare October 2, 2020 14:32
@xdustinface xdustinface changed the title backport: bitcoin#10244, bitcoin#18123 and bitcoin#12906 backport: bitcoin#10244, bitcoin#18123, bitcoin#12906 + Parts of bitcoin#11403 Oct 2, 2020
const CAmount nMinAmount = CPrivateSend::GetSmallestDenomination() + CPrivateSend::GetMaxCollateralAmount();
if (!walletModel->privateSend().isMixing()) {
auto& options = walletModel->node().privateSendOptions();
const CAmount nMinAmount = options.getSmallestDenomination() + options.getMaxCollateralAmount();
Copy link

Choose a reason for hiding this comment

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

Good question 👍 should probably be fixed by using tx builder instead (in a separate PR).

@xdustinface xdustinface force-pushed the backport-10244-18123 branch from ac3a8a0 to 0fb1a05 Compare October 3, 2020 17:19
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.

0fb1a05 works for me :) Maybe add a comment that we only do some simple checks here which should be enough to reliably detect mixing txes for this specific wallet and that this relies on PS subsystem verifying the tx earlier (during mixing) and wallet not participating in txes that won't fit more strict rules or smth like that.

  • see one tiny nit below

@xdustinface
Copy link
Author

I think 3433ec6 should fix it.

That looks better to me jup :)

UdjinM6
UdjinM6 previously approved these changes Oct 9, 2020
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.

Everything seems to be working as expected now.

ACK

@PastaPastaPasta
Copy link
Member

overall ACK, however I would like to see some commits merged. IMO all commits directly from 10244 should be one commit, then dash specific 10244 as one commit, then 18123 (then any associated review commits), then 12906 (then any associated review commits), then 11403 (then any associated review commits). It's difficult for me to tell at this point which review commits correspond to which actual backports

@UdjinM6
Copy link

UdjinM6 commented Oct 14, 2020

I don't think squashing multiple focused 10244 commits into one huge commit is a good idea, would rather prefer them as is. Squashing performance fixes after 18123 (b1bc1f1 + b46e65b + 34a146c) makes sense though. Squashing aa2ebe1 + 60a8584 might also be a good idea. 11403 and 12906 need no additional work imo.

xdustinface and others added 10 commits October 14, 2020 12:09
Refactored into interface::PrivateSend::Options and
interface::PrivateSend::Client
bf36a3c gui: Fix race in WalletModel::pollBalanceChanged (Russell Yanofsky)

Pull request description:

  Poll function was wrongly setting cached height to the current chain height instead of the chain height at the time of polling.

  This bug could cause balances to appear out of date, and was first introduced bitcoin@a0704a8#diff-2e3836af182cfb375329c3463ffd91f8L117. Before that commit, there wasn't a problem because cs_main was held during the poll update.

  Currently, the problem should be rare. But if 8937d99 from bitcoin#17954 were merged, the problem would get worse, because the wrong cachedNumBlocks value would be set if the wallet was polled in the interval between a block being connected and it processing the BlockConnected notification.

  MarcoFalke also points out that a0704a8 could lead to GUI hangs as well, because previously the pollBalanceChanged method, which runs on the GUI thread, would only make a nonblocking TRY_LOCK(cs_main) call, but after could make blocking LOCK(cs_main) calls, potentially locking up the GUI.

  Thanks to John Newbery for finding this bug this while reviewing bitcoin#17954.

ACKs for top commit:
  Empact:
    utACK bitcoin@bf36a3c
  jonasschnelli:
    utACK bf36a3c

Tree-SHA512: 1f4f229fa70a6d1fcf7be3806dca3252e86bc1755168fb421258389eb95aae67f863cb1216e6dc086b596c33560d1136215a4c87b5ff890abc8baaa3333b47f4
…windows gitian build

17780d6 scripted-diff: Avoid `interface` keyword to fix windows gitian build (Russell Yanofsky)

Pull request description:

  Rename `interface` to `interfaces`

  Build failure reported by ken2812221 in bitcoin#10244 (comment)

Tree-SHA512: e02c97c728540f344202c13b036f9f63af23bd25e25ed7a5cfe9e2c2f201a12ff232cc94a93fbe37ef6fb6bf9e036fe62210ba798ecd30de191d09338754a8d0

-BEGIN VERIFY SCRIPT-
git mv src/interface src/interfaces
ren() { git grep -l "$1" | xargs sed -i "s,$1,$2,g"; }
ren interface/            interfaces/
ren interface::           interfaces::
ren BITCOIN_INTERFACE_    BITCOIN_INTERFACES_
ren "namespace interface" "namespace interfaces"
-END VERIFY SCRIPT-
- Call `statusUpdateNeeded` before `tryGetTxStatus`. This allows to run
the latter only if really required i.e. if `statusUpdateNeeded` returns true.
- Reuse `cachedNumBlocks` from `WalletModel` in `TransactionTablePriv::index()` to _actually_ avoid redundant tx status updates
- Initialize `cachedNumBlocks` and `cachedChainLockHeight` with `-1` to avoid extra `pollBalanceChanged` call
This is required to fix a (potential) deadlock
@xdustinface
Copy link
Author

I don't think squashing multiple focused 10244 commits into one huge commit is a good idea would rather prefer them as is.

Agreed, right now i honestly don't see any benefit by doing this @PastaPastaPasta

Squashing performance fixes after 18123 (b1bc1f1 + b46e65b + 34a146c) makes sense though.

Done in 5020a68

Squashing aa2ebe1 + 60a8584 might also be a good idea.

Done

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.

utACK

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.

ACK

@UdjinM6 UdjinM6 merged commit 74f4d2a into dashpay:develop Oct 14, 2020
UdjinM6 added a commit to UdjinM6/dash that referenced this pull request Feb 7, 2021
PastaPastaPasta pushed a commit that referenced this pull request Feb 11, 2021
* qt: Fix labels in transaction list

The issue was introduced in #3682

* qt: Always use labels from TransactionStatus for transaction list

Missed this in #3155

* Update src/qt/transactiontablemodel.cpp

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Mar 12, 2022
* qt: Fix labels in transaction list

The issue was introduced in dashpay#3682

* qt: Always use labels from TransactionStatus for transaction list

Missed this in dashpay#3155

* Update src/qt/transactiontablemodel.cpp

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
PastaPastaPasta added a commit that referenced this pull request May 1, 2025
, bitcoin#20591, bitcoin#23596, bitcoin#22868, bitcoin#24225 (wallet backports: part 3)

6958a5b merge bitcoin#24225: Add sanity checks to DiscourageFeeSniping (Kittywhiskers Van Gogh)
63dc779 merge bitcoin#22868: Call load handlers without cs_wallet locked (Kittywhiskers Van Gogh)
698e01e merge bitcoin#23596: fix `wallet_transactiontime_rescan.py --descriptors` and add to test runner (Kittywhiskers Van Gogh)
72322ce merge bitcoin#20591: fix ComputeTimeSmart function during rescanning process (Kittywhiskers Van Gogh)
99c9880 merge bitcoin#22941: inline functions `{Read,Write}OrderPos` (Kittywhiskers Van Gogh)
e2ae504 merge bitcoin#25148: Remove `NO_THREAD_SAFETY_ANALYSIS` from non-test/benchmarking code (Kittywhiskers Van Gogh)
f637516 merge bitcoin#22100: Clean up new wallet spend, receive files added bitcoin#21207 (Kittywhiskers Van Gogh)
9a5dc62 partial bitcoin#22100: Clean up new wallet spend, receive files added bitcoin#21207 (Kittywhiskers Van Gogh)
258cdc2 refactor: move and rename `GetBudgetSystemCollateralTX()` to `spend.cpp` (Kittywhiskers Van Gogh)
e03fdff refactor: move ISLock and ChainLock wtx check to CWallet (Kittywhiskers Van Gogh)
460c187 refactor: move some CoinJoin-specific logic out of CWalletTx and CWallet (Kittywhiskers Van Gogh)
ed12dab move-only: section CoinJoin-specific code to separate source file (Kittywhiskers Van Gogh)
bc0a1b7 refactor: remove unused `CWalletTx::GetWallet()` (Kittywhiskers Van Gogh)

Pull request description:

  ## Additional Information

  * `CWalletTx::GetWallet()` was introduced in [dash#3155](#3155) ([commit](3b44576)) and its use was curtailed in [dash#3682](#3682) ([commit](155324e)) but it has lingered around. As [bitcoin#22100](bitcoin#22100) will get rid of `CWalletTx::pwallet` and it is unused, it is removed.

  * As [bitcoin#22100](bitcoin#22100) has a substantial diff, it has been split into two commits for ease of review, the former centers around `wallet/receive.cpp` and the latter around `wallet/spend.cpp`. The former has additional changes that are supplanted/removed in the latter to ensure they can be independently validated.

    To compare the diff against upstream, squashing the two halves may be desirable.
    * As the goal of the backport to remove the circular dependencies between `wallet.cpp` and both `spend.cpp` and `receive.cpp`, Dash-specific code that contributes to this dependency had to be moved.

      To this effect, CoinJoin-specific code has been moved to its own source file as it relies on code in both `spend.cpp` and `receive.cpp`. `GetBudgetSystemCollateralTX()` was moved to `spend.cpp` as it used `CreateTransaction()` and given a better representative name.

    * ~~`CWalletTx::Is{ChainLocked, LockedByInstantSend}()` was moved to `CWallet` and renamed to match the convention of `CWallet::GetTxDepthInMainChain()` in preparation for [bitcoin#22100](bitcoin#22100). A drawback of the new implementation is that both calls (but especially `IsTxLockedByInstantSend()`) is more expensive as per-transaction result caching is no longer available.~~ Resolved by d29b5ee, thanks Udjin!

  * Portions of [bitcoin#25148](bitcoin#25148) were included in previous commits to ensure that `-Wthread-safety` is satisfied (e.g. annotations for `MakeWalletTxStatus()` and `WalletTxToJSON()` were needed when `IsTxLockedByInstantSend()` and `IsTxChainLocked()` were introduced)

  ## Breaking Changes

  None expected.

  ## Checklist

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

ACKs for top commit:
  UdjinM6:
    utACK 6958a5b

Tree-SHA512: 4b9702c5976643d63874f245b4543c068523c0c87cc8298f8fbf0826426088397167dc775fd34aa27ce7d8decc8bb592e3ae11c6342193d757d285fad1f8d010
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.

5 participants