-
Notifications
You must be signed in to change notification settings - Fork 89
refactor(network): db executor communicates through channels #2120
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2120 +/- ##
==========================================
- Coverage 67.25% 65.78% -1.48%
==========================================
Files 136 136
Lines 17889 17900 +11
Branches 17889 17900 +11
==========================================
- Hits 12031 11775 -256
- Misses 4532 4839 +307
+ Partials 1326 1286 -40 ☔ View full report in Codecov by Sentry. |
6cdd91e
to
ecb746d
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: 0 of 4 files reviewed, 1 unresolved discussion
crates/papyrus_network/src/network_manager/mod.rs
line 3 at r1 (raw file):
mod swarm_trait; // TODO(shahak): Uncomment
Do not merge until all the PR stack is merged so that this will be uncommented
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 3 of 4 files at r1, all commit messages.
Reviewable status: 3 of 4 files reviewed, 2 unresolved discussions (waiting on @ShahakShama)
crates/papyrus_network/src/network_manager/mod.rs
line 307 at r1 (raw file):
Protocol::try_from(protocol_name).expect("Encountered unknown protocol"); let internal_query = protocol.bytes_query_to_protobuf_request(query); match protocol {
let (sender, receiver) = match protocol etc.
to reduce duplication
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: 3 of 4 files reviewed, 2 unresolved discussions (waiting on @eitanm-starkware)
crates/papyrus_network/src/network_manager/mod.rs
line 307 at r1 (raw file):
Previously, eitanm-starkware wrote…
let (sender, receiver) = match protocol etc.
to reduce duplication
This code is erased in #2122 . Is it ok if I don't fix this now to avoid rebases? or do you prefer I fix it nonetheless?
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 4 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion
crates/papyrus_network/src/network_manager/mod.rs
line 307 at r1 (raw file):
Previously, ShahakShama wrote…
This code is erased in #2122 . Is it ok if I don't fix this now to avoid rebases? or do you prefer I fix it nonetheless?
yeah
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 all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @eitanm-starkware)
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 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @asmaastarkware, @eitanm-starkware, and @ShahakShama)
-- commits
line 2 at r1:
I feel like making it generic is more important (or at least thinking that way made it easier for me to grok the PR)
Suggestion:
- ecb746d: refactor(network): make db executor generic over FetchBlockDataFromDb
This allows us to remove the concrete `Data` type.
crates/papyrus_network/src/db_executor/test.rs
line 52 at r1 (raw file):
} } }
WDYT?
Suggestion:
mut all_data = data_receiver.collect::<Vec<_>>() => {
assert_eq!(DataOrFin(None), all_data.pop().unwrap());
for (i, data) in all_data.into_iter().enumerate() {
assert_eq!(data.0.unwrap().block_header.block_number.0, i as u64);
}
}
crates/papyrus_network/src/network_manager/mod.rs
line 44 at r1 (raw file):
header_buffer_size: usize, sqmr_inbound_response_receivers: StreamHashMap<InboundSessionId, BoxStream<'static, Option<Bytes>>>,
Should we move this stream to utilize the new Stream design we discussed? As in move the concept of streaming entirely out of papyrus_network
.
Code quote:
sqmr_inbound_response_receivers:
StreamHashMap<InboundSessionId, BoxStream<'static, Option<Bytes>>>,
crates/papyrus_network/src/network_manager/mod.rs
line 288 at r1 (raw file):
fn handle_sqmr_behaviour_event(&mut self, event: sqmr::behaviour::ExternalEvent) { match event {
This function is nearly 100 lines. Can we have each branch call to a method?
Code quote:
match event {
crates/papyrus_network/src/network_manager/mod.rs
line 335 at r1 (raw file):
} } }
Is this going to remain in the future? with explicit handling for each protocol
Code quote:
match protocol {
Protocol::SignedBlockHeader => {
let (sender, receiver) = futures::channel::mpsc::channel::<
DataOrFin<SignedBlockHeader>,
>(self.header_buffer_size);
self.db_executor.register_query(internal_query, sender);
self.sqmr_inbound_response_receivers.insert(
inbound_session_id,
receiver
.map(|data| Some(Bytes::from(data)))
.chain(stream::once(ready(None)))
.boxed(),
);
}
Protocol::StateDiff => {
let (sender, receiver) = futures::channel::mpsc::channel::<
DataOrFin<StateDiffChunk>,
>(self.header_buffer_size);
self.db_executor.register_query(internal_query, sender);
self.sqmr_inbound_response_receivers.insert(
inbound_session_id,
receiver
.map(|data| Some(Bytes::from(data)))
.chain(stream::once(ready(None)))
.boxed(),
);
}
}
}
087e025
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: 2 of 4 files reviewed, 5 unresolved discussions (waiting on @asmaastarkware, @eitanm-starkware, and @matan-starkware)
Previously, matan-starkware wrote…
I feel like making it generic is more important (or at least thinking that way made it easier for me to grok the PR)
I didn't understand
crates/papyrus_network/src/network_manager/mod.rs
line 44 at r1 (raw file):
Previously, matan-starkware wrote…
Should we move this stream to utilize the new Stream design we discussed? As in move the concept of streaming entirely out of
papyrus_network
.
No. SG is based on a specific protobuf message that groups messages to streams. Also, here the responses are tied to some specific query in the networking level
crates/papyrus_network/src/network_manager/mod.rs
line 288 at r1 (raw file):
Previously, matan-starkware wrote…
This function is nearly 100 lines. Can we have each branch call to a method?
Added a TODO for now because I'm afraid of this conflicting with the future PRs
crates/papyrus_network/src/network_manager/mod.rs
line 335 at r1 (raw file):
Previously, matan-starkware wrote…
Is this going to remain in the future? with explicit handling for each protocol
No
087e025
to
7267f39
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 1 of 1 files at r2.
Reviewable status: 1 of 4 files reviewed, 4 unresolved discussions (waiting on @asmaastarkware, @eitanm-starkware, and @ShahakShama)
Previously, ShahakShama wrote…
I didn't understand
I don't think deleting Data
is the most important thing. I think making db executor generic is.
crates/papyrus_network/src/network_manager/mod.rs
line 44 at r1 (raw file):
Previously, ShahakShama wrote…
No. SG is based on a specific protobuf message that groups messages to streams. Also, here the responses are tied to some specific query in the networking level
Doesn't block the PR but I don't understand why papyrus_network
sometimes handles streams and sometimes doesn't. It would make more sense to me if the networking layer either has the generic capacity to handle a stream or no capacity and we always use SG.
crates/papyrus_protobuf/src/converters/state_diff.rs
line 94 at r2 (raw file):
auto_impl_into_and_try_from_vec_u8!(DataOrFin<StateDiffChunk>, protobuf::StateDiffsResponse); auto_impl_into_and_try_from_vec_u8!(DataOrFin<StateDiffChunk>, protobuf::StateDiffsResponse);
Suggestion:
auto_impl_into_and_try_from_vec_u8!(DataOrFin<StateDiffChunk>, protobuf::StateDiffsResponse);
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: 1 of 4 files reviewed, 4 unresolved discussions (waiting on @asmaastarkware, @eitanm-starkware, and @matan-starkware)
Previously, matan-starkware wrote…
I don't think deleting
Data
is the most important thing. I think making db executor generic is.
Oh. Changed the PR title. I prefer not touching the commits themselves and they will dissappear when we merge anyway
crates/papyrus_network/src/network_manager/mod.rs
line 44 at r1 (raw file):
Previously, matan-starkware wrote…
Doesn't block the PR but I don't understand why
papyrus_network
sometimes handles streams and sometimes doesn't. It would make more sense to me if the networking layer either has the generic capacity to handle a stream or no capacity and we always use SG.
I'll be happy to explain in huddle :)
crates/papyrus_protobuf/src/converters/state_diff.rs
line 94 at r2 (raw file):
auto_impl_into_and_try_from_vec_u8!(DataOrFin<StateDiffChunk>, protobuf::StateDiffsResponse); auto_impl_into_and_try_from_vec_u8!(DataOrFin<StateDiffChunk>, protobuf::StateDiffsResponse);
Yes, I fixed it already. This was what caused the tests to fail
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 r3, 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @asmaastarkware, @eitanm-starkware, and @ShahakShama)
crates/papyrus_network/src/network_manager/mod.rs
line 44 at r1 (raw file):
Previously, ShahakShama wrote…
I'll be happy to explain in huddle :)
Honestly I think I need this written out. You've tried to explain this to me a couple times already
7267f39
to
15cbec4
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 1 of 3 files at r5, 3 of 3 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @asmaastarkware and @eitanm-starkware)
* refactor(network): db executor communicates through channels * refactor(network): fix cr comments * refactor(network): db executor is removed from NetworkManager and runs in a separate task (#2122) * refactor(network): db executor is removed from NetworkManager and runs in a separate task * test(network): return network manager tests (#2124)
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: 1 of 9 files reviewed, 1 unresolved discussion (waiting on @eitanm-starkware and @matan-starkware)
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: 1 of 9 files reviewed, 1 unresolved discussion
This change is