Skip to content

Commit

Permalink
Exclude only successfull operations, not rejected (#2252)
Browse files Browse the repository at this point in the history
Signed-off-by: deniallugo <[email protected]>
  • Loading branch information
Deniallugo authored May 22, 2022
1 parent 036f627 commit e01006e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions core/bin/zksync_core/src/state_keeper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,17 +308,19 @@ impl ZkSyncStateKeeper {
// By giving these hashes to the mempool,
// we won't receive back transactions that we already executed in the current block.

// It's counterintuitive, but we want to exclude only successful operations, because in the situation,
// when we are under attack by rejected txs, pending block becomes massive and contains a lot of rejected txs,
// as a result we will send tons of tx_hash to the database.
// Excluding success operations is mandatory because they will fail in the next step,
// at the same time executing rejected txs is safe, in the worst-case scenario, they become successful.
// Keeping in mind that we regularly clean the memmpool from executing txs, it's impossible when
// tons of rejected txs will be returned from the database.

let executed_txs = self
.pending_block
.failed_txs
.success_operations
.iter()
.map(|tx| tx.signed_tx.hash())
.chain(
self.pending_block
.success_operations
.iter()
.filter_map(|op| op.get_executed_tx().map(|tx| tx.signed_tx.hash())),
)
.filter_map(|op| op.get_executed_tx().map(|tx| tx.signed_tx.hash()))
.collect();

let mempool_req = MempoolBlocksRequest::GetBlock(GetBlockRequest {
Expand Down

0 comments on commit e01006e

Please sign in to comment.