-
Notifications
You must be signed in to change notification settings - Fork 83
fix(l1): ignore unknown protocols in capability exchange #3543
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
Lines of code reportTotal lines added: Detailed view
|
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.
Pull Request Overview
This PR refactors how protocol identifiers are stored and matched, switching from strings to fixed-size byte arrays to allow unknown protocols to be ignored rather than causing failures.
- Changed
Capability.protocol
from&'static str
to[u8; 8]
with padding - Updated all matching sites to call the new
protocol()
method - Added helper
pad_right
, updated RLP (de)serialization, and new decode tests
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
crates/networking/rpc/admin/peers.rs | Switched to calling cap.protocol() and refactored test setup to use Capability::eth() and snap() |
crates/networking/p2p/rlpx/p2p.rs | Introduced pad_right , changed protocol field to [u8; 8] , updated RLP (de)serialization, and added tests |
crates/networking/p2p/rlpx/connection/server.rs | Updated server match clauses to use the new protocol() accessor |
Comments suppressed due to low confidence (1)
crates/networking/p2p/rlpx/p2p.rs:346
- You might add a test for decoding an unknown protocol (e.g., a custom >8-byte name) to verify that the code correctly stores arbitrary bytes and handles invalid lengths.
fn test_decode_capability() {
…#3543) **Motivation** Failing due to a peer having extra capabilities can make us lose exceptional peers. Hence, we want to ignore any extra capabilities they have. **Description** This PR changes `Capability.protocol` to be an 8-byte array instead of a string, allowing us to store any string we receive.
Motivation
Failing due to a peer having extra capabilities can make us lose exceptional peers. Hence, we want to ignore any extra capabilities they have.
Description
This PR changes
Capability.protocol
to be an 8-byte array instead of a string, allowing us to store any string we receive.