-
Notifications
You must be signed in to change notification settings - Fork 248
feat: Allow allowlisted peers to bypass gater blocks #3045
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
Conversation
Summary of ChangesHello @tac0turtle, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new feature that allows specific, pre-configured peers to bypass the standard libp2p connection gater blocks. This is particularly useful for maintaining stable connections with critical network participants, such as sequencers, even if their peer scoring might otherwise lead to them being blocked. The implementation involves a custom gater that prioritizes an allowlist, ensuring that designated peers can always connect. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Claude finished @tac0turtle's task in 2m 13s —— View job Code Review CompleteI've completed a comprehensive review of this PR. The implementation is solid and well-structured. Here are my findings: ✅ Strengths
🔍 Issues and Recommendations1. Inconsistent Bypass Logic in
|
|
The latest Buf updates on your PR. Results from workflow CI / buf-check (pull_request).
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces an allowlistGater to ensure connections to specified peers can bypass libp2p's connection gating, which is a valuable feature for maintaining connectivity to critical nodes like sequencers. The implementation is generally solid, with a new gater implementation and corresponding tests.
My review includes two main points for pkg/p2p/client.go:
- A suggestion to simplify the code in the
listenfunction by removing a redundant check. - A more critical observation about a design issue where pre-configured hosts passed via
NewClientWithHostwill not use the new allowlist functionality. This could be problematic if that function is used in production-like scenarios.
Overall, the changes are a good step forward. Addressing the identified issues will improve the robustness and clarity of the implementation.
| return c.startWithHost(ctx, c.host) | ||
| } | ||
|
|
||
| c.configureHostGater() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling configureHostGater() here is correct for the case where the client creates its own host. However, the logic path for pre-injected hosts (the if c.host != nil block above) completely bypasses this new allowlist functionality. If NewClientWithHost is used in scenarios that require the allowlist (like connecting to a sequencer), this will not work as expected.
This is a design issue that should be addressed. A potential solution could involve refactoring how hosts are injected, perhaps by moving gater configuration into NewClient and adjusting NewClientWithHost and its callers to correctly create the host with the configured gater.
| hostGater := c.hostGater | ||
| if hostGater == nil { | ||
| hostGater = c.gater | ||
| } | ||
| return libp2p.New( | ||
| libp2p.ListenAddrs(maddr), | ||
| libp2p.Identity(c.privKey), | ||
| libp2p.ConnectionGater(hostGater), | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic to select the gater can be simplified. Since configureHostGater() is called before listen() and always initializes c.hostGater, the check for nil is redundant. You can directly use c.hostGater when creating the new libp2p host.
return libp2p.New(
libp2p.ListenAddrs(maddr),
libp2p.Identity(c.privKey),
libp2p.ConnectionGater(c.hostGater),
)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3045 +/- ##
==========================================
+ Coverage 56.17% 56.22% +0.04%
==========================================
Files 118 119 +1
Lines 12066 12109 +43
==========================================
+ Hits 6778 6808 +30
- Misses 4543 4555 +12
- Partials 745 746 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Overview
Implement custom gater in order to bypass so we can try to reconnect to a sequencer