Skip to content

Commit

Permalink
gateway: move gateway functionality into its own crate
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed May 23, 2022
1 parent e7627a6 commit b20d060
Show file tree
Hide file tree
Showing 17 changed files with 97 additions and 35 deletions.
28 changes: 28 additions & 0 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ members = [
"crates/sui-adapter-transactional-tests",
"crates/sui-config",
"crates/sui-faucet",
"crates/sui-gateway",
"crates/sui-json",
"crates/sui-network",
"crates/sui-node",
"crates/sui-open-rpc",
"crates/sui-open-rpc-macros",
"crates/sui-transactional-test-runner",
"crates/sui-types",
"crates/sui-verifier",
"crates/sui-verifier-transactional-tests",
"crates/x",
"sui",
"crates/sui-open-rpc",
"crates/sui-open-rpc-macros",
"sui_core",
"sui_programmability/framework",
"sui_storage",
Expand Down
32 changes: 32 additions & 0 deletions crates/sui-gateway/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[package]
name = "sui-gateway"
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"] }
async-trait = "0.1.53"
serde = { version = "1.0.137", features = ["derive"] }
serde_json = "1.0.80"
serde_with = { version = "1.13.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"] }
futures = "0.3.21"
ed25519-dalek = { version = "1.0.1", features = ["batch", "serde"] }

sui_core = { path = "../../sui_core" }
sui-config = { path = "../sui-config" }
sui-types = { path = "../sui-types" }
sui-json = { path = "../sui-json" }
sui-open-rpc = { path = "../sui-open-rpc" }
sui-open-rpc-macros = { path = "../sui-open-rpc-macros" }

