Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.
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
120 changes: 110 additions & 10 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ libp2p-identity = "0.2.10"
tracing-loki = "0.2.6"
tracing-subscriber = "0.3.19"
tracing = { version = "0.1.41", default-features = false }
metrics-exporter-prometheus = { version = "0.16.0", default-features = false }

# Testing
pprof = "0.14.0"
Expand Down
4 changes: 2 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ build-cannon *args='':
--rm \
-v `pwd`/:/workdir \
-w="/workdir" \
ghcr.io/op-rs/kona/cannon-builder:main cargo build --workspace -Zbuild-std=core,alloc $@ --exclude kona-host --exclude kona-net --exclude kona-providers-alloy --exclude kona-providers-local
ghcr.io/op-rs/kona/cannon-builder:main cargo build --workspace -Zbuild-std=core,alloc $@ --exclude kona-host --exclude kona-nexus --exclude kona-net --exclude kona-providers-alloy --exclude kona-providers-local

# Build for the `asterisc` target. Any crates that require the stdlib are excluded from the build for this target.
build-asterisc *args='':
docker run \
--rm \
-v `pwd`/:/workdir \
-w="/workdir" \
ghcr.io/op-rs/kona/asterisc-builder:main cargo build --workspace -Zbuild-std=core,alloc $@ --exclude kona-host --exclude kona-net --exclude kona-providers-alloy --exclude kona-providers-local
ghcr.io/op-rs/kona/asterisc-builder:main cargo build --workspace -Zbuild-std=core,alloc $@ --exclude kona-host --exclude kona-nexus --exclude kona-net --exclude kona-providers-alloy --exclude kona-providers-local

# Clones and checks out the monorepo at the commit present in `.monorepo`
monorepo:
Expand Down
25 changes: 25 additions & 0 deletions bin/nexus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "kona-nexus"
version = "0.1.0"
description = "Kona Networking Component Runner"

edition.workspace = true
authors.workspace = true
license.workspace = true
keywords.workspace = true
repository.workspace = true
categories.workspace = true
rust-version.workspace = true

[dependencies]
# Workspace
kona-net.workspace = true
kona-registry.workspace = true

# Workspace
anyhow.workspace = true
tracing.workspace = true
clap = { workspace = true, features = ["derive", "env"] }
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] }
metrics-exporter-prometheus = { workspace = true, features = ["http-listener"] }
7 changes: 7 additions & 0 deletions bin/nexus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# `kona-nexus`

A binary that runs isolated components.

These include:
- gossip using [`kona-net`](https://crates.io/crates/kona-net)
- discovery using [`kona-net`](https://crates.io/crates/kona-net)
44 changes: 44 additions & 0 deletions bin/nexus/src/disc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//! Discovery subcommand for Hilo.

use crate::globals::GlobalArgs;
use clap::Args;
use kona_net::discovery::builder::DiscoveryBuilder;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};

/// The discovery subcommand.
#[derive(Debug, Clone, Args)]
#[non_exhaustive]
pub struct DiscCommand {
/// Port to listen for gossip on.
#[clap(long, short = 'l', default_value = "9099", help = "Port to listen for gossip on")]
pub gossip_port: u16,
/// Interval to send discovery packets.
#[clap(long, short = 'i', default_value = "1", help = "Interval to send discovery packets")]
pub interval: u64,
}

impl DiscCommand {
/// Run the discovery subcommand.
pub async fn run(self, args: &GlobalArgs) -> anyhow::Result<()> {
let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), self.gossip_port);
tracing::info!("Starting discovery service on {:?}", socket);

let mut discovery_builder =
DiscoveryBuilder::new().with_address(socket).with_chain_id(args.l2_chain_id);
let mut discovery = discovery_builder.build()?;
discovery.interval = std::time::Duration::from_secs(self.interval);
let mut peer_recv = discovery.start();
tracing::info!("Discovery service started, receiving peers.");

loop {
match peer_recv.recv().await {
Some(peer) => {
tracing::info!("Received peer: {:?}", peer);
}
None => {
tracing::warn!("Failed to receive peer");
}
}
}
}
}
19 changes: 19 additions & 0 deletions bin/nexus/src/globals.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//! Global arguments for the CLI.

use clap::Parser;

/// Global arguments for the CLI.
#[derive(Parser, Clone, Debug)]
pub(crate) struct GlobalArgs {
/// The L2 chain ID to use.
#[clap(long, short = 'c', default_value = "10", help = "The L2 chain ID to use")]
pub l2_chain_id: u64,
/// A port to serve prometheus metrics on.
#[clap(
long,
short = 'm',
default_value = "9090",
help = "The port to serve prometheus metrics on"
)]
pub metrics_port: u16,
}
Loading