diff --git a/src/bin/perftest.rs b/src/bin/perftest.rs index bc0952a..d8f8b80 100644 --- a/src/bin/perftest.rs +++ b/src/bin/perftest.rs @@ -135,13 +135,14 @@ async fn main() -> Result<(), Box> { let start = Instant::now(); let mut stats_calculation_timer = time::interval(cfg.stats_calculation_interval); + let start_time = current_time(); let mut block_count = 0; let mut num_messages_confirmed = 0; let mut num_messages_submitted = 0; let mut pending_messages = HashSet::new(); let mut time_to_confirmation = vec![]; let mut block_times = vec![]; - let mut last_block_time = current_time(); + let mut last_block_time = start_time; let mut iteration = 0; loop { select! { @@ -151,16 +152,18 @@ async fn main() -> Result<(), Box> { }, Some(block) = blocks_rx.recv() => { let block_timestamp = block.header.as_ref().unwrap().timestamp; - block_count += 1; - block_times.push(block_timestamp - last_block_time); - last_block_time = block_timestamp; - for chunk in &block.shard_chunks { - for tx in &chunk.transactions { - for msg in &tx.user_messages { - let msg_timestamp = msg.data.as_ref().unwrap().timestamp; - time_to_confirmation.push(block_timestamp - msg_timestamp as u64); - num_messages_confirmed += 1; - pending_messages.remove(&hex::encode(msg.hash.clone())); + if block_timestamp >= start_time { + block_count += 1; + block_times.push(block_timestamp - last_block_time); + last_block_time = block_timestamp; + for chunk in &block.shard_chunks { + for tx in &chunk.transactions { + for msg in &tx.user_messages { + let msg_timestamp = msg.data.as_ref().unwrap().timestamp; + time_to_confirmation.push(block_timestamp - msg_timestamp as u64); + num_messages_confirmed += 1; + pending_messages.remove(&hex::encode(msg.hash.clone())); + } } } } diff --git a/src/consensus/proposer.rs b/src/consensus/proposer.rs index 14c3a72..37d062f 100644 --- a/src/consensus/proposer.rs +++ b/src/consensus/proposer.rs @@ -392,9 +392,9 @@ impl Proposer for BlockProposer { let destination_addr = format!("http://{}", rpc_address.clone()); let mut rpc_client = SnapchainServiceClient::connect(destination_addr).await?; let request = Request::new(BlocksRequest { + shard_id: self.shard_id.shard_id(), start_block_number: prev_block_number + 1, stop_block_number: None, - start_timestamp: None, }); let missing_blocks = rpc_client.get_blocks(request).await?; for block in missing_blocks.get_ref().blocks.clone() { diff --git a/src/network/server.rs b/src/network/server.rs index ddb1561..e982aff 100644 --- a/src/network/server.rs +++ b/src/network/server.rs @@ -90,7 +90,6 @@ impl SnapchainService for MySnapchainService { ) -> Result, Status> { let start_block_number = request.get_ref().start_block_number; let stop_block_number = request.get_ref().stop_block_number; - let start_timestamp = request.get_ref().start_timestamp; info!( {start_block_number, stop_block_number}, "Received call to [get_blocks] RPC"); @@ -100,13 +99,6 @@ impl SnapchainService for MySnapchainService { { Err(err) => Err(Status::from_error(Box::new(err))), Ok(blocks) => { - let blocks = match start_timestamp { - None => blocks, - Some(start_timestamp) => blocks - .into_iter() - .filter(|block| block.header.as_ref().unwrap().timestamp >= start_timestamp) - .collect(), - }; let response = Response::new(BlocksResponse { blocks }); Ok(response) } diff --git a/src/proto/rpc.proto b/src/proto/rpc.proto index 7ff88b2..6cab444 100644 --- a/src/proto/rpc.proto +++ b/src/proto/rpc.proto @@ -6,9 +6,9 @@ import "blocks.proto"; import "hub_event.proto"; message BlocksRequest { - uint64 start_block_number = 1; - optional uint64 stop_block_number = 2; - optional uint64 start_timestamp = 3; + uint32 shard_id = 1; + uint64 start_block_number = 2; + optional uint64 stop_block_number = 3; } message BlocksResponse { diff --git a/src/utils/cli.rs b/src/utils/cli.rs index c7d8bb9..3857852 100644 --- a/src/utils/cli.rs +++ b/src/utils/cli.rs @@ -1,4 +1,3 @@ -use crate::consensus::proposer::current_time; use crate::proto::msg as message; use crate::proto::rpc::snapchain_service_client::SnapchainServiceClient; use crate::proto::{rpc, snapchain::Block}; @@ -42,9 +41,9 @@ pub async fn follow_blocks( loop { let msg = rpc::BlocksRequest { + shard_id: 0, start_block_number: i, stop_block_number: Some(i + FETCH_SIZE), - start_timestamp: Some(current_time()), }; let request = tonic::Request::new(msg);