Skip to content
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

feat(network): dial peer in network run function #1739

Merged
merged 1 commit into from
Feb 26, 2024

Conversation

nagmo-starkware
Copy link
Contributor

@nagmo-starkware nagmo-starkware commented Feb 25, 2024

Pull Request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this introduce a breaking change?

  • Yes
  • No

Other information


This change is Reviewable

@nagmo-starkware
Copy link
Contributor Author

nagmo-starkware commented Feb 25, 2024

Base automatically changed from nevo/network/comment_out_quic to main February 25, 2024 13:34
@nagmo-starkware nagmo-starkware changed the base branch from main to shahak/connect_p2p_sync_to_node February 25, 2024 13:34
@nagmo-starkware nagmo-starkware force-pushed the nevo/network/dial_in_network_run branch 2 times, most recently from f8aea10 to 983fbdc Compare February 25, 2024 14:06
@nagmo-starkware nagmo-starkware changed the base branch from shahak/connect_p2p_sync_to_node to main February 25, 2024 14:06
ShahakShama
ShahakShama previously approved these changes Feb 25, 2024
Copy link
Contributor

@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.

:lgtm:

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @nagmo-starkware)


crates/papyrus_network/src/network_manager/mod.rs line 47 at r1 (raw file):

    pub async fn run(mut self) -> Result<(), NetworkError> {
        if let Some(peer_id) = self.peer_id {
            debug!("Starting network manager with peer id: {peer_id:?}");

Consider "with" -> "connected to"
and "without peer id" -> "not connected to any peer"


crates/papyrus_network/src/network_manager/test.rs line 114 at r1 (raw file):

    fn dial(&mut self, peer_id: PeerId) -> Result<(), libp2p::swarm::DialError> {
        unimplemented!("MockSwarm::dial not implemented")

Consider just returning Ok(())

Copy link
Contributor Author

@nagmo-starkware nagmo-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: 0 of 5 files reviewed, 1 unresolved discussion (waiting on @ShahakShama)


crates/papyrus_network/src/network_manager/test.rs line 114 at r1 (raw file):

Previously, ShahakShama wrote…

Consider just returning Ok(())

I prefer to make it obvious that it's not dealt with

Copy link

codecov bot commented Feb 25, 2024

Codecov Report

Attention: Patch coverage is 14.28571% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 72.98%. Comparing base (1e6bf4c) to head (cb26a60).

Files Patch % Lines
...papyrus_network/src/network_manager/swarm_trait.rs 0.00% 6 Missing ⚠️
crates/papyrus_network/src/network_manager/mod.rs 33.33% 3 Missing and 1 partial ⚠️
...apyrus_network/src/bin/p2p_integration_endpoint.rs 0.00% 1 Missing ⚠️
crates/papyrus_node/src/main.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1739      +/-   ##
==========================================
- Coverage   73.03%   72.98%   -0.05%     
==========================================
  Files         131      131              
  Lines       18955    18967      +12     
  Branches    18955    18967      +12     
==========================================
+ Hits        13843    13844       +1     
- Misses       3015     3025      +10     
- Partials     2097     2098       +1     

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

Copy link
Contributor

@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.

Reviewed 4 of 5 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @nagmo-starkware)


crates/papyrus_network/src/bin/p2p_integration_endpoint.rs line 48 at r3 (raw file):

        network_manager.dial(dial_address);
    }
    let _ = network_manager.run().await;

You should handle the error, not ignore it


crates/papyrus_network/src/network_manager/swarm_trait.rs line 53 at r3 (raw file):

    fn dial(&mut self, peer_id: PeerId) -> Result<(), DialError> {
        let addresses = vec![
            Multiaddr::from_str("/ip4/127.0.0.1/tcp/10000").expect("string to multiaddr failed"),

Why is this a hardcoded address?


crates/papyrus_node/src/main.rs line 163 at r3 (raw file):

    let network_manager =
        network_manager::NetworkManager::new(network_config.clone(), storage_reader.clone());
    network_manager.run().await.expect("network manager failed");

Handle the error here in the same way it's handled with Sync. Mainly, I want to see the error when it happens

Copy link
Contributor Author

@nagmo-starkware nagmo-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: all files reviewed, 3 unresolved discussions (waiting on @ShahakShama)


crates/papyrus_network/src/bin/p2p_integration_endpoint.rs line 48 at r3 (raw file):

Previously, ShahakShama wrote…

You should handle the error, not ignore it

it's the integration endpoint.. we expect it to not return and if it returns then the endpoint will shut down


crates/papyrus_network/src/network_manager/swarm_trait.rs line 53 at r3 (raw file):

Previously, ShahakShama wrote…

Why is this a hardcoded address?

it's temporary until I'll have the PR that adds the peer stuff to the config


crates/papyrus_node/src/main.rs line 163 at r3 (raw file):

Previously, ShahakShama wrote…

Handle the error here in the same way it's handled with Sync. Mainly, I want to see the error when it happens

you've already approved the PR that fixes it. it's merged into the p2psync connection to main branch.
I'll see if I can extract the part that handles this from it and merge it to main before the rest.
for now I suggest to merge it since I agree it looks better the other way but the functionality is the same.

ShahakShama
ShahakShama previously approved these changes Feb 26, 2024
Copy link
Contributor

@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.

:lgtm:

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @nagmo-starkware)


crates/papyrus_network/src/bin/p2p_integration_endpoint.rs line 48 at r3 (raw file):

Previously, nagmo-starkware wrote…

it's the integration endpoint.. we expect it to not return and if it returns then the endpoint will shut down

Just do expect("Network manager failed")
so that the process will exit with error and not with 0
you can do it in a future PR if you prefer

Copy link
Contributor

@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.

:lgtm:

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

@nagmo-starkware nagmo-starkware added this pull request to the merge queue Feb 26, 2024
Merged via the queue into main with commit f0a7421 Feb 26, 2024
41 checks passed
@nagmo-starkware nagmo-starkware deleted the nevo/network/dial_in_network_run branch February 26, 2024 11:36
@github-actions github-actions bot locked and limited conversation to collaborators Feb 28, 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.

2 participants