Skip to content

Commit

Permalink
Unify sui, wallet, key-tool, sui-move binaries (MystenLabs#2786)
Browse files Browse the repository at this point in the history
* * unified sui, wallet, key-tool, sui-move binaries
* moved benchmark bins to sui-benchmark crate
* crate dependencies clean up

* name changes

* update wallet.md
some minor refactoring

* update wallet -> Sui CLI client to avoid confusion with the new wallet plugin

* rename wallet.md to cli-client.md

* minor fixes

* revert accidental checkin

* fixup after rebase

* Make small edits directly to renamed cli-client file

* Make small edits directly to install doc

* Fix typo in Chapter 3 - Immutable Objects

* Lowercase "client" for consistency

* Qualify client command with sui

* Capitalize Sui client, add fullnode ref

* fix docker file

Co-authored-by: Clay-Mysten <[email protected]>
  • Loading branch information
patrickkuo and Clay-Mysten authored Jun 30, 2022
1 parent 5f8b1e6 commit 4130560
Show file tree
Hide file tree
Showing 62 changed files with 2,690 additions and 2,105 deletions.
808 changes: 692 additions & 116 deletions Cargo.lock

Large diffs are not rendered by default.

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",
"crates/sui-adapter",
"crates/sui-adapter-transactional-tests",
"crates/sui-benchmark",
"crates/sui-cluster-test",
"crates/sui-config",
"crates/sui-core",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

* To learn how to use Sui, take our [end-to-end tutorial](doc/src/explore/tutorials.md).
* To jump right into building smart contract applications on top of Sui, start at the [Move Smart Contract Quick Start](doc/src/build/move.md).
* To experiment with a sample Sui wallet, check out [Wallet Quick Start](doc/src/build/wallet.md).
* To experiment with the Sui CLI client, check out [Sui CLI client Quick Start](doc/src/build/cli-client.md).
* To understand what's possible by browsing Move code built on top of Sui, review the [examples](doc/src/explore/examples.md).
* To start coding against Sui's REST APIs, start at the [API reference](https://app.swaggerhub.com/apis/arun-koshy/sui-api).
* To learn what distinguishes Sui from other blockchain systems, see [How Sui Differs?](doc/src/learn/sui-compared.md).
Expand Down
32 changes: 16 additions & 16 deletions crates/generate-json-rpc-spec/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ use pretty_assertions::assert_str_eq;
use serde::Serialize;
use serde_json::{json, Map, Value};

use sui::wallet_commands::{WalletCommandResult, WalletCommands, WalletContext};
use sui::wallet_commands::{EXAMPLE_NFT_DESCRIPTION, EXAMPLE_NFT_NAME, EXAMPLE_NFT_URL};
use sui::client_commands::{SuiClientCommandResult, SuiClientCommands, WalletContext};
use sui::client_commands::{EXAMPLE_NFT_DESCRIPTION, EXAMPLE_NFT_NAME, EXAMPLE_NFT_URL};
use sui_config::genesis_config::GenesisConfig;
use sui_config::SUI_WALLET_CONFIG;
use sui_config::SUI_CLIENT_CONFIG;
use sui_json::SuiJsonValue;
use sui_json_rpc::bcs_api::BcsApiImpl;
use sui_json_rpc::gateway_api::{GatewayWalletSyncApiImpl, RpcGatewayImpl, TransactionBuilderImpl};
Expand Down Expand Up @@ -130,7 +130,7 @@ async fn create_response_sample() -> Result<
> {
let network = start_rpc_test_network(Some(GenesisConfig::custom_genesis(1, 4, 30))).await?;
let working_dir = network.network.dir();
let config = working_dir.join(SUI_WALLET_CONFIG);
let config = working_dir.join(SUI_CLIENT_CONFIG);

let mut context = WalletContext::new(&config)?;
let address = context.config.accounts.first().cloned().unwrap();
Expand Down Expand Up @@ -186,14 +186,14 @@ async fn create_response_sample() -> Result<
async fn create_package_object_response(
context: &mut WalletContext,
) -> Result<(GetObjectDataResponse, TransactionResponse), anyhow::Error> {
let result = WalletCommands::Publish {
let result = SuiClientCommands::Publish {
path: "sui_programmability/examples/move_tutorial".to_string(),
gas: None,
gas_budget: 10000,
}
.execute(context)
.await?;
if let WalletCommandResult::Publish(response) = result {
if let SuiClientCommandResult::Publish(response) = result {
Ok((
context
.gateway
Expand All @@ -211,15 +211,15 @@ async fn create_transfer_response(
address: SuiAddress,
coins: &[SuiObjectInfo],
) -> Result<TransactionResponse, anyhow::Error> {
let response = WalletCommands::Transfer {
let response = SuiClientCommands::Transfer {
to: address,
coin_object_id: coins.first().unwrap().object_id,
gas: None,
gas_budget: 1000,
}
.execute(context)
.await?;
if let WalletCommandResult::Transfer(_, certificate, effects) = response {
if let SuiClientCommandResult::Transfer(_, certificate, effects) = response {
Ok(TransactionResponse::EffectResponse(
TransactionEffectsResponse {
certificate,
Expand All @@ -237,14 +237,14 @@ async fn create_hero_response(
coins: &[SuiObjectInfo],
) -> Result<(ObjectID, GetObjectDataResponse), anyhow::Error> {
// Create hero response
let result = WalletCommands::Publish {
let result = SuiClientCommands::Publish {
path: "sui_programmability/examples/games".to_string(),
gas: None,
gas_budget: 10000,
}
.execute(context)
.await?;
if let WalletCommandResult::Publish(response) = result {
if let SuiClientCommandResult::Publish(response) = result {
let package_id = response.package.object_id;
let game_info = response
.created_objects
Expand All @@ -254,7 +254,7 @@ async fn create_hero_response(

let game_info = SuiJsonValue::new(json!(game_info.reference.object_id.to_hex_literal()))?;
let coin = SuiJsonValue::new(json!(coins.first().unwrap().object_id.to_hex_literal()))?;
let result = WalletCommands::Call {
let result = SuiClientCommands::Call {
package: package_id,
module: "hero".to_string(),
function: "acquire_hero".to_string(),
Expand All @@ -266,7 +266,7 @@ async fn create_hero_response(
.execute(context)
.await?;

if let WalletCommandResult::Call(_, effect) = result {
if let SuiClientCommandResult::Call(_, effect) = result {
let hero = effect.created.first().unwrap();
Ok((
package_id,
Expand Down Expand Up @@ -332,7 +332,7 @@ async fn create_coin_split_response(
coins: &[SuiObjectInfo],
) -> Result<TransactionResponse, anyhow::Error> {
// create coin_split response
let result = WalletCommands::SplitCoin {
let result = SuiClientCommands::SplitCoin {
coin_id: coins.first().unwrap().object_id,
amounts: vec![20, 20, 20, 20, 20],
gas: None,
Expand All @@ -341,7 +341,7 @@ async fn create_coin_split_response(
.execute(context)
.await?;

if let WalletCommandResult::SplitCoin(resp) = result {
if let SuiClientCommandResult::SplitCoin(resp) = result {
Ok(TransactionResponse::SplitCoinResponse(resp))
} else {
panic!()
Expand All @@ -361,7 +361,7 @@ async fn get_nft_response(
.map(SuiJsonValue::new)
.collect::<Result<_, _>>()?;

let result = WalletCommands::Call {
let result = SuiClientCommands::Call {
package: ObjectID::from(SUI_FRAMEWORK_ADDRESS),
module: "devnet_nft".to_string(),
function: "mint".to_string(),
Expand All @@ -373,7 +373,7 @@ async fn get_nft_response(
.execute(context)
.await?;

if let WalletCommandResult::Call(certificate, effects) = result {
if let SuiClientCommandResult::Call(certificate, effects) = result {
let object = context
.gateway
.get_object(effects.created.first().unwrap().reference.object_id)
Expand Down
39 changes: 39 additions & 0 deletions crates/sui-benchmark/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[package]
name = "sui-benchmark"
version = "0.0.0"
authors = ["Mysten Labs <[email protected]>"]
license = "Apache-2.0"
publish = false
edition = "2021"

[dependencies]
rayon = "1.5.3"
anyhow = { version = "1.0.57", features = ["backtrace"] }
futures = "0.3.21"
serde = { version = "1.0.137", features = ["derive"] }
serde_json = "1.0.80"
tempfile = "3.3.0"
tokio = { version = "1.18.2", features = ["full"] }
strum = "0.24.0"
strum_macros = "0.24.0"
num_cpus = "1.13.1"
rocksdb = "0.18.0"
serde_with = { version = "1.14.0", features = ["hex"] }
tracing = "0.1.34"
tracing-subscriber = { version = "0.3.11", features = ["time", "registry", "env-filter"] }
clap = { version = "3.1.17", features = ["derive"] }
prometheus = "0.13.1"
multiaddr = "0.14.0"

bcs = "0.1.3"
sui-core = { path = "../sui-core" }
sui-config = { path = "../sui-config" }
sui-types = { path = "../sui-types" }

move-core-types = { git = "https://github.com/move-language/move", rev = "ae62d5f1955a9b92c3ddd31d3cc4467f9aff76ae", features = ["address20"] }
narwhal-node = { git = "https://github.com/MystenLabs/narwhal", rev = "05fa85552c49f0775a47d72c37074c9ca1754900", package = "node" }

workspace-hack = { path = "../workspace-hack"}

[features]
benchmark = ["narwhal-node/benchmark"]
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use crate::config::Config;
use sui_config::NetworkConfig;
use sui_config::{Config, NetworkConfig};

use super::load_generator::calculate_throughput;
use clap::*;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
// ./bench microbench local-single-validator-thread latency

use clap::*;
use sui::benchmark::{bench_types, run_benchmark, validator_preparer::VALIDATOR_BINARY_NAME};
use sui_benchmark::benchmark::{
bench_types, run_benchmark, validator_preparer::VALIDATOR_BINARY_NAME,
};
use tracing::subscriber::set_global_default;
use tracing_subscriber::EnvFilter;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@

use clap::*;
use futures::join;
use sui::benchmark::bench_types::{MicroBenchmarkResult, RemoteLoadGenConfig};
use sui::benchmark::load_generator::MultiFixedRateLoadGenerator;
use sui_benchmark::benchmark::bench_types::{MicroBenchmarkResult, RemoteLoadGenConfig};
use sui_benchmark::benchmark::load_generator::MultiFixedRateLoadGenerator;

use std::panic;
use std::path::PathBuf;
use sui::benchmark::transaction_creator::TransactionCreator;
use sui::benchmark::validator_preparer::ValidatorPreparer;
use sui::config::PersistedConfig;
use sui_config::NetworkConfig;
use sui_benchmark::benchmark::transaction_creator::TransactionCreator;
use sui_benchmark::benchmark::validator_preparer::ValidatorPreparer;
use sui_config::{NetworkConfig, PersistedConfig};
use sui_types::base_types::ObjectID;
use sui_types::crypto::KeyPair;
use tokio::runtime::Builder;
Expand Down
4 changes: 4 additions & 0 deletions crates/sui-benchmark/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

pub mod benchmark;
1 change: 1 addition & 0 deletions crates/sui-cluster-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ sui-json-rpc-api = { path = "../sui-json-rpc-api" }
sui-core = { path = "../sui-core" }
sui-types = { path = "../sui-types" }
sui-json = { path = "../sui-json" }
sui-config = { path = "../sui-config" }
workspace-hack = { path = "../workspace-hack"}
17 changes: 8 additions & 9 deletions crates/sui-cluster-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
use clap::*;
use serde_json::json;
use std::collections::HashMap;
use sui::config::{Config, GatewayType, WalletConfig};
use sui::{
keystore::KeystoreType,
wallet_commands::{
call_move, WalletContext, EXAMPLE_NFT_DESCRIPTION, EXAMPLE_NFT_NAME, EXAMPLE_NFT_URL,
},
use sui::client_commands::{
call_move, WalletContext, EXAMPLE_NFT_DESCRIPTION, EXAMPLE_NFT_NAME, EXAMPLE_NFT_URL,
};
use sui::config::{Config, GatewayType, SuiClientConfig};
use sui_config::SUI_KEYSTORE_FILENAME;
use sui_faucet::FaucetResponse;
use sui_json::SuiJsonValue;
use sui_json_rpc_api::keystore::KeystoreType;
use sui_json_rpc_api::rpc_types::{GetObjectDataResponse, SuiExecutionStatus, TransactionResponse};
use sui_types::{
base_types::{encode_bytes_hex, ObjectID, SuiAddress},
Expand Down Expand Up @@ -368,11 +367,11 @@ impl ClusterTest {
};

info!("Use gateway: {}", &gateway_addr);
info!("Use facuet: {}", &faucet_addr);
let keystore_path = temp_dir.path().join("wallet.key");
info!("Use facet: {}", &faucet_addr);
let keystore_path = temp_dir.path().join(SUI_KEYSTORE_FILENAME);
let keystore = KeystoreType::File(keystore_path);
let new_address = keystore.init().unwrap().add_random_key().unwrap();
WalletConfig {
SuiClientConfig {
accounts: vec![new_address],
keystore,
gateway: GatewayType::RPC(gateway_addr),
Expand Down
3 changes: 2 additions & 1 deletion crates/sui-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const SUI_DIR: &str = ".sui";
const SUI_CONFIG_DIR: &str = "sui_config";
pub const SUI_NETWORK_CONFIG: &str = "network.yaml";
pub const SUI_FULLNODE_CONFIG: &str = "fullnode.yaml";
pub const SUI_WALLET_CONFIG: &str = "wallet.yaml";
pub const SUI_CLIENT_CONFIG: &str = "client.yaml";
pub const SUI_KEYSTORE_FILENAME: &str = "sui.keystore";
pub const SUI_GATEWAY_CONFIG: &str = "gateway.yaml";
pub const SUI_GENESIS_FILENAME: &str = "genesis.blob";
pub const SUI_DEV_NET_URL: &str = "https://gateway.devnet.sui.io:443";
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-faucet/src/faucet/simple_faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use anyhow::anyhow;
use async_trait::async_trait;
use sui::wallet_commands::WalletContext;
use sui::client_commands::WalletContext;
use sui_json_rpc_api::rpc_types::{SuiExecutionStatus, SuiParsedObject};
use sui_types::{
base_types::{ObjectID, SuiAddress},
Expand Down
8 changes: 4 additions & 4 deletions crates/sui-faucet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use std::{
sync::Arc,
time::Duration,
};
use sui::wallet_commands::{WalletCommands, WalletContext};
use sui_config::{sui_config_dir, SUI_WALLET_CONFIG};
use sui::client_commands::{SuiClientCommands, WalletContext};
use sui_config::{sui_config_dir, SUI_CLIENT_CONFIG};
use sui_faucet::{Faucet, FaucetRequest, FaucetResponse, SimpleFaucet};
use tower::ServiceBuilder;
use tower_http::cors::{Any, CorsLayer};
Expand Down Expand Up @@ -145,7 +145,7 @@ async fn request_gas(

async fn create_wallet_context() -> Result<WalletContext, anyhow::Error> {
// Create Wallet context.
let wallet_conf = sui_config_dir()?.join(SUI_WALLET_CONFIG);
let wallet_conf = sui_config_dir()?.join(SUI_CLIENT_CONFIG);
info!("Initialize wallet from config path: {:?}", wallet_conf);
let mut context = WalletContext::new(&wallet_conf)?;
let address = context
Expand All @@ -156,7 +156,7 @@ async fn create_wallet_context() -> Result<WalletContext, anyhow::Error> {
.ok_or_else(|| anyhow::anyhow!("Empty wallet context!"))?;

// Sync client to retrieve objects from the network.
WalletCommands::SyncClientState {
SuiClientCommands::SyncClientState {
address: Some(address),
}
.execute(&mut context)
Expand Down
26 changes: 12 additions & 14 deletions crates/sui-gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,28 @@ edition = "2021"
anyhow = { version = "1.0.58", features = ["backtrace"] }
async-trait = "0.1.53"
serde = { version = "1.0.137", features = ["derive"] }
serde_json = "1.0.80"
serde_with = { version = "1.14.0", features = ["hex"] }
schemars = "0.8.8"
jsonrpsee = { version = "0.13.1", features = ["full"] }
jsonrpsee-proc-macros = "0.13.1"
jsonrpsee-core = "0.13.1"
tracing = "0.1.34"
tokio = { version = "1.18.2", features = ["full"] }
tokio-stream = "0.1.8"
futures = "0.3.21"
ed25519-dalek = { version = "1.0.1", features = ["batch", "serde"] }
prometheus = "0.13.1"
strum = "0.24.0"
strum_macros = "0.24.0"
once_cell = "1.11.0"
clap = { version = "3.1.17", features = ["derive"] }
telemetry-subscribers = { git = "https://github.com/MystenLabs/mysten-infra", rev = "94d7da89f6a52d7f60a9802b0a03147a9c89c3e4" }

sui-core = { path = "../sui-core" }
sui-config = { path = "../sui-config" }
sui-types = { path = "../sui-types" }
sui-json = { path = "../sui-json" }
sui-json-rpc = { path = "../sui-json-rpc" }
sui-json-rpc-api = { path = "../sui-json-rpc-api" }
sui-open-rpc = { path = "../sui-open-rpc" }
sui-node = { path = "../sui-node" }

move-core-types = { git = "https://github.com/move-language/move", rev = "ae62d5f1955a9b92c3ddd31d3cc4467f9aff76ae", features = ["address20"] }
move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "ae62d5f1955a9b92c3ddd31d3cc4467f9aff76ae" }
mysten-network = { git = "https://github.com/MystenLabs/mysten-infra", rev = "94d7da89f6a52d7f60a9802b0a03147a9c89c3e4" }
workspace-hack = { path = "../workspace-hack"}

[dev-dependencies]
test-utils = { path = "../test-utils" }
sui-framework = { path = "../sui-framework" }

[[bin]]
name = "rpc-server"
path = "src/main.rs"
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const DEFAULT_RPC_SERVER_ADDR_IPV4: &str = "127.0.0.1";
const PROM_PORT_ADDR: &str = "0.0.0.0:9184";

#[cfg(test)]
#[path = "../unit_tests/rpc_server_tests.rs"]
#[path = "unit_tests/rpc_server_tests.rs"]
mod rpc_server_tests;

#[derive(Parser)]
Expand Down
Loading

0 comments on commit 4130560

Please sign in to comment.