lnd
lnd copied to clipboard
neutrinokitserver: Added unban peer feature
Change Description
Fixes issue https://github.com/lightninglabs/neutrino/issues/253
Steps to Test
- Connect to a node that does not serve compact filter. To simulate this. Ensure these options in the Bitcoin configuration file of the full node connected to neutrino are commented out or do not exist:
# blockfilterindex=1
# peerblockfilters=1
- To confirm that your bitcoin node does not serve compact filters. Run this command:
bitcoin-cli getnetworkinfo
If your full node does not serve compact filter you should see this output:
In the output you should not see "COMPACT_FILTERS" in the "localservicesnames" key
- Build lnd with tags, neutrinorpc.
- Start lnd server. You should see the full Bitcoin node gets banned in lnd logs:

- Now, enable the full node to start serving compact filters. Change the bitcoin configuration file to start serving compact filters. Uncomment these options below:
blockfilterindex=1
peerblockfilters=1
- Stop the bitcoin daemon and start again
bitcoin-cli stop
Then
bitcoind
- To confirm that there is support for compact filters. Run this command:
bitcoin-cli getnetworkinfo
If your full node serves compact filters you should see this output:

There should be "COMPACT_FILTERS" in the "localservicesnames" key.
- Notice your peer still does not get unbanned even though the full node has started serving compact filters. This is because banned peers wait the full ban duration which by default is currently 24 hrs To confirm that your peer is still banned. Run this command:
lncli --no-macaroons neutrino isbanned <bitcoin node address>
Example of bitcoin address could be 127.0.0.1:8766. Where 127.0.0.1 is the host IP address of your Bitcoin node and 8766 is the port not rpc port (It confused me at first, lol) of your bitcoin node. It is optional and if not specified the default port would be used. If you did not specify a port in your configuration file that is not the default port that should not be a problem. Expected output:

To test the unbanPeer command. Run this command:
lncli neutrino unbanPeer <peer address>
You should see the full Bitcoin node gets unbanned in lnd logs:

- Notice your peer gets unbanned. To confirm this run this command:
lncli --no-macaroons neutrino isbanned <bitcoin address>
Expected output:

The peer has been unbanned and we do not have to wait for the ban duration period.
Associated PR in neutrino: https://github.com/lightninglabs/neutrino/pull/270
Pull Request Checklist
Testing
- [ ] Your PR passes all CI checks.
- [ ] Tests covering the positive and negative (error paths) are included.
- [ ] Bug fixes contain tests triggering the bug to prevent regressions.
Code Style and Documentation
- [x] The change obeys the Code Documentation and Commenting guidelines, and lines wrap at 80.
- [x] Commits follow the Ideal Git Commit Structure.
- [x] Any new logging statements use an appropriate subsystem and logging level.
- [ ] There is a change description in the release notes, or
[skip ci]in the commit message for small changes.
📝 Please see our Contribution Guidelines for further guidance.
Hi @Chinwendu20 - thanks for the PR
One thing that stands out from the commits is that you are making use off the new RPC endpoints before actually adding the proto definitions. This means that each commit individually will not compile - even though the end product might compile. So you need to first add the proto definitions, then implement the methods on the server side, and then you can add the client code on the lncli side.
Please also take a closer look at our contribution guidelines for commit titles and messages. I also see that the last commit fixes a mistake added in a prior commit - this should just be squashed so that the mistake never appears in the first place
Thank you so much for the review, I would reset the commits and apply them again. I need clarity on the below
- Are you asking that I should commit the proto changes first?
- I have gone through the guideline for commit message and I think I followed the guideline of including, package first: commit message. Are you asking that I should make the commit message more detailed?
Thank you.
yes the proto changes should be committed first because otherwise your first commit (the lncli one) does not compile right?
see the detail here. package first, short description for the title (ideally under 50 chars) and then you can add as much detail as you like in the commit body.
Hello @ellemouton I believe I have worked on review now.
I can see there are some merge commits as I was trying to update my branch. Would that be a problem? I am trying to figure out how to update my branch without creating merge commits.
Hi @Chinwendu20 - yes the merge commits need to please be removed. Perhaps take sometime looking into git fixup commits & how to autosquash them
I can see there are some merge commits as I was trying to update my branch. Would that be a problem? I am trying to figure out how to update my branch without creating merge commits.
What you are trying to do is called "rebasing". You want to rebase your local branch onto the latest version of master, that removes any merge commits and fixes conflicts. Here's a guide I found that explains rebases: https://www.freecodecamp.org/news/the-ultimate-guide-to-git-merge-and-git-rebase/
So helpful, thanks a lot @guggero Thank you @ellemouton
Is there a command to update the neutrino.yaml? Or I would have to do that manually
Is there a command to update the neutrino.yaml? Or I would have to do that manually
That file needs to be edited manually. It will then be used to generate some more code when running make rpc.
My suggestion for the new RPC would be:
- selector: neutrinorpc.NeutrinoKit.UnBanPeer
post: "/v2/neutrino/unban/{peer_address}"
body: "*"
This requires you to change peerAddress to peer_address in UnBanPeerRequest (since we use snake case in protobuf files).
Thank you @guggero . I changed "PeerAddres" to snake case but used "/v2/neutrino/unban/" as the url for UnBanPeer. Compiling it with the pattern you suggested gave this error:

So I took a cue from the DisconnectPeer RPC function since they both have similarities
I wonder why this error:
Maybe the neutrino pr need to merged first?
@positiveblue: review reminder @chinwendu20, remember to re-request review from reviewers when ready
Closing due to inactivity
Closing due to inactivity
Closing due to inactivity
Closing due to inactivity
Closing due to inactivity
Closing due to inactivity
Closing due to inactivity
Closing due to inactivity
Closing due to inactivity
Closing due to inactivity
!lightninglabs-deploy mute
[!IMPORTANT]
Review skipped
Auto reviews are limited to specific labels.
Labels to auto review (1)
- llm-review
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai generate interesting stats about this repository and render them as a table.@coderabbitai show all the console.log statements in this repository.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (invoked as PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Hello @ellemouton thanks a lot for the review, dropped a comment here: https://github.com/lightninglabs/neutrino/issues/253#issuecomment-2161713562