From 011e6f3fd9576572b38ec23a2e161a0986f16508 Mon Sep 17 00:00:00 2001 From: refcell Date: Mon, 11 Nov 2024 07:32:07 -0500 Subject: [PATCH 1/2] feat: driver --- Cargo.lock | 128 +++++++++++++++++++++++++++++++++- Cargo.toml | 6 +- bin/hera/Cargo.toml | 24 +++++++ bin/hera/README.md | 26 +++++++ bin/hera/src/disc.rs | 45 ++++++++++++ bin/hera/src/globals.rs | 19 +++++ bin/hera/src/gossip.rs | 59 ++++++++++++++++ bin/hera/src/main.rs | 53 ++++++++++++++ bin/hera/src/node.rs | 36 ++++++++++ bin/hera/src/telemetry.rs | 50 +++++++++++++ crates/driver/Cargo.toml | 20 ++++++ crates/driver/README.md | 3 + crates/driver/src/lib.rs | 6 ++ crates/driver/src/pipeline.rs | 3 + crates/net/src/lib.rs | 2 +- 15 files changed, 476 insertions(+), 4 deletions(-) create mode 100644 bin/hera/Cargo.toml create mode 100644 bin/hera/README.md create mode 100644 bin/hera/src/disc.rs create mode 100644 bin/hera/src/globals.rs create mode 100644 bin/hera/src/gossip.rs create mode 100644 bin/hera/src/main.rs create mode 100644 bin/hera/src/node.rs create mode 100644 bin/hera/src/telemetry.rs create mode 100644 crates/driver/Cargo.toml create mode 100644 crates/driver/README.md create mode 100644 crates/driver/src/lib.rs create mode 100644 crates/driver/src/pipeline.rs diff --git a/Cargo.lock b/Cargo.lock index 7076532..f624968 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,9 +82,9 @@ checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" [[package]] name = "allocator-api2" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611cc2ae7d2e242c457e4be7f97036b8ad9ca152b499f53faf99b1ed8fc2553f" +checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" [[package]] name = "alloy-chains" @@ -534,6 +534,55 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +dependencies = [ + "anstyle", + "windows-sys 0.59.0", +] + [[package]] name = "anyhow" version = "1.0.93" @@ -1111,6 +1160,52 @@ dependencies = [ "zeroize", ] +[[package]] +name = "clap" +version = "4.5.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "clap_lex" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" + +[[package]] +name = "colorchoice" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + [[package]] name = "concurrent-queue" version = "2.5.0" @@ -2056,6 +2151,19 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hera" +version = "0.1.0" +dependencies = [ + "clap", + "eyre", + "super", + "super-driver", + "super-net", + "tokio", + "tracing", +] + [[package]] name = "hermit-abi" version = "0.3.9" @@ -2660,6 +2768,12 @@ version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" @@ -4855,6 +4969,10 @@ dependencies = [ "tracing", ] +[[package]] +name = "super-driver" +version = "0.11.0" + [[package]] name = "super-net" version = "0.11.0" @@ -5438,6 +5556,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "valuable" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 16ed9c8..0fa7354 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["crates/*"] +members = ["crates/*", "bin/*"] resolver = "2" [workspace.package] @@ -38,6 +38,9 @@ rustdoc-args = ["--cfg", "docsrs"] [workspace.dependencies] # Workspace +super = { version = "0.11.0", path = "crates/super", default-features = false } +super-net = { version = "0.11.0", path = "crates/net", default-features = false } +super-driver = { version = "0.11.0", path = "crates/driver", default-features = false } super-derive = { version = "0.11.0", path = "crates/derive", default-features = false } super-registry = { version = "0.11.0", path = "crates/registry", default-features = false } @@ -83,6 +86,7 @@ arbitrary = "1" # Misc lru = "0.12.5" eyre = "0.6.12" +clap = "4.5.20" tokio = "1.41.0" futures = "0.3.31" reqwest = "0.12.9" diff --git a/bin/hera/Cargo.toml b/bin/hera/Cargo.toml new file mode 100644 index 0000000..d58be81 --- /dev/null +++ b/bin/hera/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "hera" +version = "0.1.0" +description = "Hera is a Rust implementation of the OP Stack Rollup Node" + +edition.workspace = true +authors.workspace = true +license.workspace = true +keywords.workspace = true +repository.workspace = true +categories.workspace = true +rust-version.workspace = true + +[dependencies] +# Local +super.workspace = true +super-net.workspace = true +super-driver.workspace = true + +# Workspace +eyre.workspace = true +tracing.workspace = true +clap = { workspace = true, features = ["derive", "env"] } +tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } diff --git a/bin/hera/README.md b/bin/hera/README.md new file mode 100644 index 0000000..dd582fc --- /dev/null +++ b/bin/hera/README.md @@ -0,0 +1,26 @@ +## `hera` + +_Hera is a Rust implementation of the [OP Stack][opstack] Rollup node._ + +### Overview + +Hera can be run as either a standalone node or as an [Execution Extension][exex] +on top of an L1 [Reth][reth] node in the same process. + +Under the hood, Hera is powered by the [Kona-derive][kona] library which handles +the [derivation pipeline][derivation] of the L2 payloads from L1 transactions. + +### Usage + +``` +cargo run --bin hera +``` + + + + +[reth]: https://github.com/paradigmxyz/reth +[kona]: https://github.com/ethereum-optimism/kona +[exex]: https://www.paradigm.xyz/2024/05/reth-exex +[opstack]: https://docs.optimism.io/ +[derivation]: https://docs.optimism.io/stack/protocol/derivation-pipeline diff --git a/bin/hera/src/disc.rs b/bin/hera/src/disc.rs new file mode 100644 index 0000000..3187ee6 --- /dev/null +++ b/bin/hera/src/disc.rs @@ -0,0 +1,45 @@ +//! Discovery subcommand for Hera. + +use crate::globals::GlobalArgs; +use clap::Args; +use eyre::Result; +use std::net::{IpAddr, Ipv4Addr, SocketAddr}; +use super_net::discovery::builder::DiscoveryBuilder; + +/// The Hera 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) -> 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"); + } + } + } + } +} diff --git a/bin/hera/src/globals.rs b/bin/hera/src/globals.rs new file mode 100644 index 0000000..6009e5c --- /dev/null +++ b/bin/hera/src/globals.rs @@ -0,0 +1,19 @@ +//! Global arguments for the Hera CLI. + +use clap::Parser; + +/// Global arguments for the Hera 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, +} diff --git a/bin/hera/src/gossip.rs b/bin/hera/src/gossip.rs new file mode 100644 index 0000000..13439d4 --- /dev/null +++ b/bin/hera/src/gossip.rs @@ -0,0 +1,59 @@ +//! Gossip subcommand for Hera. + +use super::ROLLUP_CONFIGS; +use crate::globals::GlobalArgs; +use clap::Args; +use eyre::Result; +use std::net::{IpAddr, Ipv4Addr, SocketAddr}; +use super_net::driver::NetworkDriver; + +/// The Hera gossip subcommand. +#[derive(Debug, Clone, Args)] +#[non_exhaustive] +pub struct GossipCommand { + /// 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 GossipCommand { + /// Run the gossip subcommand. + pub async fn run(self, args: &GlobalArgs) -> Result<()> { + let signer = ROLLUP_CONFIGS + .get(&args.l2_chain_id) + .ok_or(eyre::eyre!("No rollup config found for chain ID"))? + .genesis + .system_config + .as_ref() + .ok_or(eyre::eyre!("No system config found for chain ID"))? + .batcher_address; + tracing::info!("Gossip configured with signer: {:?}", signer); + + let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), self.gossip_port); + tracing::info!("Starting gossip driver on {:?}", socket); + + let mut driver = NetworkDriver::builder() + .with_chain_id(args.l2_chain_id) + .with_unsafe_block_signer(signer) + .with_gossip_addr(socket) + .with_interval(std::time::Duration::from_secs(self.interval)) + .build()?; + let recv = + driver.take_unsafe_block_recv().ok_or(eyre::eyre!("No unsafe block receiver"))?; + driver.start()?; + tracing::info!("Gossip driver started, receiving blocks."); + loop { + match recv.recv() { + Ok(block) => { + tracing::info!("Received unsafe block: {:?}", block); + } + Err(e) => { + tracing::warn!("Failed to receive unsafe block: {:?}", e); + } + } + } + } +} diff --git a/bin/hera/src/main.rs b/bin/hera/src/main.rs new file mode 100644 index 0000000..260a0f0 --- /dev/null +++ b/bin/hera/src/main.rs @@ -0,0 +1,53 @@ +#![doc = include_str!("../README.md")] +#![doc(issue_tracker_base_url = "https://github.com/anton-rs/super/issues/")] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + +use clap::{Parser, Subcommand}; +use eyre::Result; + +mod disc; +mod globals; +mod gossip; +mod node; +mod telemetry; + +/// The Hera CLI Arguments. +#[derive(Parser, Clone, Debug)] +#[command(author, version, about, long_about = None)] +pub(crate) struct HeraArgs { + /// Global arguments for the Hera CLI. + #[clap(flatten)] + pub global: globals::GlobalArgs, + /// The subcommand to run. + #[clap(subcommand)] + pub subcommand: HeraSubcommand, +} + +/// Subcommands for the CLI. +#[derive(Debug, Clone, Subcommand)] +#[allow(clippy::large_enum_variant)] +pub(crate) enum HeraSubcommand { + /// Run the standalone Hera node. + Node(node::NodeCommand), + /// Discovery service command. + Disc(disc::DiscCommand), + /// Gossip service command. + Gossip(gossip::GossipCommand), +} + +#[tokio::main] +async fn main() -> Result<()> { + // Parse arguments. + let args = HeraArgs::parse(); + + // Initialize the telemetry stack. + telemetry::init_stack(args.global.metrics_port)?; + + // Dispatch on subcommand. + match args.subcommand { + HeraSubcommand::Node(node) => node.run(&args.global).await, + HeraSubcommand::Disc(disc) => disc.run(&args.global).await, + HeraSubcommand::Gossip(gossip) => gossip.run(&args.global).await, + } +} diff --git a/bin/hera/src/node.rs b/bin/hera/src/node.rs new file mode 100644 index 0000000..f879d4b --- /dev/null +++ b/bin/hera/src/node.rs @@ -0,0 +1,36 @@ +//! Node subcommand for Hera. + +use clap::Args; +use eyre::{bail, Result}; +// use rollup::{Driver, HeraArgsExt}; +use tracing::info; + +use crate::globals::GlobalArgs; + +/// The Hera node subcommand. +#[derive(Debug, Clone, Args)] +#[non_exhaustive] +pub struct NodeCommand { + // The Hera Rollup node configuration. + // #[clap(flatten)] + // pub hera_config: HeraArgsExt, +} + +impl NodeCommand { + /// Run the node subcommand. + pub async fn run(self, _args: &GlobalArgs) -> Result<()> { + // info!( + // "Running the Hera Node in Standalone mode. Attributes validation: {}", + // self.hera_config.validation_mode + // ); + // + // let cfg = self.hera_config.get_l2_config()?; + // let driver = Driver::standalone(self.hera_config, cfg).await?; + // + // if let Err(e) = driver.start().await { + // bail!("[CRIT] Rollup driver failed: {:?}", e) + // } + + Ok(()) + } +} diff --git a/bin/hera/src/telemetry.rs b/bin/hera/src/telemetry.rs new file mode 100644 index 0000000..19b6bf2 --- /dev/null +++ b/bin/hera/src/telemetry.rs @@ -0,0 +1,50 @@ +use std::{io::IsTerminal, net::SocketAddr}; + +use eyre::{bail, Result}; +use metrics_exporter_prometheus::PrometheusBuilder; +use tracing::{info, Level}; +use tracing_subscriber::{ + fmt::Layer as FmtLayer, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer, +}; + +/// Initialize the tracing stack and Prometheus metrics recorder. +/// +/// This function should be called at the beginning of the program. +pub fn init_stack(metrics_port: u16) -> Result<()> { + let filter = EnvFilter::builder().with_default_directive("hera=info".parse()?).from_env_lossy(); + + // Whether to use ANSI formatting and colors in the console output. + // If unset, always use colors if stdout is a tty. + // If set to "never", just disable all colors. + let should_use_colors = match std::env::var("RUST_LOG_STYLE") { + Ok(val) => val != "never", + Err(_) => std::io::stdout().is_terminal(), + }; + + // Whether to show the tracing target in the console output. + // If set, always show the target unless explicitly set to "0". + // If unset, show target only if the filter is more verbose than INFO. + let should_show_target = match std::env::var("RUST_LOG_TARGET") { + Ok(val) => val != "0", + Err(_) => filter.max_level_hint().map_or(true, |max_level| max_level > Level::INFO), + }; + + let std_layer = FmtLayer::new() + .with_ansi(should_use_colors) + .with_target(should_show_target) + .with_writer(std::io::stdout) + .with_filter(filter); + + tracing_subscriber::registry().with(std_layer).try_init()?; + + let prometheus_addr = SocketAddr::from(([0, 0, 0, 0], metrics_port)); + let builder = PrometheusBuilder::new().with_http_listener(prometheus_addr); + + if let Err(e) = builder.install() { + bail!("failed to install Prometheus recorder: {:?}", e); + } else { + info!("Telemetry initialized. Serving Prometheus metrics at: http://{}", prometheus_addr); + } + + Ok(()) +} diff --git a/crates/driver/Cargo.toml b/crates/driver/Cargo.toml new file mode 100644 index 0000000..6ff81f3 --- /dev/null +++ b/crates/driver/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "super-driver" +description = "Derivation driver for the OP Stack" + +version.workspace = true +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] +# Kona +# kona-derive.workspace = true + +[features] +default = [] diff --git a/crates/driver/README.md b/crates/driver/README.md new file mode 100644 index 0000000..60e25ee --- /dev/null +++ b/crates/driver/README.md @@ -0,0 +1,3 @@ +# `super-driver` + +A driver implementation for Kona's derivation pipeline that extends `kona-driver`. diff --git a/crates/driver/src/lib.rs b/crates/driver/src/lib.rs new file mode 100644 index 0000000..bade432 --- /dev/null +++ b/crates/driver/src/lib.rs @@ -0,0 +1,6 @@ +#![doc = include_str!("../README.md")] +#![doc(issue_tracker_base_url = "https://github.com/anton-rs/super/issues/")] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + +pub mod pipeline; diff --git a/crates/driver/src/pipeline.rs b/crates/driver/src/pipeline.rs new file mode 100644 index 0000000..ffabcfb --- /dev/null +++ b/crates/driver/src/pipeline.rs @@ -0,0 +1,3 @@ +//! A pipeline + +// todo!(); diff --git a/crates/net/src/lib.rs b/crates/net/src/lib.rs index 94ef225..72007ea 100644 --- a/crates/net/src/lib.rs +++ b/crates/net/src/lib.rs @@ -1,5 +1,5 @@ #![doc = include_str!("../README.md")] -#![doc(issue_tracker_base_url = "https://github.com/ithacaxyz/op-rs/issues/")] +#![doc(issue_tracker_base_url = "https://github.com/anton-rs/super/issues/")] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(not(test), warn(unused_crate_dependencies))] From 7805156de64e3f8ee50bc6795f698d64d92a993e Mon Sep 17 00:00:00 2001 From: refcell Date: Mon, 11 Nov 2024 10:45:38 -0500 Subject: [PATCH 2/2] fixes --- Cargo.lock | 135 ++++++++++++++++++++++++++++++++++++++--- Cargo.toml | 7 ++- bin/hera/Cargo.toml | 5 +- bin/hera/src/gossip.rs | 2 +- bin/hera/src/node.rs | 4 +- 5 files changed, 139 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f624968..46f1198 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1277,6 +1277,15 @@ dependencies = [ "libc", ] +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.20" @@ -2157,11 +2166,12 @@ version = "0.1.0" dependencies = [ "clap", "eyre", - "super", - "super-driver", + "metrics-exporter-prometheus", "super-net", + "superchain", "tokio", "tracing", + "tracing-subscriber", ] [[package]] @@ -2398,6 +2408,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.1", "httparse", + "httpdate", "itoa", "pin-project-lite", "smallvec", @@ -3352,12 +3363,65 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "metrics" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae428771d17306715c5091d446327d1cfdedc82185c65ba8423ab404e45bf10" +dependencies = [ + "ahash", + "portable-atomic", +] + +[[package]] +name = "metrics-exporter-prometheus" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b6f8152da6d7892ff1b7a1c0fa3f435e92b5918ad67035c3bb432111d9a29b" +dependencies = [ + "base64 0.22.1", + "http-body-util", + "hyper 1.5.0", + "hyper-util", + "indexmap 2.6.0", + "ipnet", + "metrics", + "metrics-util", + "quanta", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "metrics-util" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b482df36c13dd1869d73d14d28cd4855fbd6cfc32294bee109908a9f4a4ed7" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", + "hashbrown 0.15.1", + "metrics", + "quanta", + "sketches-ddsketch", +] + [[package]] name = "mime" version = "0.3.17" @@ -3968,6 +4032,12 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "portable-atomic" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" + [[package]] name = "powerfmt" version = "0.2.0" @@ -4071,7 +4141,7 @@ dependencies = [ "rand", "rand_chacha", "rand_xorshift", - "regex-syntax", + "regex-syntax 0.8.5", "rusty-fork", "tempfile", "unarray", @@ -4088,6 +4158,21 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "quanta" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5167a477619228a0b284fac2674e3c388cba90631d7b7de620e6f1fcd08da5" +dependencies = [ + "crossbeam-utils", + "libc", + "once_cell", + "raw-cpuid", + "wasi", + "web-sys", + "winapi", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -4221,6 +4306,15 @@ dependencies = [ "rand_core", ] +[[package]] +name = "raw-cpuid" +version = "11.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ab240315c661615f2ee9f0f2cd32d5a7343a84d5ebcccb99d46e6637565e7b0" +dependencies = [ + "bitflags 2.6.0", +] + [[package]] name = "rcgen" version = "0.11.3" @@ -4250,21 +4344,36 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.9", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", ] [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.5", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.8.5" @@ -4813,6 +4922,12 @@ dependencies = [ "rand_core", ] +[[package]] +name = "sketches-ddsketch" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1e9a774a6c28142ac54bb25d25562e6bcf957493a184f15ad4eebccb23e410a" + [[package]] name = "slab" version = "0.4.9" @@ -5410,10 +5525,14 @@ version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ + "matchers", "nu-ansi-term", + "once_cell", + "regex", "sharded-slab", "smallvec", "thread_local", + "tracing", "tracing-core", "tracing-log", ] diff --git a/Cargo.toml b/Cargo.toml index 0fa7354..0dd2c93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,7 @@ super = { version = "0.11.0", path = "crates/super", default-features = false } super-net = { version = "0.11.0", path = "crates/net", default-features = false } super-driver = { version = "0.11.0", path = "crates/driver", default-features = false } super-derive = { version = "0.11.0", path = "crates/derive", default-features = false } +superchain = { version = "0.11.0", path = "crates/superchain", default-features = false } super-registry = { version = "0.11.0", path = "crates/registry", default-features = false } # Kona @@ -72,6 +73,11 @@ op-alloy-rpc-types-engine = { version = "0.6.3", default-features = false } serde = { version = "1.0.214", default-features = false } serde_json = { version = "1.0.132", default-features = false } +# Tracing +tracing = { version = "0.1.40", default-features = false } +tracing-subscriber = { version = "0.3.18", default-features = false } +metrics-exporter-prometheus = { version = "0.16.0", default-features = false } + # Networking snap = "1.1.1" discv5 = "0.9.0" @@ -92,6 +98,5 @@ futures = "0.3.31" reqwest = "0.12.9" async-trait = "0.1.83" unsigned-varint = "0.8.0" -tracing = { version = "0.1.40", default-features = false } derive_more = { version = "1.0.0", default-features = false } lazy_static = { version = "1.5.0", default-features = false } diff --git a/bin/hera/Cargo.toml b/bin/hera/Cargo.toml index d58be81..4fb0ac2 100644 --- a/bin/hera/Cargo.toml +++ b/bin/hera/Cargo.toml @@ -13,12 +13,13 @@ rust-version.workspace = true [dependencies] # Local -super.workspace = true super-net.workspace = true -super-driver.workspace = true +superchain = { workspace = true, features = ["registry"] } # Workspace eyre.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"] } diff --git a/bin/hera/src/gossip.rs b/bin/hera/src/gossip.rs index 13439d4..bf5fbbe 100644 --- a/bin/hera/src/gossip.rs +++ b/bin/hera/src/gossip.rs @@ -1,11 +1,11 @@ //! Gossip subcommand for Hera. -use super::ROLLUP_CONFIGS; use crate::globals::GlobalArgs; use clap::Args; use eyre::Result; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use super_net::driver::NetworkDriver; +use superchain::registry::ROLLUP_CONFIGS; /// The Hera gossip subcommand. #[derive(Debug, Clone, Args)] diff --git a/bin/hera/src/node.rs b/bin/hera/src/node.rs index f879d4b..c3de9ab 100644 --- a/bin/hera/src/node.rs +++ b/bin/hera/src/node.rs @@ -1,9 +1,9 @@ //! Node subcommand for Hera. use clap::Args; -use eyre::{bail, Result}; +use eyre::Result; // use rollup::{Driver, HeraArgsExt}; -use tracing::info; +// use tracing::info; use crate::globals::GlobalArgs;