8000 [p2p] Add `p2p::collector` by BrendanChou · Pull Request #1205 · commonwarexyz/monorepo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[p2p] Add p2p::collector #1205

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

[p2p] Add p2p::collector #1205

wants to merge 7 commits into from

Conversation

BrendanChou
Copy link
Collaborator
@BrendanChou BrendanChou commented Jul 3, 2025

Fixes #1114

Work-in-progress

TODO:

  • Currently sends the Request::commitment() to each peer, but doesn't change the message on a per-peer basis. Perhaps instead of Commitable there must be a new, similar Shardable trait that can produce a new message/digest when Shardable::shard(self, shard_by: Self::ShardBy) -> Self::Shard is called on the item.
  • Tests

/// Interface for the application that originates messages.
pub trait Originator: Clone + Send + 'static {
type PublicKey: PublicKey;
type ID: Debug + Send + 'static;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use Array here for consistency elsewhere in the codebase?

Like:

/// Type used to uniquely identify data.
type Key: Array;

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes me wonder if resolver should also be considered a p2p/utils (given it is of the same ~complexity as collector)?

Or we make collector standalone?

Copy link
Contributor

Choose a reason for hiding this comment

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

Given that broadcast is also standalone, maybe collector should also be for now.

fn send(
&mut self,
message: Self::Message,
transformer: fn(Self::Message, Self::PublicKey) -> Bytes,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should instead be:

send(PublicKey, message)

(can call commitment() on message to use for tracking outstanding).

Copy link
Contributor

Choose a reason for hiding this comment

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

This may also make it simpler to manage the message (to avoid putting it in a big struct and then pulling it apart into bytes during send).

fn send(&mut self, message: Self::Message) -> impl Future<Output = ()> + Send;

/// Peek at the collected responses for a given ID.
fn peek(
Copy link
Contributor

Choose a reason for hiding this comment

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

If we store received messages in some sort of order, could be much more efficient to peek at indices (to avoid so much memory allocation).

Copy link
codecov bot commented Jul 4, 2025

Codecov Report

Attention: Patch coverage is 0% with 131 lines in your changes missing coverage. Please review.

Project coverage is 90.30%. Comparing base (e9e0731) to head (b0c3003).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
p2p/src/collection/actor/engine.rs 0.00% 108 Missing ⚠️
p2p/src/collection/actor/ingress.rs 0.00% 23 Missing ⚠️
@@            Coverage Diff             @@
##             main    #1205      +/-   ##
==========================================
- Coverage   91.28%   90.30%   -0.98%     
==========================================
  Files         216      220       +4     
  Lines       58364    52790    -5574     
==========================================
- Hits        53278    47673    -5605     
- Misses       5086     5117      +31     
Files with missing lines Coverage Δ
p2p/src/collection/actor/ingress.rs 0.00% <0.00%> (ø)
p2p/src/collection/actor/engine.rs 0.00% <0.00%> (ø)

... and 169 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e9e0731...b0c3003. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

[p2p/utils] Add manager
2 participants
0