-
Notifications
You must be signed in to change notification settings - Fork 36
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(starknet_mempool): remove old transaction from the mempool in get_txs #4115
Conversation
4e3913f
to
5e782dd
Compare
7417bdc
to
f6b83ec
Compare
5e782dd
to
33322d8
Compare
f6b83ec
to
d15b2ba
Compare
33322d8
to
0251eb8
Compare
d15b2ba
to
b7932c9
Compare
b7932c9
to
5d5e234
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @alonh5 and @ayeletstarkware)
crates/starknet_mempool/src/mempool_test.rs
line 977 at r2 (raw file):
// Only the second transaction should be returned from get_txs, and the first should be removed. assert_eq!(mempool.get_txs(2).unwrap(), vec![second_tx.tx.clone()]);
This isn't testing the get_txs removal because you're calling add_tx before.
Code quote:
// Only the second transaction should be returned from get_txs, and the first should be removed.
assert_eq!(mempool.get_txs(2).unwrap(), vec![second_tx.tx.clone()]);
crates/starknet_mempool/src/mempool.rs
line 199 at r2 (raw file):
.remove(tx.tx_hash) .expect("Transaction hash from queue must appear in pool."); }
Consider extracting into function.
Code quote:
// Divide the chunk into transactions that are old and no longer valid and those that
// remain valid.
let (old_txs, valid_txs): (Vec<_>, Vec<_>) = chunk.into_iter().partition(|tx| {
self.tx_pool
.get_submission_time(tx.tx_hash)
.expect("Transaction hash from queue must appear in pool.")
.elapsed()
> self.config.transaction_ttl
});
// Remove old transactions from the pool.
for tx in old_txs {
self.tx_pool
.remove(tx.tx_hash)
.expect("Transaction hash from queue must appear in pool.");
}
5d5e234
to
c25f5d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @alonh5 and @ayeletstarkware)
crates/starknet_mempool/src/mempool.rs
line 199 at r2 (raw file):
Previously, alonh5 (Alon Haramati) wrote…
Consider extracting into function.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ayeletstarkware and @dafnamatsry)
crates/starknet_mempool/src/mempool.rs
line 419 at r4 (raw file):
// Given a chunk of transactions, removes from the pool those that are old, and returns the // remaining valid ones. // Note: This function assumes that the given transactions were already removed from the queue.
Suggestion:
/// Given a chunk of transactions, removes from the pool those that are old, and returns the
/// remaining valid ones.
/// Note: This function assumes that the given transactions were already removed from the queue.
c25f5d2
to
65a3c5e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @alonh5 and @ayeletstarkware)
crates/starknet_mempool/src/mempool.rs
line 419 at r4 (raw file):
// Given a chunk of transactions, removes from the pool those that are old, and returns the // remaining valid ones. // Note: This function assumes that the given transactions were already removed from the queue.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware)
65a3c5e
to
f746273
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @alonh5 and @ayeletstarkware)
crates/starknet_mempool/src/mempool_test.rs
line 977 at r2 (raw file):
Previously, alonh5 (Alon Haramati) wrote…
This isn't testing the get_txs removal because you're calling add_tx before.
Right! thanks :)
Had to change the mempool a bit, to use the clock.now()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware)
crates/starknet_mempool/src/mempool.rs
line 431 at r6 (raw file):
let tx_submission_time = self .tx_pool .get_submission_time(tx.tx_hash)
Instead of cloning the clock and having it in both places, how about you implement is_expired
for tx pool instead of get_submission_time
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @alonh5 and @ayeletstarkware)
crates/starknet_mempool/src/mempool.rs
line 431 at r6 (raw file):
Previously, alonh5 (Alon Haramati) wrote…
Instead of cloning the clock and having it in both places, how about you implement
is_expired
for tx pool instead ofget_submission_time
?
It would require implementing it both in TransactionPool
and TimedTransactionMap
. I think it's easier to just hold the clock. Might be useful for future things we might have as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! all files reviewed, all discussions resolved (waiting on @ayeletstarkware)
No description provided.