closes #27494
This adds support for syncing multiple signets.
Each custom signet is stored in a different datadir, using the first 8 bytes of the signet challenge in hex as the suffix.
The default signet is always stored without a suffix for backward compatibility, even if the default challenge is provided explicitly via -signetchallenge.
This builds upon #29838.
For those already familiar with #29838, here are the differences between #29838 and this that are visible to the user:
- The suffix does not use the first 4 bytes of hash160(challenge), but rather the first 8 bytes of the unhashed challenge. If desired, I can use the message start instead as suggested in #29838 (comment).
- If the default challenge is provided to
-signetchallenge, #29838 added a suffix to the datadir, whereas this PR does not. This includes backward compatibility when the default signet is used explicitly, not only implicitly, even though the default signet consensus parameters aren’t used in the explicit case.1 A test was added for this case.
Unlike #29838, this PR does not update tests that didn’t break (rpc_bind.py, interface_bitcoin_cli.py). I have found other tests where datadir_path is used in combination with self.chain (regexp: datadir_path.*chain). I considered it inconsistent to update some tests but not all of them. I’ve decided to not update all of them to keep the scope of this PR low until feedback. I can go through all tests in a follow-up PR to make sure they don’t break when they are ever used with (custom) signet, however unlikely that might be.
I have done some manual testing like this:
bitcoind -signet: ‘signet’ directory is used, IBDbitcoind -signet -signetchallenge=512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be430210359ef5021964fe22d6f8e05b2463c9540ce96883fe3b278760f048f5189f2e6c452ae: ‘signet’ directory is used, no IBD without-addnode(see #29838 (comment))bitcoind -conf="signet_default.conf": ‘signet’ directory is usedbitcoind -conf="signet_custom.conf": ‘signet_0014d4528367459d’ directory is usedbitcoin-cli getblockchaininfowith the same options (-signet,-conf, or-signet -signetchallenge)
0# signet_default.conf
1signet=1
2[signet]
3signetchallenge=512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be430210359ef5021964fe22d6f8e05b2463c9540ce96883fe3b278760f048f5189f2e6c452ae
0# signet_custom.conf
1signet=1
2[signet]
3signetchallenge=0014d4528367459d54e1545b0d0a677d2a7d71d648e0
I’m new to contributing to Bitcoin Core so it’s entirely possible that I’ve missed something obvious.
Feedback welcome on where to best define the default signet challenge for the functional tests and the C++ code to avoid duplication.
-
could be something for a follow-up PR, or maybe it’s intentional to not mix explicit with implicit options? ↩︎