-
Notifications
You must be signed in to change notification settings - Fork 38.7k
test: Reduce number of blocks generated in rpc_signrawtransaction #22542
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
Conversation
Reduce the number of blocks generated to make sure CSV is activated in `test_signing_with_cltv` from 1500 to 500. This makes it consistent with the test above it, `test_signing_with_csv`. Also, generating 1500 blocks in one go takes longer than the alotted 30 seconds and times out consistently on Sifive Unmatched.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the number is okay, but it is the comment that is wrong here? I.e.
s/Make sure CSV is active/Make sure CLTV is active/
Improvement ideas for the sub-tests test_signing_with_{csv,cltv}:
- use constants
CSV_ACTIVATION_HEIGHT,CLTV_HEIGHTinstead of magic numbers 500, 1500 - check if CSV and CLTV have been really activated by asserting
getblockchaininfo()['softforks'] after generating the blocks...
jonatack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I've been seeing this timeout as well and have been cherry-picking this commit jonatack@e99f9b2 as a workaround, as I wasn't sure if the number of blocks could be reduced. The code was added in a97a929, @achow101 thoughts?
|
Thanks for the suggestions @theStack @jonatack will update with that.
SGTM (but both would be 500?). I sometimes wonder if we can do some kind of caching, pre-generate block chains with mechanisms activated, and share them among tests to save time (out of scope for this PR imo). |
|
I think we should activate all soft forks as early as possible in regtest. I am working on this, but progress is slow: #16333 |
The constants I was referring to already exist, though they are not in a common module yet: matching the corresponding regtest chain parameters in src/chainparams.cpp: I don't think after changing from 1500 to 500 blocks the test does what it is supposed to do anymore -- CLTV is not activated then, so OP_CLTV just behaves like a NOP. To proof, checking whether CLTV was activated with the following assertion succeeds on master, but fails in this PR: |
Okay, I'll close this and disable the test locally until something like #16333. |
|
I guess one way to make this work more reliably on systems that cannot generate the amount of blocks within the timeout would be to do multiple calls to |
|
There is also a timeout factor option, which can be used to scale all timeouts on slower systems (valgrind, VM, CI, ...) |
…tv}` subtests (speed, prevent timeout) 12f094e test: use constants for CSV/CLTV activation heights in rpc_signrawtransaction (Sebastian Falbesoner) 746f203 test: introduce `generate_to_height` helper, use in rpc_signrawtransaction (Sebastian Falbesoner) e3237b1 test: check that CSV/CLTV are active in rpc_signrawtransaction (Sebastian Falbesoner) Pull request description: This PR primarily aims to solve the current RPC timeout problem for test rpc_signrawtransaction.py, as described in #22542. In the course of that the test is also improved in other ways (see bitcoin/bitcoin#22542 (review)). Reviewers guideline: * In `test_signing_with_cltv()`, a comment is fixed -- it wrongly referred to CSV, it should be CLTV. * As preparation, assertions are added that ensure that CSV and CLTV have been really activated after generating blocks by checking the 'softforks' output of the getblockchaininfo() RPC. Right now in master, one could remove (or decrease, like in #22542) the generate calls and the test would still pass, when it shouldn't. * A helper `generate_to_height()` is introduced which improves the previous way of reaching a block height in two ways: - instead of blindly generating TH blocks to reach target block height >= TH, the current block height CH is taken into account, and only (TH - CH) are generated in total - to avoid potential RPC timeouts, the block generation is split up into multiple generatetoaddress RPC calls ([as suggested by laanwj](bitcoin/bitcoin#22542 (comment))); here chunks of 200 blocks have been chosen * The helper is used in the affected sub-tests, which should both speed-up the test (from ~18s to ~12s on my machine) and avoid potential timeouts * Finally, the activation constants for CSV and CLTV are used instead of using magic numbers 500 and 1500 Open questions: * Any good naming alternatives for `generate_to_height()`? Not really happy with the name, happy to hear suggestions * Where to put the CSV and CLTV activation height constants in the test_framewor folder? I guess importing constants from other tests isn't really the desired way to go ACKs for top commit: laanwj: Code review and tested ACK 12f094e rajarshimaitra: reACK bitcoin/bitcoin@12f094e Tree-SHA512: 14509f6d3e5a5a05d6a30a3145bb82cd96a29d9d8a589abf1944a8bf34291cde78ce711195f52e9426588dc822b3618ec9b455e057360021ae46152bb7613516
…tests (speed, prevent timeout) 12f094e test: use constants for CSV/CLTV activation heights in rpc_signrawtransaction (Sebastian Falbesoner) 746f203 test: introduce `generate_to_height` helper, use in rpc_signrawtransaction (Sebastian Falbesoner) e3237b1 test: check that CSV/CLTV are active in rpc_signrawtransaction (Sebastian Falbesoner) Pull request description: This PR primarily aims to solve the current RPC timeout problem for test rpc_signrawtransaction.py, as described in bitcoin#22542. In the course of that the test is also improved in other ways (see bitcoin#22542 (review)). Reviewers guideline: * In `test_signing_with_cltv()`, a comment is fixed -- it wrongly referred to CSV, it should be CLTV. * As preparation, assertions are added that ensure that CSV and CLTV have been really activated after generating blocks by checking the 'softforks' output of the getblockchaininfo() RPC. Right now in master, one could remove (or decrease, like in bitcoin#22542) the generate calls and the test would still pass, when it shouldn't. * A helper `generate_to_height()` is introduced which improves the previous way of reaching a block height in two ways: - instead of blindly generating TH blocks to reach target block height >= TH, the current block height CH is taken into account, and only (TH - CH) are generated in total - to avoid potential RPC timeouts, the block generation is split up into multiple generatetoaddress RPC calls ([as suggested by laanwj](bitcoin#22542 (comment))); here chunks of 200 blocks have been chosen * The helper is used in the affected sub-tests, which should both speed-up the test (from ~18s to ~12s on my machine) and avoid potential timeouts * Finally, the activation constants for CSV and CLTV are used instead of using magic numbers 500 and 1500 Open questions: * Any good naming alternatives for `generate_to_height()`? Not really happy with the name, happy to hear suggestions * Where to put the CSV and CLTV activation height constants in the test_framewor folder? I guess importing constants from other tests isn't really the desired way to go ACKs for top commit: laanwj: Code review and tested ACK 12f094e rajarshimaitra: reACK bitcoin@12f094e Tree-SHA512: 14509f6d3e5a5a05d6a30a3145bb82cd96a29d9d8a589abf1944a8bf34291cde78ce711195f52e9426588dc822b3618ec9b455e057360021ae46152bb7613516
Reduce the number of blocks generated to make sure CSV is activated in
test_signing_with_cltvfrom 1500 to 500. This makes it consistent with the test above it,test_signing_with_csv.Also, generating 1500 blocks in one go takes longer than the alotted 30 seconds and times out consistently on Sifive Unmatched.