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

Added basic yamux connection upgrade #1096

Merged
merged 1 commit into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 2
version: 2.1

defaults:
rust_image: &rust_image quay.io/tarilabs/rust_tari-build-with-deps:nightly-2019-10-04
Expand All @@ -9,6 +9,10 @@ jobs:
- image: *rust_image
steps:
- checkout
- run:
command: |
git submodule update --init --recursive
name: Init git submodule
- run:
name: RFC documentation
command: |
Expand All @@ -25,6 +29,10 @@ jobs:
- image: quay.io/tarilabs/git-ssh-client:0.2-alpine
steps:
- checkout
- run:
command: |
git submodule update --init --recursive
name: Init git submodule
- attach_workspace:
at: .
- add_ssh_keys:
Expand Down Expand Up @@ -68,6 +76,10 @@ jobs:
resource_class: medium
steps:
- checkout
- run:
command: |
git submodule update --init --recursive
name: Init git submodule
- run:
name: Tari source code
command: |
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "comms/yamux"]
path = comms/yamux
url = https://github.com/tari-project/yamux.git
branch = futures-alpha
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ to generate the documentation. The generated html sits in `target/doc/`. Alterna

See [RFC-0110/CodeStructure](./RFC/src/RFC-0010_CodeStructure.md) for details on the code structure and layout.

### Git submodules
Copy link
Member Author

Choose a reason for hiding this comment

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

@CjS77 Added this section


Git submodules are use temporarily until some dependent libraries are stabilized and released as crates.
When checking out code take the following steps to ensure submodules are up to date.

```shell script
# Initialize submodules
git submodule init
# Sets `git pull` to automatically pull submodules
git config submodule.recurse true
# Checkout/update all submodules
git submodule update --recursive --remote
```

## Conversation channels

[<img src="https://ionicons.com/ionicons/svg/md-paper-plane.svg" width="32">](https://t.me/tarilab) Non-technical discussions and gentle sparring.
Expand Down
140 changes: 0 additions & 140 deletions base_layer/p2p/tests/ping_pong/mod.rs

This file was deleted.

26 changes: 11 additions & 15 deletions base_layer/p2p/tests/services/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn setup_liveness_service(
node_identity: NodeIdentity,
peers: Vec<NodeIdentity>,
data_path: &str,
) -> (LivenessHandle, Arc<CommsNode>, Dht)
) -> (LivenessHandle, CommsNode, Dht)
{
let (publisher, subscription_factory) = pubsub_connector(runtime.executor(), 100);
let subscription_factory = Arc::new(subscription_factory);
Expand Down Expand Up @@ -97,60 +97,49 @@ fn end_to_end() {
.unwrap();

let alice_temp_dir = TempDir::new(string(8).as_str()).unwrap();
let (mut liveness1, _comms_1, _dht_1) = setup_liveness_service(
let (mut liveness1, comms_1, dht_1) = setup_liveness_service(
&runtime,
node_1_identity.clone(),
vec![node_2_identity.clone()],
alice_temp_dir.path().to_str().unwrap(),
);
let bob_temp_dir = TempDir::new(string(8).as_str()).unwrap();
let (mut liveness2, _comms_2, _dht_2) = setup_liveness_service(
let (mut liveness2, comms_2, dht_2) = setup_liveness_service(
&runtime,
node_2_identity.clone(),
vec![node_1_identity.clone()],
bob_temp_dir.path().to_str().unwrap(),
);

let mut pingpong1_total = (0, 0);
let mut pingpong2_total = (0, 0);

for _ in 0..5 {
let _ = runtime
.block_on(liveness2.send_ping(node_1_identity.node_id().clone()))
.unwrap();
pingpong1_total = (pingpong1_total.0 + 1, pingpong1_total.1);
pingpong2_total = (pingpong2_total.0, pingpong2_total.1 + 1);
}

for _ in 0..4 {
let _ = runtime
.block_on(liveness1.send_ping(node_2_identity.node_id().clone()))
.unwrap();
pingpong2_total = (pingpong2_total.0 + 1, pingpong2_total.1);
pingpong1_total = (pingpong1_total.0, pingpong1_total.1 + 1);
}

for _ in 0..5 {
let _ = runtime
.block_on(liveness2.send_ping(node_1_identity.node_id().clone()))
.unwrap();
pingpong1_total = (pingpong1_total.0 + 1, pingpong1_total.1);
pingpong2_total = (pingpong2_total.0, pingpong2_total.1 + 1);
}

for _ in 0..4 {
let _ = runtime
.block_on(liveness1.send_ping(node_2_identity.node_id().clone()))
.unwrap();
pingpong2_total = (pingpong2_total.0 + 1, pingpong2_total.1);
pingpong1_total = (pingpong1_total.0, pingpong1_total.1 + 1);
}

let events = collect_stream!(
runtime,
liveness1.get_event_stream_fused(),
take = 18,
timeout = Duration::from_secs(10),
timeout = Duration::from_secs(20),
);

let ping_count = events
Expand Down Expand Up @@ -209,4 +198,11 @@ fn end_to_end() {
assert_eq!(pongcount1, 8);
assert_eq!(pingcount2, 8);
assert_eq!(pongcount2, 10);

drop(dht_1);
drop(dht_2);
comms_1.shutdown().unwrap();
comms_2.shutdown().unwrap();

runtime.shutdown_on_idle();
}
6 changes: 2 additions & 4 deletions base_layer/p2p/tests/support/comms_and_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ pub fn setup_comms_services<TSink>(
peers: Vec<NodeIdentity>,
publisher: InboundDomainConnector<TSink>,
data_path: &str,
) -> (Arc<CommsNode>, Dht)
) -> (CommsNode, Dht)
where
TSink: Sink<Arc<PeerMessage>> + Clone + Unpin + Send + Sync + 'static,
TSink::Error: Error + Send + Sync,
{
let (comms, dht) = initialize_local_test_comms(executor, node_identity, publisher, data_path)
.map(|(comms, dht)| (Arc::new(comms), dht))
.unwrap();
let (comms, dht) = initialize_local_test_comms(executor, node_identity, publisher, data_path).unwrap();

for p in peers {
let addr = p.control_service_address().clone();
Expand Down
1 change: 1 addition & 0 deletions comms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ time = "0.1.42"
tokio = "0.2.0-alpha.6"
tokio-executor = { version ="^0.2.0-alpha.6", features = ["threadpool"] }
ttl_cache = "0.5.1"
yamux = {path="./yamux"}
zmq = "0.9.2"

[dev-dependencies]
Expand Down
1 change: 1 addition & 0 deletions comms/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub mod connection_manager;
mod consts;
pub mod control_service;
pub mod inbound_message_service;
mod multiplexing;
mod noise;
pub mod outbound_message_service;
pub mod peer_manager;
Expand Down
23 changes: 23 additions & 0 deletions comms/src/multiplexing/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2019, The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pub mod yamux;
Loading