move-core-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["address20"] }
mysten-network = { git = "https://github.com/MystenLabs/mysten-infra", rev = "7c247967e5a5abd59ecaa75bc62b05bcdf4503fe" }
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use crate::{config::Config, rpc_gateway_client::RpcGatewayClient};
use crate::rpc_gateway_client::RpcGatewayClient;
use serde::{Deserialize, Serialize};
use std::{
collections::BTreeMap,
fmt::{Display, Formatter, Write},
path::PathBuf,
time::Duration,
};
use sui_config::Config;
use sui_config::ValidatorInfo;
use sui_core::{
authority_client::NetworkAuthorityClient,
Expand Down
7 changes: 7 additions & 0 deletions crates/sui-gateway/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

pub mod api;
pub mod rpc_gateway;
pub mod rpc_gateway_client;
pub mod config;
22 changes: 10 additions & 12 deletions sui/src/rpc_gateway.rs → crates/sui-gateway/src/rpc_gateway.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use std::path::Path;

use crate::rpc_gateway::responses::SuiTypeTag;
use crate::{
api::{RpcGatewayServer, TransactionBytes},
config::GatewayConfig,
rpc_gateway::responses::ObjectResponse,
};
use anyhow::anyhow;
use async_trait::async_trait;
use ed25519_dalek::ed25519::signature::Signature;
use jsonrpsee::core::RpcResult;
use sui_core::gateway_types::{TransactionEffectsResponse, TransactionResponse};
use tracing::debug;

use std::path::Path;
use sui_config::PersistedConfig;
use sui_core::gateway_state::{GatewayClient, GatewayState, GatewayTxSeqNumber};
use sui_core::gateway_types::GetObjectInfoResponse;
use sui_core::gateway_types::{TransactionEffectsResponse, TransactionResponse};
use sui_json::SuiJsonValue;
use sui_types::sui_serde::Base64;
use sui_types::{
Expand All @@ -20,13 +24,7 @@ use sui_types::{
crypto::SignableBytes,
messages::{Transaction, TransactionData},
};

use crate::rpc_gateway::responses::SuiTypeTag;
use crate::{
api::{RpcGatewayServer, TransactionBytes},
config::{GatewayConfig, PersistedConfig},
rpc_gateway::responses::ObjectResponse,
};
use tracing::debug;

pub mod responses;

Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions sui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ sui-verifier = { path = "../crates/sui-verifier" }
sui-open-rpc = { path = "../crates/sui-open-rpc" }
sui-open-rpc-macros = { path = "../crates/sui-open-rpc-macros" }
sui-json = { path = "../crates/sui-json" }
sui-gateway = { path = "../crates/sui-gateway" }

rustyline = "9.1.2"
rustyline-derive = "0.6.0"
Expand Down
2 changes: 1 addition & 1 deletion sui/src/bin/full_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use std::{
path::PathBuf,
};
use sui::{
api::{RpcGatewayOpenRpc, RpcGatewayServer},
config::{sui_config_dir, FULL_NODE_DB_PATH},
sui_full_node::SuiFullNode,
};
use sui_gateway::api::{RpcGatewayOpenRpc, RpcGatewayServer};
use tracing::info;

const DEFAULT_NODE_SERVER_PORT: &str = "5002";
Expand Down
4 changes: 2 additions & 2 deletions sui/src/bin/rpc-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use std::{
path::PathBuf,
time::Instant,
};
use sui::{
use sui_config::sui_config_dir;
use sui_gateway::{
api::{RpcGatewayOpenRpc, RpcGatewayServer},
config::sui_config_dir,
rpc_gateway::RpcGatewayImpl,
};
use tracing::info;
Expand Down
4 changes: 1 addition & 3 deletions sui/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ use sui_types::base_types::*;
pub use sui_config::Config;
pub use sui_config::PersistedConfig;

pub mod gateway;

pub use sui_config::utils;

pub use gateway::{GatewayConfig, GatewayType};
pub use sui_gateway::config::{GatewayConfig, GatewayType};

const SUI_DIR: &str = ".sui";
const SUI_CONFIG_DIR: &str = "sui_config";
Expand Down
7 changes: 2 additions & 5 deletions sui/src/generate_json_rpc_spec.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use std::fs::File;
use std::io::Write;

use clap::ArgEnum;
use clap::Parser;
use pretty_assertions::assert_str_eq;
use serde::Serialize;
use serde_json::json;

use sui::api::RpcGatewayOpenRpc;
use std::fs::File;
use std::io::Write;
use sui::config::SUI_WALLET_CONFIG;
use sui::wallet_commands::{WalletCommandResult, WalletCommands, WalletContext};
use sui::wallet_commands::{EXAMPLE_NFT_DESCRIPTION, EXAMPLE_NFT_NAME, EXAMPLE_NFT_URL};
Expand Down
3 changes: 0 additions & 3 deletions sui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

pub mod api;
pub mod benchmark;
pub mod config;
pub mod keystore;
pub mod rpc_gateway;
pub mod rpc_gateway_client;
pub mod shell;
pub mod sui_commands;
pub mod sui_full_node;
Expand Down
8 changes: 4 additions & 4 deletions sui/src/sui_full_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ use std::{collections::BTreeMap, path::Path, sync::Arc, time::Duration};
use sui_storage::IndexStore;
use sui_types::{crypto::get_key_pair, sui_serde::Base64};

use crate::{
api::{RpcGatewayServer, TransactionBytes},
rpc_gateway::responses::{ObjectResponse, SuiTypeTag},
};
use anyhow::anyhow;
use async_trait::async_trait;
use jsonrpsee::core::RpcResult;
Expand All @@ -21,6 +17,10 @@ use sui_core::{
},
};
use sui_core::{authority_client::NetworkAuthorityClient, gateway_state::GatewayTxSeqNumber};
use sui_gateway::{
api::{RpcGatewayServer, TransactionBytes},
rpc_gateway::responses::{ObjectResponse, SuiTypeTag},
};
use sui_json::SuiJsonValue;
use sui_types::base_types::{ObjectID, SuiAddress, TransactionDigest};
use tracing::info;
Expand Down
6 changes: 4 additions & 2 deletions sui/src/unit_tests/rpc_server_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ use jsonrpsee::{
};

use sui::{
api::{RpcGatewayClient, RpcGatewayServer, TransactionBytes},
config::{PersistedConfig, WalletConfig, SUI_GATEWAY_CONFIG, SUI_WALLET_CONFIG},
keystore::{Keystore, SuiKeystore},
rpc_gateway::{responses::ObjectResponse, RpcGatewayImpl},
sui_commands::SuiNetwork,
};
use sui_core::gateway_state::GatewayTxSeqNumber;
use sui_core::gateway_types::{
GetObjectInfoResponse, TransactionEffectsResponse, TransactionResponse,
};
use sui_framework::build_move_package_to_bytes;
use sui_gateway::{
api::{RpcGatewayClient, RpcGatewayServer, TransactionBytes},
rpc_gateway::{responses::ObjectResponse, RpcGatewayImpl},
};
use sui_json::SuiJsonValue;
use sui_types::sui_serde::Base64;
use sui_types::{
Expand Down

0 comments on commit b20d060

Please sign in to comment.