Make deployment options available on all networks in unit tests#98
Make deployment options available on all networks in unit tests#98darosior wants to merge 2 commits intobitcoin-inquisition:29.xfrom
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. |
a6fe2a7 to
85e4009
Compare
Are referring to the different timewarp grace period between testnet4 and mainnet? If so, I would just ignore the testnet4 value. |
|
I am talking mainly about difficulty adjustments. Regtest has none and the testnets have tweaks. Are you suggesting a different approach? |
|
Oh I see, we need difficulty adjustment to test the timewarp. I agree that the tweaks in testnet3 and testnet4 ruin that. I think a better approach is to allow difficulty adjustment on regtest. It could be implemented by adding a This avoids the need to pre-mine mainnet transactions (like in |
|
I think that enabling difficulty adjustments on regtest would be a pretty invasive change, potentially lead to overflows, all that in consensus-critical code (gated to regtest of course, but still). To be clear i'm not trying to avoid going through the whole process of generating the test vectors again, and updating them in the BIP, it just seems to me that your suggestion is not a good tradeoff compared to the current approach. |
|
I don't think it's invasive at all if you keep the default
It's regtest that's gated, the normal difficulty adjustment code runs on all other networks: unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params& params)
{
if (params.fPowNoRetargeting)
return pindexLast->nBits;
... |
|
@Sjors if you allow difficulty adjustments on regtest it's very easy to overflow the calculations causing much larger than 4x changes. I'm not sure it's worth the squeeze. |
|
It's also not clear to me if you are suggesting to throw away the current BIP test vectors, or if you are suggesting this to improve the current Timewarp functional test provided with the BIP 54 implementation for Bitcoin Core. Also note other implementations may not have regtest, and being compatible with other implementations is a goal of the BIP test vectors. It's usually not an issue for BIPs that pertain to Script stuff since they can be applied to either, but here the test vectors would be based on a genesis block (header) that other Bitcoin clients may not have, for what appear to be very marginal gains to the Bitcoin Core implementation. |
|
Oh I see you used mainnet headers for the BIP54 test vectors. I guess you don't run into the minimum chain work check for these alternate histories, because the timewarp check will fail first? I'm a bit worried that people are going to abuse Another option could be to use a signet with |
We already expose functionalities that allow to do the same. We should avoid introducing footguns, and bigger ones already exist (
I can explicitly disable using the startup option on other network than regtest if you'd like. I didn't think it was worth doing because as i said we already expose bigger footguns (especially as undocumented commands and startup options). But if it can help address others' concerns i am happy to do that.
How is this related to this discussion? Functional tests use regtest.
Yes, and moreover Signet has different difficulty adjustment parameters (maximum target). |
|
Using
It can use any network, see I wrote:
But this can be changed if
Oh, the higher |
|
If i prevented using |
We've had people wanting to vary signet consensus params for other reasons (mutinynet's 1m block time eg); at least this would be a reason to do that that's directly related to improving mainnet. |
89b7c26 to
56af124
Compare
|
Rebased on top of updated #90 and added a startup check to make sure deployment options may only be used on regtest (as per the existing documentation). |
|
#90 landed, so maybe give this a rebase so it looks less scary :-) |
This encapsulates the soft fork configuration logic as set by the `-testactivationheight` (for buried deployments) and `-vbparams` (for version bits deployments) options which for the moment are regtest-only, in order to make them available on other networks as well in the next commit. Can be reviewed using git's --color-moved option.
56af124 to
620f348
Compare
|
Rebased. |
|
Actually it may be preferable to only prevent the argument from being used on mainnet, rather than making it regtest only, because we also have functional tests for other test networks. For instance |
|
That seems fine, only mainnet needs seatbelts. |
620f348 to
3a77a06
Compare
|
Updated to only prevent starting up with |
|
utACK 3a77a06 I briefly checked that (if you disable the "Disallow mainnet/testnet operation" guard) it rejects |
4b2aca2 to
f30d527
Compare
There was a problem hiding this comment.
Non-binding NACK f30d527 -- at this point, this PR is just a very small amount of setup work with no payoff and only one dependency, so I think we should just merge these commits as part of #99 without keeping them in a separate PR. Otherwise, apart from the TestNet4 vs TestNet issue below, looks good to me.
…n unit tests This allows unit tests to set `-testactivationheight` and `-vbparams` on all networks instead of exclusively on regtest. Those are kept test-network-only when used as startup parameters.
f30d527 to
6665296
Compare
|
OK. Pushed one last time to address your review comment, and closing this to have the commits directly as part of #99 instead. |
Based on top of #90, this is the second (and last) preparatory PR to the BIP54 implementation.
We use deployment options to test soft forks. Some of the BIP54 mitigations are specific to the mainnet chain params, therefore the BIP54 implementation unit tests need to be able to set an active deployment even if the chain type is not regtest. This PR makes the
-vbparamsand-testactivationheightavailable on all networks in the unit tests framework.I don't think those options are particularly more of a footgun than other options/commands already available to users, but logic was added to prevent using the startup options on mainnet (#98 (comment)).