-
Notifications
You must be signed in to change notification settings - Fork 37.7k
test: Extend salvage test for wallet tool #19078
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
Conversation
Test seems to fail: |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
166187b
to
3650390
Compare
Concept ACK. Seeing this error: Assertion `new_tx' failed:
|
b53ccb5
to
fab4fa1
Compare
test/functional/tool_wallet.py
Outdated
self.stop_node(0) | ||
|
||
self.assert_tool_output('', '-wallet=salvage', 'salvage') | ||
|
||
self.start_node(0, ['-wallet=salvage']) |
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 had to add self.nodes[0].rescanblockchain(0)
to make this pass after merging with #19457
fab4fa1
to
9670752
Compare
Maybe I should look at the test to understand better, but both of these changes are avoiding failures when there are duplicate transactions in the database. But we still don't know how duplicate transactions are winding up in the database to begin with? |
The duplicate transactions are showing up in the records the salvage pulls from the database. This doesn't mean the database actually contains duplicate transactions but is actually more of an artifact of the aggressive salvage. Specifically, the aggressive salvage will likely recover deleted data as such data is not actually overwritten, just marked deleted. The aggressive salvage ignores the deletion flag so it will pull up those records. In this test, the Btree ends up being rebalanced which involves moving data around and this is done via copy and delete. So the aggressive salvage is finding records in the "deleted space". |
0bbe26a wallet: filter for keys only before record deser in salvage (Andrew Chow) 544e12a walletdb: Add KeyFilterFn to ReadKeyValue (Andrew Chow) Pull request description: When salvaging a wallet, the only things that matter are the private keys. It is not necessary to attempt to deserialize any other records, especially if those records are corrupted too. This PR adds a `KeyFilterFn` function callback to `ReadKeyValue` that salvage uses to filter for only the records that it wants. Of course doing it this way also lets us do other filters in the future from other places should we so desire. ACKs for top commit: ryanofsky: Code review ACK 0bbe26a. Looks great! This should make the recovery code more robust. Normally it'd be good to have a test case for the problem this fixes, but Marco already wrote one in #19078, so I think we're covered laanwj: Code review ACK 0bbe26a Tree-SHA512: 8e3ee283a22a79273915711c4fb751f3c9b02ce94e6bf08dc468f1cfdf9fac35c693bbfd2435ce43c3a06c601b9b0a67e209621f6814bedfe3bc7a7ccc37bb01
…salvaging 0bbe26a wallet: filter for keys only before record deser in salvage (Andrew Chow) 544e12a walletdb: Add KeyFilterFn to ReadKeyValue (Andrew Chow) Pull request description: When salvaging a wallet, the only things that matter are the private keys. It is not necessary to attempt to deserialize any other records, especially if those records are corrupted too. This PR adds a `KeyFilterFn` function callback to `ReadKeyValue` that salvage uses to filter for only the records that it wants. Of course doing it this way also lets us do other filters in the future from other places should we so desire. ACKs for top commit: ryanofsky: Code review ACK 0bbe26a. Looks great! This should make the recovery code more robust. Normally it'd be good to have a test case for the problem this fixes, but Marco already wrote one in bitcoin#19078, so I think we're covered laanwj: Code review ACK 0bbe26a Tree-SHA512: 8e3ee283a22a79273915711c4fb751f3c9b02ce94e6bf08dc468f1cfdf9fac35c693bbfd2435ce43c3a06c601b9b0a67e209621f6814bedfe3bc7a7ccc37bb01
9670752
to
fa6154b
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.
Code review ACK fa6154b
Test looks right to me but there is an travis failure on one platform
self.nodes[0].generatetoaddress(1, gna()) | ||
self.nodes[0].sendmany(amounts={gna(): 0.05 for _ in range(50)}) | ||
self.nodes[0].sendmany(amounts={gna(): 0.05 for _ in range(50)}) | ||
balances_before = self.nodes[0].getbalances() | ||
self.stop_node(0) | ||
|
||
self.assert_tool_output('', '-wallet=salvage', 'salvage') |
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.
In commit "test: Add salvage test for wallet tool" (fa6154b)
It seems the test is failing on this line due to stderr output https://travis-ci.org/github/bitcoin/bitcoin/jobs/735969416#L2582:
Salvage: WARNING: Number of keys in data does not match number of values.
Salvage: WARNING: Unexpected end of file while reading salvage output.
WARNING: WalletBatch::Recover skipping key: CDataStream::read(): end of data: unspecified iostream_category error
WARNING: WalletBatch::Recover skipping key: CDataStream::read(): end of data: unspecified iostream_category error
WARNING: WalletBatch::Recover skipping key: Error reading wallet database: CPubKey/CPrivKey corrupt
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.
96239e8
to
66660e4
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.
Code review ACK 66660e4. Only change since last review is rebase. Also travis seems to pass now.
I'm confused about why the test was failing before #19078 (comment) but succeeding now. The bug report #20151 just points back to this PR for steps to reproduce (which I guess no longer work?) and doesn't mention whether the problem happens reliably or is maybe random or platform specific.
Please don't merge this. The failure still happens intermittently. |
@MarcoFalke how often does the intermittent test failure occur? I've rebased this on a branch which incorporates a few other salvage things, which fixes the assert(new_tx) thing again. I haven't been able to hit #20151 yet after multiple re-runs locally. |
66660e4
to
8d600d6
Compare
How often did you try? I am running
and it fails after 36 tries:
|
…salvaging 0bbe26a wallet: filter for keys only before record deser in salvage (Andrew Chow) 544e12a walletdb: Add KeyFilterFn to ReadKeyValue (Andrew Chow) Pull request description: When salvaging a wallet, the only things that matter are the private keys. It is not necessary to attempt to deserialize any other records, especially if those records are corrupted too. This PR adds a `KeyFilterFn` function callback to `ReadKeyValue` that salvage uses to filter for only the records that it wants. Of course doing it this way also lets us do other filters in the future from other places should we so desire. ACKs for top commit: ryanofsky: Code review ACK 0bbe26a. Looks great! This should make the recovery code more robust. Normally it'd be good to have a test case for the problem this fixes, but Marco already wrote one in bitcoin#19078, so I think we're covered laanwj: Code review ACK 0bbe26a Tree-SHA512: 8e3ee283a22a79273915711c4fb751f3c9b02ce94e6bf08dc468f1cfdf9fac35c693bbfd2435ce43c3a06c601b9b0a67e209621f6814bedfe3bc7a7ccc37bb01
…salvaging 0bbe26a wallet: filter for keys only before record deser in salvage (Andrew Chow) 544e12a walletdb: Add KeyFilterFn to ReadKeyValue (Andrew Chow) Pull request description: When salvaging a wallet, the only things that matter are the private keys. It is not necessary to attempt to deserialize any other records, especially if those records are corrupted too. This PR adds a `KeyFilterFn` function callback to `ReadKeyValue` that salvage uses to filter for only the records that it wants. Of course doing it this way also lets us do other filters in the future from other places should we so desire. ACKs for top commit: ryanofsky: Code review ACK 0bbe26a. Looks great! This should make the recovery code more robust. Normally it'd be good to have a test case for the problem this fixes, but Marco already wrote one in bitcoin#19078, so I think we're covered laanwj: Code review ACK 0bbe26a Tree-SHA512: 8e3ee283a22a79273915711c4fb751f3c9b02ce94e6bf08dc468f1cfdf9fac35c693bbfd2435ce43c3a06c601b9b0a67e209621f6814bedfe3bc7a7ccc37bb01
…salvaging 0bbe26a wallet: filter for keys only before record deser in salvage (Andrew Chow) 544e12a walletdb: Add KeyFilterFn to ReadKeyValue (Andrew Chow) Pull request description: When salvaging a wallet, the only things that matter are the private keys. It is not necessary to attempt to deserialize any other records, especially if those records are corrupted too. This PR adds a `KeyFilterFn` function callback to `ReadKeyValue` that salvage uses to filter for only the records that it wants. Of course doing it this way also lets us do other filters in the future from other places should we so desire. ACKs for top commit: ryanofsky: Code review ACK 0bbe26a. Looks great! This should make the recovery code more robust. Normally it'd be good to have a test case for the problem this fixes, but Marco already wrote one in bitcoin#19078, so I think we're covered laanwj: Code review ACK 0bbe26a Tree-SHA512: 8e3ee283a22a79273915711c4fb751f3c9b02ce94e6bf08dc468f1cfdf9fac35c693bbfd2435ce43c3a06c601b9b0a67e209621f6814bedfe3bc7a7ccc37bb01
Are you still working on this? |
Closing this as it has not had any activity in a while. If you are interested in continuing work on this, please leave a comment so that it can be reopened. |
Ok, I'll rebase |
8d600d6
to
fa60b70
Compare
The test still fails locally after a sufficient number of iterations, so I guess it is best to remove the command along with the removal of bdb |
Extend the test to check the balance remains the same before and after the salvage