Skip to content

PANIC at pepper-sync/src/wallet/traits.rs #2012

@Tomas-M

Description

@Tomas-M

I am using zingo-cli.
From time to time, it throws panic with this error:

thread 'tokio-runtime-worker' panicked at /usr/src/aa/zingolib/pepper-sync/src/wallet/traits.rs:325:13:
max checkpoints should always be higher or equal to max verification window!

This makes the wallet completely unusable, requiring full rescan. I thought this could be a of-by-one error or something like that, but after printing some debug log messages, it appears to be something else. I got help from ChatGPT, so please consider this with grain of salt, but the final solution WORKED FOR ME TO FIX THE PROBLEM so I believe we are on the right track.

If you want to test it, here is the broken wallet.dat file for download:
https://dropcube.net/dl/qvCbG/zingo-wallet.dat

The logs show that the return value is not a window-size rejection (to_remove <= 100), but instead that the implementation refuses the request when the requested height is not an existing sapling checkpoint. In other words: orchard had an exact checkpoint at the requested height but sapling did not, and the caller asked to truncate both trees to the same truncate_height. Seems like sapling rejects the request and the caller panics.

So it seems the panic is not caused by removing too many checkpoints (not a MAX_VERIFICATION_WINDOW violation). It looks like it is caused by a mismatch between the requested checkpoint height and the sapling checkpoint set (sapling has no checkpoint at requested height). The panic message is probably misleading for this particular failure mode.

Now, to the fix.

If I identified the root cause properly, then I think the best fix would be to change the caller to request truncation to a height that exists in both trees (e.g., pick a common checkpoint height, or pick the nearest lower checkpoint that both trees share). But I don't know how to do that properly. But I found a way to do it in truncate_shard_trees() - to finds common checkpoint height for truncation, below the requested truncate_height, and truncate to that common checkpoint.

EDIT: I removed the code which was here, in favour of code in my following reply.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions