Skip to content

Conversation

@reemuru
Copy link

@reemuru reemuru commented May 19, 2021

This is a PR proposed in #20078

This PR enables one more of the non-wallet functional tests (mempool_updatefromblock.py) to be run even with the Bitcoin Core wallet disabled by using the new MiniWallet instead.

Overview:

  • Refactoring and removal of unnecessary imports and arguments to transaction_graph_test()
  • Improve logging
  • Decrease test execution time by ~70% (39s => 12s)

Before:

[USER@SERVER functional]$ time ./mempool_updatefromblock.py 
2021-05-19T21:02:10.809000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_42xs1s0g
2021-05-19T21:02:11.154000Z TestFramework (INFO): Creating 100 transactions...
2021-05-19T21:02:15.741000Z TestFramework (INFO): The batch of 25 transactions has been accepted into the mempool.
2021-05-19T21:02:15.756000Z TestFramework (INFO): All of the transactions from the current batch have been mined into a block.
2021-05-19T21:02:20.097000Z TestFramework (INFO): The batch of 25 transactions has been accepted into the mempool.
2021-05-19T21:02:20.115000Z TestFramework (INFO): All of the transactions from the current batch have been mined into a block.
2021-05-19T21:02:24.687000Z TestFramework (INFO): The batch of 25 transactions has been accepted into the mempool.
2021-05-19T21:02:24.705000Z TestFramework (INFO): All of the transactions from the current batch have been mined into a block.
2021-05-19T21:02:28.774000Z TestFramework (INFO): The last batch of 25 transactions has been accepted into the mempool.
2021-05-19T21:02:29.160000Z TestFramework (INFO): All of the recently mined transactions have been re-added into the mempool in 0.3855452537536621 seconds.
2021-05-19T21:02:29.161000Z TestFramework (INFO): Checking descendants/ancestors properties of all of the in-mempool transactions...
2021-05-19T21:02:50.455000Z TestFramework (INFO): Stopping nodes
2021-05-19T21:02:50.508000Z TestFramework (INFO): Cleaning up /tmp/bitcoin_func_test_42xs1s0g on exit
2021-05-19T21:02:50.508000Z TestFramework (INFO): Tests successful

real    0m39.895s
user    0m34.627s
sys     0m2.474s

After:

[USER@SERVER functional]$ time ./mempool_updatefromblock.py 
2021-05-19T21:08:17.190000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test__3fuskkh
2021-05-19T21:08:17.493000Z TestFramework (INFO): Creating 100 transactions...
2021-05-19T21:08:17.634000Z TestFramework (INFO): The batch of 25 transactions has been accepted into the mempool.
2021-05-19T21:08:17.686000Z TestFramework (INFO): All of the transactions from the current batch have been mined into a block.
2021-05-19T21:08:17.771000Z TestFramework (INFO): The batch of 25 transactions has been accepted into the mempool.
2021-05-19T21:08:17.820000Z TestFramework (INFO): All of the transactions from the current batch have been mined into a block.
2021-05-19T21:08:17.896000Z TestFramework (INFO): The batch of 25 transactions has been accepted into the mempool.
2021-05-19T21:08:17.943000Z TestFramework (INFO): All of the transactions from the current batch have been mined into a block.
2021-05-19T21:08:18.009000Z TestFramework (INFO): The batch of 25 transactions has been accepted into the mempool.
2021-05-19T21:08:18.058000Z TestFramework (INFO): All of the transactions from the current batch have been mined into a block.
2021-05-19T21:08:18.060000Z TestFramework (INFO): Mempool size pre-invalidation: 0
2021-05-19T21:08:18.080000Z TestFramework (INFO): Mempool size post-invalidation: 100
2021-05-19T21:08:18.082000Z TestFramework (INFO): All of the recently mined transactions have been re-added into the mempool in 0.0179746150970459 seconds.
2021-05-19T21:08:18.082000Z TestFramework (INFO): Checking descendants/ancestors properties of all of the in-mempool transactions...
2021-05-19T21:08:29.441000Z TestFramework (INFO): Stopping nodes
2021-05-19T21:08:29.496000Z TestFramework (INFO): Cleaning up /tmp/bitcoin_func_test__3fuskkh on exit
2021-05-19T21:08:29.496000Z TestFramework (INFO): Tests successful

real    0m12.465s
user    0m5.843s
sys     0m0.800s

@fanquake fanquake added the Tests label May 19, 2021
Copy link
Contributor

@DariusParvin DariusParvin left a comment

Choose a reason for hiding this comment

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

obvious concept ACK.
Great work! I left some suggestions/questions

@reemuru
Copy link
Author

reemuru commented May 20, 2021

Updated with ac8b08b. Let me know if I missed anything! Also, should I roll theses commits up into one, or will they get squashed at merge time? Forgot to sign the first few.
Recent changes:

  • self.wallet.generate(1) to self.wallet.scan_blocks(start=76, num=1)
  • remove blocks mined block_ids from cluttering logs along with unnecessary math import
  • put back enumerate for mempool properties checks
  • added assert before mining block

@DariusParvin
Copy link
Contributor

