-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Use different datadirs for different signets #29838
base: master
Are you sure you want to change the base?
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. 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. |
64d3828
to
9e81922
Compare
🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the Possibly this is due to a silent merge conflict (the changes in this pull request being Leave a comment here, if you need help tracking down a confusing failure. |
Concept ACK |
Concept ACK |
src/common/args.cpp
Outdated
if (!signet_challenge_str.empty()) { | ||
std::vector<uint8_t> signet_challenge = ParseHex(signet_challenge_str); | ||
const auto hash_160 = Hash160(signet_challenge); | ||
return fs::PathFromString(base_data_dir + "-" + HexStr(hash_160)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the hash160 will better guarantee uniqueness, but a 40 character string is kind-of long? Would it make sense to use the 8 character HexStr(Params().MessageStart())
value instead, special-casing for when the message start magic number matches the default signet's 0a03cf40
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach to use the 8-character message start (i.e. first 4 bytes of the SHA256 hash of the challenge) seems better to me as well. More concise directory lengths with a reasonably low chance of collision between signets.
nit: Recommend avoiding using -
(dash) and instead using something like _
(underscore) when building signet paths to prevent unexpected issues when including custom signet directory paths in command line arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the PR to use the first 8 bytes of the hash160
and replaced the -
with _
as suggested
Concept ACK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK.
Great feature to help prevent conflicting datadir conflicts when switching between signets.
Inline comments added.
Received failures for functional tests feature_signet.py and tool_signet_miner.py.
dev@bdev01:~/bitcoin$ test/functional/test_runner.py -u --cachedir=/mnt/tmp/cache --tmpdir=/mnt/tmp test/functional/feature_signet.py test/functional/tool_signet_miner.py
Temporary test directory at /mnt/tmp/test_runner_₿_🏃_20240413_214701
Remaining jobs: [feature_signet.py, tool_signet_miner.py --legacy-wallet, tool_signet_miner.py --descriptors]
1/3 - feature_signet.py failed, Duration: 60 s
stdout:
2024-04-14T01:47:02.221000Z TestFramework (INFO): PRNG seed is: 2979480965586364484
2024-04-14T01:47:02.222000Z TestFramework (INFO): Initializing test directory /mnt/tmp/test_runner_₿_🏃_20240413_214701/feature_signet_2
2024-04-14T01:48:02.321000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 565, in start_nodes
node.wait_for_rpc_connection()
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 314, in wait_for_rpc_connection
self._raise_assertion_error("Unable to connect to bitcoind after {}s".format(self.rpc_timeout))
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 188, in _raise_assertion_error
raise AssertionError(self._node_msg(msg))
AssertionError: [node 0] Unable to connect to bitcoind after 60s
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 131, in main
self.setup()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 302, in setup
self.setup_network()
File "/home/dev/bitcoin/test/functional/feature_signet.py", line 43, in setup_network
self.setup_nodes()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 418, in setup_nodes
self.start_nodes()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 568, in start_nodes
self.stop_nodes()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 583, in stop_nodes
node.stop_node(wait=wait, wait_until_stopped=False)
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 375, in stop_node
self.stop(wait=wait)
^^^^^^^^^
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 205, in __getattr__
assert self.rpc_connected and self.rpc is not None, self._node_msg("Error: no RPC connection")
^^^^^^^^^^^^^^^^^^^^
AssertionError: [node 0] Error: no RPC connection
2024-04-14T01:48:02.376000Z TestFramework (INFO): Stopping nodes
[node 5] Cleaning up leftover process
[node 4] Cleaning up leftover process
[node 3] Cleaning up leftover process
[node 2] Cleaning up leftover process
[node 1] Cleaning up leftover process
[node 0] Cleaning up leftover process
stderr:
Traceback (most recent call last):
File "/home/dev/bitcoin/test/functional/feature_signet.py", line 85, in <module>
SignetBasicTest().main()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 155, in main
exit_code = self.shutdown()
^^^^^^^^^^^^^^^
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 318, in shutdown
self.stop_nodes()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 583, in stop_nodes
node.stop_node(wait=wait, wait_until_stopped=False)
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 375, in stop_node
self.stop(wait=wait)
^^^^^^^^^
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 205, in __getattr__
assert self.rpc_connected and self.rpc is not None, self._node_msg("Error: no RPC connection")
^^^^^^^^^^^^^^^^^^^^
AssertionError: [node 0] Error: no RPC connection
2/3 - tool_signet_miner.py --descriptors failed, Duration: 60 s
stdout:
2024-04-14T01:47:02.220000Z TestFramework (INFO): PRNG seed is: 1471356017149591392
2024-04-14T01:47:02.221000Z TestFramework (INFO): Initializing test directory /mnt/tmp/test_runner_₿_🏃_20240413_214701/tool_signet_miner_0
2024-04-14T01:48:02.317000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 565, in start_nodes
node.wait_for_rpc_connection()
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 314, in wait_for_rpc_connection
self._raise_assertion_error("Unable to connect to bitcoind after {}s".format(self.rpc_timeout))
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 188, in _raise_assertion_error
raise AssertionError(self._node_msg(msg))
AssertionError: [node 0] Unable to connect to bitcoind after 60s
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 131, in main
self.setup()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 302, in setup
self.setup_network()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 396, in setup_network
self.setup_nodes()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 418, in setup_nodes
self.start_nodes()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 568, in start_nodes
self.stop_nodes()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 583, in stop_nodes
node.stop_node(wait=wait, wait_until_stopped=False)
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 375, in stop_node
self.stop(wait=wait)
^^^^^^^^^
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 205, in __getattr__
assert self.rpc_connected and self.rpc is not None, self._node_msg("Error: no RPC connection")
^^^^^^^^^^^^^^^^^^^^
AssertionError: [node 0] Error: no RPC connection
2024-04-14T01:48:02.370000Z TestFramework (INFO): Stopping nodes
[node 0] Cleaning up leftover process
stderr:
Traceback (most recent call last):
File "/home/dev/bitcoin/test/functional/tool_signet_miner.py", line 65, in <module>
SignetMinerTest().main()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 155, in main
exit_code = self.shutdown()
^^^^^^^^^^^^^^^
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 318, in shutdown
self.stop_nodes()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 583, in stop_nodes
node.stop_node(wait=wait, wait_until_stopped=False)
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 375, in stop_node
self.stop(wait=wait)
^^^^^^^^^
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 205, in __getattr__
assert self.rpc_connected and self.rpc is not None, self._node_msg("Error: no RPC connection")
^^^^^^^^^^^^^^^^^^^^
AssertionError: [node 0] Error: no RPC connection
Remaining jobs: [tool_signet_miner.py --legacy-wallet]
3/3 - tool_signet_miner.py --legacy-wallet failed, Duration: 61 s
stdout:
2024-04-14T01:47:02.211000Z TestFramework (INFO): PRNG seed is: 4742527368365497737
2024-04-14T01:47:02.212000Z TestFramework (INFO): Initializing test directory /mnt/tmp/test_runner_₿_🏃_20240413_214701/tool_signet_miner_1
2024-04-14T01:48:02.317000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 565, in start_nodes
node.wait_for_rpc_connection()
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 314, in wait_for_rpc_connection
self._raise_assertion_error("Unable to connect to bitcoind after {}s".format(self.rpc_timeout))
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 188, in _raise_assertion_error
raise AssertionError(self._node_msg(msg))
AssertionError: [node 0] Unable to connect to bitcoind after 60s
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 131, in main
self.setup()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 302, in setup
self.setup_network()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 396, in setup_network
self.setup_nodes()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 418, in setup_nodes
self.start_nodes()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 568, in start_nodes
self.stop_nodes()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 583, in stop_nodes
node.stop_node(wait=wait, wait_until_stopped=False)
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 375, in stop_node
self.stop(wait=wait)
^^^^^^^^^
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 205, in __getattr__
assert self.rpc_connected and self.rpc is not None, self._node_msg("Error: no RPC connection")
^^^^^^^^^^^^^^^^^^^^
AssertionError: [node 0] Error: no RPC connection
2024-04-14T01:48:02.370000Z TestFramework (INFO): Stopping nodes
[node 0] Cleaning up leftover process
stderr:
Traceback (most recent call last):
File "/home/dev/bitcoin/test/functional/tool_signet_miner.py", line 65, in <module>
SignetMinerTest().main()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 155, in main
exit_code = self.shutdown()
^^^^^^^^^^^^^^^
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 318, in shutdown
self.stop_nodes()
File "/home/dev/bitcoin/test/functional/test_framework/test_framework.py", line 583, in stop_nodes
node.stop_node(wait=wait, wait_until_stopped=False)
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 375, in stop_node
self.stop(wait=wait)
^^^^^^^^^
File "/home/dev/bitcoin/test/functional/test_framework/test_node.py", line 205, in __getattr__
assert self.rpc_connected and self.rpc is not None, self._node_msg("Error: no RPC connection")
^^^^^^^^^^^^^^^^^^^^
AssertionError: [node 0] Error: no RPC connection
TEST | STATUS | DURATION
feature_signet.py | ✖ Failed | 60 s
tool_signet_miner.py --descriptors | ✖ Failed | 60 s
tool_signet_miner.py --legacy-wallet | ✖ Failed | 61 s
ALL | ✖ Failed | 181 s (accumulated)
Runtime: 61 s
dev@bdev01:~/bitcoin$
src/common/args.cpp
Outdated
if (!signet_challenge_str.empty()) { | ||
std::vector<uint8_t> signet_challenge = ParseHex(signet_challenge_str); | ||
const auto hash_160 = Hash160(signet_challenge); | ||
return fs::PathFromString(base_data_dir + "-" + HexStr(hash_160)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach to use the 8-character message start (i.e. first 4 bytes of the SHA256 hash of the challenge) seems better to me as well. More concise directory lengths with a reasonably low chance of collision between signets.
nit: Recommend avoiding using -
(dash) and instead using something like _
(underscore) when building signet paths to prevent unexpected issues when including custom signet directory paths in command line arguments.
Concept ACK |
1 similar comment
Concept ACK |
I use both the default signet and at least one custom one, so having separate directories would be quite useful. Shorter would be nice. Ideally we would also support different config file sections and startup flags, using the same convention:
[signet]
prune=1000
[signet_xxx]
signetchallenge=51
signetseednode=... |
i concur with @tdb3 - use underscores for signet paths. |
I concur with @Sjors. |
Ensure the signet path pre/postfix is shared with the wallet so it can find the appropriate wallets for each signet. Treating the global signet as “just another signet” ought to simplify the wallet logic as well as avoiding a bug where the wallet doesn’t distinguish between global signet and custom signets. |
You may be able to allow cascading signet [signet] prefix=<short_string1> prefix=<short_string2> note: consider supporting forward slashes in the signet path - allowing more control on where the data lands in disk. |
9e81922
to
9f8b438
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK.
Code looks good, but not tested yet.
Any way to add a functional test for this?
9f8b438
to
8c3c484
Compare
If the -signetchallenge argument is provided, the hash-160 (first 8 characters) of the challenge is appended to the datadir name, resulting in unique data directories for each signet, i.e., signet_XXXXXXX.
8c3c484
to
ac1ccd5
Compare
@Sjors and @RandyMcMillan I love the idea of the |
- Added a test to verify the Signet data directory when -signetchallenge=51 is correctly set to 'signet_da1745e9'. - Added a test to verify the main Signet data directory is correctly set to 'signet'.
a0b1d77
to
50f4ca2
Compare
Concept ACK |
Fixes #27494
When the
-signetchallenge
argument is provided, the hash-160 of the challenge is appended to the data directory name. This ensures that each signet has its own distinct data directory, following the naming conventionsignet_XXXXXXX
.Update:
When the
-signetchallenge
argument is provided,the first 8 characters of the hash-160 of the challenge
are appended to the data directory name. This ensures that each signet has its own distinct data directory, following the naming conventionsignet_XXXXXXX
.