Skip to content

Conversation

jtimon
Copy link
Contributor

@jtimon jtimon commented Oct 2, 2019

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.

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 3, 2019

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.

@maflcko
Copy link
Member

maflcko commented Oct 8, 2019

Concept ACK. Didn't look at the approach.

Copy link
Contributor

@fjahr fjahr 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. Did a light code review.

@jtimon jtimon force-pushed the b20-customizable-regtest branch from 6c54f7d to 56fd4b3 Compare October 30, 2019 12:51
@jtimon
Copy link
Contributor Author

jtimon commented Oct 30, 2019

Rebased after #17306 was merged.
Fixed nit in #17306 (comment) here.

@jtimon
Copy link
Contributor Author

jtimon commented Feb 19, 2020

Rebased

@jtimon jtimon force-pushed the b20-customizable-regtest branch from ff1d546 to 2aaf473 Compare February 19, 2020 20:50
Sjors added a commit to jonathanbier/forkmonitor that referenced this pull request Mar 3, 2020
A rebased version of: bitcoin/bitcoin#17032
This adds consensus customization support to regtest.
Copy link
Member

@Sjors Sjors 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. 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);
Copy link
Member

Choose a reason for hiding this comment

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

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);
Copy link
Member

Choose a reason for hiding this comment

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

This seems useless?

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);
Copy link
Member

Choose a reason for hiding this comment

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

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);
Copy link
Member

Choose a reason for hiding this comment

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

Light preference for making this hex, to be consistent with -extpubkeyprefix and friends.

@@ -42,9 +42,9 @@ def test_config_file_parser(self):
self.nodes[0].assert_start_raises_init_error(expected_msg='Error: Config setting for -wallet only applied on %s network when in [%s] section.' % (self.chain, self.chain))

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
Copy link
Member

Choose a reason for hiding this comment

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

This seems unsafe. We really want to test with actual mainnet, see e.g. #17449.

@jtimon
Copy link
Contributor Author

jtimon commented May 6, 2020

Thanks for all the reviews, really.
But I'm no longer interested in this.
Please, if anyone is interested, don't hesitate to take the branch and improve it and try, rewrite it or whatever.

@jtimon jtimon closed this May 6, 2020
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants