-
Notifications
You must be signed in to change notification settings - Fork 352
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
BDK keychain tracker gets wiped after processing empty update #1060
Comments
Just to confirm, are you sure this is a bug for This should not be a problem for |
This is alpha 1. I'm not sure what things are called but whatever we have to persist, gets emptied |
Would you be able to provide a bit more detail? How are you using the library - which methods are you calling? Maybe some steps for reproducing? Even showing how we can reproduce the issue with Thanks in advance. |
This is our syncing logic https://github.com/MutinyWallet/mutiny-node/blob/master/mutiny-core/src/onchain.rs#L93 This is how we do storage https://github.com/MutinyWallet/mutiny-node/blob/master/mutiny-core/src/storage.rs#L564 To reproduce in mutiny, create a wallet, send on-chain, wait for a new block to sync, restart mutiny and it'll have 0 balance until it syncs again |
Hey @benthecarman. Could you tell us whether there is any data in the database when you read it in and you get 0 balance. E.g. you could run through the issue reproduction and just There are two possible explanations that I can think of:
|
Can do |
{
"chain_changeset": {
"306879": "00000103bf2e590cd1103392d397b885e326e7a76ca9bd258c68a550db5e2d08"
},
"indexed_additions": {
"graph_additions": {
"anchors": [
[
{
"anchor_block": {
"hash": "00000103bf2e590cd1103392d397b885e326e7a76ca9bd258c68a550db5e2d08",
"height": 306879
},
"confirmation_height": 297446,
"confirmation_time": 1691182925
},
"1d3df203b1308d7d1bb03ad43f49ab23e202766f4db19d5a2c98b19db97c7d73"
]
],
"last_seen": {},
"txouts": {},
"txs": []
},
"index_additions": {
}
}
} |
So the most likely explanation here is that you are fully writing over the original changeset with the new one (rather than merging them). The logic in your code doesn't look like you do that but the result is indeed that somehow. Can you dump us the following before doing the commit that gives you that db state:
Thanks! |
1: |
Hmm might have found the bug on our end, we would remove the bdk store from our in memory cache after it was read, removing that seemed to fix |
Okay was able to figure out our issue, thanks for the help! |
Good news. One thing I noted while looking at your implementation that might have made harder to reason about was that you fully read in the existing changeset, append to it and then write it out again for every change. Since it looks like you are working with a key value store, the way we imagined you'd do this is you would insert each changeset separately at a certain key with an index and then at start up do a range query to collect all the changesets within that range and append them altogether. Note that at the moment they have to be stored and
oops. My bad. |
Yeah we could do that, appending all the changes into a single key makes it much simpler for us however. |
Describe the bug
The bdk keychain tracker will get wiped when we do a sync that does not have any updates (no new or updated txs). This makes it so we need to do a full sync every time the wallet is opened and wastes a lot of resources.
Build environment
Additional context
this happened with our previous full sync and the new just checking unused addresses sync
The text was updated successfully, but these errors were encountered: