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

Adjust ping parameters to improve tor stability #8762

Merged
merged 3 commits into from
May 22, 2024

Conversation

ProofOfKeags
Copy link
Collaborator

@ProofOfKeags ProofOfKeags commented May 15, 2024

Change Description

Here we do the following things to increase stability with tor peers:

  1. Reduce maximum pong payload size to ease bandwidth consumption
  2. Make PingManager.Stop infallible so that it doesn't pollute the logs with false errors in the case where we fail to send or receive the init message.
  3. If we detect that the connection with our peer is over tor (heuristic), then we will triple the timeout parameters to give them more time to respond.

Steps to Test

Run this patch with a bunch of tor peers and see if it improves the long term stability of those peers.

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.

Copy link

coderabbitai bot commented May 15, 2024

Important

Review Skipped

Auto reviews are disabled on this repository.

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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@saubyk saubyk added this to the v0.18.0 milestone May 15, 2024
@Liongrass
Copy link
Contributor

I ran this and it does indeed fix the problem I was seeing. Thank you!

@ProofOfKeags ProofOfKeags marked this pull request as ready for review May 16, 2024 15:23
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.

lgtm! 🚢

peer/brontide.go Outdated Show resolved Hide resolved
peer/brontide.go Outdated Show resolved Hide resolved
@Liongrass
Copy link
Contributor

I'm running this now, and so far so good! Will report back in the morning!

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 🐠

peer/brontide.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

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

LGTM ⚡, with a nit (+ the helper function)

peer/ping_manager.go Outdated Show resolved Hide resolved
// when the PingManager is running.
func (m *PingManager) Stop() error {
// Stop interrupts the goroutines that the PingManager owns.
func (m *PingManager) Stop() {
if m.pingTicker == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

q: Do we still need ths conditional here? Would it ever be hit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It turns out, yes. Testing this code reveals that if there is a timeout during the init process of the Brontide, then we call Disconnect before the ping manager is ever started. Since Start is what initializes the Timer this will be nil at that point.

Copy link
Contributor

@Chinwendu20 Chinwendu20 left a comment

Choose a reason for hiding this comment

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

Nice work. left some nits and qs

peer/brontide.go Outdated
@@ -1258,15 +1258,13 @@ func (p *Brontide) Disconnect(reason error) {

p.log.Infof(err.Error())

// Stop ping manager before closing TCP connection
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: missing full stop

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fwiw, as far as I can tell, the full-stop rule is only important for godocs since it affects the godoc rendering semantics. In-line comments like this aren't rendered and so I don't think it matters, but others may know things that I don't.

CC @ellemouton @yyforyongyu

peer/brontide.go Outdated Show resolved Hide resolved
peer/brontide.go Outdated Show resolved Hide resolved
peer/brontide.go Outdated Show resolved Hide resolved
@ProofOfKeags
Copy link
Collaborator Author

Not sure what to make of the unit-race CI check failing here.

@Roasbeef
Copy link
Member

Not sure what to make of the unit-race CI check failing here.

Appears to be a known flake.

@Roasbeef Roasbeef merged commit 64639fb into lightningnetwork:master May 22, 2024
25 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants