Skip to content

Commit 5b7a537

Browse files
0xzoz0o-de-lallycoin1111sirouk
committed
[release] 7.0.0 (#223)
Co-authored-by: 0o-de-lally <[email protected]> Co-authored-by: coin1111 <[email protected]> Co-authored-by: sirouk <[email protected]>
1 parent 0595eea commit 5b7a537

File tree

4 files changed

+63
-13
lines changed

4 files changed

+63
-13
lines changed

framework/libra-framework/sources/ol_sources/community_wallet_init.move

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ module ol_framework::community_wallet_init {
8383
/// qualify
8484
public fun check_proposed_auths(initial_authorities: vector<address>, num_signers:
8585
u64): bool {
86-
// // enforce n/m multi auth
86+
87+
// TODO: enforce n/m multi auth such as:
8788
// let n = if (len == 3) { 2 }
8889
// else {
8990
// (MINIMUM_SIGS * len) / MINIMUM_AUTH
6.37 MB
Binary file not shown.

tools/storage/src/main.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,41 @@ use clap::Parser;
33
use diem_db_tool::DBTool;
44
use diem_logger::{Level, Logger};
55
use diem_push_metrics::MetricsPusher;
6+
use std::path::PathBuf;
7+
use storage::read_snapshot::manifest_to_json;
8+
9+
#[derive(Parser)]
10+
#[clap(name = "libra storage", author, version)]
11+
#[allow(clippy::large_enum_variant)]
12+
enum StorageCli {
13+
#[clap(subcommand)]
14+
Db(DBTool),
15+
ExportSnapshot {
16+
#[clap(short, long)]
17+
manifest_path: PathBuf,
18+
#[clap(short, long)]
19+
out_path: Option<PathBuf>,
20+
},
21+
}
622

723
#[tokio::main]
824
async fn main() -> Result<()> {
925
Logger::new().level(Level::Info).init();
1026
let _mp = MetricsPusher::start(vec![]);
1127

28+
match StorageCli::parse() {
29+
StorageCli::Db(tool) => {
30+
tool.run().await?;
31+
}
32+
StorageCli::ExportSnapshot {
33+
manifest_path,
34+
out_path,
35+
} => {
36+
manifest_to_json(manifest_path, out_path).await;
37+
}
38+
}
39+
1240
DBTool::parse().run().await?;
41+
1342
Ok(())
1443
}

tools/storage/src/read_snapshot.rs

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,18 @@ use diem_backup_cli::{
77
},
88
storage::{FileHandle, FileHandleRef},
99
};
10-
11-
use tokio::{fs::OpenOptions, io::AsyncRead};
12-
1310
use diem_types::account_address::AccountAddress;
1411
use diem_types::account_state::AccountState;
1512
use diem_types::state_store::state_key::{StateKey, StateKeyInner};
1613
use diem_types::state_store::state_value::StateValue;
17-
14+
use libra_types::legacy_types::legacy_recovery_v6;
15+
use serde_json::json;
1816
use std::collections::HashMap;
1917
use std::{
2018
fs,
2119
path::{Path, PathBuf},
2220
};
21+
use tokio::{fs::OpenOptions, io::AsyncRead};
2322

2423
#[cfg(test)]
2524
use libra_types::legacy_types::legacy_recovery_v6::{get_legacy_recovery, AccountRole};
@@ -135,6 +134,34 @@ fn test_parse_manifest() {
135134
// dbg!(&r.epoch);
136135
}
137136

137+
pub async fn manifest_to_json(manifest_path: PathBuf, out_path: Option<PathBuf>) {
138+
let snapshot_manifest = load_snapshot_manifest(&manifest_path).expect("parse manifest");
139+
let archive_path = manifest_path.parent().unwrap();
140+
let account_states = accounts_from_snapshot_backup(snapshot_manifest, archive_path)
141+
.await
142+
.expect("could not parse snapshot");
143+
let mut legacy_recovery_vec = Vec::new();
144+
for account_state in account_states.iter() {
145+
let legacy_recovery = legacy_recovery_v6::get_legacy_recovery(account_state)
146+
.expect("could not get legacy recovery");
147+
148+
legacy_recovery_vec.push(legacy_recovery);
149+
}
150+
151+
let json = json!(&legacy_recovery_vec);
152+
let out = out_path.unwrap_or(manifest_path.parent().unwrap().join("migration.json"));
153+
fs::write(out, json.to_string()).expect("could not save file");
154+
}
155+
156+
#[tokio::test]
157+
async fn test_export() {
158+
use std::str::FromStr;
159+
let this_path = PathBuf::from_str(env!("CARGO_MANIFEST_DIR")).unwrap();
160+
let manifest_path = this_path.join("fixtures/state_epoch_79_ver_33217173.795d/state.manifest");
161+
let export_path = this_path.join("json/v6_migration.json");
162+
manifest_to_json(manifest_path, Some(export_path)).await;
163+
}
164+
138165
#[tokio::test]
139166
async fn test_deserialize_account() {
140167
use std::str::FromStr;
@@ -147,19 +174,12 @@ async fn test_deserialize_account() {
147174
.expect("could not parse snapshot");
148175
let mut legacy_recovery_vec = Vec::new();
149176
for account_state in account_states.iter() {
150-
// println!("----------------------------------------------------");
151-
// println!("account_address: {:?}", account_state.get_account_address());
152177
let legacy_recovery =
153178
get_legacy_recovery(account_state).expect("could not get legacy recovery");
154-
//println!("legacy_recovery: {:?}", legacy_recovery);
179+
155180
legacy_recovery_vec.push(legacy_recovery);
156181
}
157182

158-
// let legacy_recovery_vec_json =
159-
// serde_json::to_string(&legacy_recovery_vec).expect("could not create json for state");
160-
161-
// println!("{}", legacy_recovery_vec_json);
162-
163183
// basic validation of the account state
164184
let account_count = 23634;
165185
assert_eq!(account_states.len(), account_count);

0 commit comments

Comments
 (0)