Skip to content
This repository has been archived by the owner on Dec 26, 2024. It is now read-only.

refactor(network): db executor communicates through channels #2121

Merged
merged 3 commits into from
Jun 25, 2024

Conversation

ShahakShama
Copy link
Contributor

@ShahakShama ShahakShama commented Jun 19, 2024

  • refactor(network): remove Data from db executor
  • refactor(network): db executor communicates through channels

This change is Reviewable

@ShahakShama ShahakShama changed the base branch from main to shahak/remove_data June 19, 2024 03:42
Copy link

codecov bot commented Jun 19, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 84 lines in your changes missing coverage. Please review.

Project coverage is 64.37%. Comparing base (15cbec4) to head (bb9be89).

Current head bb9be89 differs from pull request most recent head f69f005

Please upload reports for the commit f69f005 to get more accurate results.

Files Patch % Lines
crates/papyrus_network/src/network_manager/mod.rs 0.00% 66 Missing ⚠️
crates/papyrus_network/src/db_executor/mod.rs 75.67% 12 Missing and 6 partials ⚠️
Additional details and impacted files
@@                  Coverage Diff                   @@
##           shahak/remove_data    #2121      +/-   ##
======================================================
- Coverage               64.39%   64.37%   -0.03%     
======================================================
  Files                     136      136              
  Lines                   17870    17941      +71     
  Branches                17870    17941      +71     
======================================================
+ Hits                    11508    11550      +42     
- Misses                   5083     5113      +30     
+ Partials                 1279     1278       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ShahakShama ShahakShama force-pushed the shahak/db_executor_channels branch from 771f1f9 to fc774a1 Compare June 19, 2024 05:30
Copy link
Contributor

@eitanm-starkware eitanm-starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ShahakShama)

@ShahakShama ShahakShama force-pushed the shahak/db_executor_channels branch from fc774a1 to 48cd1af Compare June 19, 2024 10:56
Copy link
Contributor

@asmaastarkware asmaastarkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ShahakShama)

@ShahakShama ShahakShama force-pushed the shahak/db_executor_channels branch from 48cd1af to cb8c766 Compare June 20, 2024 04:39
Copy link
Contributor

@matan-starkware matan-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 4 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @ShahakShama)


crates/papyrus_network/src/db_executor/mod.rs line 88 at r2 (raw file):

    state_diff_queries_receiver:
        Option<SqmrQueryReceiver<StateDiffQuery, DataOrFin<StateDiffChunk>>>,
}

The DBExecutor is going to become the SyncServer. And therefore it make sense to have specific reference to header and state diff. right?

Code quote:

pub struct DBExecutor {
    storage_reader: StorageReader,
    // TODO(shahak): Make this non-option.
    header_queries_receiver: Option<SqmrQueryReceiver<HeaderQuery, DataOrFin<SignedBlockHeader>>>,
    // TODO(shahak): Make this non-option.
    state_diff_queries_receiver:
        Option<SqmrQueryReceiver<StateDiffQuery, DataOrFin<StateDiffChunk>>>,
}

crates/papyrus_network/src/db_executor/mod.rs line 123 at r2 (raw file):

            tokio::select! {
                Some((query_result, response_sender)) = header_queries_receiver_future => {

What happens if the future returns None?

Code quote:

                Some((query_result, response_sender)) = header_queries_receiver_future => {

crates/papyrus_network/src/db_executor/mod.rs line 264 at r2 (raw file):

    // If this function fails, we still want to send fin before failing.
    let result = send_data_without_fin_for_query(&storage_reader, query, &mut sender).await;
    sender.feed(DataOrFin(None)).await?;

when do we flush?

Code quote:

sender.feed(DataOrFin(None)).await?;

crates/papyrus_network/src/db_executor/mod.rs line 295 at r2 (raw file):

        for data in data_vec {
            // TODO: consider implement retry mechanism.
            sender.feed(DataOrFin(Some(data))).await?;

When do we flush?

Code quote:

sender.feed(DataOrFin(Some(data))).await?;

Copy link
Contributor Author

@ShahakShama ShahakShama left a 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, 2 unresolved discussions (waiting on @matan-starkware)


crates/papyrus_network/src/db_executor/mod.rs line 88 at r2 (raw file):

Previously, matan-starkware wrote…

The DBExecutor is going to become the SyncServer. And therefore it make sense to have specific reference to header and state diff. right?

Yes, we will move it from the network crate


crates/papyrus_network/src/db_executor/mod.rs line 123 at r2 (raw file):

Previously, matan-starkware wrote…

What happens if the future returns None?

Fixed. If you're interested I can tell you what was the previous code in huddle


crates/papyrus_network/src/db_executor/mod.rs line 264 at r2 (raw file):

Previously, matan-starkware wrote…

when do we flush?

We don't need to, it's flushed automatically (not sure when but I've checked the final PR with e2e with the node executable so it works)


crates/papyrus_network/src/db_executor/mod.rs line 295 at r2 (raw file):

Previously, matan-starkware wrote…

When do we flush?

Same

Copy link
Contributor

@matan-starkware matan-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ShahakShama)


crates/papyrus_network/src/db_executor/mod.rs line 123 at r2 (raw file):

Previously, ShahakShama wrote…

Fixed. If you're interested I can tell you what was the previous code in huddle

I don't see any change in the code.

Copy link
Contributor Author

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ShahakShama)


crates/papyrus_network/src/db_executor/mod.rs line 123 at r2 (raw file):

Previously, matan-starkware wrote…

I don't see any change in the code.

Forgot to push 😅

Copy link
Contributor

@matan-starkware matan-starkware left a 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 r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ShahakShama)


crates/papyrus_network/src/db_executor/mod.rs line 123 at r2 (raw file):

Previously, ShahakShama wrote…

Forgot to push 😅

Ok. Do we prefer expect outside of test code?

@ShahakShama ShahakShama force-pushed the shahak/db_executor_channels branch from c354b00 to 4a49a45 Compare June 20, 2024 14:31
Copy link
Contributor Author

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ShahakShama)


crates/papyrus_network/src/db_executor/mod.rs line 123 at r2 (raw file):

Previously, matan-starkware wrote…

Ok. Do we prefer expect outside of test code?

You and clippy are best friends

@ShahakShama ShahakShama force-pushed the shahak/db_executor_channels branch from 4a49a45 to bb9be89 Compare June 24, 2024 05:40
Copy link
Contributor

@matan-starkware matan-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ShahakShama)


crates/papyrus_network/src/db_executor/mod.rs line 123 at r2 (raw file):

Previously, ShahakShama wrote…

You and clippy are best friends

:D

…s 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)
@ShahakShama ShahakShama merged commit a4415af into shahak/remove_data Jun 25, 2024
16 of 17 checks passed
@ShahakShama ShahakShama deleted the shahak/db_executor_channels branch June 25, 2024 04:57
github-merge-queue bot pushed a commit that referenced this pull request Jun 25, 2024
* refactor(network): remove Data from db executor

* refactor(network): fix cr comments

* refactor(network): db executor communicates through channels (#2121)

* 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)
@github-actions github-actions bot locked and limited conversation to collaborators Jun 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants