diff --git a/Cargo.lock b/Cargo.lock index 8bfa2fd0..e4509d18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1728,6 +1728,19 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "console" +version = "0.15.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b" +dependencies = [ + "encode_unicode", + "libc", + "once_cell", + "unicode-width", + "windows-sys 0.59.0", +] + [[package]] name = "const-fnv1a-hash" version = "1.1.0" @@ -2141,6 +2154,12 @@ dependencies = [ "log", ] +[[package]] +name = "encode_unicode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + [[package]] name = "encoding_rs" version = "0.8.35" @@ -2221,6 +2240,7 @@ dependencies = [ "dry_hint_processor", "futures", "indexer", + "indicatif", "serde_json", "thiserror 1.0.69", "tokio", @@ -2982,6 +3002,19 @@ dependencies = [ "serde", ] +[[package]] +name = "indicatif" +version = "0.17.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf675b85ed934d3c67b5c5469701eec7db22689d0a2139d856e0925fa28b281" +dependencies = [ + "console", + "number_prefix", + "portable-atomic", + "unicode-width", + "web-time", +] + [[package]] name = "indoc" version = "2.0.5" @@ -3438,6 +3471,12 @@ dependencies = [ "syn 2.0.91", ] +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "nybbles" version = "0.3.0" @@ -5335,6 +5374,12 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -5524,6 +5569,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki-roots" version = "0.26.7" diff --git a/Cargo.toml b/Cargo.toml index a6fc87d9..3de9231e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,6 +39,7 @@ strum_macros = "0.26.4" thiserror = "1.0.64" tiny-keccak = { version = "2.0.2", features = ["keccak"] } tokio = { version = "1.41.1", features = ["full"] } +indicatif = "0.17.9" dry_hint_processor = { path = "crates/dry_hint_processor" } eth_essentials_cairo_vm_hints = { path = "packages/eth_essentials/cairo_vm_hints"} diff --git a/crates/fetcher/Cargo.toml b/crates/fetcher/Cargo.toml index a3bca172..aab6f76d 100644 --- a/crates/fetcher/Cargo.toml +++ b/crates/fetcher/Cargo.toml @@ -11,6 +11,7 @@ futures.workspace = true serde_json.workspace = true thiserror.workspace = true tokio.workspace = true +indicatif.workspace = true indexer.workspace = true types.workspace = true \ No newline at end of file diff --git a/crates/fetcher/src/main.rs b/crates/fetcher/src/main.rs index 87e87e72..42998e6b 100644 --- a/crates/fetcher/src/main.rs +++ b/crates/fetcher/src/main.rs @@ -8,6 +8,7 @@ use clap::{Parser, ValueHint}; use dry_hint_processor::syscall_handler::evm::{self, SyscallHandler}; use futures::{FutureExt, StreamExt}; use indexer::types::IndexerError; +use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; use proof_keys::ProofKeys; use std::{collections::HashSet, fs, num::ParseIntError, path::PathBuf}; use thiserror::Error; @@ -15,7 +16,7 @@ use types::proofs::{account::Account, storage::Storage, HeaderMmrMeta, Proofs}; pub mod proof_keys; -const BUFFER_UNORDERED: usize = 10; +const BUFFER_UNORDERED: usize = 50; #[derive(Parser, Debug)] #[clap(author, version, about, long_about = None)] @@ -30,6 +31,11 @@ struct Args { async fn main() -> Result<(), FetcherError> { let args = Args::try_parse_from(std::env::args()).map_err(FetcherError::Args)?; + let multi_progress = MultiProgress::new(); + let progress_style = ProgressStyle::with_template("[{elapsed_precise}] [{bar:40}] {pos}/{len} {msg}") + .unwrap() + .progress_chars("=> "); + let input_file = fs::read(args.filename)?; let syscall_handler = serde_json::from_slice::(&input_file)?; @@ -48,6 +54,16 @@ async fn main() -> Result<(), FetcherError> { } } + let pb_header_keys = multi_progress.add(ProgressBar::new(proof_keys.header_keys.len() as u64)); + let pb_account_keys = multi_progress.add(ProgressBar::new(proof_keys.account_keys.len() as u64)); + let pb_storage_keys = multi_progress.add(ProgressBar::new(proof_keys.storage_keys.len() as u64)); + pb_header_keys.set_style(progress_style.clone()); + pb_header_keys.set_message("header_keys"); + pb_account_keys.set_style(progress_style.clone()); + pb_account_keys.set_message("account_keys"); + pb_storage_keys.set_style(progress_style); + pb_storage_keys.set_message("storage_keys"); + let mut headers_with_mmr: HashSet = HashSet::default(); let mut headers_with_mmr_fut = futures::stream::iter(proof_keys.header_keys.iter().map(ProofKeys::fetch_header_proof).map(|f| f.boxed_local())) @@ -55,6 +71,7 @@ async fn main() -> Result<(), FetcherError> { while let Some(Ok(item)) = headers_with_mmr_fut.next().await { headers_with_mmr.insert(item); + pb_header_keys.inc(1); } let mut accounts: HashSet = HashSet::default(); @@ -71,6 +88,7 @@ async fn main() -> Result<(), FetcherError> { while let Some(Ok((header_with_mmr, account))) = accounts_fut.next().await { headers_with_mmr.insert(header_with_mmr); accounts.insert(account); + pb_account_keys.inc(1); } let mut storages: HashSet = HashSet::default(); @@ -88,6 +106,7 @@ async fn main() -> Result<(), FetcherError> { headers_with_mmr.insert(header_with_mmr.clone()); accounts.insert(account); storages.insert(storage); + pb_storage_keys.inc(1); } let proofs = Proofs {