apollo_mempool: same block logic#13300
Conversation
8dc2c20 to
fa6269e
Compare
e92d95a to
3820494
Compare
ron-starkware
left a comment
There was a problem hiding this comment.
@ron-starkware reviewed 2 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on ayeletstarkware).
matanl-starkware
left a comment
There was a problem hiding this comment.
@matanl-starkware reviewed 2 files and all commit messages, and made 4 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on ayeletstarkware).
crates/apollo_mempool/src/fifo_transaction_queue.rs line 223 at r1 (raw file):
fn pop_ready_chunk(&mut self, n_txs: usize) -> Vec<TransactionReference> { let Some(mut current_state) = self.current_proposal_state else {
Avoid unnecessary move, and then you don't need the last self.current_proposal_state = Some(current_state);
Suggestion:
let Some(current_state) = self.current_proposal_state.as_mut() else {crates/apollo_mempool/src/fifo_transaction_queue.rs line 232 at r1 (raw file):
// Queue is empty, nothing to return. return Vec::new(); };
Check this before the non-None current_proposal_state panic
Code quote:
let Some(front_tx) = self.queue.front() else {
// Queue is empty, nothing to return.
return Vec::new();
};crates/apollo_mempool/src/fifo_transaction_queue.rs line 307 at r1 (raw file):
(Some(state), Some(front_tx)) => state.matches_tx(front_tx), _ => false, }
I like !
Code quote:
match (self.current_proposal_state, self.queue.front()) {
(Some(state), Some(front_tx)) => state.matches_tx(front_tx),
_ => false,
}crates/apollo_mempool/src/fifo_transaction_queue.rs line 315 at r1 (raw file):
.iter() .take_while(|tx| { self.current_proposal_state.is_some_and(|state| state.matches_tx(tx))
Extract outside the for loop
Code quote:
self.current_proposal_state.is_some_and(|state| state3820494 to
6fc960a
Compare
ayeletstarkware
left a comment
There was a problem hiding this comment.
@ayeletstarkware made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on matanl-starkware).
crates/apollo_mempool/src/fifo_transaction_queue.rs line 223 at r1 (raw file):
Previously, matanl-starkware (Matan Lior) wrote…
Avoid unnecessary move, and then you don't need the last
self.current_proposal_state = Some(current_state);
Done.
crates/apollo_mempool/src/fifo_transaction_queue.rs line 315 at r1 (raw file):
Previously, matanl-starkware (Matan Lior) wrote…
Extract outside the for loop
Done.
6fc960a to
4575a22
Compare
matanl-starkware
left a comment
There was a problem hiding this comment.
@matanl-starkware reviewed 2 files and all commit messages, and resolved 2 discussions.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on ayeletstarkware).

Note
Medium Risk
Changes FIFO mempool batching semantics to depend on both
timestampandblock_number, including emitting empty results on block gaps and realigning after rewinds; this affects block-building behavior and could impact liveness/ordering if edge cases are missed.Overview
FIFO (Echonet) transaction batching is now block-aware. The FIFO queue replaces the single
last_returned_timestampgate with aCurrentProposalStatethat tracks the proposaltimestamp, theexpected_block_number, and whether an empty block should be emitted.get_txs/has_ready_txs/iter_over_ready_txsnow only return transactions matching the current proposal’s(timestamp, expected_block_number), advanceexpected_block_numberonce a block is drained, return an empty chunk once when a block-number gap is detected, and realign to earlier blocks when rewound transactions reappear at the head.Adds targeted tests covering: same-block retrieval across multiple
get_txschunks, block-number gaps (single and long), resolving timestamps after the queue is emptied and after new txs arrive, and rewind scenarios that continue within the same block or realign to an earlier block.Written by Cursor Bugbot for commit 4575a22. This will update automatically on new commits. Configure here.