Skip to content

Commit

Permalink
sui-node: replace validator binary with sui-node
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed May 23, 2022
1 parent dfe87bc commit 7965618
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 100 deletions.
15 changes: 15 additions & 0 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 @@ -5,6 +5,7 @@ members = [
"crates/sui-config",
"crates/sui-faucet",
"crates/sui-network",
"crates/sui-node",
"crates/sui-transactional-test-runner",
"crates/sui-types",
"crates/sui-verifier",
Expand Down
20 changes: 20 additions & 0 deletions crates/sui-node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "sui-node"
version = "0.0.0"
authors = ["Mysten Labs <[email protected]>"]
license = "Apache-2.0"
publish = false
edition = "2021"

[dependencies]
anyhow = { version = "1.0.57", features = ["backtrace"] }
clap = { version = "3.1.17", features = ["derive"] }
multiaddr = "0.14.0"
prometheus_exporter = "0.8.4"
tokio = { version = "1.18.2", features = ["full"] }
tracing = "0.1.34"

sui-config = { path = "../sui-config" }
sui_core = { path = "../../sui_core" }

telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7c247967e5a5abd59ecaa75bc62b05bcdf4503fe" }
29 changes: 29 additions & 0 deletions crates/sui-node/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use anyhow::Result;
use sui_config::ValidatorConfig;
use sui_core::authority_server::AuthorityServerHandle;
use tracing::info;

pub struct SuiNode {
authority_server: AuthorityServerHandle,
}

impl SuiNode {
pub async fn start(config: &ValidatorConfig) -> Result<()> {
let server = sui_core::make::make_server(config).await?.spawn().await?;

info!(node =? config.public_key(),
"Initializing sui-node listening on {}", config.network_address
);

let node = SuiNode {
authority_server: server,
};

node.authority_server.join().await?;

Ok(())
}
}
51 changes: 51 additions & 0 deletions crates/sui-node/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use anyhow::Result;
use clap::Parser;
use multiaddr::Multiaddr;
use std::path::PathBuf;
use sui_config::{PersistedConfig, ValidatorConfig};
use tracing::info;

const PROM_PORT_ADDR: &str = "0.0.0.0:9184";

#[derive(Parser)]
#[clap(rename_all = "kebab-case")]
struct Args {
#[clap(long)]
pub config_path: PathBuf,

#[clap(long, help = "Specify address to listen on")]
listen_address: Option<Multiaddr>,
}

#[tokio::main]
async fn main() -> Result<()> {
// Initialize logging
let config = telemetry_subscribers::TelemetryConfig {
service_name: "sui-node".into(),
enable_tracing: std::env::var("SUI_TRACING_ENABLE").is_ok(),
json_log_output: std::env::var("SUI_JSON_SPAN_LOGS").is_ok(),
..Default::default()
};

let _guard = telemetry_subscribers::init(config);

let args = Args::parse();

let mut config = PersistedConfig::<ValidatorConfig>::read(&args.config_path)?;

// TODO: Switch from prometheus exporter. See https://github.com/MystenLabs/sui/issues/1907
let prom_binding = PROM_PORT_ADDR.parse().unwrap();
info!("Starting Prometheus HTTP endpoint at {}", PROM_PORT_ADDR);
prometheus_exporter::start(prom_binding).expect("Failed to start Prometheus exporter");

if let Some(listen_address) = args.listen_address {
config.network_address = listen_address;
}

sui_node::SuiNode::start(&config).await?;

Ok(())
}
100 changes: 0 additions & 100 deletions sui/src/bin/validator.rs

This file was deleted.

0 comments on commit 7965618

Please sign in to comment.