The changes look good to me! I'm relatively new myself but I think at this stage it would make sense to squash everything into one commit.

@reemuru
Copy link
Author

reemuru commented May 21, 2021

The changes look good to me! I'm relatively new myself but I think at this stage it would make sense to squash everything into one commit.

Got it, thank you for your assistance!

Copy link
Contributor

@sriramdvt sriramdvt left a comment

Choose a reason for hiding this comment

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

tACK df07919caa36d1345590010f5552d9e24db2bbde. The test works properly and checks what it is supposed to check. I strongly recommend making these changes for clarity and to maintain forward compatibility with MiniWallet.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Replace self.nodes[0] with node

Copy link
Author

@reemuru reemuru left a comment

Choose a reason for hiding this comment

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

tACK df07919. The test works properly and checks what it is supposed to check. I strongly recommend making these changes for clarity and to maintain forward compatibility with MiniWallet.

Thanks for reviewing! Made some changes based on your suggestions.

@josibake
Copy link
Member

Concept ACK

Thanks for posting the profiling data! Definitely agree with more miniwallet usage, especially if it increases test execution speed. I compiled and ran the tests and everything passed, but I would definitely recommend running flake8 and making the suggested style changes. you can do this automatically with autopep8 (I did it by with the following steps):

pip install autopep8
autopep8 --in-place mempool_updatefromblock.py

you can double check the changes by running flake8 mempool_updatefromblock.py. you should only see line length warnings, which are fine to ignore

@practicalswift
Copy link
Contributor

Concept ACK

@reemuru
Copy link
Author

reemuru commented Jul 26, 2021

pip install autopep8

oh shoots! never used autopep8 before. will use from now on. Thanks for the tip! (^_^) => 0b7dbeb

@josibake
Copy link
Member

pip install autopep8

oh shoots! never used autopep8 before. will use from now on. Thanks for the tip! (^_^) => 0b7dbeb

looks great! id suggest squashing into one atomic commit per the contributing guide

@reemuru
Copy link
Author

reemuru commented Jul 27, 2021

pip install autopep8

oh shoots! never used autopep8 before. will use from now on. Thanks for the tip! (^_^) => 0b7dbeb

looks great! id suggest squashing into one atomic commit per the contributing guide

Got it, thanks much!

@josibake
Copy link
Member

ACK 446c06a

built without wallet, ran the test to verify everything is behaving as expected. also code reviewed to verify the logic of the test is unchanged (strictly a refactor)

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 27, 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:

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
Member

@maflcko maflcko Jul 28, 2021

Choose a reason for hiding this comment

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

please don't commit large style changes in the same commit as refactors/features. This makes review harder because it is not clear what is a refactor/style-change/feature

https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#committing-patches

Copy link
Member

Choose a reason for hiding this comment

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

Also I don't think the change here makes the code easier to read (neither for devs nor for scripts and parsers)

Copy link
Author

Choose a reason for hiding this comment

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

Oh shoot, my bad. 😭 Was using some auto-styling tool and must've finger fudged it. Fixed and squashed into 33865a5

Copy link
Member

Choose a reason for hiding this comment

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

Oh shoot, my bad. sob Was using some auto-styling tool and must've finger fudged it. Fixed and squashed into 33865a5

my fault, @reemuru , i gave bad advice. @MarcoFalke is correct: linting (style changes) should be in separate PR's from refactors/features

@josibake
Copy link
Member

ACK c1c0768

built without wallet and ran test

Copy link
Member

Choose a reason for hiding this comment

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

here are still style changes mixed in

Copy link
Member

Choose a reason for hiding this comment

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

why is this changed?

Copy link
Author

Choose a reason for hiding this comment

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

Ah ok, apologies for the noise. Will put this into draft mode since some work is still needed. Thanks for review!

Enables the mempool_updatefromblock non-wallet functional test
to be run even with the Bitcoin Core wallet disabled by using
the new MiniWallet instead.

- Refactoring and removal of unnecessary imports and arguments to
  transaction_graph_test()
- Improve logging
- Decrease test execution time by ~70% (39s => 12s)
@reemuru reemuru marked this pull request as draft July 30, 2021 13:59
@reemuru reemuru closed this Aug 1, 2021
@reemuru reemuru deleted the test branch August 1, 2021 02:46
@adamjonas
Copy link
Member

@reemuru was there a reason this closed? Would you like to mark it up for grabs?

@pg156
Copy link

pg156 commented Jan 12, 2022

I will start working on this as it is up for grabs. Please let me know if this is done elsewhere or no longer necessary?

@maflcko
Copy link
Member

maflcko commented Jan 12, 2022

You can open the file on the master branch and check if skip_if_no_wallet is still in the file to see if this is still relevant.

@pg156
Copy link

pg156 commented Jan 13, 2022

Thanks @MarcoFalke. I see skip_if_no_wallet is still in https://github.com/bitcoin/bitcoin/blob/master/test/functional/mempool_updatefromblock.py. I also checked each revision to the file since this PR was created, and don't see any change making this PR irrelevant. Did I miss anything before determining it is useful to work on this?

@bitcoin bitcoin locked and limited conversation to collaborators Mar 22, 2023
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.

10 participants