-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Test: wallet issue with orphaned rewards #18795
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
This is meant as an example for #14148 as requested by @MarcoFalke , not to be merged for now. |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
If this demonstrates an unfixed issue, shouldn't the test fail on master? |
That's a good point. The test was originally written to assert the current behaviour and thus passed (but looking at the code one could see the behaviour described in #14148). But I agree that is probably confusing. I've added another commit now that makes the test fail as expected (the original version is still preserved in the first commit, as it might be interesting as well for understanding what the issue is about). |
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
Thanks for the feeback, @MarcoFalke ! I've addressed it with a new commit (so as to not invalidate comments made on previous commits), but am of course happy to squash all history into a single commit any time. |
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 think I am going to merge this.
Maybe squash the commits and add a check for getbalances
also before the abandontransaction call. Due to the bug it should be all zeros, right?
957dee4
to
7aeaa92
Compare
@MarcoFalke Thanks! I've rebased onto latest |
ACK 7aeaa92 |
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.
ACK 7aeaa92
Nice PR! I made sure the test passes as written, and that removing the abandontransaction
makes it fail as expected. Suggestions are minor nits, nonblocking.
"untrusted_pending": 0, | ||
"immature": 0, | ||
}) | ||
self.nodes[1].sendtoaddress(address=self.nodes[0].getnewaddress(), amount=9, subtractfeefromamount=True) |
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.
Can this last sendtoaddress
be removed?
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.
Yes it can, but I think having it in there is an extra check that the wallet does properly handle the coins. So unless there is a strong preference to remove it, I'd rather keep it in to make the test more robust and descriptive.
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.
... having it in there is an extra check ...
I verified that if this sendtoaddress
fails (which I forced by increasing the amount sent to 99999), the entire test fails, which is good. (I wasn't aware of that, which is why I thought this was an unnecessary line of code -- good to leave it in as you have. Need to put an RPC within a try
to have its failure not fail the overall test.)
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.
tACK 7aeaa92. Tested on Ubuntu 20.04.
The test successfully demonstrates that when an orphaned block reward is spent together with other outputs, the wallet stops showing any funds and that "abandontransaction(txid)" restores the valid funds.
Agree with #18795 (comment) and #18795 (comment). Using 152 blocks apparently works fine and there's no need of the last line.
The code below would also work as the final validation of this test:
self.stop_node(1)
self.start_node(1, ["-zapwallettxes=2"])
assert_equal(self.nodes[1].getbalances()["mine"], {
"trusted": 10,
"untrusted_pending": 0,
"immature": 0,
})
7aeaa92
to
ef9f3f4
Compare
Thanks @LarryRuane and @leonardojobim , and sorry for the long response time on my end. I have now rebased the PR onto latest As for the alternate final validation with |
ACK ef9f3f4 |
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.
reACK ef9f3f4
Ping for rebase @domob1812. |
This adds a new test case demonstrating the wallet issue when block rewards are orphaned (bitcoin#14148).
ef9f3f4
to
e4356f6
Compare
Thanks for the reminder, rebased. |
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.
ACK e4356f6
I verified that without the abandontransaction
, the assertion fails, and (if I comment out the assertion) the sendtoaddress
fails.
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 10) | ||
self.nodes[0].generate(1) | ||
|
||
# Get a block reward with node 1 and remember the block so we can orphan |
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.
# Get a block reward with node 1 and remember the block so we can orphan | |
# Get a block reward (25) with node 1 and remember the block so we can orphan |
(Non-blocking, only if you touch-up, would have made the test easier for me to understand.)
CI fail is unrelated, see #20975 |
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.
reACK e4356f6 .
Tested on Ubuntu 20.04.
e4356f6 Testcase for wallet issue with orphaned rewards. (Daniel Kraft) Pull request description: This adds a new test case demonstrating the wallet issue when block rewards are orphaned (bitcoin#14148). ACKs for top commit: LarryRuane: ACK e4356f6 leonardojobim: reACK bitcoin@e4356f6 . Tree-SHA512: e9a2310ee1b3d52cfa302f431ed3d272bbc1b9195439ff318d9eb1006c0b28968dbe840e1600b6ff185e5d7ea57e4dcc837cef16051b5537445e10bc363b8c22
This adds a new test case demonstrating the wallet issue when block rewards are orphaned (#14148).