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

rpc, wallet: Scan mempool after import* - Second attempt #25351

Merged
merged 7 commits into from
Jul 18, 2022

Conversation

fjahr
Copy link
Contributor

@fjahr fjahr commented Jun 12, 2022

This PR picks up the work from #18964 and closes #18954.

It should incorporate all the unaddressed feedback from the PR:

  • Mempool rescan now expanded to all relevant import* RPCs
  • Added documentation in the help of each RPC
  • More tests

@fjahr fjahr force-pushed the 202204-import-scan branch 2 times, most recently from 5e4f269 to abdaa25 Compare June 12, 2022 18:41
@achow101
Copy link
Member

ACK abdaa25

src/wallet/rpc/backup.cpp Outdated Show resolved Hide resolved
@achow101 achow101 added this to the 24.0 milestone Jun 17, 2022
@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 21, 2022

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

Conflicts

No conflicts as of last run.

Copy link
Member

@Sjors Sjors left a comment

Choose a reason for hiding this comment

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

I'm unable to get this to work with descriptor wallets; still seeing the issue I reported in #25453.

Step 1: create a regular descriptor wallet, put some coins in it (I used a Taproot address for this)
Step 2: get one of its the matching receive descriptor s via listdescriptors
Step 3: create a watch-only wallet
Step 4: send coins to self, and before it confirms do:
Step 5: call importdescriptors on the watch-only wallet, using the above descriptor and some recent timestamp.

It will not add the mempool transaction until you either restart or it confirms.

rescanblockchain also doesn't add the transaction, but I suppose that's out of scope here.

Update: Note that you DO see the confirmed deposit transaction, but you don't see the outgoing mempool transaction.

@@ -765,7 +765,7 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
// being blocked
wallet = TestLoadWallet(context);
BOOST_CHECK(rescan_completed);
BOOST_CHECK_EQUAL(addtx_count, 2);
BOOST_CHECK_EQUAL(addtx_count, 3);
Copy link
Member

Choose a reason for hiding this comment

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

a43ee48: maybe add a comment to explain what those 3 transactions are: 2 m_coinbase_txns entries and mempool_tx?

I'm confused why it's 3 here and 5 below.

Copy link
Contributor

@w0xlt w0xlt Jun 23, 2022

Choose a reason for hiding this comment

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

a43ee48: maybe add a comment to explain what those 3 transactions are: 2 m_coinbase_txns entries and mempool_tx?
I'm confused why it's 3 here and 5 below.

Agreed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I see what you mean. The TestLoadWallet() helper function had a call to postInitProcess() which meant that the mempool was checked twice. Removing that led to the numbers in the CreateWallet test being much more sensible and there seem to be no other negative effects from that change. At least the test isn't failing and I also didn't see any other reason to keep it. I added some comments as well.

Copy link
Member

Choose a reason for hiding this comment

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

IMO bumping the numbers was better. :/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO bumping the numbers was better. :/

Could you say why you like it better? When the numbers are bumped I feel they don't match what the test is doing and I would need to add more comments to explain why this is the case. Hence it seemed like the better choice to me. Also curious to hear your feedback here @w0xlt and @Sjors :)

Copy link
Member

Choose a reason for hiding this comment

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

Seems like it would be undefined behaviour (between modules) to skip postInitProcess.

Counting AddToWallet calls might be too low-level to be a good test, but that seems out of scope here IMO.

Copy link
Member

Choose a reason for hiding this comment

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

I have no strong feelings about this, as long as it's clear from the code documentation where the transactions are coming from.

@w0xlt
Copy link
Contributor

w0xlt commented Jun 23, 2022

@Sjors I was able to retrieve the mempool transactions by following these steps on regtest and signet.

@Sjors
Copy link
Member

Sjors commented Jun 23, 2022

@Sjors I was able to retrieve the mempool transactions by following these steps on regtest and signet.

Mmm, and without this PR you're able to reproduce the original issue?

Copy link
Contributor

@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

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

