-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is first step towards CLI command of state reconstruction tool.
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
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,58 @@ | ||
use clap::{arg, value_parser, Command}; | ||
|
||
fn cli() -> Command { | ||
Command::new("state-reconstruct") | ||
.about("zkSync state reconstruction tool") | ||
.subcommand_required(true) | ||
.arg_required_else_help(false) | ||
.subcommand( | ||
Command::new("reconstruct") | ||
.about("Reconstruct L2 state") | ||
.subcommand_required(true) | ||
.subcommand( | ||
Command::new("l1") | ||
.about("Read state from Ethereum L1") | ||
.arg( | ||
arg!(--"start-block" <START_BLOCK>) | ||
.help("Ethereum block number to start state import from") | ||
.default_value(state_reconstruct::GENESIS_BLOCK.to_string()) | ||
.value_parser(value_parser!(u64)), | ||
) | ||
.arg( | ||
arg!(--"block-step" <BLOCK_STEP>) | ||
.help("Number of blocks to filter & process in one step") | ||
.default_value(state_reconstruct::BLOCK_STEP.to_string()) | ||
.value_parser(value_parser!(u64)), | ||
), | ||
) | ||
.subcommand( | ||
Command::new("file") | ||
.about("Read state from file") | ||
.arg(arg!(<FILE> "File to import state from")) | ||
.arg_required_else_help(true), | ||
), | ||
) | ||
} | ||
|
||
fn main() { | ||
let matches = cli().get_matches(); | ||
|
||
match matches.subcommand() { | ||
Some(("reconstruct", sub_matches)) => { | ||
match sub_matches.subcommand() { | ||
Some(("l1", args)) => { | ||
let start_block = args.get_one::<u64>("start-block").expect("required"); | ||
let block_step = args.get_one::<u64>("block-step").expect("required"); | ||
println!("reconstruct from L1, starting from block number {}, processing {} blocks at a time", start_block, block_step); | ||
// TODO(tuommaki): Implement block fetch logic. | ||
} | ||
Some(("file", args)) => { | ||
let input_file = args.get_one::<String>("FILE").expect("required"); | ||
println!("reconstruct from file (path: \"{}\")", input_file); | ||
} | ||
_ => unreachable!(), | ||
} | ||
} | ||
_ => unreachable!(), | ||
} | ||
} |