Skip to content
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

test: Fixes and updates to wallet_backwards_compatibility.py for 25.0 and descriptor wallets #28027

Merged

Conversation

achow101
Copy link
Member

@achow101 achow101 commented Jul 4, 2023

It was somewhat surprising to me that wallet_backwards_compatibility.py did not catch #27915 since the purpose of the test is to find downgrade issues such as that. It turns out the test was deficient in several places when it came to testing descriptor wallets, as well as deficient in addition to failing to correctly test some releases.

This PR fixes these test cases, adds more informative logging, slightly refactors the entire test in order to better test future versions, and adds a 25.0 node to the test.

Notable changes:

  • The compatibility test with 0.16 should not have been passing. The wallets were being copied incorrectly for 0.16 and resulting in 0.16 creating new wallets rather than testing the target wallets.
  • The downgrade test will actually be run on descriptor wallets and it will test that downgrades are successful, and a subsequent upgrade is also successful. This catches wallets created on master get corrupted when processed with v25 #27915.
  • The upgrade and downgrade test will be run on all versions up to master, rather than just 0.16, 0.17, and 0.19.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 4, 2023

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

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK furszy, Sjors
Concept ACK ismaelsadeeq
Approach ACK S3RK

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #28528 (test: Use test framework utils in functional tests by osagie98)
  • #26728 (wallet: Have the wallet store the key for automatically generated descriptors by achow101)
  • #25907 (wallet: rpc to add automatically generated descriptors by achow101)
  • #20892 (tests: Run both descriptor and legacy tests within a single test invocation by achow101)

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.

@DrahtBot DrahtBot added the Tests label Jul 4, 2023
@achow101 achow101 force-pushed the 2023-07-test-wallet-back-compat-updates branch from 325d6e7 to 8c887c3 Compare July 4, 2023 03:44
@achow101 achow101 force-pushed the 2023-07-test-wallet-back-compat-updates branch 2 times, most recently from 07a8cf4 to 604440c Compare July 4, 2023 03:51
@Sjors
Copy link
Member

Sjors commented Jul 4, 2023

Thanks for improving these tests. Added to review list.

@ismaelsadeeq
Copy link
Member

Concept ACK

@achow101 achow101 force-pushed the 2023-07-test-wallet-back-compat-updates branch from 604440c to e408968 Compare July 10, 2023 17:11
Copy link
Member

@ismaelsadeeq ismaelsadeeq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running this test failed on my device not sure if it's from this PR though.

Steps to recreate
git checkout pr/28027
make clean
./autogen.sh
./configure
make
test/functional/test_runner.py wallet_backwards_compatibility.py

2023-07-11T00:04:00.468000Z TestFramework (INFO): PRNG seed is: 1124432296273551722
2023-07-11T00:04:00.468000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_banbrcm1
2023-07-11T00:04:00.472000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/home/abubakarsadiq/Desktop/bitcoin/test/functional/test_framework/test_framework.py", line 550, in start_nodes
    node.start(extra_args[i], *args, **kwargs)
  File "/home/abubakarsadiq/Desktop/bitcoin/test/functional/test_framework/test_node.py", line 221, in start
    self.process = subprocess.Popen(self.args + extra_args, env=subp_env, stdout=stdout, stderr=stderr, cwd=cwd, **kwargs)
  File "/usr/lib/python3.10/subprocess.py", line 969, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1845, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/home/abubakarsadiq/Desktop/bitcoin/releases/v25.0/bin/bitcoind'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/abubakarsadiq/Desktop/bitcoin/test/functional/test_framework/test_framework.py", line 130, in main
    self.setup()
  File "/home/abubakarsadiq/Desktop/bitcoin/test/functional/test_framework/test_framework.py", line 295, in setup
    self.setup_network()
  File "/home/abubakarsadiq/Desktop/bitcoin/test/functional/test_framework/test_framework.py", line 389, in setup_network
    self.setup_nodes()
  File "/home/abubakarsadiq/Desktop/bitcoin/test/functional/wallet_backwards_compatibility.py", line 74, in setup_nodes
    self.start_nodes()
  File "/home/abubakarsadiq/Desktop/bitcoin/test/functional/test_framework/test_framework.py", line 555, in start_nodes
    self.stop_nodes()
  File "/home/abubakarsadiq/Desktop/bitcoin/test/functional/test_framework/test_framework.py", line 570, in stop_nodes
    node.stop_node(wait=wait, wait_until_stopped=False)
  File "/home/abubakarsadiq/Desktop/bitcoin/test/functional/test_framework/test_node.py", line 346, in stop_node
    self.stop(wait=wait)
  File "/home/abubakarsadiq/Desktop/bitcoin/test/functional/test_framework/test_node.py", line 192, 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
2023-07-11T00:04:00.523000Z TestFramework (INFO): Stopping nodes
Traceback (most recent call last):
  File "/home/abubakarsadiq/Desktop/bitcoin/test/functional/wallet_backwards_compatibility.py", line 368, in <module>
    BackwardsCompatibilityTest().main()
  File "/home/abubakarsadiq/Desktop/bitcoin/test/functional/test_framework/test_framework.py", line 154, in main
    exit_code = self.shutdown()
  File "/home/abubakarsadiq/Desktop/bitcoin/test/functional/test_framework/test_framework.py", line 311, in shutdown
    self.stop_nodes()
  File "/home/abubakarsadiq/Desktop/bitcoin/test/functional/test_framework/test_framework.py", line 570, in stop_nodes
    node.stop_node(wait=wait, wait_until_stopped=False)
  File "/home/abubakarsadiq/Desktop/bitcoin/test/functional/test_framework/test_node.py", line 346, in stop_node
    self.stop(wait=wait)
  File "/home/abubakarsadiq/Desktop/bitcoin/test/functional/test_framework/test_node.py", line 192, 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
