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

Reduce unhandled NetworkEvents #982

Merged
merged 2 commits into from Nov 20, 2023
Merged

Reduce unhandled NetworkEvents #982

merged 2 commits into from Nov 20, 2023

Conversation

joshuef
Copy link
Contributor

@joshuef joshuef commented Nov 20, 2023

Description

Summary generated by Reviewpad on 20 Nov 23 10:37 UTC

This pull request includes the following changes:

  1. In sn_networking/src/cmd.rs:

    • Modified the handling of a request sent to itself by the swarm driver. If the request is a Query type, it sends a NetworkEvent::QueryRequestReceived. Otherwise, it logs a message stating that a replicate command to self was received and it is ignored.
  2. In sn_networking/src/driver.rs:

    • Updated the configuration of the gossipsub behavior to disable sending to all peers subscribed to a topic (flood_publish(false)).
  3. In sn_networking/src/event.rs:

    • Renamed RequestReceived to CmdRequestReceived and added a new variant QueryRequestReceived in the NetworkEvent enum.
  4. In sn_networking/src/swarm_driver.rs:

    • Modified the handling of a request received from a peer. If the request is a Cmd type, it sends a replicate OK response to the peer and handles the command separately. If the request is a Query type, it sends a NetworkEvent::QueryRequestReceived.
  5. In sn_node/src/node.rs:

    • Updated the handling of network events in the handle_response function. If the response is a replicate OK response, it logs a warning as it should have been handled earlier.
    • Updated the handling of network events in the handle_query and handle_node_cmd functions. Instead of returning a response, it now directly sends the response using the send_response function.
  6. In sn_transfers/src/cashnotes/signed_spend.rs:

    • Added the custom_debug attribute to the Spend struct.

These changes improve the handling of requests and responses in the code.

Copy link

reviewpad bot commented Nov 20, 2023

Reviewpad Report

‼️ Errors

  • Unconventional title detected: 'Reduce unhandled NetworkEvents' illegal 'd' character in commit message type: col=02

@joshuef joshuef force-pushed the CmdLogging branch 3 times, most recently from 48e6346 to a1812e5 Compare November 20, 2023 12:35
channel: MsgResponder::FromSelf(sender),
});
} else {
trace!("Replicate cmd to self received, ignoring");
Copy link
Member

Choose a reason for hiding this comment

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

the log is bit confusing.
As I understand, it is a non-query request to self, which can be ignored, maybe due to replicate ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yeh, we'd be asking ourself to replicate data which we're already holding? So can be ignored

@@ -394,6 +394,8 @@ impl NetworkBuilder {

// Gossipsub behaviour
let gossipsub_config = libp2p::gossipsub::ConfigBuilder::default()
// disable sending to ALL_PEERS subscribed to a topic, which is the default behaviour
.flood_publish(false)
Copy link
Member

Choose a reason for hiding this comment

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

this may cause a subscriber miss a msg?
it it is not known by ALL publisher ?

with the flood disabled, will forwarding` still get undertaken?

// if the request is replication, we can handle it and send the OK response here,
// as we send that regardless of how we handle the request as its unimportant to the sender.
match request {
Request::Cmd(cmd) => {
Copy link
Member

Choose a reason for hiding this comment

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

sounds like the Replicate is the only Request::Cmd to be received across nodes?
I'd prefer narrow down then enum to be Cmd::Replicate only, to avoid later on it mess-up with other new work flow ?

This should avoid issues if that enum grows
@joshuef joshuef added this pull request to the merge queue Nov 20, 2023
Merged via the queue into maidsafe:main with commit 8428c6c Nov 20, 2023
27 of 28 checks passed
@joshuef joshuef deleted the CmdLogging branch November 20, 2023 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Medium Medium sized PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants