-
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
bdk + esplora not seeing an old transaction as confirmed #1151
Comments
...before using missing_heights 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 update the tx_graph immediately after getting the graph update, so that `missing_heights` can correctly return the anchor height, and `update_local_chain` fetch it and include it in the chain.
The bug is in the above code and in the wallet example. You're meant to ask the update what heights are missing from the current chain not the wallet. Though I'm not sure why it would be unconfirmed forever. The transaction should be added with its anchors anyway so it should be missing the next time I would have thought. Can we confirm why the anchor is not returned from |
@LLFourn bdk/crates/esplora/src/blocking_ext.rs Lines 134 to 140 in 4a65a12
|
...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.
b1461f0 fix(wallet_esplora): missing_heights uses the... ...graph update (Daniela Brozzoni) Pull request description: 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), 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. ### 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: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### Bugfixes: * [x] This pull request breaks the existing API * [ ] I've added tests to reproduce the issue which are now passing * [x] I'm linking the issue being fixed by this PR ACKs for top commit: evanlinjin: ACK b1461f0 Tree-SHA512: ba0cf85929644ee737dbc77e6afec662845532de0f120917aa6000ca8f5db79d0cb3971bd92285b5c5b5d26042b60b6c8536f50c9bd49615e31f5da28e80a509
But it should be part of bdk/crates/esplora/src/blocking_ext.rs Lines 107 to 117 in 4a65a12
So more succinct question why isn't the things in bdk/crates/esplora/src/blocking_ext.rs Lines 178 to 186 in 4a65a12
|
Yeah, I can look better into it tomorrow, but as far as I can tell the block is fetched as part of the request heights, but then not added to the chain because the earliest agreement checkpoint is not early enough. I initially thought it was because of ASSUME_FINAL_DEPTH, but I might be wrong.
-------- Original Message --------
…On Oct 10, 2023, 02:02, Lloyd Fournier wrote:
> ***@***.***(https://github.com/LLFourn) missing_heights would return the anchor, but update_local_chain wouldn't insert it as it's older than ASSUME_FINAL_DEPTH:
>
> https://github.com/bitcoindevkit/bdk/blob/4a65a12c4fe9bb419906d5c921bbff8b8b4e5379/crates/esplora/src/blocking_ext.rs#L134-L140
But it should be part of request_heights is what I mean. The things in request_heights are always fetched:
https://github.com/bitcoindevkit/bdk/blob/4a65a12c4fe9bb419906d5c921bbff8b8b4e5379/crates/esplora/src/blocking_ext.rs#L107-L117
So more succinct question why isn't the things in missing_heights going into request_heights and then being returned.
Maybe something going wrong here:
https://github.com/bitcoindevkit/bdk/blob/4a65a12c4fe9bb419906d5c921bbff8b8b4e5379/crates/esplora/src/blocking_ext.rs#L178-L186
—
Reply to this email directly, [view it on GitHub](#1151 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AF7B4KP2RUA23JKPRJQHRCLX6SF77AVCNFSM6AAAAAA5V5GK5GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJUGA3TOMRWGE).
You are receiving this because you were assigned.Message ID: ***@***.***>
|
This seems like a bug if so. Thanks a lot for looking into it. I'll just reopen this because I think although this is not the main problem it should have fixed itself. FWIW I don't understand why we are doing a cc @evanlinjin |
https://github.com/sebastianmontero/bdk-esplora-test/blob/master/src/main.rs#L34 Would this line be the culprit? Edit: okay this is already bought up, I didn't read the above conversation. |
I close this issue since it was fixed by #1152 |
Fair, I opened #1199 to keep track of the bug we discovered while investigating this one |
Describe the bug
When syncing using bdk and esplora, we might not see that a certain tx is confirmed, and consider it unconfirmed forever
To Reproduce
See https://github.com/sebastianmontero/bdk-esplora-test
Expected behavior
bdk correctly seeing a transaction as confirmed when it is
Build environment
The text was updated successfully, but these errors were encountered: