[RPC] Fix Invalidateblock#2856
Conversation
caf0f85 to
859ae93
Compare
d480ec9 to
2a1a11f
Compare
|
thanks for the review Duddino! I rebased with your suggestion...
I don't totally agree on this, from PR #2820 users will also be able to rollback to the last checkpoint which is quite fast. So I'd keep the limit of 1 month or in case extend it to 2 months |
|
Update: found an optimization that makes the rpc call much faster so I decided to remove the upper bound limit of 1 month. On my regtest it took 15 seconds to invalidate a block and in the wallet I had 15 sapling notes each with a depth of around 70k blocks. |
|
rebased on master |
Invalidateblock has not been working since sapling came out. This happens because the current maximum witness cache has a depth of only 100 blocks. With this PR I want to fix this issue by manually building the witness cache if the block has a depth bigger than the cache size.
Since this operation can become pretty lengthy, the RPC will just return error if your oldest sapling note is older than 1 month (43200 blocks behind the chain tip).
Note: After using invalidateblock the user might need to do
-> debug ->wallet repair -> recover transactionsin order to recover the correct balance. This is not a limit of this PR and you can test that it already happens with the current implementation of invalidateblock.Anyways "recover transactions" also cleans the wallet GUI from "conflicted" txs that you get after invalidating a block so it would be useful regardless.
Overall invalidating + eventually using recover transactions is faster than the current rescanning the blockchain from 0
Solves #2605