Tests: Chainparams: Make regtest almost fully customizable#17032
Tests: Chainparams: Make regtest almost fully customizable#17032jtimon wants to merge 2 commits intobitcoin:masterfrom
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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. |
|
Concept ACK. Didn't look at the approach. |
fjahr
left a comment
There was a problem hiding this comment.
Concept ACK. Did a light code review.
6c54f7d to
56fd4b3
Compare
|
Rebased after #17306 was merged. |
56fd4b3 to
ff1d546
Compare
|
Rebased |
ff1d546 to
2aaf473
Compare
A rebased version of: bitcoin/bitcoin#17032 This adds consensus customization support to regtest.
There was a problem hiding this comment.
Concept ACK. Lightly tested 2aaf473 in a different project, by simulating a chain split caused by a different halving interval. It sets up two nodes, a regular one (A) and one (B) with -con_nsubsidyhalvinginterval=10. It generates a longer chain on A, which is rejected by B, and shows up as invalid in getchaintips. A test like that would be useful here.
You may also want to add tests that at least touch the other params, and e.g. make sure the node doesn't complain about unrecognized params.
| gArgs.AddArg("-assumed_blockchain_size", "Estimated current blockchain size (in GB) for UI purposes. Default 0 (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); | ||
| gArgs.AddArg("-assumed_chain_state_size", "Estimated current chain state size (in GB) for UI purposes. Default 0 (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); | ||
| gArgs.AddArg("-fdefaultconsistencychecks", "Whether -checkblockindex and -checkmempool are active by default or not. Consider using those options instead. Default: 1 (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); | ||
| gArgs.AddArg("-frequirestandard", "Whether standard policy rules are applied in the local mempool by default. Consider using -acceptnonstdtxn=0 instead of changing the default. Default: 0 (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); |
There was a problem hiding this comment.
Why even expose this option if -acceptnonstdtxn=0 does the trick?
| gArgs.AddArg("-assumed_chain_state_size", "Estimated current chain state size (in GB) for UI purposes. Default 0 (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); | ||
| gArgs.AddArg("-fdefaultconsistencychecks", "Whether -checkblockindex and -checkmempool are active by default or not. Consider using those options instead. Default: 1 (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); | ||
| gArgs.AddArg("-frequirestandard", "Whether standard policy rules are applied in the local mempool by default. Consider using -acceptnonstdtxn=0 instead of changing the default. Default: 0 (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); | ||
| gArgs.AddArg("-is_test_chain", "Whether it's allowed to set -acceptnonstdtxn=0 for this chain or not. Default: 1 (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); |
| gArgs.AddArg("-fdefaultconsistencychecks", "Whether -checkblockindex and -checkmempool are active by default or not. Consider using those options instead. Default: 1 (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); | ||
| gArgs.AddArg("-frequirestandard", "Whether standard policy rules are applied in the local mempool by default. Consider using -acceptnonstdtxn=0 instead of changing the default. Default: 0 (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); | ||
| gArgs.AddArg("-is_test_chain", "Whether it's allowed to set -acceptnonstdtxn=0 for this chain or not. Default: 1 (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); | ||
| gArgs.AddArg("-is_mockable_chain", "Whether mocktime rpc calls are allowed or not. Default: 1 (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); |
There was a problem hiding this comment.
Can you think of a use case where disabling mocktime on regtest makes sense?
| gArgs.AddArg("-is_test_chain", "Whether it's allowed to set -acceptnonstdtxn=0 for this chain or not. Default: 1 (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); | ||
| gArgs.AddArg("-is_mockable_chain", "Whether mocktime rpc calls are allowed or not. Default: 1 (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); | ||
| gArgs.AddArg("-bech32_hrp", "Human readable part for bech32 addresses. See BIP173 for more info. Default: bcrt (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); | ||
| gArgs.AddArg("-pubkeyprefix", "Magic for base58 pubkeys. (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); |
There was a problem hiding this comment.
Light preference for making this hex, to be consistent with -extpubkeyprefix and friends.
|
|
||
| with open(inc_conf_file_path, 'w', encoding='utf-8') as conf: | ||
| conf.write('regtest=0\n') # mainnet | ||
| conf.write('is_test_chain=0\n') # like mainnet |
There was a problem hiding this comment.
This seems unsafe. We really want to test with actual mainnet, see e.g. #17449.
|
Thanks for all the reviews, really. |
Almost all chain params fields are made configurable for regtest and documented in --help for debug.
Unlike #8994 this doesn't allow to create an arbitrary number of regtests with different genesis blocks, but it also doesn't touch consensus code nor changes all the tests from "regtest" to "regtest2" to make sure the custom genesis blocks work, so it should be much easier to review in comparison.
This is supposed to save people from having to create more set methods on CRegTestParams in the future.
This is also supposed to force programmers (that's us) to maintain a documentation readable with --help for any present or future chainparam and their modifications.
As a simple example, it is tested that regtest can disallow setting -acceptnonstdtxn=1, which is something, for example, signets may want some times.
If someone doesn't like the example chainparam field I picked for the test for whatever reason, anybody's welcomed to suggest some other field or set of fields to test in a new test.py file.
I'm happy to code it myself or take someone else's test as a replacement.
A long time ago, we talked about loading the chainparams from a file.
Well, combined with the existing section (by chain) feature for loading the config file, this provides that feature.