Tested ACK abdaa25

Some nits:

test/functional/wallet_import_rescan.py Outdated Show resolved Hide resolved
test/functional/wallet_importdescriptors.py Show resolved Hide resolved
@@ -765,7 +765,7 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
// being blocked
wallet = TestLoadWallet(context);
BOOST_CHECK(rescan_completed);
BOOST_CHECK_EQUAL(addtx_count, 2);
BOOST_CHECK_EQUAL(addtx_count, 3);
Copy link
Contributor

@w0xlt w0xlt Jun 23, 2022

Choose a reason for hiding this comment

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

a43ee48: maybe add a comment to explain what those 3 transactions are: 2 m_coinbase_txns entries and mempool_tx?
I'm confused why it's 3 here and 5 below.

Agreed.

@w0xlt
Copy link
Contributor

w0xlt commented Jun 23, 2022

@Sjors Yes, without this PR (using the master branch), I am able to reproduce the issue.

@Sjors
Copy link
Member

Sjors commented Jun 24, 2022

@Sjors and your second wallet was a watch-only wallet? Guess I'll have to retry to check my own sanity :-)

@w0xlt
Copy link
Contributor

w0xlt commented Jun 24, 2022

@Sjors the watch-only was created with disable_private_keys=true blank=true and the tr(xpub...) descriptors (internal and external) were imported from the first wallet.

@fjahr
Copy link
Contributor Author

fjahr commented Jun 26, 2022

Addressed feedback but have yet to go through @Sjors steps to see if I can reproduce his issue.

@Sjors
Copy link
Member

Sjors commented Jun 28, 2022

I redid the experiment and clarified the procedure a bit. It might be taproot-specific.

Oops, I managed to run an earlier build of QT, because I reconfigred using --without-gui at some point. Will retry. Update: works!

Copy link
Member

@Sjors Sjors left a comment

Choose a reason for hiding this comment

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

tACK 8f59d58

(though I only manually tested with a taproot descriptor)

@fjahr
Copy link
Contributor Author

fjahr commented Jul 3, 2022

Addressed feedback from @luke-jr

Copy link
Contributor

@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

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

reACK 1be7964

@Sjors
Copy link
Member

Sjors commented Jul 7, 2022

re-utACK 1be7964 (only a test change)

@achow101
Copy link
Member

ACK 1be7964

@achow101 achow101 merged commit 4aaa3b5 into bitcoin:master Jul 18, 2022
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 18, 2022
… attempt

1be7964 test, wallet: Add mempool rescan test for import RPCs (Fabian Jahr)
833ce76 rpc, wallet: Document mempool rescan after importdescriptor, importwallet (Fabian Jahr)
0e396d1 rpc, wallet: Document mempool scan after importmulti (Fabian Jahr)
e6d3ef8 rpc, wallet: Document mempool scan after importpubkey (Fabian Jahr)
6d3db52 rpc, wallet: Document and test mempool scan after importprivkey (João Barbosa)
3abdbbb rpc, wallet: Document and test mempool scan after importaddress (João Barbosa)
236239b wallet: Rescan mempool for transactions as well (Fabian Jahr)

Pull request description:

  This PR picks up the work from bitcoin#18964 and closes bitcoin#18954.

  It should incorporate all the unaddressed feedback from the PR:
  - Mempool rescan now expanded to all relevant import* RPCs
  - Added documentation in the help of each RPC
  - More tests

ACKs for top commit:
  Sjors:
    re-utACK 1be7964 (only a test change)
  achow101:
    ACK 1be7964
  w0xlt:
    reACK bitcoin@1be7964

Tree-SHA512: b62fed5f97c6c242b2af417b41c9696a1f18878483d9e1c9429791f9c05257f57a00540a9a84df23c49faf6a61c3109c22972de81540083f38b506217804fcc5
@bitcoin bitcoin locked and limited conversation to collaborators Jul 26, 2023
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.

import* wallet RPCs don't "rescan" the mempool
8 participants