Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/konaPublic

Commit5cbc559

Browse files
authored
feat(bin): Network Component Runner (#1058)
1 parent54f28c3 commit5cbc559

File tree

11 files changed

+365
-13
lines changed

11 files changed

+365
-13
lines changed

‎Cargo.lock

Lines changed: 110 additions & 10 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ libp2p-identity = "0.2.10"
173173
tracing-loki ="0.2.6"
174174
tracing-subscriber ="0.3.19"
175175
tracing = {version ="0.1.41",default-features =false }
176+
metrics-exporter-prometheus = {version ="0.16.0",default-features =false }
176177

177178
# Testing
178179
pprof ="0.14.0"

‎Justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ build-cannon *args='':
102102
--rm \
103103
-v`pwd`/:/workdir \
104104
-w="/workdir" \
105-
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
105+
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
106106

107107
# Build for the `asterisc` target. Any crates that require the stdlib are excluded from the build for this target.
108108
build-asterisc*args='':
109109
docker run \
110110
--rm \
111111
-v`pwd`/:/workdir \
112112
-w="/workdir" \
113-
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
113+
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
114114

115115
# Clones and checks out the monorepo at the commit present in `.monorepo`
116116
monorepo:

‎bin/nexus/Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name ="kona-nexus"
3+
version ="0.1.0"
4+
description ="Kona Networking Component Runner"
5+
6+
edition.workspace =true
7+
authors.workspace =true
8+
license.workspace =true
9+
keywords.workspace =true
10+
repository.workspace =true
11+
categories.workspace =true
12+
rust-version.workspace =true
13+
14+
[dependencies]
15+
# Workspace
16+
kona-net.workspace =true
17+
kona-registry.workspace =true
18+
19+
# Workspace
20+
anyhow.workspace =true
21+
tracing.workspace =true
22+
clap = {workspace =true,features = ["derive","env"] }
23+
tokio = {workspace =true,features = ["rt-multi-thread","macros"] }
24+
tracing-subscriber = {workspace =true,features = ["env-filter","fmt"] }
25+
metrics-exporter-prometheus = {workspace =true,features = ["http-listener"] }

‎bin/nexus/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#`kona-nexus`
2+
3+
A binary that runs isolated components.
4+
5+
These include:
6+
- gossip using[`kona-net`](https://crates.io/crates/kona-net)
7+
- discovery using[`kona-net`](https://crates.io/crates/kona-net)

‎bin/nexus/src/disc.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//! Discovery subcommand for Hilo.
2+
3+
usecrate::globals::GlobalArgs;
4+
use clap::Args;
5+
use kona_net::discovery::builder::DiscoveryBuilder;
6+
use std::net::{IpAddr,Ipv4Addr,SocketAddr};
7+
8+
/// The discovery subcommand.
9+
#[derive(Debug,Clone,Args)]
10+
#[non_exhaustive]
11+
pubstructDiscCommand{
12+
/// Port to listen for gossip on.
13+
#[clap(long, short ='l', default_value ="9099", help ="Port to listen for gossip on")]
14+
pubgossip_port:u16,
15+
/// Interval to send discovery packets.
16+
#[clap(long, short ='i', default_value ="1", help ="Interval to send discovery packets")]
17+
pubinterval:u64,
18+
}
19+
20+
implDiscCommand{
21+
/// Run the discovery subcommand.
22+
pubasyncfnrun(self,args:&GlobalArgs) -> anyhow::Result<()>{
23+
let socket =SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0,0,0,0)),self.gossip_port);
24+
tracing::info!("Starting discovery service on {:?}", socket);
25+
26+
letmut discovery_builder =
27+
DiscoveryBuilder::new().with_address(socket).with_chain_id(args.l2_chain_id);
28+
letmut discovery = discovery_builder.build()?;
29+
discovery.interval = std::time::Duration::from_secs(self.interval);
30+
letmut peer_recv = discovery.start();
31+
tracing::info!("Discovery service started, receiving peers.");
32+
33+
loop{
34+
match peer_recv.recv().await{
35+
Some(peer) =>{
36+
tracing::info!("Received peer: {:?}", peer);
37+
}
38+
None =>{
39+
tracing::warn!("Failed to receive peer");
40+
}
41+
}
42+
}
43+
}
44+
}

‎bin/nexus/src/globals.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//! Global arguments for the CLI.
2+
3+
use clap::Parser;
4+
5+
/// Global arguments for the CLI.
6+
#[derive(Parser,Clone,Debug)]
7+
pub(crate)structGlobalArgs{
8+
/// The L2 chain ID to use.
9+
#[clap(long, short ='c', default_value ="10", help ="The L2 chain ID to use")]
10+
publ2_chain_id:u64,
11+
/// A port to serve prometheus metrics on.
12+
#[clap(
13+
long,
14+
short ='m',
15+
default_value ="9090",
16+
help ="The port to serve prometheus metrics on"
17+
)]
18+
pubmetrics_port:u16,
19+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp