-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from 0xPolygonZero/trie_stats
Trie stats, query params, and better usage docs
- Loading branch information
Showing
8 changed files
with
166 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
[workspace] | ||
members = [ "common", "trie_diff", "trie_query"] | ||
members = [ "common", "trie_diff", "trie_query", "trie_stats" ] | ||
resolver = "2" | ||
|
||
[workspace.dependencies] | ||
anyhow = { version = "1.0.75", features = ["backtrace"] } | ||
clap = { version = "4.4.6", features = ["derive", "env"] } | ||
mpt_trie = { version = "0.1.0", git = "https://github.com/0xPolygonZero/zk_evm.git", branch = "robins_not_so_awesome_branch_for_brendan" } | ||
mpt_trie = "0.3.0" | ||
pretty_env_logger = "0.5.0" | ||
trace_decoder = { version = "0.1.0", git = "https://github.com/0xPolygonZero/zk_evm.git", branch = "robins_not_so_awesome_branch_for_brendan" } | ||
trace_decoder = "0.4.0" | ||
serde_json = "1.0.114" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "trie_stats" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
common = { path = "../common" } | ||
|
||
anyhow = { workspace = true } | ||
clap = { workspace = true } | ||
mpt_trie ={ workspace = true } | ||
pretty_env_logger = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use std::path::PathBuf; | ||
|
||
use clap::Parser; | ||
use common::{read_input_from_file, TRIE_PATH_DOC_STR}; | ||
use mpt_trie::debug_tools::stats::get_trie_stats_with_name; | ||
|
||
/// Analyze one or two tries and output stats. | ||
#[derive(Debug, Parser)] | ||
#[command(after_help = TRIE_PATH_DOC_STR)] | ||
struct ProgArgs { | ||
/// The primary trie to compare against. | ||
trie_path: PathBuf, | ||
|
||
/// If a second trie is provided, a comparison will be made between the two tries along with printout out their individual stats. | ||
other_trie_path: Option<PathBuf>, | ||
} | ||
|
||
fn main() { | ||
pretty_env_logger::init(); | ||
|
||
let p_args = ProgArgs::parse(); | ||
let trie = read_input_from_file(&p_args.trie_path); | ||
let trie_name = p_args | ||
.trie_path | ||
.file_name() | ||
.map(|os_str| os_str.to_string_lossy()) | ||
.unwrap_or("Trie".into()); | ||
|
||
let stats = get_trie_stats_with_name(&trie, trie_name.to_string()); | ||
println!("{}", stats); | ||
|
||
if let Some(other_trie_path) = p_args.other_trie_path { | ||
// A second trie was passed in. Print its stats and also do a comparison. | ||
let other_trie = read_input_from_file(&other_trie_path); | ||
let other_trie_name = other_trie_path | ||
.file_name() | ||
.map(|os_str| os_str.to_string_lossy()) | ||
.unwrap_or("Trie".into()); | ||
let other_trie_stats = get_trie_stats_with_name(&other_trie, other_trie_name.into()); | ||
|
||
println!("{}", other_trie_stats); | ||
|
||
let comparison = stats.compare(&other_trie_stats); | ||
|
||
println!("{}", comparison); | ||
} | ||
} |