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

[Bug Report] The endpoint triggers an exception if it is empty #3918

Closed
jackzhhuang opened this issue Jun 22, 2023 · 0 comments · Fixed by #3900
Closed

[Bug Report] The endpoint triggers an exception if it is empty #3918

jackzhhuang opened this issue Jun 22, 2023 · 0 comments · Fixed by #3900
Assignees
Labels
bug Something isn't working

Comments

@jackzhhuang
Copy link
Collaborator

Bug Report

Starcoin version:

Current behavior:

The endpoint in network-p2p module triggers an exception if it is empty when trying to get the network state by the console command.

The reason for this issue is that even though the endpoint was defined with a fixed length, if it is not initialized, it remains empty. Therefore, accessing it will still generate an exception.

Here's the translation of the code snippet:

network-p2p/src/service.rs:415

let endpoint = if let Some(e) = swarm.behaviour_mut().node(peer_id).map(|i| i.endpoint()) {
    e.clone().into()
} else {
    error!(target: "sub-libp2p", "Found state inconsistency between custom protocol \
and debug information about {:?}", peer_id);
    return None;
};

network-p2p/peer_info.rs:142

pub struct Node<'a>(&'a NodeInfo);

impl<'a> Node<'a> {
    /// Returns the endpoint of an established connection to the peer.
    pub fn endpoint(&self) -> &'a ConnectedPoint {
        &self.0.endpoints[0] // `endpoints` are non-empty by definition
    }

The comment above said: endpoints are non-empty by definition but it will trigger an exception when accessing if no item was pushed.

Expected behavior:

Steps to reproduce:

Related code:

insert short code snippets here

Other information:

@jackzhhuang jackzhhuang added the bug Something isn't working label Jun 22, 2023
jackzhhuang added a commit that referenced this issue Jun 22, 2023
@jackzhhuang jackzhhuang self-assigned this Jun 22, 2023
@jackzhhuang jackzhhuang linked a pull request Jun 22, 2023 that will close this issue
7 tasks
jackzhhuang added a commit that referenced this issue Jun 26, 2023
* add network reconstruction for handshaking

* network construction

* process the unwrap

* fix test_handshake_message

* fix cargo fmt

* move derive and core from network-rpc to network-p2p

* fix fmt

* commit drive and core in network-p2p

* 1, rebase the master
2, resolve the compatibility issue

* move the stauts into the network module from the network-p2p module

* Add log and follow-up actions for protocol procedures

* test status in service_test.rs

* rebase network reconstruction

* network construction

* fix test_handshake_message

* fix cargo fmt

* move the stauts into the network module from the network-p2p module

* test status in service_test.rs

* fix fmt

* fix clippy

* fix fmt

* fix fmt

* fix fmt

* fix serde and fmt

* fix unittest in network-p2p

* fix clippy

* use 1.13.5

* fix:
1, add expect in upadte business status
2, handshake return the result struct hence decouple the relation of network-p2p and network modules

* fix bug: #3918
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant