#42938 [BC-Insight] Inefficient Garbage Collection Implementation in `UsedSequenceNumberPool`
Description
Bug Description
pub(crate) fn gc(&mut self, current_time_ms: u64) {
let gc_slot = current_time_ms / self.gc_slot_duration_ms;
let slot_cutoff = gc_slot - self.sequence_number_ttl_ms / self.gc_slot_duration_ms;
let slots_to_remove: Vec<u64> = self
.sequence_number_lifetimes
.keys()
.take_while(|slot| **slot < slot_cutoff)
.cloned()
.collect(); //@audit same thing can be done using retain, helps in avoiding clone and two loop cycles
for slot in slots_to_remove {
debug!(
"Garbage collecting sequence number slot {} with duration {} timestamp {}",
slot,
self.gc_slot_duration_ms,
slot * self.gc_slot_duration_ms
);
self.sequence_number_lifetimes.remove(&slot);
}
}Impact
Recommendation
Proof of Concept
Proof Of Concept
Previous#42937 [BC-Insight] Public Exposure of Validator Signer Private Key in Executor StructNext#42939 [BC-Insight] Transaction expiration is not validated correctly in mempool and sequencer
Was this helpful?