| Crates.io | kona-net |
| lib.rs | kona-net |
| version | 0.1.0 |
| created_at | 2025-02-13 23:30:06.13704+00 |
| updated_at | 2025-02-13 23:30:06.13704+00 |
| description | Consensus networking library for the OP Stack |
| homepage | https://github.com/op-rs/kona |
| repository | https://github.com/op-rs/kona |
| max_upload_size | |
| id | 1555205 |
| size | 67,031 |
kona-netA consensus network library for the OP Stack.
Contains a gossipsub driver to run discv5 peer discovery and block gossip.
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.1aka "localhost", which can prevent outward facing connections.
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.");
Largely based off magi's p2p module.