pub fn next_transaction(
        &mut self,
        filter: &L2TxFilter,
    ) -> Option<(Transaction, TransactionTimeRangeConstraint)> {
        if let Some(transaction) = self.l1_transactions.remove(&self.next_priority_id) {
            self.next_priority_id += 1;
            // L1 transactions can't use block.timestamp in AA and hence do not need to have a constraint
            return Some((
                transaction.into(),
                TransactionTimeRangeConstraint::default(),
            ));
        }

        let mut removed = 0;
        // We want to fetch the next transaction that would match the fee requirements.
        let tx_pointer = self
            .l2_priority_queue
            .iter()
            .rfind(|el| el.matches_filter(filter))?
            .clone();

        let initial_length = self.stashed_accounts.len();

        // Stash all observed transactions that don't meet criteria
        for stashed_pointer in self
            .l2_priority_queue
            .split_off(&tx_pointer)
            .into_iter()
            .skip(1)
        {
            removed += {
                let account = self
                    .l2_transactions_per_account
                    .get_mut(&stashed_pointer.account)
                    .expect("mempool: dangling pointer in priority queue");
                let txs_len = account.len();
                account.clear_txs();
                txs_len
            };

            self.stashed_accounts.push(stashed_pointer.account);
        }

        tracing::debug!(
            "Stashed {} accounts by filter: {:?}",
            self.stashed_accounts.len() - initial_length,
            filter
        );

        // insert pointer to the next transaction if it exists
        let (transaction, constraint, score) = self
            .l2_transactions_per_account
            .get_mut(&tx_pointer.account)
            .expect("mempool: dangling pointer in priority queue")
            .next();

        if let Some(score) = score {
            self.l2_priority_queue.insert(score);
        }
        self.size = self
            .size
            .checked_sub((removed + 1) as u64)
            .expect("mempool size can't be negative");
        Some((transaction.into(), constraint))
    }
Returns next transaction for execution from mempool
core/lib/mempool/src/mempool_store.rs