From 86fbe1bb2d2ab81310fc6bc6430ba1b7a1d48481 Mon Sep 17 00:00:00 2001 From: Age Manning Date: Wed, 25 Sep 2024 13:16:36 +1000 Subject: [PATCH] Restructure codebase --- Cargo.lock | 12 ++++++++++ Cargo.toml | 24 ++++++++++++------- anchor/Cargo.toml | 24 +++++++++++++++++++ build.rs => anchor/build.rs | 0 anchor/client/Cargo.toml | 17 +++++++++++++ {src => anchor/client/src}/config.rs | 0 src/client/mod.rs => anchor/client/src/lib.rs | 5 +++- {src => anchor/src}/cli.rs | 7 +++--- {src => anchor/src}/environment.rs | 0 {src => anchor/src}/main.rs | 9 +++---- {src => anchor/src}/version.rs | 0 11 files changed, 81 insertions(+), 17 deletions(-) create mode 100644 anchor/Cargo.toml rename build.rs => anchor/build.rs (100%) create mode 100644 anchor/client/Cargo.toml rename {src => anchor/client/src}/config.rs (100%) rename src/client/mod.rs => anchor/client/src/lib.rs (98%) rename {src => anchor/src}/cli.rs (96%) rename {src => anchor/src}/environment.rs (100%) rename {src => anchor/src}/main.rs (91%) rename {src => anchor/src}/version.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 10fda84..d373b5d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,6 +32,7 @@ version = "0.1.0" dependencies = [ "async-channel", "clap", + "client", "dirs", "ethereum_hashing", "futures", @@ -183,6 +184,17 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +[[package]] +name = "client" +version = "0.1.0" +dependencies = [ + "clap", + "dirs", + "sensitive_url", + "serde", + "task_executor", +] + [[package]] name = "colorchoice" version = "1.0.2" diff --git a/Cargo.toml b/Cargo.toml index 1850bb6..b251438 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,16 @@ -[package] -name = "anchor" -version = "0.1.0" +[workspace] +# Extra tooling projects will be added. +members = [ + "anchor", + "anchor/client", +] +resolver = "2" + +[workspace.package] edition = "2021" -authors = ["Sigma Prime "] -rust-version = "1.80.0" -[dependencies] +[workspace.dependencies] +client = { path = "anchor/client" } task_executor = { git = "https://github.com/sigp/lighthouse", branch = "anchor", default-features = false, features = ["tracing"] } sensitive_url = { git = "https://github.com/sigp/lighthouse", branch = "anchor"} async-channel = "1.9" @@ -20,5 +25,8 @@ tracing = "0.1.40" git-version = "0.3.9" target_info = "0.1.0" -[dev-dependencies] -regex = "1.10.6" +[profile.maxperf] +inherits = "release" +lto = "fat" +codegen-units = 1 +incremental = false diff --git a/anchor/Cargo.toml b/anchor/Cargo.toml new file mode 100644 index 0000000..67c1c9f --- /dev/null +++ b/anchor/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "anchor" +version = "0.1.0" +edition = { workspace = true } +authors = ["Sigma Prime "] +rust-version = "1.80.0" + +[dependencies] +task_executor = { workspace = true } +sensitive_url = { workspace = true } +async-channel = { workspace = true } +clap = { workspace = true } +dirs = { workspace = true } +ethereum_hashing = { workspace = true } +futures = { workspace = true } +serde = { workspace = true } +tokio = { workspace = true } +tracing = { workspace = true } +git-version = { workspace = true } +target_info = { workspace = true } +client = { workspace = true } + +[dev-dependencies] +regex = "1.10.6" diff --git a/build.rs b/anchor/build.rs similarity index 100% rename from build.rs rename to anchor/build.rs diff --git a/anchor/client/Cargo.toml b/anchor/client/Cargo.toml new file mode 100644 index 0000000..e69699f --- /dev/null +++ b/anchor/client/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "client" +version = "0.1.0" +authors = ["Sigma Prime Command { .styles(get_color_style()) .next_line_help(true) .term_width(80) - .disable_help_flag(true) .about( - "Anchor client. Maintained by Sigma Prime", + "Anchor is a rust-based SSV client. Currently under active developement and should not be used for production." ) .long_version(LONG_VERSION.as_str()) .display_order(0) @@ -71,8 +70,8 @@ pub fn cli_app() -> Command { .value_name("DIR") .global(true) .help( - "Used to specify a custom root data directory for lighthouse keys and databases. \ - Defaults to $HOME/.lighthouse/{network} where network is the value of the `network` flag \ + "Used to specify a custom root data directory for anchor keys and databases. \ + Defaults to $HOME/.anchor/{network} where network is the value of the `network` flag \ Note: Users should specify separate custom datadirs for different networks.") .action(ArgAction::Set) .display_order(0) diff --git a/src/environment.rs b/anchor/src/environment.rs similarity index 100% rename from src/environment.rs rename to anchor/src/environment.rs diff --git a/src/main.rs b/anchor/src/main.rs similarity index 91% rename from src/main.rs rename to anchor/src/main.rs index 9b40b84..bf33720 100644 --- a/src/main.rs +++ b/anchor/src/main.rs @@ -1,8 +1,6 @@ use tracing::{error, info}; mod cli; -mod client; -mod config; mod environment; mod version; @@ -20,8 +18,11 @@ fn main() { // Obtain the CLI and build the config let cli = cli::cli_app(); let matches = cli.get_matches(); - // Build the config - let config = match config::from_cli(&matches) { + + // Currently the only binary is the client. We build the client config, but later this will + // generalise to other sub commands + // Build the client config + let config = match client::config::from_cli(&matches) { Ok(config) => config, Err(e) => { error!(e, "Unable to initialize configuration"); diff --git a/src/version.rs b/anchor/src/version.rs similarity index 100% rename from src/version.rs rename to anchor/src/version.rs