diff --git a/node/Cargo.toml b/node/Cargo.toml index 9cb6d73..0f2639d 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -23,6 +23,3 @@ spec = "config_spec.toml" [[bin]] name = "ibd" - -[[bin]] -name = "bench" diff --git a/node/src/bin/bench.rs b/node/src/bin/bench.rs deleted file mode 100644 index 992df1f..0000000 --- a/node/src/bin/bench.rs +++ /dev/null @@ -1,55 +0,0 @@ -// This binary is used to assess the impact of accumulator designs - -use std::{path::PathBuf, str::FromStr, time::Instant}; - -use bitcoin::{consensus, OutPoint}; -use kernel::{ChainType, ChainstateManager, ChainstateManagerOptions, ContextBuilder}; -use node::elapsed_time; - -fn main() { - let subscriber = tracing_subscriber::FmtSubscriber::new(); - tracing::subscriber::set_global_default(subscriber).unwrap(); - let home = std::env::var("HOME").unwrap(); - let path_buf = PathBuf::from_str(&home).unwrap(); - let bitcoin_dir = path_buf.join(".bitcoin"); - let blocks_dir = bitcoin_dir.join("blocks"); - let ctx = ContextBuilder::new() - .chain_type(ChainType::MAINNET) - .build() - .unwrap(); - let opts = ChainstateManagerOptions::new( - &ctx, - bitcoin_dir.to_str().unwrap(), - blocks_dir.to_str().unwrap(), - ) - .unwrap(); - let chainman = ChainstateManager::new(opts).unwrap(); - chainman.import_blocks().unwrap(); - let mut acc = accumulator::Accumulator::new(); - let mut tip = chainman.block_index_tip(); - tracing::info!("Starting accumulator bench"); - let start = Instant::now(); - while let Ok(next) = tip.prev() { - tracing::info!("process block {}", next.height()); - let block = chainman.read_block_data(&next).unwrap(); - let (_, transactions) = consensus::deserialize::(&block.to_bytes()) - .unwrap() - .into_parts(); - for tx in transactions { - let txid = tx.compute_txid(); - for input in tx.inputs { - let outpoint = input.previous_output; - acc.spend(outpoint); - } - for vout in 0..tx.outputs.len() { - let outpoint = OutPoint { - txid, - vout: vout as u32, - }; - acc.add(outpoint); - } - } - tip = next; - } - elapsed_time(start); -} diff --git a/node/src/lib.rs b/node/src/lib.rs index 5223aec..fb3ce8a 100644 --- a/node/src/lib.rs +++ b/node/src/lib.rs @@ -294,17 +294,18 @@ pub fn get_blocks_for_range( batch = next; completed_batches += 1; tracing::info!( - "[thread {task_id:2}]: requesting next batch. blocks downloaded: {}", - CHUNK_SIZE * completed_batches + "[thread {task_id:2}]: blocks downloaded: {}/{}", + CHUNK_SIZE * completed_batches, + stop_height, ); let percent = (1. - ((CHUNK_SIZE * jobs_lock.len()) as f32 / stop_height as f32)) * 100.0; tracing::info!( - "[thread m]: {:.6}/{}; progress: {:.6}%", + "[thread m]: progress: {:.6}% ; blocks remaining: {}/{}", + percent, CHUNK_SIZE * jobs_lock.len(), stop_height, - percent, ); let payload = InventoryPayload( batch.iter().map(|hash| Inventory::Block(*hash)).collect(),