-
Notifications
You must be signed in to change notification settings - Fork 89
feat(network): register_broadcast_subscriber receives any type with TryFrom/Into<Bytes> #2001
feat(network): register_broadcast_subscriber receives any type with TryFrom/Into<Bytes> #2001
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2001 +/- ##
==========================================
- Coverage 71.60% 70.16% -1.45%
==========================================
Files 129 131 +2
Lines 16751 17092 +341
Branches 16751 17092 +341
==========================================
- Hits 11995 11992 -3
- Misses 3417 3774 +357
+ Partials 1339 1326 -13 ☔ View full report in Codecov by Sentry. |
7e0eb65
to
9869d04
Compare
987de80
to
a349790
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @dan-starkware and @ShahakShama)
crates/papyrus_network/src/network_manager/mod.rs
line 114 at r1 (raw file):
where T: TryFrom<Bytes>, Bytes: From<T>,
So this means that we handle deserialization errors T: TryFrom<Bytes>
but we expect serialization to be infallible Bytes: From<T>
?
Code quote:
T: TryFrom<Bytes>,
Bytes: From<T>,
crates/papyrus_network/src/network_manager/mod.rs
line 494 at r1 (raw file):
pub type ReportCallback = Box<dyn Fn() + Send>; // TODO(shahak): Make this generic in a type that implements TryFrom<Bytes> and Into<Bytes>.
Can this be removed? Do we not need to specify here Into/TryFrom on T?
Code quote:
// TODO(shahak): Make this generic in a type that implements TryFrom<Bytes> and Into<Bytes>.
crates/papyrus_network/src/network_manager/mod.rs
line 506 at r1 (raw file):
Receiver<(Bytes, ReportCallback)>, fn((Bytes, ReportCallback)) -> (Result<T, E>, ReportCallback), >,
This is quite ugly. Maybe we should have a comment explaining the types?
Code quote:
pub struct BroadcastSubscriberChannels<T, E> {
pub messages_to_broadcast_sender: With<
Sender<Bytes>,
Bytes,
T,
Ready<Result<Bytes, SendError>>,
fn(T) -> Ready<Result<Bytes, SendError>>,
>,
pub broadcasted_messages_receiver: Map<
Receiver<(Bytes, ReportCallback)>,
fn((Bytes, ReportCallback)) -> (Result<T, E>, ReportCallback),
>,
crates/papyrus_network/src/network_manager/test.rs
line 482 at r1 (raw file):
let mut broadcasted_messages_receiver = network_manager .register_broadcast_subscriber::<Bytes>(topic.clone(), BUFFER_SIZE)
So does this mean that we are converting the incoming Vec<u8>
into Bytes
? Should we try something with actual deserialization?
Code quote:
::<Bytes>
…ryFrom/Into<Bytes>
a349790
to
549cd1f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @dan-starkware and @matan-starkware)
crates/papyrus_network/src/network_manager/mod.rs
line 114 at r1 (raw file):
Previously, matan-starkware wrote…
So this means that we handle deserialization errors
T: TryFrom<Bytes>
but we expect serialization to be infallibleBytes: From<T>
?
Yes
crates/papyrus_network/src/network_manager/mod.rs
line 494 at r1 (raw file):
Previously, matan-starkware wrote…
Can this be removed? Do we not need to specify here Into/TryFrom on T?
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 506 at r1 (raw file):
Previously, matan-starkware wrote…
This is quite ugly. Maybe we should have a comment explaining the types?
clippy agrees with you 😅
Is now better?
crates/papyrus_network/src/network_manager/test.rs
line 482 at r1 (raw file):
Previously, matan-starkware wrote…
So does this mean that we are converting the incoming
Vec<u8>
intoBytes
? Should we try something with actual deserialization?
Yes. In a future PR I did an e2e test for the broadcast and there I putted a "real" deserialization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dan-starkware and @ShahakShama)
crates/papyrus_network/src/network_manager/mod.rs
line 506 at r1 (raw file):
Previously, ShahakShama wrote…
clippy agrees with you 😅
Is now better?
Matan Clippy Markind
It's better. It still feels like there is a lot of type complexity, but I also feel like reducing that would mean a significant change in approach, which I am not asking for.
This change is