[node 1] Cleaning up leftover process
[node 0] Cleaning up leftover process

Left some comments and question

assert info['private_keys_enabled']
assert info['keypoolsize'] > 0
# Use addmultisigaddress (see #18075)
address_18075 = wallet.rpc.addmultisigaddress(1, ["0296b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52", "037211a824f55b505228e4c3d5194c1fcfaa15a456abdf37f9b9d97a4040afc073"], "", "legacy")["address"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The v19 test pubkeys 0296b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52 and 037211a824f55b505228e4c3d5194c1fcfaa15a456abdf37f9b9d97a4040afc073 are they relevant to the test? I see they are the same as the one reported in #18075

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the specific keys are relevant.

test/functional/wallet_backwards_compatibility.py Outdated Show resolved Hide resolved
@@ -127,13 +126,6 @@ def run_test(self):
assert wallet.getaddressinfo(address_18075)["solvable"]
node_v19.unloadwallet("w1_v19")

# w1_v18: regular wallet, created with v0.18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we no longer using the wallet?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would guess that it was used in the up-downgrade test but was accidentally removed at some point. It isn't necessary anymore either as that test is now automated to go over all of the previous versions so the hardcoded specific wallet versions are no longer necessary.

@S3RK
Copy link
Contributor

S3RK commented Jul 11, 2023

Approach ACK

@achow101
Copy link
Member Author

Running this test failed on my device not sure if it's from this PR though.

It looks like you're missing the 25.0 binaries. The test is expecting to find 25.0's bitcoind at /home/abubakarsadiq/Desktop/bitcoin/releases/v25.0/bin/bitcoind but doesn't.

@Sjors
Copy link
Member

Sjors commented Jul 14, 2023

0ffa0f1 (and later) breaks at line line 96 when you run wallet_backwards_compatibility.py --descriptors without BDB:

JSONRPCException: Wallet file verification failed. Failed to open database path '/tmp/bitcoin_func_test_x3n9_0vn/node1/regtest/wallets/w1_v19'. Build does not support Berkeley DB database format. (-18)

Otherwise it works, just some stylistic notes inline (e408968).

0.16 creating new wallets rather than testing the target wallets

Is there an assert you can add in c31e0db that would catch this directly? Right now a regression would be "caught" simply because it doesn't fail to load. Ideally we'd check this for every version before we dropped the "just create a new one if it doesn't exist" behavior was dropped.

test/functional/wallet_backwards_compatibility.py Outdated Show resolved Hide resolved
@@ -76,7 +76,6 @@ def run_test(self):
node_miner = self.nodes[0]
node_master = self.nodes[1]
node_v19 = self.nodes[self.num_nodes - 4]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6a5d245: if a node is node is not used, we should reduce the number of nodes and node_v19 should be self.num_nodes - 3.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.18 is still tested, just not explicitly with its own special casing and variables.

test/functional/wallet_backwards_compatibility.py Outdated Show resolved Hide resolved
@achow101 achow101 force-pushed the 2023-07-test-wallet-back-compat-updates branch from e408968 to 505e91f Compare July 14, 2023 20:58
@achow101
Copy link
Member Author

0ffa0f1 (and later) breaks at line line 96 when you run wallet_backwards_compatibility.py --descriptors without BDB:

Fixed

0.16 creating new wallets rather than testing the target wallets

Is there an assert you can add in c31e0db that would catch this directly? Right now a regression would be "caught" simply because it doesn't fail to load. Ideally we'd check this for every version before we dropped the "just create a new one if it doesn't exist" behavior was dropped.

With the versions that have loadwallet, we catch that case by checking the contents of the wallet. The test previously wasn't doing that for 0.16 (it was actually one of the first things I changed before I realized there was an incompatibility).

@achow101 achow101 force-pushed the 2023-07-test-wallet-back-compat-updates branch from 505e91f to 10740c2 Compare July 14, 2023 21:03
@achow101 achow101 force-pushed the 2023-07-test-wallet-back-compat-updates branch from 10740c2 to 91f47e6 Compare July 14, 2023 21:07
@Sjors
Copy link
Member

Sjors commented Jul 28, 2023

ACK 91f47e6

Also tested that reverting 6a9510d causes the test to fail when it tries to load the wallet in master after having loaded it in v25 (Wallet corrupted).

@achow101 achow101 force-pushed the 2023-07-test-wallet-back-compat-updates branch from 91f47e6 to add9d14 Compare August 23, 2023 20:42
The test for 0.16 wallet downgrading was using the wrong wallet path and
thus incorrectly finding that 0.16 could open wallets created in master.
This wallet is no longer used in the test
This specific test is distinct from the rest of the backwards
compatibility tests as it is checking a specific failure.
Test that old nodes don't mess up new wallets by loading a downgraded
wallet in master again.
@achow101 achow101 force-pushed the 2023-07-test-wallet-back-compat-updates branch from add9d14 to afd9a67 Compare August 23, 2023 20:49
Copy link
Member

@furszy furszy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK afd9a67

@Sjors
Copy link
Member

Sjors commented Oct 5, 2023

re-ACK afd9a67

@DrahtBot DrahtBot removed the request for review from Sjors October 5, 2023 07:46
@maflcko maflcko added this to the 26.0 milestone Oct 5, 2023
@fanquake fanquake merged commit d9c1cc5 into bitcoin:master Oct 5, 2023
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants