Add aliases to the -chain param #23068

pull katesalazar wants to merge 1 commits into bitcoin:master from katesalazar:20210922 changing 3 files +23 −1
  1. katesalazar commented at 9:02 pm on September 22, 2021: contributor

    This change adds some aliases to the -chain param. -chain=signet is accepted, and this changes it into accepting -chain=testnet too.

    Stay a private API, no documentation is changed. Some tests could be added, or not, depending on the software’s code coverage policy.

  2. Add aliases to the `-chain` param
    This change adds some aliases to the `-chain` param. `-chain=signet`
    is accepted, and this changes it into accepting `-chain=testnet` too.
    
    Stay a private API, no documentation is changed. Some tests could be
    added, or not, depending on the software's code coverage policy.
    c0cf3b0ed5
  3. DrahtBot added the label Utils/log/libs on Sep 22, 2021
  4. DrahtBot added the label Validation on Sep 22, 2021
  5. laanwj commented at 10:29 am on September 23, 2021: member
    But why? Without any context I think it’s best to have one, unambiguous, name per chain. I would also imagine this option is mostly used by scripts, not by users (which tend to type -testnet -regtest etc). If you do type it a lot and get it wrong every time, why not define an alias at the shell level.
  6. katesalazar commented at 3:04 pm on September 23, 2021: contributor

    I think it’s best to have one, unambiguous, name per chain.

    Yes.

    Consistently. main, test and sig; or mainnet, testnet and signet.

    I would also imagine this option is mostly used by scripts, not by users (which tend to type -testnet -regtest etc).

    Yea, I just thought of iterating prettier.

    If you do type it a lot and get it wrong every time, why not define an alias at the shell level.

    This made me realize, using shell variables I can almost do what I want. Good enough. Thank you! ❤️

  7. laanwj commented at 7:39 pm on September 23, 2021: member

    Consistently. main, test and sig; or mainnet, testnet and signet.

    I agree it’s not really pretty. Some of the identifiers come from long-defunct BIP70 (main and test), the rest were added ad-hoc. I think if you present it as a plan to deprecate the old names eventually and go to, say {mainnet, testnet[3], regtest, signet} it might be more acceptable than ‘just adding aliases’. I don’t know.

  8. katesalazar commented at 9:48 pm on September 23, 2021: contributor

    I think if you present it as a plan to deprecate the old names eventually and go to, say {mainnet, testnet, regtest, signet} it might be more acceptable than ‘just adding aliases’.

    • Change: Replaces ‘main’ and ’test’ ‘-chain’ param values with ‘mainnet’ and ’testnet’ aiming increased consistency with the recently added ‘signet’.

      • Introduce ‘-chain’ param values ‘mainnet’ and ’testnet’. They are equivalent to ‘main’ and ’test’ before this change.

      • Deprecate ‘-chain’ param values ‘main’ and ’test’. Using them makes the software log and output a warning. Add a note (comment) asking for removing the deprecated values no later than five years after being deprecated (unless the deprecation is reversed), the years are written in the comment.

    This is small enough it doesn’t require a BIP, but this description must be sent to the mailing list after the PR is not pending requested changes, long before actually merging it.

    If this sounds airy, it is, I’m missing a lot of BIP reading, I haven’t even ever used regtest, I’m not familiar with the source code.

  9. laanwj commented at 11:08 am on September 24, 2021: member
    It wouldn’t need a BIP, nor mailing list discussion. The chain names are no longer used in any protocol, they’re purely internal, as well as used as argument to -chain.
  10. in src/util/system.cpp:1016 in c0cf3b0ed5
    1010@@ -1011,7 +1011,18 @@ std::string ArgsManager::GetChainName() const
    1011     if (fTestNet)
    1012         return CBaseChainParams::TESTNET;
    1013 
    1014-    return GetArg("-chain", CBaseChainParams::MAIN);
    1015+    auto chain_name = GetArg("-chain", CBaseChainParams::MAIN);
    1016+    std::string chain_name_post_alias;
    1017+    if (chain_name == CBaseChainParams::MAINNET_ALIAS) {
    


    brunoerg commented at 1:09 pm on September 24, 2021:
    Wouldn’t it be better using a switch statement here?

    katesalazar commented at 7:35 pm on September 24, 2021:

    I never really upgraded to C++11.

    It’ll take me a while to figure this out.

  11. katesalazar commented at 5:07 pm on September 24, 2021: contributor

    laanwj commented: It wouldn’t need a BIP, nor mailing list discussion.

    I’ll see about writing the code and submitting another PR.

  12. katesalazar marked this as a draft on Sep 24, 2021
  13. DrahtBot commented at 3:42 pm on September 25, 2021: member

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #23090 (Deprecate main and test -chain params by katesalazar)

    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.

  14. fanquake commented at 6:28 am on September 28, 2021: member
    Closing this given it’s superseded by #23090.
  15. fanquake closed this on Sep 28, 2021

  16. DrahtBot locked this on Oct 30, 2022

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: 2024-09-29 01:12 UTC

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