Skip to content

Conversation

@ycshao
Copy link
Contributor

@ycshao ycshao commented Jun 8, 2020

This PR moves sync_blocks and sync_mempool out from test_framework/util.py to test_framework/test_framework.py so they can take contextual information of test framework into account.

  • Change all reference callers to call functions from test_framework.py
  • Remove **kwargs which is not used
  • Take into account of timeout_factor when respecting timeout in function implementations.
  • Pass all tests by running ./test/functional/test_runner.py

fixes #18930

@maflcko
Copy link
Member

maflcko commented Jun 8, 2020

Nice! Concept ACK

@ycshao
Copy link
Contributor Author

ycshao commented Jun 8, 2020

Seems like the style of those files are auto-formatted by autopep8. I'll leave the reviewers to comment about the format.

One question about the implementation. Does it make sense to move assert (all([len(x.getpeerinfo()) for x in rpc_connections])) up to immediately after the while loop starts? It will assert sooner and save some time and operations.

@ycshao ycshao marked this pull request as ready for review June 8, 2020 13:12
@ycshao
Copy link
Contributor Author

ycshao commented Jun 8, 2020

Looks like wallet_avoidreuse.py failed in travis but it works fine on my machine. Is there a way to replay the travis failed tests?

@ycshao ycshao changed the title test: move sync_blocks and sync_mempool functions to test_framework.py test: move sync_blocks and sync_mempool functions to test_framework.py Jun 8, 2020
@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 9, 2020

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.

@ycshao
Copy link
Contributor Author

ycshao commented Jun 9, 2020

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.

Could someone explain what does conflicts mean here? Is there a logical order of PRs mentioned + mine to review and merge?

@adamjonas
Copy link
Member

@ycshao DrahtBot crawls over open PRs and alerts you when there is a conflict with the main branch that requires a rebase or, in this case, other PRs that may lead to future conflicts indicating that you are working on similar code. DrahtBot is not sentient enough to decide the merge order. It's just raising it to your attention.

@adamjonas
Copy link
Member

adamjonas commented Jun 9, 2020

Re the format - autopep8 is making the diff much larger. I think it's easier, for now, to keep the diff as minimal as possible so reviewers can focus on the changes relevant to your patch. At the very least, you can break the formatting changes into their own commit and follow the lead of this reformat.

I'd also suggest squashing your second commit since the first commit doesn't pass the linter without it.

@ycshao
Copy link
Contributor Author

ycshao commented Jun 9, 2020

@adamjonas thanks for the answer and suggestion. I'll squash and break formatting into it's own commit.

Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

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

Oo first PR? Concept ACK :) I'm guessing "contextual information of test framework" is the timeout_factor?
+1 to Jonas, just appeasing test/lint/lint-python.sh for now would be better.

Does it make sense to move assert (all([len(x.getpeerinfo()) for x in rpc_connections])) up to immediately after the while loop starts? It will assert sooner and save some time and operations.

I had this thought too. But I think it would fail if the nodes happened to all be synced up (despite not being connected right now) before the first iteration of the while loop. I think it's possible...?

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 a question - it's probably not a big deal to require at least one node to be updated, but would it be appropriate to have an optional blockhash parameter and enforce that hash instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see a use case like that in current code. But I think one benefit your idea will give is to shorten test run time if the block we need to sync to is not usually the tip.

@ycshao
Copy link
Contributor Author

ycshao commented Jun 9, 2020

Oo first PR? Concept ACK :) I'm guessing "contextual information of test framework" is the timeout_factor?

Yeah for now timeout_factor is easiest to be used. There are other things potentially can be used. I'm open to suggestions.

  • rpc_timeout - I think rpc_timeout is usually sometime different than timeout people want to configure for syncing operations. Unless there is a factor that can be applied to rpc_timeout to estimate syncing timeout. Open to suggestions.
  • nodes - We can by default sync all nodes and take in a parameter in sync_blocks and sync_mempool in case subset of nodes need to be synced. This way we get rid of nodes input of those two functions.

+1 to Jonas, just appeasing test/lint/lint-python.sh for now would be better.

lint-python.sh gives me other linting errors which is not related to the file I touched. I guess I'll just make those five files I touched to be pep8 in a separate commit. If it's not necessary, it's easy to take it out.

test/functional/p2p_compactblocks.py:688:43: E741 ambiguous variable name 'l'
test/functional/p2p_compactblocks.py:694:13: E741 ambiguous variable name 'l'
test/functional/p2p_compactblocks.py:697:17: E741 ambiguous variable name 'l'
test/functional/p2p_dos_header_tree.py:37:38: E741 ambiguous variable name 'l'
test/functional/p2p_dos_header_tree.py:42:31: E741 ambiguous variable name 'l'
test/functional/p2p_dos_header_tree.py:43:55: E741 ambiguous variable name 'l'
test/functional/test_framework/messages.py:70:22: E741 ambiguous variable name 'l'
test/functional/test_framework/messages.py:142:16: E741 ambiguous variable name 'l'
test/functional/test_framework/messages.py:161:24: E741 ambiguous variable name 'l'
test/functional/test_framework/messages.py:177:23: E741 ambiguous variable name 'l'
test/functional/wallet_labels.py:149:13: E741 ambiguous variable name 'l'
test/functional/wallet_labels.py:155:13: E741 ambiguous variable name 'l'
test/lint/lint-python.sh: line 105: mypy: command not found

