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

feat: update utp-rs dependency #1652

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

morph-dev
Copy link
Collaborator

@morph-dev morph-dev commented Jan 28, 2025

What was wrong?

It's possible for wrong Enr to be passed to utp library if it was changed recently.
See #1596 for more details.

How was it fixed?

The utp-rs library is updated (see ethereum/utp#136) so only peer id (NodeId) is required when receiving the utp packet, while entire peer (Enr) is passed when calling accept_with_cid.

The biggest change is in crates/portalnet/src/discovery.rs, where we now call find_enr only if Enr is unknown when we have to send them packet (which should rarely happen), instead of every time we receive packet.

Worth highlighting that due to the nature of #1596, we can't easily verify that this actually fixes it until it's deployed to the servers. I did some manual testing and I'm confident that this should fix it (but I plan to verify once this is merged and deployed).

To-Do

@morph-dev morph-dev self-assigned this Jan 28, 2025
@morph-dev morph-dev marked this pull request as ready for review January 28, 2025 21:25
Copy link
Member

@KolbyML KolbyML left a comment

Choose a reason for hiding this comment

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

Looks pretty good I am only concerned with cloning the enr twice in a hot path, and the specifics of renaming the UtpEnr struct, as EnrPeer sounds pretty broad and ambiguous if its only use is uTP


impl UtpEnr {
impl EnrPeer {
Copy link
Member

@KolbyML KolbyML Feb 3, 2025

Choose a reason for hiding this comment

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

Is this struct only going to be used with uTP or will it be used elsewhere, as we should be specific if the usecase is specific, if UtpEnr is going to start being used more broadly I think it is fine to rename it. EnrPeer is just extremely broad, so if it is still exclusive for utp maybe keeping the old name makes sense as it is more to the point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For me, UtpEnr sounds like a special/different version of Enr that is used for utp. But I understand your comment as well.

So I settled for UtpPeer. I think it's the cleanest.
Let me know if you don't like it, as I don't care that much and I'm willing to revert it back to UtpEnr.

Copy link
Member

Choose a reason for hiding this comment

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

I think UtpPeer looks good

Comment on lines 407 to 414
let peer = peer.clone();
let discv5 = Arc::clone(&self.discv5);
let target = target.0.clone();
let enr_cache = Arc::clone(&self.enr_cache);
let header_oracle = Arc::clone(&self.header_oracle);
let data = buf.to_vec();
tokio::spawn(async move {
match discv5.send_talk_req(target, Subnetwork::Utp, data).await {
let enr = match peer.peer() {
Some(enr) => enr.0.clone(),
Copy link
Member

Choose a reason for hiding this comment

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

we are already cloning the Enr above, shouldn't we be able to avoid cloning it twice?

Copy link
Member

@KolbyML KolbyML left a comment

Choose a reason for hiding this comment

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

:shipit: looks good

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.

2 participants