Skip to content

Commit

Permalink
[sui-rosetta] - default data directory to /data, and override fullnod…
Browse files Browse the repository at this point in the history
…e's db dir (MystenLabs#8158)

CB is having issue restoring from snapshots, possibly due to data
directory configuration issues, this PR defaults the data directory to
/data and also override embedded sui node's database directory to
/data/sui_db
  • Loading branch information
patrickkuo authored Feb 8, 2023
1 parent 830660e commit ecac2ce
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/rosetta/start_rosetta.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

echo "Start Rosetta online server"
sui-rosetta start-online-server &
sui-rosetta start-online-server --data-path ./data &

echo "Start Rosetta offline server"
sui-rosetta start-offline-server &
21 changes: 5 additions & 16 deletions crates/sui-rosetta/docker/sui-rosetta-devnet/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
---
version: "3.9"
services:
sui-full-node:
image: mysten/sui-rosetta-devnet
ports:
- "9000:9000"
expose:
- "9000"
working_dir: /sui/devnet
command:
- /bin/bash
- -c
- |
/usr/local/bin/sui-node --config-path fullnode.yaml
stdin_open: true
tty: true
rosetta-online:
image: mysten/sui-rosetta-devnet
ports:
- "9002:9002"
expose:
- "9002"
volumes:
- data:/data:rw
working_dir: /sui/devnet
command:
- /bin/bash
- -c
- |
/usr/local/bin/sui-rosetta generate-rosetta-cli-config --env devnet &
/usr/local/bin/sui-rosetta start-online-remote-server --env devnet --full-node-url http://sui-full-node:9000
/usr/local/bin/sui-rosetta start-online-server --env devnet --node-config fullnode.yaml
stdin_open: true
tty: true
rosetta-offline:
Expand All @@ -44,4 +32,5 @@ services:
/usr/local/bin/sui-rosetta start-offline-server --env devnet
stdin_open: true
tty: true

volumes:
data:
20 changes: 15 additions & 5 deletions crates/sui-rosetta/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub enum RosettaServerCommand {
addr: SocketAddr,
#[clap(long)]
full_node_url: String,
#[clap(long, default_value = "data")]
#[clap(long, default_value = "/data")]
data_path: PathBuf,
},
StartOnlineServer {
Expand All @@ -54,7 +54,7 @@ pub enum RosettaServerCommand {
addr: SocketAddr,
#[clap(long)]
node_config: Option<PathBuf>,
#[clap(long, default_value = "data")]
#[clap(long, default_value = "/data")]
data_path: PathBuf,
},
StartOfflineServer {
Expand Down Expand Up @@ -141,7 +141,9 @@ impl RosettaServerCommand {
"Starting Rosetta Online Server with remove Sui full node [{full_node_url}]."
);
let sui_client = wait_for_sui_client(full_node_url).await;
let rosetta = RosettaOnlineServer::new(env, sui_client, &data_path);
let rosetta_path = data_path.join("rosetta_db");
info!("Rosetta db path : {rosetta_path:?}");
let rosetta = RosettaOnlineServer::new(env, sui_client, &rosetta_path);
rosetta.serve(addr).await??;
}

Expand All @@ -152,20 +154,28 @@ impl RosettaServerCommand {
data_path,
} => {
info!("Starting Rosetta Online Server with embedded Sui full node.");
info!("Data directory path: {data_path:?}");

let node_config = node_config.unwrap_or_else(|| {
let path = sui_config_dir().unwrap().join(SUI_FULLNODE_CONFIG);
info!("Using default node config from {path:?}");
path
});
let config = NodeConfig::load(&node_config)?;

let mut config = NodeConfig::load(&node_config)?;
config.db_path = data_path.join("sui_db");
info!("Overriding Sui db path to : {:?}", config.db_path);

let registry_service = metrics::start_prometheus_server(config.metrics_address);
// Staring a full node for the rosetta server.
let rpc_address = format!("http://127.0.0.1:{}", config.json_rpc_address.port());
let _node = SuiNode::start(&config, registry_service).await?;

let sui_client = wait_for_sui_client(rpc_address).await;
let rosetta = RosettaOnlineServer::new(env, sui_client, &data_path);

let rosetta_path = data_path.join("rosetta_db");
info!("Rosetta db path : {rosetta_path:?}");
let rosetta = RosettaOnlineServer::new(env, sui_client, &rosetta_path);
rosetta.serve(addr).await??;
}
};
Expand Down

0 comments on commit ecac2ce

Please sign in to comment.