mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-08 23:08:19 -05:00
feat(trie): Add flag to enable proof v2 for storage proof workers (#20617)
Co-authored-by: YK <chiayongkang@hotmail.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env -S cargo +nightly -Zscript
|
||||
#!/usr/bin/env -S cargo -Zscript
|
||||
---
|
||||
[package]
|
||||
edition = "2021"
|
||||
@@ -260,12 +260,17 @@ fn update_root_summary(root_dir: &Path, root_summary: &str) -> io::Result<()> {
|
||||
}
|
||||
|
||||
/// Generates TypeScript sidebar files for each command.
|
||||
fn generate_sidebar_files(vocs_dir: &Path, output: &[(Cmd, String)], verbose: bool) -> io::Result<()> {
|
||||
fn generate_sidebar_files(
|
||||
vocs_dir: &Path,
|
||||
output: &[(Cmd, String)],
|
||||
verbose: bool,
|
||||
) -> io::Result<()> {
|
||||
// Group commands by their root command name (reth or op-reth)
|
||||
// Also create a map of commands to their help output
|
||||
let mut commands_by_root: std::collections::HashMap<String, Vec<&Cmd>> = std::collections::HashMap::new();
|
||||
let mut commands_by_root: std::collections::HashMap<String, Vec<&Cmd>> =
|
||||
std::collections::HashMap::new();
|
||||
let mut help_map: std::collections::HashMap<String, String> = std::collections::HashMap::new();
|
||||
|
||||
|
||||
for (cmd, help_output) in output {
|
||||
let root_name = cmd.command_name().to_string();
|
||||
commands_by_root.entry(root_name.clone()).or_insert_with(Vec::new).push(cmd);
|
||||
@@ -288,7 +293,7 @@ fn generate_sidebar_files(vocs_dir: &Path, output: &[(Cmd, String)], verbose: bo
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
let sidebar_file = vocs_dir.join(file_name);
|
||||
if verbose {
|
||||
println!("Writing sidebar file: {}", sidebar_file.display());
|
||||
@@ -307,19 +312,16 @@ fn generate_sidebar_ts(
|
||||
help_map: &std::collections::HashMap<String, String>,
|
||||
) -> io::Result<String> {
|
||||
// Find all top-level commands (commands with exactly one subcommand)
|
||||
let mut top_level_commands: Vec<&Cmd> = commands
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|cmd| cmd.subcommands.len() == 1)
|
||||
.collect();
|
||||
|
||||
let mut top_level_commands: Vec<&Cmd> =
|
||||
commands.iter().copied().filter(|cmd| cmd.subcommands.len() == 1).collect();
|
||||
|
||||
// Remove duplicates using a set
|
||||
let mut seen = std::collections::HashSet::new();
|
||||
top_level_commands.retain(|cmd| {
|
||||
let key = &cmd.subcommands[0];
|
||||
seen.insert(key.clone())
|
||||
});
|
||||
|
||||
|
||||
// Sort by the order they appear in help output, not alphabetically
|
||||
if let Some(help) = root_help {
|
||||
let help_order = parse_sub_commands(help);
|
||||
@@ -345,14 +347,15 @@ fn generate_sidebar_ts(
|
||||
ts_code.push_str(&format!(" link: \"/cli/{}\",\n", root_name));
|
||||
ts_code.push_str(" collapsed: false,\n");
|
||||
ts_code.push_str(" items: [\n");
|
||||
|
||||
|
||||
for (idx, cmd) in top_level_commands.iter().enumerate() {
|
||||
let is_last = idx == top_level_commands.len() - 1;
|
||||
if let Some(item_str) = build_sidebar_item(root_name, cmd, &commands, 1, help_map, is_last) {
|
||||
if let Some(item_str) = build_sidebar_item(root_name, cmd, &commands, 1, help_map, is_last)
|
||||
{
|
||||
ts_code.push_str(&item_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ts_code.push_str(" ]\n");
|
||||
ts_code.push_str("};\n\n");
|
||||
|
||||
@@ -371,17 +374,18 @@ fn build_sidebar_item(
|
||||
) -> Option<String> {
|
||||
let full_cmd_name = cmd.to_string();
|
||||
let link_path = format!("/cli/{}", full_cmd_name.replace(" ", "/"));
|
||||
|
||||
// Find all direct child commands (commands whose subcommands start with this command's subcommands)
|
||||
|
||||
// Find all direct child commands (commands whose subcommands start with this command's
|
||||
// subcommands)
|
||||
let mut children: Vec<&Cmd> = all_commands
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|other_cmd| {
|
||||
other_cmd.subcommands.len() == cmd.subcommands.len() + 1
|
||||
&& other_cmd.subcommands[..cmd.subcommands.len()] == cmd.subcommands[..]
|
||||
other_cmd.subcommands.len() == cmd.subcommands.len() + 1 &&
|
||||
other_cmd.subcommands[..cmd.subcommands.len()] == cmd.subcommands[..]
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
// Sort children by the order they appear in help output, not alphabetically
|
||||
if children.len() > 1 {
|
||||
// Get help output for this command to determine subcommand order
|
||||
@@ -396,31 +400,37 @@ fn build_sidebar_item(
|
||||
});
|
||||
} else {
|
||||
// Fall back to alphabetical if we can't get help
|
||||
children.sort_by(|a, b| {
|
||||
a.subcommands.last().unwrap().cmp(b.subcommands.last().unwrap())
|
||||
});
|
||||
children
|
||||
.sort_by(|a, b| a.subcommands.last().unwrap().cmp(b.subcommands.last().unwrap()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let indent = " ".repeat(depth);
|
||||
let mut item_str = String::new();
|
||||
|
||||
|
||||
item_str.push_str(&format!("{}{{\n", indent));
|
||||
item_str.push_str(&format!("{} text: \"{}\",\n", indent, full_cmd_name));
|
||||
item_str.push_str(&format!("{} link: \"{}\"", indent, link_path));
|
||||
|
||||
|
||||
if !children.is_empty() {
|
||||
item_str.push_str(",\n");
|
||||
item_str.push_str(&format!("{} collapsed: true,\n", indent));
|
||||
item_str.push_str(&format!("{} items: [\n", indent));
|
||||
|
||||
|
||||
for (idx, child_cmd) in children.iter().enumerate() {
|
||||
let child_is_last = idx == children.len() - 1;
|
||||
if let Some(child_str) = build_sidebar_item(root_name, child_cmd, all_commands, depth + 1, help_map, child_is_last) {
|
||||
if let Some(child_str) = build_sidebar_item(
|
||||
root_name,
|
||||
child_cmd,
|
||||
all_commands,
|
||||
depth + 1,
|
||||
help_map,
|
||||
child_is_last,
|
||||
) {
|
||||
item_str.push_str(&child_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
item_str.push_str(&format!("{} ]\n", indent));
|
||||
if is_last {
|
||||
item_str.push_str(&format!("{}}}\n", indent));
|
||||
|
||||
@@ -956,6 +956,9 @@ Engine:
|
||||
--engine.account-worker-count <ACCOUNT_WORKER_COUNT>
|
||||
Configure the number of account proof workers in the Tokio blocking pool. If not specified, defaults to the same count as storage workers
|
||||
|
||||
--engine.enable-proof-v2
|
||||
Enable V2 storage proofs for state root calculations
|
||||
|
||||
ERA:
|
||||
--era.enable
|
||||
Enable import from ERA1 files
|
||||
|
||||
@@ -956,6 +956,9 @@ Engine:
|
||||
--engine.account-worker-count <ACCOUNT_WORKER_COUNT>
|
||||
Configure the number of account proof workers in the Tokio blocking pool. If not specified, defaults to the same count as storage workers
|
||||
|
||||
--engine.enable-proof-v2
|
||||
Enable V2 storage proofs for state root calculations
|
||||
|
||||
ERA:
|
||||
--era.enable
|
||||
Enable import from ERA1 files
|
||||
|
||||
Reference in New Issue
Block a user