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

blockcache: add blockcache pkg and pass it to all backends #5156

Merged
merged 11 commits into from
Apr 29, 2021

Conversation

ellemouton
Copy link
Collaborator

@ellemouton ellemouton commented Mar 30, 2021

This PR adds a blockcache package. An lnd-wide blockcache is instantiated and passed to which ever chain backend is being used.

Addresses step 1 of #5075

@ellemouton
Copy link
Collaborator Author

fyi @wpaulino

@wpaulino wpaulino self-requested a review March 30, 2021 20:05
@Roasbeef Roasbeef added this to the 0.13.0 milestone Mar 31, 2021
@Roasbeef Roasbeef added enhancement Improvements to existing features / behaviour optimization P2 should be fixed if one has time pruning labels Mar 31, 2021
@Roasbeef Roasbeef removed the P2 should be fixed if one has time label Mar 31, 2021
@Roasbeef Roasbeef removed this from the 0.13.0 milestone Mar 31, 2021
Copy link
Contributor

@wpaulino wpaulino left a comment

Choose a reason for hiding this comment

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

Great work! I've been running this along with the pruned node branch for a few days and it's been working well.

config.go Outdated Show resolved Hide resolved
blockcache/blockcache_test.go Show resolved Hide resolved
lnd.go Show resolved Hide resolved
chainntnfs/neutrinonotify/neutrino.go Outdated Show resolved Hide resolved
@ellemouton
Copy link
Collaborator Author

Thanks for the review @wpaulino 😊 Updated 👍

Copy link
Collaborator

@carlaKC carlaKC left a comment

Choose a reason for hiding this comment

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

Awesome optimization, looking really good @ellemouton!

blockcache/blockcache.go Outdated Show resolved Hide resolved
blockcache/blockcache_test.go Outdated Show resolved Hide resolved
blockcache/blockcache_test.go Outdated Show resolved Hide resolved
sample-lnd.conf Outdated Show resolved Hide resolved
routing/chainview/bitcoind.go Outdated Show resolved Hide resolved
routing/chainview/bitcoind.go Show resolved Hide resolved
@ellemouton
Copy link
Collaborator Author

Thanks @carlaKC 🚀 Updated 👍

@ellemouton ellemouton changed the title [WIP] blockcache: add blockcache pkg and pass it to all backends blockcache: add blockcache pkg and pass it to all backends Apr 1, 2021
blockcache/blockcache.go Outdated Show resolved Hide resolved
@ellemouton ellemouton force-pushed the blockcache branch 2 times, most recently from e6db16a to c149bb3 Compare April 12, 2021 06:19
Copy link
Collaborator

@carlaKC carlaKC left a comment

Choose a reason for hiding this comment

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

LGTM! 🥇

@wpaulino
Copy link
Contributor

cc @Roasbeef

@Roasbeef
Copy link
Member

Needs a rebase!

@ellemouton
Copy link
Collaborator Author

Will be afk till Tuesday evening. Will rebase then 💪

@ellemouton
Copy link
Collaborator Author

Cool beans, rebased 👍

This commit adds a new blockcache package along with the GetBlock method
to be used along with the blockcache.
This commit adds block cache size to the main lnd config along with the
chainreg config.
This commit makes the blockcache available to BtcWallet so that any
GetBlock call made to BtcWallet is wrapped by the blockcache GetBlock
call.
This commit adds the block cache to the BitcoindFilteredChainView struct
and wraps its GetBlock function so that block cache is used.
This commit makes the block cache available to BtcdFilteredChainView and
wraps its GetBlock method so that the block cache is used.
This commit adds a blockcache pointer to BitcoindNotifier and wraps its
GetBlock method so that the block cache is used.
This commit adds gives BtcdNotifier access to the block cache and wraps
its GetBlock method so that it uses the block cache.
This commit initializes the nwutrino backend with the lnd blockcache so
that the two can share a block cache instead of each having its own.
This commit ensures that for the neutrino implementation of
lnwallet.BlockChainIO, the neutrino GetBlock method is called directly
(since it already uses the blockcache). It also ensures that the block
cache mutex for the given hash is locked before the call to GetBlock.
This commit adds the block cache to the CfFilteredChainView struct
and wraps its GetBlock function so that block cache mutex map is used
when the call to neutrino's GetBlock function is called.
This commit adds gives BtcdNotifier access to the block cache and wraps
its GetBlock method so that the block cache's mutex map for the specific
hash is used.
@Roasbeef Roasbeef merged commit 2a2bc64 into lightningnetwork:master Apr 29, 2021
@ellemouton ellemouton deleted the blockcache branch April 30, 2021 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements to existing features / behaviour optimization pruning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants