Skip to content

Conversation

@furszy
Copy link

@furszy furszy commented Nov 1, 2020

Up until now, one of the several capabilities that #1798 introduced was the wallet's shielded transactions balances calculation, a purely on-demand process (which is not so performant as txs balances are requested more than once during the entire software lifecycle).
This PR is going further, introducing a new wallet balance cache system for shielded transactions. Covered by a good amount of units tests that can be run pre and post the new cache system.

This PR is obviously built on top of 1798. Part of the shielded GUI work that will be coming soon.

@furszy furszy self-assigned this Nov 1, 2020
furszy added 14 commits November 4, 2020 20:35
… pointer. The block index is not needed and it will make unit tests simpler to code.
 * Validates:
 * 1) CWalletTx getCredit for shielded credit.
 * Incoming spendable shielded balance must be cached in the cacheableAmounts.
 *
 * 2) CWalletTx getDebit & getCredit for shielded debit to transparent address.
 * Same wallet as point (1), spending half of the credit received in (1) to a transparent remote address.
 * The other half of the balance - minus fee - must appear as credit (shielded change).
@furszy furszy force-pushed the 2020_v5_privacy_cached_tx_balances branch from 23bf366 to e14bbbf Compare November 5, 2020 00:42
@furszy
Copy link
Author

furszy commented Nov 5, 2020

rebased on master now that #1798 got merged.

@furszy furszy added this to the 5.0.0 milestone Nov 5, 2020
…ote every time that the wallet needs to know the note value.
Now GetCredit will not need to decrypt the note on every single call. Only will do it once if the note value is not cached and set it.
Plus, added a GetCredit method to retrieve the value of an specific shielded output.
@furszy furszy force-pushed the 2020_v5_privacy_cached_tx_balances branch from e14bbbf to 9047f74 Compare November 7, 2020 20:45
@furszy
Copy link
Author

furszy commented Nov 7, 2020

Pushed the fix for the lock held assertion issue on the new test cases. Travis happy now, ready for review.

Copy link

@random-zebra random-zebra left a comment

Choose a reason for hiding this comment

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

utACK 9047f74 (with few nits that can be ignored).

{
LOCK(cs_wallet);
if (!AddToWalletIfInvolvingMe(tx, pindex, posInBlock, true))
if (!AddToWalletIfInvolvingMe(tx, (pindex) ? pindex->GetBlockHash() : uint256(), posInBlock, true))

Choose a reason for hiding this comment

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

nit: UINT256_ZERO

ISMINE_SPENDABLE_SHIELDED = 1 << 5,
ISMINE_SPENDABLE_ALL = ISMINE_SPENDABLE_DELEGATED | ISMINE_SPENDABLE | ISMINE_SPENDABLE_SHIELDED,
ISMINE_WATCH_ONLY_ALL = ISMINE_WATCH_ONLY | ISMINE_WATCH_ONLY_SHIELDED,
ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE | ISMINE_COLD | ISMINE_SPENDABLE_DELEGATED | ISMINE_SPENDABLE_SHIELDED | ISMINE_WATCH_ONLY_SHIELDED,

Choose a reason for hiding this comment

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

nit:

Suggested change
ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE | ISMINE_COLD | ISMINE_SPENDABLE_DELEGATED | ISMINE_SPENDABLE_SHIELDED | ISMINE_WATCH_ONLY_SHIELDED,
ISMINE_ALL = ISMINE_SPENDABLE_ALL | ISMINE_WATCH_ONLY_ALL | ISMINE_COLD

Comment on lines +505 to +506
CAmount SaplingScriptPubKeyMan::GetCredit(const CWalletTx& tx, const isminefilter& filter, const bool fUnspent)
{

Choose a reason for hiding this comment

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

Might be good to assert(tx.SapData) at the beginning of this function.

@furszy furszy requested a review from Fuzzbawls November 8, 2020 23:41
Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

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

utACK 9047f74

Also agree that the remaining nits can be done in their own PR

random-zebra added a commit that referenced this pull request Nov 10, 2020
…isSaplingVersion

fc9ffe5 SSPKM: fix GetShieldedChange, tx.isSapling migrating to tx.isSaplingVersion (furszy)

Pull request description:

  Small and quick fix, master is currently not compiling due #1955 and #1952 getting merged without being based one on the other. the first PR renamed the tx `isSapling` method to `isSaplingVersion` and in the second PR, a new function was implemented `GetShieldedChange` that was using using `isSapling`.

ACKs for top commit:
  Fuzzbawls:
    ACK fc9ffe5
  random-zebra:
    utACK fc9ffe5 and merging...

Tree-SHA512: 463df6059b756bf1301faad5b3780b74720e5520232686b225bb3af02288e441af70a44a19803e530c5b922d92fd7feb949ecfc59685f797d7943471b6137bc3
@furszy furszy deleted the 2020_v5_privacy_cached_tx_balances branch November 29, 2022 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants