lnd icon indicating copy to clipboard operation
lnd copied to clipboard

neutrinokitserver: Added unban peer feature

Open Chinwendu20 opened this issue 2 years ago • 26 comments
trafficstars

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:

image 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:

image

  • 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:

image

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:

image

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:

image

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

Expected output:

image

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

📝 Please see our Contribution Guidelines for further guidance.

Chinwendu20 avatar Apr 18 '23 06:04 Chinwendu20

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

ellemouton avatar Apr 20 '23 08:04 ellemouton

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.

Chinwendu20 avatar Apr 20 '23 10:04 Chinwendu20

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.

ellemouton avatar Apr 20 '23 10:04 ellemouton

Hello @ellemouton I believe I have worked on review now.

Chinwendu20 avatar Apr 22 '23 20:04 Chinwendu20

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.

Chinwendu20 avatar Apr 24 '23 10:04 Chinwendu20

Hi @Chinwendu20 - yes the merge commits need to please be removed. Perhaps take sometime looking into git fixup commits & how to autosquash them

ellemouton avatar Apr 24 '23 10:04 ellemouton

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/

guggero avatar Apr 24 '23 10:04 guggero

So helpful, thanks a lot @guggero Thank you @ellemouton

Chinwendu20 avatar Apr 24 '23 10:04 Chinwendu20

Is there a command to update the neutrino.yaml? Or I would have to do that manually

Chinwendu20 avatar Apr 24 '23 11:04 Chinwendu20

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).

guggero avatar Apr 24 '23 11:04 guggero

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:

image

So I took a cue from the DisconnectPeer RPC function since they both have similarities

Chinwendu20 avatar Apr 25 '23 06:04 Chinwendu20

I wonder why this error: image Maybe the neutrino pr need to merged first?

Chinwendu20 avatar May 02 '23 07:05 Chinwendu20

@positiveblue: review reminder @chinwendu20, remember to re-request review from reviewers when ready

lightninglabs-deploy avatar Oct 23 '23 08:10 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Oct 30 '23 00:10 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Oct 30 '23 01:10 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Oct 30 '23 02:10 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Oct 30 '23 03:10 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Oct 30 '23 04:10 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Oct 30 '23 05:10 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Oct 30 '23 06:10 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Oct 30 '23 07:10 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Oct 30 '23 08:10 lightninglabs-deploy

Closing due to inactivity

lightninglabs-deploy avatar Oct 30 '23 09:10 lightninglabs-deploy

!lightninglabs-deploy mute

yyforyongyu avatar Oct 30 '23 09:10 yyforyongyu

[!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.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in 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?

Share
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 @coderabbitai in 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 @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to 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.yaml file 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.

coderabbitai[bot] avatar May 21 '24 13:05 coderabbitai[bot]

Hello @ellemouton thanks a lot for the review, dropped a comment here: https://github.com/lightninglabs/neutrino/issues/253#issuecomment-2161713562

Chinwendu20 avatar Jun 11 '24 22:06 Chinwendu20