Bitcoin-ABC / Bitcoin-ABC/bitcoin-abc

Multiple instances of bitcoind can use the same -walletdir on Windows

Open
#380 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1.3k
Forks
788
PR merge metrics
No merged PRs in 30d

Description

I'm running Windows 10 Pro and building in WSL/Ubunut.

I've downloaded the latest master `501a8f0d` and found that the functional test wallet_multiwallet.py fails with the following output:

```
mtrycz@LAPTOP-00AACAV2:~/git/bitcoin-abc/build/test/functional$ ./test_runner.py wallet_multiwallet.py
Starting Bitcoin ABC functional tests
Temporary test directory at /home/mtrycz/git/bitcoin-abc/build/test/tmp/bitcoin_test_runner_20200415_123649
wallet_multiwallet.py --usecli started
wallet_multiwallet.py started
wallet_multiwallet.py failed, Duration: 8 s

stdout:
2020-04-15T10:36:53.433000Z TestFramework (INFO): Initializing test directory /home/mtrycz/git/bitcoin-abc/build/test/tmp/bitcoin_test_runner_20200415_123649/wallet_multiwallet_175
2020-04-15T10:36:57.672000Z TestFramework (INFO): Do not allow -zapwallettxes with multiwallet
2020-04-15T10:36:58.463000Z TestFramework (INFO): Do not allow -salvagewallet with multiwallet
2020-04-15T10:36:58.994000Z TestFramework (INFO): Do not allow -upgradewallet with multiwallet
2020-04-15T10:37:01.214000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
File "/home/mtrycz/git/bitcoin-abc/test/functional/test_framework/test_framework.py", line 161, in main
self.run_test()
File "/home/mtrycz/git/bitcoin-abc/test/functional/wallet_multiwallet.py", line 195, in run_test
['-walletdir=' + competing_wallet_dir], exp_stderr, match=ErrorMatch.PARTIAL_REGEX)
File "/home/mtrycz/git/bitcoin-abc/test/functional/test_framework/test_node.py", line 367, in assert_start_raises_init_error
self._raise_assertion_error(assert_msg)
File "/home/mtrycz/git/bitcoin-abc/test/functional/test_framework/test_node.py", line 146, in _raise_assertion_error
raise AssertionError(self._node_msg(msg))
AssertionError: [node 1] bitcoind should have exited with expected error Error: Error initializing wallet database environment \"\S+competing_walletdir\"!
2020-04-15T10:37:01.266000Z TestFramework (INFO): Stopping nodes
2020-04-15T10:37:01.570000Z TestFramework (WARNING): Not cleaning up dir /home/mtrycz/git/bitcoin-abc/build/test/tmp/bitcoin_test_runner_20200415_123649/wallet_multiwallet_175
2020-04-15T10:37:01.570000Z TestFramework (ERROR): Test failed. Test logging available at /home/mtrycz/git/bitcoin-abc/build/test/tmp/bitcoin_test_runner_20200415_123649/wallet_multiwallet_175/test_framework.log
2020-04-15T10:37:01.571000Z TestFramework (ERROR): Hint: Call /home/mtrycz/git/bitcoin-abc/test/functional/combine_logs.py '/home/mtrycz/git/bitcoin-abc/build/test/tmp/bitcoin_test_runner_20200415_123649/wallet_multiwallet_175' to consolidate all logs

stderr:

wallet_multiwallet.py --usecli failed, Duration: 8 s

stdout:
2020-04-15T10:36:53.433000Z TestFramework (INFO): Initializing test directory /home/mtrycz/git/bitcoin-abc/build/test/tmp/bitcoin_test_runner_20200415_123649/wallet_multiwallet_174
2020-04-15T10:36:58.005000Z TestFramework (INFO): Do not allow -zapwallettxes with multiwallet
2020-04-15T10:36:58.801000Z TestFramework (INFO): Do not allow -salvagewallet with multiwallet
2020-04-15T10:36:59.328000Z TestFramework (INFO): Do not allow -upgradewallet with multiwallet
2020-04-15T10:37:01.543000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
File "/home/mtrycz/git/bitcoin-abc/test/functional/test_framework/test_framework.py", line 161, in main
self.run_test()
File "/home/mtrycz/git/bitcoin-abc/test/functional/wallet_multiwallet.py", line 195, in run_test
['-walletdir=' + competing_wallet_dir], exp_stderr, match=ErrorMatch.PARTIAL_REGEX)
File "/home/mtrycz/git/bitcoin-abc/test/functional/test_framework/test_node.py", line 367, in assert_start_raises_init_error
self._raise_assertion_error(assert_msg)
File "/home/mtrycz/git/bitcoin-abc/test/functional/test_framework/test_node.py", line 146, in _raise_assertion_error
raise AssertionError(self._node_msg(msg))
AssertionError: [node 1] bitcoind should have exited with expected error Error: Error initializing wallet database environment \"\S+competing_walletdir\"!
2020-04-15T10:37:01.595000Z TestFramework (INFO): Stopping nodes
2020-04-15T10:37:01.875000Z TestFramework (WARNING): Not cleaning up dir /home/mtrycz/git/bitcoin-abc/build/test/tmp/bitcoin_test_runner_20200415_123649/wallet_multiwallet_174
2020-04-15T10:37:01.875000Z TestFramework (ERROR): Test failed. Test logging available at /home/mtrycz/git/bitcoin-abc/build/test/tmp/bitcoin_test_runner_20200415_123649/wallet_multiwallet_174/test_framework.log
2020-04-15T10:37:01.875000Z TestFramework (ERROR): Hint: Call /home/mtrycz/git/bitcoin-abc/test/functional/combine_logs.py '/home/mtrycz/git/bitcoin-abc/build/test/tmp/bitcoin_test_runner_20200415_123649/wallet_multiwallet_174' to consolidate all logs

stderr:

TEST | STATUS | DURATION

wallet_multiwallet.py | ✖ Failed | 8 s
wallet_multiwallet.py --usecli | ✖ Failed | 8 s

ALL | ✖ Failed | 16 s (accumulated)
Runtime: 8 s
```

I've singled out the cause as multiple instances of bitcoind being able to point to the same walletdir.

I've downloaded the latest binaries (0.21.4) and tried the following manual test in Windows in command prompt:

1. Create two directories, for example `C:\node0` and `C:\node1`; create a bitcoin.conf file in C:\node1 with a single line `rpcport=8333` (otherwise the second node will fail for an unrelated reason)
2. Open a command prompt and run `bitcoind.exe -datadir=C:\node0 -walletdir=D:\bchwallettest`
3. Open a second prompt and run `bitcoind.exe -datadir=C:\node1 -walletdir=D:\bchwallettest`
4. Expect the second node to fail at startup

I've tried this earlier today and can confirm that the second node erroneously starts.

Contributor guide

Open the contributing guide

Research direction

Start with test/functional/wallet_multiwallet.py at the competing_wallet_dir check around line 195, then trace the implementation behind -walletdir and its platform-specific locking behavior. Reproduce the two-process Windows command-line case; done means the second bitcoind exits with the expected wallet database environment error and the functional test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.