From b91554f218fadfb0de6dc7004833504e363e93ad Mon Sep 17 00:00:00 2001 From: deniallugo Date: Fri, 16 Jul 2021 12:19:56 +0300 Subject: [PATCH 1/2] Do not check ongoing list if the block has not changed Signed-off-by: deniallugo --- core/bin/zksync_eth_sender/src/lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/bin/zksync_eth_sender/src/lib.rs b/core/bin/zksync_eth_sender/src/lib.rs index d77e161d3d..af3b7ed7e9 100644 --- a/core/bin/zksync_eth_sender/src/lib.rs +++ b/core/bin/zksync_eth_sender/src/lib.rs @@ -279,6 +279,7 @@ impl ETHSender { // states for the block with number `last_used_block` on the previous call of // `proceed_next_operations`, so if the block number hasn't changed we shouldn't request // states because it would be spare requests. + // The ongoing operations list would be the same for the next step if last_used_block != current_block { // Commit the next operations (if any). while let Some(mut current_op) = self.ongoing_ops.pop_front() { @@ -308,15 +309,14 @@ impl ETHSender { } } } + assert!( + self.ongoing_ops.is_empty(), + "Ongoing ops queue should be empty after draining" + ); + // Store the ongoing operations for the next round. + self.ongoing_ops = new_ongoing_ops; } - assert!( - self.ongoing_ops.is_empty(), - "Ongoing ops queue should be empty after draining" - ); - - // Store the ongoing operations for the next round. - self.ongoing_ops = new_ongoing_ops; metrics::histogram!("eth_sender.proceed_next_operations", start.elapsed()); current_block } From 8d265dba9daa4066ef1a4d3bb9e123622c101c76 Mon Sep 17 00:00:00 2001 From: deniallugo Date: Fri, 16 Jul 2021 12:34:29 +0300 Subject: [PATCH 2/2] Move creating ongoing ops Signed-off-by: deniallugo --- core/bin/zksync_eth_sender/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/bin/zksync_eth_sender/src/lib.rs b/core/bin/zksync_eth_sender/src/lib.rs index af3b7ed7e9..ecaec583ac 100644 --- a/core/bin/zksync_eth_sender/src/lib.rs +++ b/core/bin/zksync_eth_sender/src/lib.rs @@ -258,9 +258,6 @@ impl ETHSender { } }; - // Queue for storing all the operations that were not finished at this iteration. - let mut new_ongoing_ops = VecDeque::new(); - while let Some(tx) = self.tx_queue.pop_front() { if let Err(e) = self.initialize_operation(tx.clone(), current_block).await { Self::process_error(e).await; @@ -281,6 +278,9 @@ impl ETHSender { // states because it would be spare requests. // The ongoing operations list would be the same for the next step if last_used_block != current_block { + // Queue for storing all the operations that were not finished at this iteration. + let mut new_ongoing_ops = VecDeque::new(); + // Commit the next operations (if any). while let Some(mut current_op) = self.ongoing_ops.pop_front() { // We perform a commitment step here. In case of error, we suppose that this is some