Make deployment configuration available outside of regtest in unit tests #35335

pull darosior wants to merge 3 commits into bitcoin:master from darosior:2605_more_deployment_config changing 6 files +149 −81
  1. darosior commented at 4:29 PM on May 20, 2026: member

    It's sometimes useful to test a deployment on other networks than regtest. This may be e.g. because regtest lacks a property relevant for the test, or simply because the test aims to be portable while regtest is Bitcoin Core specific.

    This PR makes it possible to set the -vbparams and -testactivationheight options on any network in unit tests, and on any test network as a startup option.

    This is preparatory work for a BIP 54 implementation, but may be useful separately.

  2. DrahtBot commented at 4:29 PM on May 20, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35335.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK sedited, instagibbs, edilmedeiros, achow101
    Concept ACK willcl-ark

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34566 (feature: Use different datadirs for different signets by ekzyis)
    • #31260 (scripted-diff: Type-safe settings retrieval by ryanofsky)
    • #17783 (common: Disallow calling IsArgSet() on ALLOW_LIST options by ryanofsky)
    • #17581 (refactor: Remove settings merge reverse precedence code by ryanofsky)
    • #17580 (refactor: Add ALLOW_LIST flags and enforce usage in CheckArgFlags by ryanofsky)
    • #17493 (util: Forbid ambiguous multiple assignments in config file by ryanofsky)

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  3. chainparams: encapsulate deployment configuration logic
    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 with `--color-moved-ws=allow-indentation-change`.
    df7ed5f355
  4. DrahtBot added the label CI failed on May 20, 2026
  5. DrahtBot commented at 5:58 PM on May 20, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task test ancestor commits: https://github.com/bitcoin/bitcoin/actions/runs/26175913652/job/77006888711</sub> <sub>LLM reason (✨ experimental): CI failed due to a C++ build error: chainparams.cpp references missing member dep_opts in CChainParams::SigNetOptions (compile error: “no member named 'dep_opts'”).</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  6. darosior force-pushed on May 20, 2026
  7. sedited commented at 7:15 PM on May 20, 2026: contributor

    Concept ACK

  8. DrahtBot removed the label CI failed on May 20, 2026
  9. sedited requested review from ajtowns on May 21, 2026
  10. willcl-ark commented at 8:08 PM on May 21, 2026: member

    Concept ACK.

    Seems generally useful and, if I'm honest, I'm kind of surprised we didn't need/have this ability already.

    Are you after this for BIP54 because some of the timestamp/retarget-boundary behavior is awkward to model cleanly on regtest? It seems useful to be able to test deployments on signet/testnet without needing custom chainparams patches in any case.

  11. darosior commented at 8:16 PM on May 21, 2026: member

    The BIP 54 test vectors use mainnet headers and blocks for the timewarp(s) test cases and nlocktime-in-coinbase test cases. This is because regtest does not have retargets, and is Bitcoin Core specific. Mainnet is more portable to other clients and closer to what we want to test for, so i went the extra mile and generated valid mainnet blocks / block headers for the BIP test vectors (implementation here, documentation to reproduce here).

  12. sedited commented at 1:20 PM on May 25, 2026: contributor

    Re this part of the description:

    simply because the test aims to be portable while regtest is Bitcoin Core specific.

    I'm not sure what you mean with this, I guess this is about generating test vectors? Maybe link to a branch where you are using them already?

  13. darosior commented at 6:42 PM on May 25, 2026: member

    Yes, BIP test vectors are an example of a test that aims to be portable across Bitcoin clients. Here is a link to my BIP 54 branch that uses them.

  14. in src/kernel/chainparams.h:177 in 93c3b39b2a outdated
     175 | +    static std::unique_ptr<const CChainParams> Main(const MainNetOptions& options);
     176 | +    static std::unique_ptr<const CChainParams> Main() { const MainNetOptions opts{}; return Main(opts); }
     177 | +    static std::unique_ptr<const CChainParams> TestNet(const TestNetOptions& options);
     178 | +    static std::unique_ptr<const CChainParams> TestNet() { const TestNetOptions opts{}; return TestNet(opts); }
     179 | +    static std::unique_ptr<const CChainParams> TestNet4(const TestNetOptions& options);
     180 | +    static std::unique_ptr<const CChainParams> TestNet4() { const TestNetOptions opts{}; return TestNet4(opts); }
    


    sedited commented at 8:24 PM on May 25, 2026:

    Would be nice to add the same overloads to RegTest and SigNet, we do have a few places that could use them.


    darosior commented at 11:13 PM on May 25, 2026:

    Done along with call sites update in a new commit.

  15. in src/init.cpp:1439 in 93c3b39b2a
    1434 | +            return InitError(_("The -testactivationheight option may not be used on mainnet."));
    1435 | +        }
    1436 | +        if (args.IsArgSet("-vbparams")) {
    1437 | +            return InitError(_("The -vbparams option may not be used on mainnet."));
    1438 | +        }
    1439 | +    }
    


    sedited commented at 8:35 PM on May 25, 2026:

    I think this should go in AppInitParameterInteraction. That makes it exit before daemonization and this is basically an interaction between the chain arg and the two args here.


    darosior commented at 11:13 PM on May 25, 2026:

    Makes sense. Done.

  16. sedited commented at 8:35 PM on May 25, 2026: contributor

    LGTM

  17. chainparams: make deployment configuration available on all test networks
    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.
    4995c00a9c
  18. chainparams: add overloads for RegTest and SigNet with no options
    For consistency with the overloads introduced in the previous commit,
    and because there is already a few places where they are useful.
    801e3bfe38
  19. darosior force-pushed on May 25, 2026
  20. sedited approved
  21. sedited commented at 9:21 AM on May 26, 2026: contributor

    ACK 801e3bfe38e82ca8e99e6628e59dde1f1fe9a060

  22. DrahtBot requested review from willcl-ark on May 26, 2026
  23. instagibbs approved
  24. instagibbs commented at 1:48 PM on May 26, 2026: member

    ACK 801e3bfe38e82ca8e99e6628e59dde1f1fe9a060

    lightly tested to ensure bitcoind cannot be started up with these options. bitcoin-tx/utils can be (though couldn't think of a reason why this would be problematic)

  25. in src/chainparams.cpp:91 in 801e3bfe38
      85 | @@ -107,6 +86,43 @@ void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& opti
      86 |      }
      87 |  }
      88 |  
      89 | +void ReadMainNetArgs(const ArgsManager& args, CChainParams::MainNetOptions& options)
      90 | +{
      91 | +    HandleDeploymentArgs(args, options.dep_opts);
    


    edilmedeiros commented at 2:16 PM on May 29, 2026:

    I wonder if this is needed at all. HandleDeploymentArgs() is handling -testactivationheight and -vbparams, but the test in init.cpp will not allow initialization to proceed in mainnet if these parameters are present. Thus, current behavior will be like no-op, but wouldn't be better to just leave it out?


    darosior commented at 2:24 PM on May 29, 2026:

    The point is to make those parameters available from unit tests. This line is necessary so setting those tests in unit tests isn't a noop.


    edilmedeiros commented at 2:44 PM on May 29, 2026:

    Oh, I see.

  26. edilmedeiros commented at 2:20 PM on May 29, 2026: contributor

    Concept ACK

  27. edilmedeiros commented at 2:50 PM on May 29, 2026: contributor

    utACK 801e3bfe38e82ca8e99e6628e59dde1f1fe9a060

  28. achow101 commented at 8:40 PM on June 3, 2026: member

    ACK 801e3bfe38e82ca8e99e6628e59dde1f1fe9a060

  29. achow101 merged this on Jun 3, 2026
  30. achow101 closed this on Jun 3, 2026

  31. darosior deleted the branch on Jun 3, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-06-11 10:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me