Skip to content

Commit

Permalink
Add anemo CLI features to sui-tool. (MystenLabs#8132)
Browse files Browse the repository at this point in the history
Includes manual definitions for Sui and Narwhal services.
  • Loading branch information
aschran authored Feb 9, 2023
1 parent 0977fa1 commit 2bd96d2
Show file tree
Hide file tree
Showing 8 changed files with 239 additions and 25 deletions.
88 changes: 80 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@ fastcrypto-zkp = { git = "https://github.com/MystenLabs/fastcrypto", rev = "b2c7
fastcrypto-tbls = { git = "https://github.com/MystenLabs/fastcrypto", rev = "b2c77ad4aff173462a1270b4ce0be63ef37db06b", package = "fastcrypto-tbls" }

# anemo dependencies
anemo = { git = "https://github.com/mystenlabs/anemo.git", rev = "0e0ef7054082a6f5a8921688e3d568761bc3be21" }
anemo-build = { git = "https://github.com/mystenlabs/anemo.git", rev = "0e0ef7054082a6f5a8921688e3d568761bc3be21" }
anemo-tower = { git = "https://github.com/mystenlabs/anemo.git", rev = "0e0ef7054082a6f5a8921688e3d568761bc3be21" }
anemo = { git = "https://github.com/mystenlabs/anemo.git", rev = "d4017b6cefad7ebc5e84b5c6b8eeff4668f719ff" }
anemo-build = { git = "https://github.com/mystenlabs/anemo.git", rev = "d4017b6cefad7ebc5e84b5c6b8eeff4668f719ff" }
anemo-cli = { git = "https://github.com/mystenlabs/anemo.git", rev = "d4017b6cefad7ebc5e84b5c6b8eeff4668f719ff" }
anemo-tower = { git = "https://github.com/mystenlabs/anemo.git", rev = "d4017b6cefad7ebc5e84b5c6b8eeff4668f719ff" }

# Use the same workspace-hack across crates.
workspace-hack = { path = "crates/workspace-hack" }
Expand Down
5 changes: 4 additions & 1 deletion crates/sui-tool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ anemo.workspace = true
anyhow = { version = "1.0.64", features = ["backtrace"] }
tokio = { workspace = true, features = ["full"] }
tracing = "0.1.36"
clap = { version = "3.2.17", features = ["derive"] }
clap = { version = "4.1.4", features = ["derive"] }

mysten-network.workspace = true
itertools = { version = "0.10.3", features = ["use_alloc"] }
Expand All @@ -25,13 +25,16 @@ strum_macros = "^0.24"
strum = "0.24.1"
serde = { version = "1.0.144", features = ["derive"] }
eyre = "0.6.8"
ron = "0.8.0"

narwhal-types = { path = "../../narwhal/types" }
sui-storage = { path = "../sui-storage" }
sui-core = { path = "../sui-core" }
sui-config = { path = "../sui-config" }
sui-types = { path = "../sui-types" }
sui-network = { path = "../sui-network" }

anemo-cli.workspace = true
telemetry-subscribers.workspace = true
typed-store.workspace = true

Expand Down
16 changes: 14 additions & 2 deletions crates/sui-tool/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use sui_types::messages_checkpoint::{
CheckpointRequest, CheckpointResponse, CheckpointSequenceNumber,
};

#[derive(Parser, Clone, ArgEnum)]
#[derive(Parser, Clone, ValueEnum)]
pub enum Verbosity {
Grouped,
Concise,
Expand Down Expand Up @@ -64,7 +64,7 @@ pub enum ToolCommand {
/// --history --verbosity concise --concise-no-header
/// ```
#[clap(
arg_enum,
value_enum,
long = "verbosity",
default_value = "grouped",
ignore_case = true
Expand All @@ -86,6 +86,7 @@ pub enum ToolCommand {
#[clap(long, help = "The transaction ID to fetch")]
digest: TransactionDigest,
},

/// Tool to read validator & node db.
#[clap(name = "db-tool")]
DbTool {
Expand Down Expand Up @@ -113,6 +114,7 @@ pub enum ToolCommand {
#[clap(long = "genesis")]
genesis: PathBuf,
},

/// Fetch authenticated checkpoint information at a specific sequence number.
/// If sequence number is not specified, get the latest authenticated checkpoint.
#[clap(name = "fetch-checkpoint")]
Expand All @@ -122,6 +124,12 @@ pub enum ToolCommand {
#[clap(long, help = "Fetch checkpoint at a specific sequence number")]
sequence_number: Option<CheckpointSequenceNumber>,
},

#[clap(name = "anemo")]
Anemo {
#[clap(next_help_heading = "foo", flatten)]
args: anemo_cli::Args,
},
}

trait OptionDebug<T> {
Expand Down Expand Up @@ -261,6 +269,10 @@ impl ToolCommand {
println!("Content: {:?}\n", contents);
}
}
ToolCommand::Anemo { args } => {
let config = crate::make_anemo_config();
anemo_cli::run(config, args).await
}
};
Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-tool/src/db_tool/db_dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use anyhow::anyhow;
use clap::Parser;
use clap::{Parser, ValueEnum};
use eyre::eyre;
use rocksdb::MultiThreaded;
use std::collections::{BTreeMap, HashMap};
Expand All @@ -21,7 +21,7 @@ use sui_types::temporary_store::InnerTemporaryStore;
use typed_store::rocks::MetricConf;
use typed_store::traits::{Map, TableSummary};

#[derive(EnumString, Parser, Debug)]
#[derive(EnumString, Clone, Parser, Debug, ValueEnum)]
pub enum StoreName {
Validator,
Index,
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-tool/src/db_tool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum DbToolCommand {
#[clap(rename_all = "kebab-case")]
pub struct Dump {
/// The type of store to dump
#[clap(long = "store")]
#[clap(long = "store", value_enum)]
store_name: StoreName,
/// The name of the table to dump
#[clap(long = "table-name")]
Expand Down
Loading

0 comments on commit 2bd96d2

Please sign in to comment.