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

neutrinokitserver: Added unban peer feature #7606

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Chinwendu20
Copy link
Contributor

@Chinwendu20 Chinwendu20 commented Apr 18, 2023

Change Description

Fixes issue lightninglabs/neutrino#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: lightninglabs/neutrino#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 Chinwendu20 marked this pull request as draft April 18, 2023 06:36
@Chinwendu20 Chinwendu20 changed the title [WIP]neutrinokitserver: Added unban peer feature neutrinokitserver: Added unban peer feature Apr 19, 2023
@Chinwendu20 Chinwendu20 marked this pull request as ready for review April 19, 2023 16:32
@Chinwendu20 Chinwendu20 force-pushed the addUnBan branch 2 times, most recently from 98ad4fb to 5c88b17 Compare April 19, 2023 17:42
@ellemouton
Copy link
Collaborator

ellemouton commented Apr 20, 2023

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

@Chinwendu20
Copy link
Contributor Author

Chinwendu20 commented Apr 20, 2023

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.

@ellemouton
Copy link
Collaborator

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.

@Chinwendu20 Chinwendu20 force-pushed the addUnBan branch 2 times, most recently from e8fe58a to 8bfca7e Compare April 22, 2023 20:25
@Chinwendu20
Copy link
Contributor Author

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

@Chinwendu20
Copy link
Contributor Author

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 Chinwendu20 requested a review from ellemouton April 24, 2023 10:14
@ellemouton
Copy link
Collaborator

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

@ellemouton ellemouton removed their request for review April 24, 2023 10:17
@guggero
Copy link
Collaborator

guggero commented Apr 24, 2023

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/

@Chinwendu20
Copy link
Contributor Author

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

@Chinwendu20
Copy link
Contributor Author

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

@guggero
Copy link
Collaborator

guggero commented Apr 24, 2023

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

@lightninglabs-deploy
Copy link

Closing due to inactivity

9 similar comments
@lightninglabs-deploy
Copy link

Closing due to inactivity

@lightninglabs-deploy
Copy link

Closing due to inactivity

@lightninglabs-deploy
Copy link

Closing due to inactivity

@lightninglabs-deploy
Copy link

Closing due to inactivity

@lightninglabs-deploy
Copy link

Closing due to inactivity

@lightninglabs-deploy
Copy link

Closing due to inactivity

@lightninglabs-deploy
Copy link

Closing due to inactivity

@lightninglabs-deploy
Copy link

Closing due to inactivity

@lightninglabs-deploy
Copy link

Closing due to inactivity

@yyforyongyu
Copy link
Member

!lightninglabs-deploy mute

Copy link
Contributor

coderabbitai bot commented May 21, 2024

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.

Copy link
Collaborator

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

Nice and clean! Almost there 👍

@@ -225,6 +225,51 @@ func getCFilter(ctx *cli.Context) error {
return nil
}

var unbanPeerCommand = cli.Command{
Name: "unbanPeer",
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/unbanPeer/unbanpeer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks just that unban and peer are two separate words so I was following the convention

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah but see how the other commands are done, for example addpeer


// Indicates if the peer to be unbanned should be connected as a
// permanent peer.
bool permanent = 2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we make the name more descriptive? maybe something like perm_connect? just a suggestion.

Action: actionDecorator(unbanPeer),
Flags: []cli.Flag{
cli.BoolFlag{
Name: "permanent",
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe permconnect or something to make it more clear this has to do with how we connect to the peer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will change to permconnect, thanks.

// Display the command's help message if we do not have the expected
// number of arguments/flags.
if ctx.NArg() != 1 || ctx.NumFlags() > 1 {
return cli.ShowCommandHelp(ctx, "unbanpeer")
Copy link
Collaborator

Choose a reason for hiding this comment

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

this doesnt work cause it doesnt match the command name. Suggest changing the command name to this though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, thanks!

},
}

func unbanPeer(ctx *cli.Context) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggest: unbanNeutrinoPeer

Name: "permanent",
Usage: "indicates if the peer to be unbanned should " +
"be connected as a permanent peer. If set, " +
"it connects as a permanent peer",
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: the second sentence isnt needed imo. It just repeats the first sentence

* [Added unbanPeer command](https://github.com/lightningnetwork/lnd/pull/7606/).
This would enable unbanning and connecting to a previously banned peer using
the lncli command.

Copy link
Collaborator

Choose a reason for hiding this comment

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

can move these to 0.18.1 now :)

go.mod Outdated
@@ -208,3 +208,5 @@ replace google.golang.org/protobuf => github.com/lightninglabs/protobuf-go-hex-d
go 1.21.4

retract v0.0.2

replace github.com/lightninglabs/neutrino => github.com/Chinwendu20/neutrino v0.0.0-20240514174050-3275e33e5504
Copy link
Collaborator

Choose a reason for hiding this comment

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

can point to the merge commit instead now so that the ci can run against latest version 👍

Comment on lines 262 to 265
message UnbanPeerResponse {
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think the general pattern we are aiming towards with responses is to include a string status so that the user sees some sort of success message instead of just an empty JSON struct.

See message BumpFeeResponse { for an example of this

@Chinwendu20
Copy link
Contributor Author

Hello @ellemouton thanks a lot for the review, dropped a comment here: lightninglabs/neutrino#253 (comment)

@Chinwendu20 Chinwendu20 force-pushed the addUnBan branch 2 times, most recently from 9b88479 to b4437e8 Compare June 12, 2024 10:41
Chinwendu20 and others added 5 commits June 12, 2024 14:48
Signed-off-by: Ononiwu Maureen <[email protected]>
Example usage:

lncli neutrino unBanPeer <peer node address>

Signed-off-by: Ononiwu Maureen <[email protected]>
Signed-off-by: Ononiwu Maureen <[email protected]>
@Chinwendu20 Chinwendu20 requested a review from ellemouton June 12, 2024 15:39
@ellemouton ellemouton removed their request for review August 12, 2024 06:58
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 neutrino Lightweight neutrino backend-type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants