Summary
In src/message_pool/msgpool/republish.rs, the bubble-down loop inside
select_messages_to_republish compares chains[j] vs chains[j + 1]
but swaps using hardcoded indices i and i + 1 instead of j and
j + 1. This means the trimmed chain never bubbles past the first slot —
it toggles back and forth between positions i and i + 1 on each
iteration, leaving chains incorrectly ordered after a trim.
Affected code
// src/message_pool/msgpool/republish.rs
let mut j = i;
while j < chains.len() - 1 {
#[allow(clippy::indexing_slicing)]
if chains[j].compare(&chains[j + 1]) == Ordering::Less {
break;
}
chains.key_vec.swap(i, i + 1); // ← bug: should be swap(j, j + 1)
j += 1;
}
Expected fix
chains.key_vec.swap(j, j + 1);
Impact
After trimming an over-gas chain, the chain is supposed to be pushed down
(re-sorted) by bubbling it toward its correct position. With
swap(i, i + 1), only the first two elements ever exchange, so the
ordering invariant is not restored and lower-priority chains may be
processed before higher-priority ones in subsequent iterations of the
outer loop.
References
Summary
In
src/message_pool/msgpool/republish.rs, the bubble-down loop insideselect_messages_to_republishcompareschains[j]vschains[j + 1]but swaps using hardcoded indices
iandi + 1instead ofjandj + 1. This means the trimmed chain never bubbles past the first slot —it toggles back and forth between positions
iandi + 1on eachiteration, leaving chains incorrectly ordered after a trim.
Affected code
Expected fix
chains.key_vec.swap(j, j + 1);
Impact
After trimming an over-gas chain, the chain is supposed to be pushed down
(re-sorted) by bubbling it toward its correct position. With
swap(i, i + 1), only the first two elements ever exchange, so theordering invariant is not restored and lower-priority chains may be
processed before higher-priority ones in subsequent iterations of the
outer loop.
References
#7033: refactor: msg pool to make more structured part 3 #7033 (comment)