-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from anton-rs/rf/feat/net-bin
chore: rework binaries
- Loading branch information
Showing
14 changed files
with
234 additions
and
148 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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# `net` | ||
|
||
A hilo-powered binary that runs gossip and discovery services. |
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
//! Gossip subcommand for Hera. | ||
//! Gossip subcommand. | ||
use crate::globals::GlobalArgs; | ||
use clap::Args; | ||
|
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
File renamed without changes.
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,25 @@ | ||
[package] | ||
name = "node" | ||
version = "0.1.0" | ||
description = "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 | ||
# hilo-net.workspace = true | ||
# hilo = { 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"] } |
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 |
---|---|---|
@@ -1,26 +1,25 @@ | ||
## `hera` | ||
## `node` | ||
|
||
_Hera is a Rust implementation of the [OP Stack][opstack] Rollup node._ | ||
A rollup or consensus node powered by [hilo] and [kona]. | ||
|
||
### Overview | ||
|
||
Hera can be run as either a standalone node or as an [Execution Extension][exex] | ||
It 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 | ||
Under the hood, the node 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 | ||
cargo run --bin node | ||
``` | ||
|
||
|
||
<!-- Links --> | ||
|
||
[hilo]: https://github.com/anton-rs/hilo | ||
[kona]: https://github.com/anton-rs/kona | ||
[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 |
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,52 @@ | ||
#![doc = include_str!("../README.md")] | ||
#![doc(issue_tracker_base_url = "https://github.com/anton-rs/hilo/issues/")] | ||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] | ||
#![cfg_attr(not(test), warn(unused_crate_dependencies))] | ||
|
||
use clap::Parser; | ||
use eyre::Result; | ||
|
||
mod telemetry; | ||
|
||
/// CLI Arguments. | ||
#[derive(Parser, Clone, Debug)] | ||
#[command(author, version, about, long_about = None)] | ||
pub(crate) struct NodeArgs { | ||
/// 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, | ||
// The hilo Rollup node configuration. | ||
// #[clap(flatten)] | ||
// pub hilo_config: HiloArgsExt, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
// Parse arguments. | ||
let args = NodeArgs::parse(); | ||
|
||
// Initialize the telemetry stack. | ||
telemetry::init_stack(args.metrics_port)?; | ||
|
||
// info!( | ||
// "Running the Hilo 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(()) | ||
} |
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,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(()) | ||
} |