-
Notifications
You must be signed in to change notification settings - Fork 924
txpool: fix tx removal from unlocks set #8500
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
base: master
Are you sure you want to change the base?
txpool: fix tx removal from unlocks set #8500
Conversation
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
/cmd prdoc |
/cmd fmt |
Command "fmt" has failed ❌! See logs here |
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
if let Some(tx_unlocking) = ready.get_mut(hash) { | ||
remove_item( | ||
&mut tx_unlocking.unlocks, | ||
&tx.transaction.transaction.hash, |
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.
could be just tx_hash
?:
&tx.transaction.transaction.hash, | |
&tx_hash, |
@@ -298,8 +298,11 @@ impl<Hash: hash::Hash + Member + Serialize, Ex> ReadyTransactions<Hash, Ex> { | |||
// remove from unlocks | |||
for tag in &tx.transaction.transaction.requires { | |||
if let Some(hash) = self.provided_tags.get(tag) { | |||
if let Some(tx) = ready.get_mut(hash) { | |||
remove_item(&mut tx.unlocks, hash); | |||
if let Some(tx_unlocking) = ready.get_mut(hash) { |
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.
Like the name change here 👍
let tx3 = it.next().unwrap(); | ||
let lock = ready.ready.read(); | ||
let tx1_unlocks = &lock.get(&tx1.hash).unwrap().unlocks; | ||
assert_eq!(tx1_unlocks[0], tx2.hash); |
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.
we could check tx3 is also unlocked by tx1.
assert_eq!(removed[1].hash, tx3.hash); | ||
let lock = ready.ready.read(); | ||
let tx1_unlocks = &lock.get(&tx1.hash).unwrap().unlocks; | ||
assert!(!tx1_unlocks.contains(&tx2.hash)); |
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.
and here tx3 shall still be unlocked by tx1 (assuming I read populate_pool
correctly :) )
note - just for the record - I think this bug was not causing any user-facing problems. Not removing transactions from unlocks set deep in |
Description
Removing a tx subtree means partly removing some txs from the unlocks set of other txs. This logic is buggy and the PR attempts to fix it.
Closes #8498
Integration
N/A
Review Notes
This doesn't seem to be an important bug. Unit tests for txpool still pass after the fix, so txpool behavior isn't changing much.
TODOs