Skip to content

Commit

Permalink
Revert "Use actual chunks left (#2354)"
Browse files Browse the repository at this point in the history
This reverts commit d354026.
  • Loading branch information
Deniallugo committed Mar 23, 2023
1 parent d354026 commit 718ff20
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
7 changes: 5 additions & 2 deletions core/bin/zksync_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,11 @@ pub async fn run_core(
);

// Start mempool.
let mempool_block_handler_task =
run_mempool_block_handler(connection_pool.clone(), mempool_block_request_receiver);
let mempool_block_handler_task = run_mempool_block_handler(
connection_pool.clone(),
mempool_block_request_receiver,
config.chain.state_keeper.block_chunk_sizes.clone(),
);

// Start token handler.
let token_handler_task = run_token_handler(
Expand Down
1 change: 0 additions & 1 deletion core/bin/zksync_core/src/state_keeper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ impl ZkSyncStateKeeper {
block_timestamp,
response_sender,
executed_txs,
chunks_left: self.pending_block.chunks_left,
});

self.tx_for_mempool
Expand Down
6 changes: 2 additions & 4 deletions core/lib/mempool/src/block_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ impl ProposedBlock {
pub struct GetBlockRequest {
pub last_priority_op_number: u64,
pub block_timestamp: u64,
pub chunks_left: usize,
pub executed_txs: Vec<TxHash>,
pub response_sender: oneshot::Sender<ProposedBlock>,
}
Expand All @@ -47,14 +46,14 @@ pub enum MempoolBlocksRequest {
pub(crate) struct MempoolBlocksHandler {
pub mempool_state: MempoolState,
pub requests: mpsc::Receiver<MempoolBlocksRequest>,
pub max_block_size_chunks: usize,
}

impl MempoolBlocksHandler {
async fn propose_new_block(
&mut self,
current_unprocessed_priority_op: u64,
block_timestamp: u64,
chunks_left: usize,
executed_txs: &[TxHash],
) -> Result<ProposedBlock, TxAddError> {
let start = std::time::Instant::now();
Expand All @@ -67,7 +66,7 @@ impl MempoolBlocksHandler {

let (txs, priority_ops, chunks_left) = tx_queue
.select_transactions(
chunks_left,
self.max_block_size_chunks,
current_unprocessed_priority_op,
block_timestamp,
&self.mempool_state,
Expand Down Expand Up @@ -122,7 +121,6 @@ impl MempoolBlocksHandler {
.propose_new_block(
block.last_priority_op_number,
block.block_timestamp,
block.chunks_left,
&block.executed_txs,
)
.await
Expand Down
6 changes: 6 additions & 0 deletions core/lib/mempool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,18 @@ pub fn run_mempool_tx_handler(
pub fn run_mempool_block_handler(
db_pool: ConnectionPool,
block_requests: mpsc::Receiver<MempoolBlocksRequest>,
block_chunk_sizes: Vec<usize>,
) -> JoinHandle<()> {
let mempool_state = MempoolState::new(db_pool);
let max_block_size_chunks = *block_chunk_sizes
.iter()
.max()
.expect("failed to find max block chunks size");

let blocks_handler = MempoolBlocksHandler {
mempool_state,
requests: block_requests,
max_block_size_chunks,
};

tokio::spawn(blocks_handler.run())
Expand Down

0 comments on commit 718ff20

Please sign in to comment.