From e9602335addd6dc85fd0de2f6f3730114298faa9 Mon Sep 17 00:00:00 2001 From: Zaki Manian Date: Wed, 22 Dec 2021 12:51:23 -0800 Subject: [PATCH] Harden the mempool against a flood of new txs by discarding them earlier in validation (#922) --- mempool/src/shared_mempool/tasks.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mempool/src/shared_mempool/tasks.rs b/mempool/src/shared_mempool/tasks.rs index abe6c6a7e0..53f9c1f779 100644 --- a/mempool/src/shared_mempool/tasks.rs +++ b/mempool/src/shared_mempool/tasks.rs @@ -223,9 +223,17 @@ where .enumerate() .filter_map(|(idx, t)| { if let Ok(sequence_number) = seq_numbers[idx] { - if t.sequence_number() >= sequence_number { + if t.sequence_number() == sequence_number { return Some((t, sequence_number)); - } else { + } else if t.sequence_number() > sequence_number{ + statuses.push(( + t, + ( + MempoolStatus::new(MempoolStatusCode::VmError), + Some(DiscardedVMStatus::SEQUENCE_NUMBER_TOO_NEW), + ), + )); + }else { statuses.push(( t, (