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

cmd/utils,p2p: enable discv5 by default #30327

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,9 @@ var (
DiscoveryV5Flag = &cli.BoolFlag{
Name: "discovery.v5",
Aliases: []string{"discv5"},
Usage: "Enables the experimental RLPx V5 (Topic Discovery) mechanism",
Usage: "Enables the V5 discovery mechanism",
Category: flags.NetworkingCategory,
Value: true,
}
NetrestrictFlag = &cli.StringFlag{
Name: "netrestrict",
Expand Down
5 changes: 3 additions & 2 deletions p2p/discover/v4_udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,9 @@ func (t *UDPv4) readLoop(unhandled chan<- ReadPacket) {
}
return
}
if t.handlePacket(from, buf[:nbytes]) != nil && unhandled != nil {
if err := t.handlePacket(from, buf[:nbytes]); err != nil && unhandled == nil {
t.log.Debug("Bad discv4 packet", "addr", from, "err", err)
} else if err != nil && unhandled != nil {
Comment on lines +550 to +552
Copy link
Contributor

Choose a reason for hiding this comment

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

This changes the semantics. Previously, if there was an error, we did the log.Debug unconditioally. Now we only do if it unhandled == nil.

Shouldn't you do something like this?

Suggested change
if err := t.handlePacket(from, buf[:nbytes]); err != nil && unhandled == nil {
t.log.Debug("Bad discv4 packet", "addr", from, "err", err)
} else if err != nil && unhandled != nil {
if err := t.handlePacket(from, buf[:nbytes]); err != nil {
t.log.Debug("Bad discv4 packet", "addr", from, "err", err)
if unhandled != nil {

Copy link
Member Author

@lightclient lightclient Aug 20, 2024

Choose a reason for hiding this comment

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

Right so that was actually the goal. Every discv5 message goes through unhandled, which means every discv5 message causes a "Bad discv4 packet" log to print. That doesn't seem correct.

select {
case unhandled <- ReadPacket{buf[:nbytes], from}:
default:
Expand All @@ -564,7 +566,6 @@ func (t *UDPv4) handlePacket(from netip.AddrPort, buf []byte) error {

rawpacket, fromKey, hash, err := v4wire.Decode(buf)
if err != nil {
t.log.Debug("Bad discv4 packet", "addr", from, "err", err)
return err
}
packet := t.wrapPacket(rawpacket)
Expand Down