Does it make sense to move assert (all([len(x.getpeerinfo()) for x in rpc_connections])) up to immediately after the while loop starts? It will assert sooner and save some time and operations.

I had this thought too. But I think it would fail if the nodes happened to all be synced up (despite not being connected right now) before the first iteration of the while loop. I think it's possible...?

I guess it's theoretically possible.

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

Concept ACK, but please change the commit title to

test: move sync_blocks and sync_mempool functions to test_framework.py

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
Contributor Author

Choose a reason for hiding this comment

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

I removed **kwargs which are not used.

Copy link
Member

Choose a reason for hiding this comment

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

I think they might come in handy in the future. Is there a reason they will be unused forever?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel it's better to add it when it will be used in instead of putting it there up front just because some time in the future it might be used. What do you think?

@maflcko
Copy link
Member

maflcko commented Jun 18, 2020

Please squash your commits according to https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#squashing-commits and change the commit title to something more meaningful: #19208 (review)

@maflcko
Copy link
Member

maflcko commented Jun 18, 2020

ACK cc84460 , reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space 💫

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

ACK cc84460c164bcb2a874d4f08b3a2624e5ee9ff0a , reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space 💫
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUh0+gv+MXi8uR6BQOeLwvt+luY9+MDS6qKEVkd1x6tUrhNL4R/1/HzIbCPA0n0O
FH/bMuzMk19Fn4qkH4vGEJHPQTeT+CNEf9omuWRSrNU8pqicaBpAN0cpWcHbJSxD
A8TC5uecJ1vWLmYruW9mnSTyYFTL7maKas7yKv4JsmsLIRhMPhWnJ2VU7MrCq9Uv
UyR5VTYjiqmw3Gz24RJ9QTtJWTDJjlkNXs01ZrO1ijVX5Gak9QLx47wz60lh8wtT
XtRQKOxsBGbJfrFexpU3IdThhNTuLTx1zcULgE2S6IOBF1Lph/CrSuZLv69H3bhW
S45h7iliCQR5njyC93TB1GB56BDFGcvbFqkjP0jgB0sVdh+pRP4lcgTNRGPD8O+t
p4TbuTKMo6P1JbqB1TAzZCmWUjVLmTjReSvGlMKegA3FHTm2XyXQEuOT7KHNk2Bm
2BHyvABW/hlIB/79YlUQ59pTC8CIvjEl0JQxY5VXOARyESD9PAteaJ5aFplnHtYl
eIUZJOgR
=adom
-----END PGP SIGNATURE-----

Timestamp of file with hash bea4e035a3dba2f2997391d4f35010649fa6ca21167797054925a5e15c237f47 -

@maflcko maflcko merged commit 4b5c919 into bitcoin:master Jun 21, 2020
@ycshao
Copy link
Contributor Author

ycshao commented Jun 22, 2020

@MarcoFalke @gzhao408 @adamjonas thanks for reviewing and merge!

furszy added a commit to PIVX-Project/PIVX that referenced this pull request Mar 20, 2021
2488ebc test: move sync_blocks and sync_mempool functions to test_framework.py (random-zebra)
d076c81 [Test] Fix intermittent sync_blocks failures (random-zebra)
f0de789 Move g_is_mempool_loaded into CTxMemPool::m_is_loaded (Ben Woosley)
0169a75 rpc: Expose g_is_mempool_loaded via getmempoolinfo and /rest/mempool/info.json (Ben Woosley)

Pull request description:

  Backport the following PRs:
  - bitcoin#15323: rpc: Expose g_is_mempool_loaded via getmempoolinfo
  - bitcoin#18873: test: Fix intermittent sync_blocks failures
  - bitcoin#19208: test: move sync_blocks and sync_mempool functions to test_framework.py

ACKs for top commit:
  furszy:
    nice finding!, code review ACK 2488ebc.
  Fuzzbawls:
    ACK 2488ebc

Tree-SHA512: 4971a0076b4179b78c5338073a10fbf0649310c2cf3907cff1ab5c02f8dd67f5f7bb4bf524d69c554c8317bd98ce46411ff740aff676ed147525c75d83214976
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Apr 21, 2021
Summary: This is a backport of [[bitcoin/bitcoin#19208 | core#19208]]

Test Plan: `ninja check-functional-extended`

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D9431
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
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.

test: Remove sync_blocks global

6 participants