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

Speed up ENR update #196

Merged
merged 9 commits into from
Jun 27, 2023
Merged

Speed up ENR update #196

merged 9 commits into from
Jun 27, 2023

Conversation

ackintosh
Copy link
Member

@ackintosh ackintosh commented Jun 18, 2023

Description

closes #144.

By this PR, we send PING immediately when the session is established if the direction is Outgoing.

Notes & open questions

I have tested this PR with the enr-update test plan. You can run the test plan locally.
ackintosh/discv5-testground#109

Also I have tested with lighthouse (current unstable Lighthouse/v4.2.0-cc780aa). The ENR update had happened within 113sec avg from start-up.

Jun 25 05:33:06.794 INFO Lighthouse started, version: Lighthouse/v4.2.0-cc780aa, module: lighthouse:579
...
...
Jun 25 05:33:50.189 INFO Address updated, udp_port: 3365, ip: 133.32.132.191, service: libp2p, module: lighthouse_network::discovery:1012

Change checklist

  • Self-review
  • Documentation updates if relevant
  • Tests if relevant

@ackintosh ackintosh changed the title [WIP] Speed up ENR update Speed up ENR update Jun 25, 2023
@ackintosh ackintosh marked this pull request as ready for review June 25, 2023 05:58
@ackintosh ackintosh requested review from divagant-martian and AgeManning and removed request for divagant-martian June 25, 2023 05:58
src/service.rs Outdated
Comment on lines 1397 to 1403
self.connection_updated(node_id, ConnectionStatus::Connected(enr.clone(), direction));

// PING immediately if the direction is outgoing. This allows us to receive a PONG without
// waiting for the ping_interval, making ENR updates faster.
if matches!(direction, ConnectionDirection::Outgoing) {
self.send_ping(enr, None);
}
Copy link
Collaborator

@divagant-martian divagant-martian Jun 25, 2023

Choose a reason for hiding this comment

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

looking to reduce the clone I suggest moving this to the connection_updated fn. This way the clone is only done when the direction is outgoing instead of every time ackintosh#2

Copy link
Member Author

Choose a reason for hiding this comment

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

I have merged your suggestion, thank you!

…rnative

suggested alternative that reduces cloning
@AgeManning
Copy link
Member

Yeah nice.

I think we should move this statement into the match just below it tho, so that we only ping peers that manage to make it into the routing table.

The reason being, is I'm a little worried that if we do a FINDNODE to a malicious peer, that can direct to us to connect (in an outgoing direction) to a bunch of other malicious peers that want us to edit our IP address.

If we limit this PING approach to only peers that make it into our routing table we get the added security measures that are applied there, like bucket and table limits which would help mitigate this scenario.

@divagant-martian
Copy link
Collaborator

@ackintosh can you test this works as expected in testground? I see no reason to believe it won't but let's be sure. I'll merge after your confirmation 🎉

@ackintosh
Copy link
Member Author

ackintosh commented Jun 27, 2023

Yeah, I was just testing this again. I have tested the latest change with Testground and Lighthouse, and confirmed that this works as expected. 🙆‍♂️

@divagant-martian divagant-martian merged commit a9ded04 into sigp:master Jun 27, 2023
@ackintosh ackintosh deleted the enr-update branch June 27, 2023 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Speed up ENR update
3 participants