Skip to content

Commit

Permalink
Showing 11 changed files with 91 additions and 22 deletions.
85 changes: 75 additions & 10 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -5,26 +5,91 @@
"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": "rescue-script",
"name": "restore-epoch",
"type": "lldb",
"request": "launch",
"cargo": {
"args": [
"build",
"-p",
"rescue"
"storage"
],
},
"args": [
"rescue-tx",
"--data-path",
// "/root/test-db/db",
"/root/dbarchive/data_bak_2023-12-11/db",
// "--script-path",
// "${workspaceFolder}/tools/rescue/fixtures/rescue_framework_script",
"--framework-upgrade"
"restore",
"oneoff",
"epoch-ending",
"--epoch-ending-manifest",
"${workspaceFolder}/tools/storage/fixtures/epoch_ending_79-.166d/epoch_ending.manifest.unzip",
"--local-fs-dir",
"${workspaceFolder}/test_db",
"--target-db-dir",
"${workspaceFolder}/test_db",
],
"env": {
"RUST_LOG": "warn"
},
"cwd": "${workspaceFolder}"
},
{
"name": "restore-state",
"type": "lldb",
"request": "launch",
"cargo": {
"args": [
"build",
"-p",
"storage"
],
},
"args": [
"restore",
"oneoff",
"state-snapshot",
"--state-manifest",
"${workspaceFolder}/tools/storage/fixtures/state.manifest",
"--restore-mode",
"default",
"--state-into-version",
"1",
"--local-fs-dir",
"${workspaceFolder}/test_db",
"--target-db-dir",
"${workspaceFolder}/test_db",
],
"env": {
"RUST_LOG": "warn"
},
"cwd": "${workspaceFolder}"
},
{
@@ -389,4 +454,4 @@
"cwd": "${workspaceFolder}"
},
]
}
}
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions tools/storage/Cargo.toml
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ rust-version = { workspace = true }
[dependencies]
anyhow = { workspace = true }
clap = { workspace = true }
diem-api-types = { workspace = true }
diem-backup-cli = { workspace = true }
diem-db-tool = { workspace = true }
diem-logger = { workspace = true }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"first_epoch":79,"last_epoch":79,"waypoints":["33217173:632e6be8f7c0e6abccd101deba8aa109ea8ce36186978b5ae4656a510eddc5ea"],"chunks":[{"first_epoch":79,"last_epoch":79,"ledger_infos":"epoch_ending_79-.166d/79-.chunk"}]}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":33217173,"epoch":79,"root_hash":"d5fc08dbe1756f9399be8edb26d194ec1c97442139849556bb9652a52b374995","chunks":[{"first_idx":0,"last_idx":141533,"first_key":"0000acadcb83f9bdcffcbb63d132be250f8018a731137db7e3aab5af2e3bc8bd","last_key":"fffff7e8a7aff9e730227f0decbef95c00ccdd60744654b8c4799a80bec23e5a","blobs":"state_epoch_79_ver_33217173.795d/0-.chunk","proof":"state_epoch_79_ver_33217173.795d/0-141533.proof"}],"proof":"state_epoch_79_ver_33217173.795d/state.proof"}
Binary file not shown.
24 changes: 12 additions & 12 deletions tools/storage/src/read_snapshot.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
//! read-archive
use anyhow::{Error, Result};
use diem_backup_cli::{
backup_types::{epoch_ending::manifest::EpochEndingBackup, state_snapshot::manifest::StateSnapshotBackup},
metadata::StateSnapshotBackupMeta,
// storage::{FileHandle, FileHandleRef},
// utils::read_record_bytes::ReadRecordBytes,
use diem_backup_cli::backup_types::{
epoch_ending::manifest::EpochEndingBackup, state_snapshot::manifest::StateSnapshotBackup,
};
use serde_json::json;
// use serde_json::json;
// use diem_crypto::HashValue;
// use diem_types::account_state_blob::AccountStateBlob;
use std::{
fs,
path::{Path, PathBuf}, str::FromStr,
path::{Path, PathBuf},
};
// use tokio::{fs::OpenOptions, io::AsyncRead};

////// SNAPSHOT FILE IO //////
/// read snapshot manifest file into object
pub fn read_from_json(path: &PathBuf) -> Result<StateSnapshotBackup, Error> {
pub fn load_snapshot_manifest(path: &PathBuf) -> Result<StateSnapshotBackup, Error> {
let config = std::fs::read_to_string(path).map_err(|e| {
format!("Error: cannot read file {:?}, error: {:?}", &path, &e);
e
@@ -36,11 +33,14 @@ fn load_epoch_manifest(p: &Path) -> Result<EpochEndingBackup> {

#[test]
fn test_parse_manifest() {
let mut this_path = PathBuf::from_str(env!("CARGO_MANIFEST_DIR")).unwrap();
this_path.push("fixtures/epoch_ending_79-.166d/epoch_ending.manifest");
let r = load_epoch_manifest(&this_path).expect("parse manifest");
dbg!(json!(&r));
use std::str::FromStr;
let mut this_path = PathBuf::from_str(env!("CARGO_MANIFEST_DIR")).unwrap();
this_path.push("fixtures/state_epoch_79_ver_33217173.795d/state.manifest.unzip");
let r = load_snapshot_manifest(&this_path).expect("parse manifest");
dbg!(&r.epoch);
}


// /// parse each chunk of a state snapshot manifest
// pub async fn read_account_state_chunk(
// file_handle: FileHandle,

0 comments on commit 782b5ee

Please sign in to comment.