-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(services): Networking Crate (#1032)
- Loading branch information
Showing
25 changed files
with
3,861 additions
and
102 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
[package] | ||
name = "kona-net" | ||
version = "0.1.0" | ||
description = "Consensus networking library for the OP Stack" | ||
|
||
edition.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
homepage.workspace = true | ||
keywords.workspace = true | ||
categories.workspace = true | ||
repository.workspace = true | ||
rust-version.workspace = true | ||
|
||
[dependencies] | ||
# Alloy | ||
alloy-rlp.workspace = true | ||
alloy-primitives = { workspace = true, features = ["k256", "getrandom"] } | ||
alloy-rpc-types-engine = { workspace = true, features = ["std"] } | ||
|
||
# Op Alloy | ||
op-alloy-rpc-types-engine = { workspace = true, features = ["std"] } | ||
|
||
# Networking | ||
snap.workspace = true | ||
futures.workspace = true | ||
discv5.workspace = true | ||
libp2p = { workspace = true, features = ["macros", "tokio", "tcp", "noise", "gossipsub", "ping", "yamux"] } | ||
openssl = { workspace = true, features = ["vendored"] } | ||
libp2p-identity = { workspace = true, features = ["secp256k1"] } | ||
|
||
# Misc | ||
tokio.workspace = true | ||
tracing.workspace = true | ||
thiserror.workspace = true | ||
lazy_static.workspace = true | ||
unsigned-varint.workspace = true | ||
|
||
# `arbitrary` feature dependencies | ||
arbitrary = { workspace = true, features = ["derive"], optional = true } | ||
|
||
[dev-dependencies] | ||
arbtest.workspace = true | ||
arbitrary = { workspace = true, features = ["derive"] } | ||
alloy-primitives = { workspace = true, features = ["arbitrary"] } | ||
|
||
[features] | ||
default = [] | ||
arbitrary = ["dep:arbitrary", "alloy-primitives/arbitrary"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# `kona-net` | ||
|
||
A consensus network library for the OP Stack. | ||
|
||
Contains a gossipsub driver to run discv5 peer discovery and block gossip. | ||
|
||
### Example | ||
|
||
> **Warning** | ||
> | ||
> Notice, the socket address uses `0.0.0.0`. | ||
> If you are experiencing issues connecting to peers for discovery, | ||
> check to make sure you are not using the loopback address, | ||
> `127.0.0.1` aka "localhost", which can prevent outward facing connections. | ||
```rust,no_run | ||
use std::net::{IpAddr, Ipv4Addr, SocketAddr}; | ||
use alloy_primitives::address; | ||
use kona_net::driver::NetworkDriver; | ||
// Build the network driver. | ||
let signer = address!("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); | ||
let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 9099); | ||
let driver = NetworkDriver::builder() | ||
.with_chain_id(10) // op mainnet chain id | ||
.with_unsafe_block_signer(signer) | ||
.with_gossip_addr(socket) | ||
.build() | ||
.expect("Failed to builder network driver"); | ||
// Call `.start()` on the driver. | ||
driver.start().expect("Failed to start network driver"); | ||
println!("NetworkDriver started."); | ||
``` | ||
|
||
[!WARNING]: ###example | ||
|
||
### Acknowledgements | ||
|
||
Largely based off [magi]'s [p2p module][p2p]. | ||
|
||
<!-- Links --> | ||
|
||
[magi]: https://github.com/a16z/magi | ||
[p2p]: https://github.com/a16z/magi/tree/master/src/network |
Oops, something went wrong.