-
Notifications
You must be signed in to change notification settings - Fork 329
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
fix(wallet_esplora): missing_heights uses the graph update #1152
Conversation
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.
Good one.
Another MSRV break in CI...
tACK cbf0ad9 (with mempool.space
not blockstream.info
)
This is clearly my oversight. Thanks for identifying and fixing it. Can you rearrange the commits to that the MSRV fix comes before the Will give this a test, ACK and merge tomorrow. |
cbf0ad9
to
ea903db
Compare
I updated the code to match @LLFourn suggestion; other than being way cleaner, I later found out that my original solution was broken as well. FYI, doing let update = Update {
last_active_indices,
graph: update_graph,
chain: Some(chain_update),
};
wallet.apply_update(update)?; yields a different result than let update = Update {
graph: update_graph,
..Default::default()
};
wallet.apply_update(update)?;
let update = Update {
last_active_indices,
chain: Some(chain_update),
..Default::default()
};
wallet.apply_update(update)?; I haven't looked much into it, but when the graph update is added separately from the rest of the update, |
Regarding tests, we have an issue open for integration tests: #1094. Should I start to tackle it in this PR, or can we merge and think about it in the next milestone? |
...graph update Fixes bitcoindevkit#1151. When wallet_esplora_* was used to sync a wallet containing a transaction confirmed some time ago (more than 10-15 blocks ago), the transaction would be stuck in an "unconfirmed" state forever. At the first scan time, `update_local_chain` would just fetch the last 10 to 15 blocks (depending on the server used), and `tx_graph.missing_heights` wouldn't return the tx's confirmation block as it was called on the original, non-updated tx_graph. So, after the first scan, we would have a transaction in memory with an anchor that doesn't exist in our local_chain, and try_get_chain_position would return unconfirmed. When scanning again, missing_heights would find the missing anchor, but `update_local_chain` wouldn't include it as it's older than ASSUME_FINAL_DEPTH. The missing block would be downloaded every time, but never included in the local_chain, and the transaction would remain unconfirmed forever. Here we call missing_heights on the updated graph, so that it can correctly return the anchor height, and `update_local_chain` can fetch it and include it in the chain.
ea903db
to
b1461f0
Compare
We should always apply the index update first. When the index update and graph update is in the same Calling |
As a side note, I realized there is no way to set the keychain index's lookahead in |
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 b1461f0
Fixes #1151.
When wallet_esplora_* was used to sync a wallet containing a transaction confirmed some time ago (more than 10-15 blocks ago), the transaction would be stuck in an "unconfirmed" state forever.
At the first scan time,
update_local_chain
would just fetch the last 10 to 15 blocks (depending on the server used), andtx_graph.missing_heights
wouldn't return the tx's confirmation block as it was called on the original, non-updated tx_graph.So, after the first scan, we would have a transaction in memory with an anchor that doesn't exist in our local_chain, and try_get_chain_position would return unconfirmed.
When scanning again, missing_heights would find the missing anchor, but
update_local_chain
wouldn't include it as it's older than ASSUME_FINAL_DEPTH.The missing block would be downloaded every time, but never included in the local_chain, and the transaction would remain unconfirmed forever.
Here we call missing_heights on the updated graph, so that it can correctly return the anchor height, and
update_local_chain
can fetch it and include it in the chain.Notes to the reviewers
I'm not sure if this is the right approach, so I'm opening this PR to gather feedback. I still need to add tests, I'll do so once we decide if this is the right way to go or not.
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingBugfixes: