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

Implement K-DHT for spartan-farmer #27

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
4c6e6c0
Add `libp2p` as a dependency.
Sep 18, 2021
cd7f3d1
Add `dht` module and sub-modules for `client`, `eventloop` and `core`.
Sep 18, 2021
a223c53
Add `libp2p` imports for creating ComposedBehaviour in `core`
Sep 18, 2021
06b596a
Add method to create swarm for farmer.
Sep 18, 2021
d73b610
Add code for `client` module.
Sep 18, 2021
45cc2cc
Add code for `eventloop` module.
Sep 18, 2021
29c41b7
Create a seperate method to create `Client` API and `EventLoop` objects
Sep 18, 2021
9949e4f
Call DHT methods in `farm.rs`
Sep 18, 2021
5021ee0
cargo format
Sep 18, 2021
f6a2d5e
Add `select!` for running eventloop for client and swarm events.
Sep 18, 2021
69cc4d2
Add `start_listening` method in `Client` API.
Sep 18, 2021
d5a021e
Add `ClientConfig` for bootstrapping
Sep 19, 2021
2229914
Implement `listen_on` in `Client` API and `EventLoop`
Sep 19, 2021
204675a
fix clippy error
Sep 19, 2021
186678e
Bootstrap implementation, Part 1.
Sep 19, 2021
c58af02
remove rustfmt.toml
Sep 19, 2021
0f0c738
Bootstrap implementation, part 2.
Sep 20, 2021
2966a81
Bootstrap implementation, part 3.
Sep 20, 2021
5977e61
Bootstrap implementation, Part 4.
Sep 20, 2021
cbec847
Bootstrap implementation, Part 5.
Sep 20, 2021
d71ced5
Trash commit. Please, Ignore
Sep 20, 2021
ebbe17b
Trash commit 2
Sep 20, 2021
1568107
Merge branch 'main' of upstream into impletement-dht2
Sep 20, 2021
c70b679
Add peers to routing table, whenever we come across a new one
Sep 20, 2021
66be40e
Clippy fixes.
Sep 20, 2021
609bb25
Remove `create_bootstrap` method as we don't need it.
Sep 21, 2021
37a8f4c
Add flag for `listen_addr`.
Sep 21, 2021
e035caf
Better comments.
Sep 21, 2021
f8a8f31
Add `Result` return type to `handle_client_event`.
Sep 21, 2021
7bc8bf6
Change type for `listen_addr` in `main.rs` CLAP arguments
Sep 21, 2021
668ada9
Format dependencies in a prettier way.
Sep 21, 2021
709dfbe
Remove unnecessary match statements in `handle_network_event`
Sep 21, 2021
57292e7
Add `test` module.
Sep 21, 2021
44bbd8a
Clippy fixes.
Sep 21, 2021
cc9829f
Make `create_connection` method synchronous from async
Sep 21, 2021
1f5357e
Add `KnownPeers` client event.
Sep 21, 2021
0165b73
Add `Dial` Client Event.
Sep 21, 2021
79b40d0
Add `GetRecord` event.
Sep 21, 2021
02d36d9
Add new client events: Random Walk, Listener, Query Result
Sep 21, 2021
c53f9a1
Remove unused imports.
Sep 21, 2021
c11574b
Add test for `bootstrap`.
Sep 21, 2021
dd2ab06
Remove commented code
Sep 21, 2021
7e271cd
Corrections to Bootstrap test
Sep 22, 2021
6336ff1
Add `QueryResult` event.
Sep 22, 2021
8f3d6dd
Inelegant fix for BootStrap test.
Sep 22, 2021
b316edb
Merge branch 'main' of upstream into impletement-dht2
Sep 22, 2021
4c64bd6
Code ready for review (unless, clippy gets in the way)
Sep 22, 2021
a38dd71
Appease clippy.
Sep 23, 2021
4e3e476
Add rustfmt.toml and rewrite dependencies
Sep 23, 2021
77496fe
Move `dht` module out of `commands` and seperate imports.
Sep 23, 2021
2408b66
Reassign scopes to objects in dht module
Sep 23, 2021
8e638a3
Remove ClientEvents that we are not using.
Sep 23, 2021
f1deb68
Remove `ClientType` enum.
Sep 24, 2021
3770fa0
Move `ClientEvent` and `handle_client_event` to eventloop.rs
Sep 24, 2021
6ecf049
Merge branch 'main' into impletement-dht2
Sep 26, 2021
408b389
Fix gitignore
Sep 26, 2021
9f265b0
Merge branch 'impletement-dht2' of github.com:whereistejas/subspace i…
Sep 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
@@ -1,2 +1,5 @@
.gitignore
/.idea
/target
**/rustfmt.toml
.vscode/
nazar-pc marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion crates/spartan-farmer/Cargo.toml
Expand Up @@ -30,7 +30,7 @@ serde_json = "1.0.64"
schnorrkel = "0.10.1"
spartan-codec = "0.1.0"
thiserror = "1.0.24"
tokio = "1.11.0"
tokio = { version = "1.11.0", features = [ "macros" ] }
whereistejas marked this conversation as resolved.
Show resolved Hide resolved

[dependencies.jsonrpsee]
features = ["client"]
Expand All @@ -48,6 +48,11 @@ version = "0.17.0"
features = ["derive"]
version = "1.0.125"

[dependencies.libp2p]
whereistejas marked this conversation as resolved.
Show resolved Hide resolved
version = "0.39.1"
features = [ "noise", "mplex", "kad", "tcp-tokio" ]
default-features = false

[dependencies.subspace-core-primitives]
version = "0.1.0"
path = "../subspace-core-primitives"
Expand Down
1 change: 1 addition & 0 deletions crates/spartan-farmer/src/commands.rs
@@ -1,3 +1,4 @@
mod dht;
whereistejas marked this conversation as resolved.
Show resolved Hide resolved
mod farm;
mod plot;

Expand Down
40 changes: 40 additions & 0 deletions crates/spartan-farmer/src/commands/dht.rs
@@ -0,0 +1,40 @@
// Stuff for Kademlia
use libp2p::kad::{record::store::MemoryStore, Kademlia, KademliaEvent, QueryId, QueryResult};

// Stuff for defining composed behaviour
use libp2p::NetworkBehaviour;

// Stuff needed to create the swarm
use libp2p::core::{upgrade, Transport};
use libp2p::identity;
use libp2p::mplex;
use libp2p::noise::{Keypair, NoiseConfig, X25519Spec};
use libp2p::swarm::{SwarmBuilder, SwarmEvent};
use libp2p::tcp::TokioTcpConfig;
use libp2p::{Multiaddr, PeerId, Swarm};

// Stuff needed to set up channels between Client API task and EventLoop task.
use futures::channel::{
mpsc::{channel, Receiver, Sender},
oneshot,
};
use futures::prelude::*;
use futures::StreamExt;

use log::info;
whereistejas marked this conversation as resolved.
Show resolved Hide resolved

type OneshotError = Box<dyn std::error::Error + Send>;
type OneshotType = Result<(), OneshotError>;

// The Client API which the end-user is supposed to interact with.
pub mod client;
// Core libp2p activities like defining network behaviour and events, bootstrap-ing,
// creating of swarm and such...
mod core;
// EventLoop which actually processes libp2p SwarmEvents. The Client API interacts with the
// EventLoop to transfer and receieve data.
mod eventloop;

// DHT related tests.
#[cfg(test)]
mod test;