Skip to content

Conversation

@laanwj
Copy link
Member

@laanwj laanwj commented Jul 25, 2021

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.

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.
@laanwj laanwj added the Tests label Jul 25, 2021
Copy link
Contributor

@theStack theStack left a 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_HEIGHT instead of magic numbers 500, 1500
  • check if CSV and CLTV have been really activated by asserting getblockchaininfo()['softforks'] after generating the blocks...

Copy link
Member

@jonatack jonatack left a 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?

@laanwj
Copy link
Member Author

laanwj commented Jul 25, 2021

Thanks for the suggestions @theStack @jonatack will update with that.

use constants CSV_ACTIVATION_HEIGHT, CLTV_HEIGHT instead of magic numbers 500, 1500

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).

@maflcko
Copy link
Member

maflcko commented Jul 25, 2021

I think we should activate all soft forks as early as possible in regtest. I am working on this, but progress is slow: #16333

@theStack
Copy link
Contributor

use constants CSV_ACTIVATION_HEIGHT, CLTV_HEIGHT instead of magic numbers 500, 1500

SGTM (but both would be 500?).

The constants I was referring to already exist, though they are not in a common module yet:

test/functional/feature_csv_activation.py:CSV_ACTIVATION_HEIGHT = 432
test/functional/feature_cltv.py:CLTV_HEIGHT = 1351

matching the corresponding regtest chain parameters in src/chainparams.cpp:

consensus.CSVHeight = 432; // CSV activated on regtest (Used in rpc activation tests)
consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in functional tests)

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:

assert(self.nodes[0].getblockchaininfo()['softforks']['bip65']['active'])

@laanwj
Copy link
Member Author

laanwj commented Jul 25, 2021

I don't think after changing from 1500 to 500 blocks the test does what it is supposed to do anymore

Okay, I'll close this and disable the test locally until something like #16333.

@laanwj laanwj closed this Jul 25, 2021
@laanwj
Copy link
Member Author

laanwj commented Jul 25, 2021

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 generatetoaddress.
I have no idea why generating empty blocks is so slow in the first place though.

@maflcko
Copy link
Member

maflcko commented Jul 25, 2021

There is also a timeout factor option, which can be used to scale all timeouts on slower systems (valgrind, VM, CI, ...)

maflcko pushed a commit to bitcoin-core/gui that referenced this pull request Jul 28, 2021
…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
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 28, 2021
…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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 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.

4 participants