Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upProblem with use #648
Comments
tomaka
added
the
discussion
label
Nov 16, 2018
This comment has been minimized.
This comment has been minimized.
|
You need to manually open substreams. This is done by returning a Note that the high level API is slowly coming along, and documentation is in progress. |
This comment has been minimized.
This comment has been minimized.
driftluo
commented
Nov 16, 2018
•
|
Oh, yeah, it works, thank you very much. I did not expect that I ignored this thing, I thought that out substream will open itself at the low level. I am looking forward to a better use of API and documentation. I look at the recent pr and discussion, it seems that we will split the I will continue to pay attention, then I will try to implement a custom protocol. |
This comment has been minimized.
This comment has been minimized.
driftluo
commented
Dec 5, 2018
•
|
@tomaka I found a memory leak problem, but I can't locate what the problem is. The code is still in the repo above. One bash: $ cargo run --bin node_1Another shell $ cargo run --bin node_2Node 1 listen on Now, it works well. On my machine, do the following: $ ps -aux | rg node_
luoc 6632 1.6 0.0 71124 11308 pts/3 Sl+ 16:50 0:00 ./target/release/node_1
luoc 6647 2.7 0.0 71124 11420 pts/4 Sl+ 16:50 0:00 ./target/release/node_2
luoc 6664 0.0 0.0 24880 6272 pts/5 S+ 16:50 0:00 rg node_
$ kill -9 6647Now you can directly view the I see that tokio poll is constantly being awakened, it make cpu usage more than 200%. |
This comment has been minimized.
This comment has been minimized.
|
What's the code you're running? I don't see that with the chat example. |
This comment has been minimized.
This comment has been minimized.
driftluo
commented
Dec 5, 2018
•
|
https://github.com/cryptape/cita-p2p Sorry, it's trace log block on here:
|
This comment has been minimized.
This comment has been minimized.
driftluo
commented
Dec 6, 2018
•
|
@tomaka @twittner I have found out where the problem is. The problem is on the The function to create transport is as follows: fn build_transport(key_pair: secio::SecioKeyPair) -> Boxed<(PeerId, StreamMuxerBox)> {
let mut mplex_config = mplex::MplexConfig::new();
mplex_config.max_buffer_len_behaviour(mplex::MaxBufferBehaviour::Block);
mplex_config.max_buffer_len(usize::MAX);
let base = libp2p::CommonTransport::new()
.with_upgrade(secio::SecioConfig::new(key_pair))
.and_then(move |out, endpoint| {
let upgrade = upgrade::or(
upgrade::map(yamux::Config::default(), either::EitherOutput::First),
upgrade::map(mplex_config, either::EitherOutput::Second),
);
let peer_id = out.remote_key.into_peer_id();
let upgrade = upgrade::map(upgrade, move |muxer| (peer_id, muxer));
upgrade::apply(out.stream, upgrade, endpoint.into())
}).map(|(id, muxer), _| (id, StreamMuxerBox::new(muxer)));
TransportTimeout::new(base, Duration::from_secs(20)).boxed()
}The transport created in this way takes precedence on yamux, and if I do as I said above, problems will occur. But, when I changed to use
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
driftluo
commented
Dec 6, 2018
Deleting logger init didn't solve the problem, In my case, this is still a memory leak.
Using |
This comment has been minimized.
This comment has been minimized.
|
Ok, that's too bad we're not seeing the same thing. Makes it harder to investigate. What OS/version are you on? And what Rust version are you using? I ran my tests on OS X 10.14.2 using rustc 1.32.0-nightly (14997d56a 2018-12-05). Do you think you can prepare a minimal test for us to run and see what is going on? The code in your repo does not run against the latest master and contains stuff that is probably not relevant for this problem? |
This comment has been minimized.
This comment has been minimized.
driftluo
commented
Dec 6, 2018
•
|
OS:Ubuntu 18.04 I'll try to write a minimal reproducible version, but, due to the complexity of libp2p itself, it's necessary to write a lot of code to run. By the way,I use the same commit as substrace use ,but yamux upgrade to 0.1.1 |
This comment has been minimized.
This comment has been minimized.
driftluo
commented
Dec 11, 2018
|
@dvdplm The latest master branch code, chat example, default use
change: let upgrade = mplex::MplexConfig::new().map_outbound(move |muxer| (peer_id, muxer) );to let upgrade = yamux::Config::default().map_outbound(move |muxer| (peer_id, muxer) );Other issues, I need to use By the way, why |
This comment has been minimized.
This comment has been minimized.
|
Hi @driftluo, so sorry you're having issues. We are currently working on stabilizing APIs and add more ergonomic high-level helpers to do common tasks, but there are plenty of rough edges still, as you have discovered. To use Yamux with the chat example, try this: let transport = libp2p::CommonTransport::new()
.with_upgrade(secio::SecioConfig::new(local_key))
.and_then(move |out, cp| {
let peer_id1 = out.remote_key.into_peer_id();
let peer_id2 = peer_id1.clone();
let upgrade = libp2p::yamux::Config::default()
.map_inbound(move |muxer| (peer_id1, muxer))
.map_outbound(move |muxer| (peer_id2, muxer));
upgrade::apply(out.stream, upgrade, cp).map_err(|e| e.into_io_error())
});(The |
This comment has been minimized.
This comment has been minimized.
driftluo
commented
Dec 11, 2018
|
@dvdplm Hey, I successfully reproduce two problems, the code is here: https://github.com/cryptape/cita-p2p/tree/p2p-bug-report This code uses Only the ping protocol is mounted in the handle, pinging every 5 seconds, nothing else. This is the simplest example, using the latest master code. Ok, here are two questions I found. First, One bash:
Another shell
You wil look some log like follow,then same as
Second, I tried to connect myself in the same swarm and rejected the connection in the connected event,code is here, but connection doesn't drop, and cpu usage is more than 200%. run node3:
network status, connection does not broken:
log output:
|
This comment has been minimized.
This comment has been minimized.
driftluo
commented
Dec 11, 2018
•
|
@dvdplm Ok, I use this to create transport:
After
rustc: rustc 1.31.0 (abe02cefd 2018-12-04) |
This comment has been minimized.
This comment has been minimized.
|
Excellent, this will definitely help. |
driftluo commentedNov 16, 2018
After reading the libp2p api and substrace network-libp2p source code, I tried to refer to substrace write a repo , using only the ping protocol for testing.
However, from the operation of this repo, the
inject_substreammethod ofNodeHandleris not called, which means that the substream is not upgraded.I don't understand now that there is a problem with my code or a problem with the library call. After all, there is almost no documentation for this library right now.
repo:https://github.com/driftluo/p2p-test
output: