Skip to content
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

chain: PrunedBlockDispatcher bugfix. #903

Merged
merged 2 commits into from
Jan 27, 2024

Conversation

ziggie1984
Copy link
Contributor

@ziggie1984 ziggie1984 commented Jan 24, 2024

This addresses #lightningnetwork/lnd#8250.

(Still need to update the unittests).

So this does not address the related time issue for now which is acutally the case why the requests where failing in the first place.

I would add the new timing logic and introduce the getblockfrompeer command for bitcoind >24 (iirc) in a followup PR.

@ziggie1984 ziggie1984 force-pushed the prune-node-deadlock-blocksync branch 2 times, most recently from f13e5df to 3441fd7 Compare January 24, 2024 00:51
@yyforyongyu yyforyongyu self-requested a review January 24, 2024 23:46
chain/bitcoind_conn.go Show resolved Hide resolved
chain/pruned_block_dispatcher.go Outdated Show resolved Hide resolved
@ziggie1984 ziggie1984 force-pushed the prune-node-deadlock-blocksync branch 3 times, most recently from 2397f1f to 1ef6e6c Compare January 25, 2024 11:45
@ziggie1984 ziggie1984 marked this pull request as ready for review January 25, 2024 11:53
chain/bitcoind_conn.go Outdated Show resolved Hide resolved
chain/bitcoind_conn.go Outdated Show resolved Hide resolved
@ziggie1984 ziggie1984 force-pushed the prune-node-deadlock-blocksync branch 2 times, most recently from 842064b to 577dd4a Compare January 25, 2024 13:01
@ziggie1984 ziggie1984 force-pushed the prune-node-deadlock-blocksync branch from 577dd4a to b104af5 Compare January 25, 2024 13:07
Copy link
Collaborator

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Left a comment about how we add the cancelChan.

For future concerns, although GetBlock may ask for the same block, we should treat each request independently. We can use something like a requestID to handle sending back the corresponding response, to make sure one request doesn't interfere with others. On top of that we can think about optimizations such as caching a previous success block response for future requests. Then ofc there's the new RPC getblockfrompeer we can use for pruned nodes.

chain/pruned_block_dispatcher.go Show resolved Hide resolved
chain/pruned_block_dispatcher.go Show resolved Hide resolved
@C-Otto
Copy link

C-Otto commented Jan 25, 2024

Note that caching is currently done in lnd: blockcache/blockcache.go

@ziggie1984
Copy link
Contributor Author

ziggie1984 commented Jan 25, 2024

Refined the peer selection logic, to not waste time connecting to inbound peers and as well sort by pingtime, I think thats a quick win which prevents us running in this timeout issue in the first place.

Copy link
Collaborator

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🌹

chain/pruned_block_dispatcher.go Show resolved Hide resolved
chain/pruned_block_dispatcher.go Show resolved Hide resolved
chain/pruned_block_dispatcher_test.go Show resolved Hide resolved
chain/pruned_block_dispatcher_test.go Show resolved Hide resolved
@ziggie1984 ziggie1984 force-pushed the prune-node-deadlock-blocksync branch from f4361d8 to 5d82d84 Compare January 25, 2024 15:45
@ziggie1984 ziggie1984 requested a review from Roasbeef January 25, 2024 15:46
chain/pruned_block_dispatcher.go Show resolved Hide resolved
chain/pruned_block_dispatcher.go Outdated Show resolved Hide resolved
chain/pruned_block_dispatcher.go Outdated Show resolved Hide resolved
@ziggie1984 ziggie1984 force-pushed the prune-node-deadlock-blocksync branch from 5d82d84 to c5fe5d3 Compare January 25, 2024 23:16
@ziggie1984 ziggie1984 requested a review from Roasbeef January 25, 2024 23:21
@ziggie1984 ziggie1984 force-pushed the prune-node-deadlock-blocksync branch from c5fe5d3 to e55c3f7 Compare January 25, 2024 23:40
In case we fail the request via the neutriono block peer fetcher
we make sure we fail all dependant `GetBlock` calls and remove
this block request completely so that a new request for this same
block hash can be made.
We discard inbound peers because we don't know their listen port
and sort the peers by pingtime to select the fastest first.
@ziggie1984 ziggie1984 force-pushed the prune-node-deadlock-blocksync branch from e55c3f7 to 987fbac Compare January 25, 2024 23:43
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💣

@Roasbeef Roasbeef merged commit 16b422a into btcsuite:master Jan 27, 2024
3 checks passed
buck54321 pushed a commit to buck54321/btcwallet that referenced this pull request Apr 21, 2024
…locksync

Plus lightninglabs/neutrino#273
Author: Elle Mouton <[email protected]>
Date:   Mon May 22 15:53:49 2023 +0200

chain: PrunedBlockDispatcher bugfix.
buck54321 pushed a commit to buck54321/btcwallet that referenced this pull request Apr 21, 2024
…locksync

Plus lightninglabs/neutrino#273
Author: Elle Mouton <[email protected]>
Date:   Mon May 22 15:53:49 2023 +0200

chain: PrunedBlockDispatcher bugfix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants