Skip to content

feat(portalnet): handle content that doesn't depend on distance to content #1859

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

Merged
merged 2 commits into from
May 28, 2025

Conversation

morph-dev
Copy link
Collaborator

What was wrong?

The portalnet crate didn't handle the content that doesn't depend on distance to content (e.g. ephemeral headers).

Some examples:

  • use random gossip when:
    • receiving content via Offer
    • during PutContent json rpc
  • selecting peers when initiating FindContent
    • we should select random peers
  • deciding whether to poke the content to the peer
    • before, we would use radius to decide if peer should store the content, which doesn't apply in this case
  • replying to FindContent requests (see discord discussion)
    • we should send empty peer list

How was it fixed?

We now handle all cases from above.

I extracted some/most of the logic from crates/portalnet/src/put_content.rs and put it in crates/portalnet/src/gossip/neighborhood.rs.

Added various gossip unit tests.

@morph-dev morph-dev requested review from carver and KolbyML May 26, 2025 14:05
@morph-dev morph-dev self-assigned this May 26, 2025
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: PR looks very good

Comment on lines +14 to +15
mod neighborhood;
mod random;
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't we put these above imports?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I remember that I was seeing them go under imports, but I can't find where. All that I found now is that there is no strict rule or even strong recommentation.

Then I checked some of the popular crates and it's not easy to find mod.rs files that have similar structure, but here are few that do it this way:

I also checked our code base and it seems that we are using both. So I'm just going to leave it as is. If we agree to use one style over the other, we should go and clean up entire codebase (but considering that rust core is doing imports first, I would prefer that one).

@morph-dev morph-dev merged commit cc9c5f5 into ethereum:master May 28, 2025
16 checks passed
@morph-dev morph-dev deleted the random_gossip branch May 28, 2025 09:46
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