Closed castarco closed 5 years ago
I would say it's not an error message. It can be prevented by removing transactions from the wallet after reorgs. But I'm not sure we should do it.
We can remove coinbase transaction A from the wallet once another transaction B which spends A's stake has been finalized. Otherwise we risk A's fork becoming active again.
Otherwise we risk A's fork becoming active again.
In that case CWallet::BlockConnected
will be called again and A will be added to the wallet.
Well I think it's more in terms of usability the wallet should only provide what's on your main chain, even if you still keep this block.
My doubt here is if there's any reason why this was done that way before. I mean, why after reorg the wallet is not purged by default from transactions created in the old fork? Is it because we already have this method that does it "on demand"? Or is there any other reason?
I'm looking into it to see if it makes sense to apply this idea of removing UTXOs from the wallet proactively without waiting for conflicts.
My doubt here is if there's any reason why this was done that way before.
Because usually, wallet handles transactions created by the user. It would be strange to delete user's transactions after switching to another fork.
But for coinbase transactions, it makes more sense since they cannot be included in other blocks.
Yeah it’s a side effect of the staking wallet. In Bitcoin the wallet is of course not remotely close to create coinbase transactions, not even the entire codebase. Yeah we should definitely handle it specially and I’m not surprised,
True. What comes to my mind now is if the maturity constrains are enough to avoid having to care about the following case (the problem here is that we still don't have definitive values):
In the case of a coinbase transaction that has to be discarded, whose outputs are used to create regular transactions... what should the Wallet do with those regular transactions?
I'll close this issue for now, as the remaining doubts deserve a proper issue... and just in case anyone really cares about that.
I don't see a real/important problem here, since it's already expected that re-orgs could lead to discarding transactions. It's true that we could slightly improve the node's behaviour in some cases, but in my opinion the effort isn't worth it because such cases will be very rare.
Here, the transaction
b2fe27c7e3986803749ef0ed0b5afcc5ae2de60270f52de2bc5486412490113c
was created when proposing the block68a60775ac89520b1ab9f8fa6783fb28462529324affe6567c9bd8e34e65045a
, which was discarded after some time to follow a longer chain [c14175679a5db141206b01def9841eba0e3056a7d0fd7b0333309d5aadfbe541
,c77ebab0ae95cbc51508ffd4b89ee8f7373c44b26447986b7e8f246f223b7caa
].Then, the node proposed again using the same funds were used to stake for
68a60775ac89520b1ab9f8fa6783fb28462529324affe6567c9bd8e34e65045a
, which should be OK since we are in a fork were these funds were not used. But then the node shows us an error message, telling us that there's a conflict (the coinbase transactionb1f8f4eb440799573f4fcce00f634444cf8e4666ff147676bee7ae9db66d10e7
conflicts withb2fe27c7e3986803749ef0ed0b5afcc5ae2de60270f52de2bc5486412490113c
).As far as I understand, we should not see this kind or error message in the logs since everything was working as expected.
To Reproduce No clear way to reproduce the issue, it depends on randomness.
Expected behavior The error message should not appear at all.
Environment Testnet (early stages) Ubuntu 18.04, but this is not really relevant.