Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mempool): insert eligible tx to tx queue in commit-block accordi… #464

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions crates/mempool/src/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,8 @@ impl Mempool {
) -> MempoolResult<()> {
for (address, AccountState { nonce }) in state_changes {
let next_nonce = nonce.try_increment().map_err(|_| MempoolError::FeltOutOfRange)?;
// Dequeue transactions from the queue in the following cases:
// 1. Remove a transaction from queue with nonce lower and eq than those committed to
// the block, applicable when the block is from the same leader.
// 2. Remove a transaction from queue with nonce greater than the next nonce block,
// applicable when the block is from a different leader.

// Align the queue with the committed nonces.
if self
.tx_queue
.get_nonce(address)
Expand All @@ -90,10 +87,15 @@ impl Mempool {
self.tx_queue.remove(address);
}

if self.tx_queue.get_nonce(address).is_none() {
if let Some(tx) = self.tx_pool.get_by_address_and_nonce(address, nonce) {
self.tx_queue.insert(*tx);
}
}

self.tx_pool.remove_up_to_nonce(address, next_nonce);
}
// TODO: update the tx_queue with the new state changes.
todo!()
Ok(())
}

fn insert_tx(&mut self, input: MempoolInput) -> MempoolResult<()> {
Expand Down
Loading