Skip to content

Commit

Permalink
[tools] add storage and rescue tools to libra-cli (0LNetworkCommunity…
Browse files Browse the repository at this point in the history
…#300)

Co-authored-by: xyz <xyz>
  • Loading branch information
0o-de-lally committed Aug 8, 2024
1 parent 9aaaccf commit 2def15e
Show file tree
Hide file tree
Showing 46 changed files with 388 additions and 220 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,20 @@ jobs:
if: ${{runner.environment == 'self-hosted'}}
working-directory: ./tools/rescue
run: RUST_MIN_STACK=104857600 cargo test --no-fail-fast -- --test-threads=1
storage:
timeout-minutes: 60
needs: [build-framework]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: setup env
uses: ./.github/actions/build_env

- uses: Swatinem/[email protected]
with:
shared-key: "libra-framework"
cache-all-crates: true
- name: storage
working-directory: ./tools/storage
# TODO: not testing the V6 file parsing
run: cargo test --no-fail-fast e2e_
16 changes: 0 additions & 16 deletions .vscode/launch-orig-.json

This file was deleted.

97 changes: 57 additions & 40 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,6 @@
"version": "0.2.0",
// target/debug/ol-genesis-tools --fork --output-path /opt/genesis_from_snapshot.blob --snapshot-path /Users/gsimsek/code/libra-main/ol/devnet/snapshot/state_ver_267.54ab`
"configurations": [
{
"name": "restore-bootstrap",
"type": "lldb",
"request": "launch",
"cargo": {
"args": [
"build",
"-p",
"storage"
],
},
// cd ${ARCHIVE_PATH} && ${BIN_PATH}/${BIN_FILE} restore bootstrap-db --target-db-dir ${DB_PATH} --metadata-cache-dir ${REPO_PATH}/metacache --command-adapter-config ${REPO_PATH}/epoch-archive.yaml

"args": [
"restore",
"bootstrap-db",
"epoch-ending",
"--metadata-cache-dir",
"${workspaceFolder}/tools/storage/fixtures/epoch_ending.manifest",
"--command-adapter-config",
"${workspaceFolder}/tools/storage/fixtures",
"--target-db-dir",
"${workspaceFolder}/test_db",
],
"env": {
"RUST_LOG": "warn"
},
"cwd": "${workspaceFolder}"
},
{
"name": "restore-epoch",
"type": "lldb",
Expand All @@ -42,24 +13,21 @@
"args": [
"build",
"-p",
"storage"
"libra-storage"
],
},
"args": [
"db",
"restore",
"oneoff",
"epoch-ending",
"--epoch-ending-manifest",
"${workspaceFolder}/tools/storage/fixtures/epoch_ending_79-.166d/epoch_ending.manifest.unzip",
"${workspaceFolder}/tools/storage/fixtures/v7/epoch_ending_116-.be9b/epoch_ending.manifest",
"--local-fs-dir",
"${workspaceFolder}/test_db",
"${workspaceFolder}/tools/storage/fixtures/v7",
"--target-db-dir",
"${workspaceFolder}/test_db",
],
"env": {
"RUST_LOG": "warn"
},
"cwd": "${workspaceFolder}"
},
{
"name": "restore-state",
Expand All @@ -69,27 +37,76 @@
"args": [
"build",
"-p",
"storage"
"libra-storage"
],
},
"args": [
"db",
"restore",
"oneoff",
"state-snapshot",
"--state-manifest",
"${workspaceFolder}/tools/storage/fixtures/state.manifest",
"${workspaceFolder}/tools/storage/fixtures/v7/state_epoch_116_ver_38180075.05af/state.manifest",
"--restore-mode",
"default",
"--state-into-version",
"1",
"--local-fs-dir",
"${workspaceFolder}/tools/storage/fixtures/v7/",
"--target-db-dir",
"${workspaceFolder}/test_db",
],
"cwd": "${workspaceFolder}"
},
{
"name": "restore-from-cli",
"type": "lldb",
"request": "launch",
"cargo": {
"args": [
"build",
"-p",
"libra"
],
},
"args": [
"ops",
"storage",
"db",
"restore",
"oneoff",
"epoch-ending",
"--epoch-ending-manifest",
"${workspaceFolder}/tools/storage/fixtures/v7/epoch_ending_116-.be9b/epoch_ending.manifest",
"--local-fs-dir",
"${workspaceFolder}/tools/storage/fixtures/v7",
"--target-db-dir",
"${workspaceFolder}/test_db",
],
"env": {
"RUST_LOG": "warn"
},
{
"name": "restore-bootstrap",
"type": "lldb",
"request": "launch",
"cargo": {
"args": [
"build",
"-p",
"storage"
],
},
// cd ${ARCHIVE_PATH} && ${BIN_PATH}/${BIN_FILE} restore bootstrap-db --target-db-dir ${DB_PATH} --metadata-cache-dir ${REPO_PATH}/metacache --command-adapter-config ${REPO_PATH}/epoch-archive.yaml
"args": [
"restore",
"bootstrap-db",
"epoch-ending",
"--metadata-cache-dir",
"${workspaceFolder}/tools/storage/fixtures/epoch_ending.manifest",
"--command-adapter-config",
"${workspaceFolder}/tools/storage/fixtures",
"--target-db-dir",
"${workspaceFolder}/test_db",
],
"cwd": "${workspaceFolder}"
},
{
Expand Down
123 changes: 63 additions & 60 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ libra-config = { path = "tools/config" }
libra-framework = { path = "framework" }
libra-genesis-tools = { path = "tools/genesis" }
libra-query = { path = "tools/query" }
libra-rescue = { path = "tools/rescue" }
libra-storage = { path = "tools/storage" }
libra-smoke-tests = { path = "smoke-tests" }
libra-tower = { path = "tools/tower" }
libra-types = { path = "types" }
Expand Down
2 changes: 2 additions & 0 deletions tools/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ libra-config = { workspace = true }
libra-framework = { workspace = true }
libra-genesis-tools = { workspace = true }
libra-query = { workspace = true }
libra-rescue = { workspace = true }
libra-storage = { workspace = true }
libra-txs = { workspace = true }
libra-types = { workspace = true }
libra-wallet = { workspace = true }
Expand Down
13 changes: 6 additions & 7 deletions tools/cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
mod move_cli;
mod node_cli;
mod ops_cli;

use anyhow::anyhow;
use clap::{Parser, Subcommand};
use libra_config::config_cli::ConfigCli;
use libra_genesis_tools::cli::GenesisCli;
use libra_query::query_cli::QueryCli;
use libra_txs::txs_cli::TxsCli;
use libra_wallet::wallet_cli::WalletCli;
Expand All @@ -26,7 +26,8 @@ enum Sub {
Query(QueryCli),
Txs(TxsCli),
Wallet(WalletCli),
Genesis(GenesisCli),
#[clap(subcommand)]
Ops(ops_cli::OpsTool),
Version,
}

Expand Down Expand Up @@ -81,13 +82,11 @@ fn main() -> anyhow::Result<()> {
}
}

// Execute Genesis CLI subcommand
Some(Sub::Genesis(genesis_cli)) => {
if let Err(e) = genesis_cli.execute().await {
eprintln!("Failed to execute genesis tool, message: {}", &e);
Some(Sub::Ops(tool)) => {
if let Err(e) = tool.run().await {
eprintln!("Failed to execute ops tool, message: {}", &e);
}
}

// Display version information
Some(Sub::Version) => {
println!("LIBRA VERSION {}", env!("CARGO_PKG_VERSION"));
Expand Down
Loading

0 comments on commit 2def15e

Please sign in to comment.