-
Notifications
You must be signed in to change notification settings - Fork 20.3k
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
core: fix race conditions in txpool #23474
Conversation
core/tx_list.go
Outdated
} | ||
|
||
// reheap forcibly rebuilds the heap based on the current remote transaction set. | ||
// Expects the reheap mutex to be held |
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.
If the mu
is only there to protect the reheap
operation, perhaps rename it to reheapMu
and do the lock/unlock inside of reheap
instead?
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.
Renamed and moved
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.
Actually, now you can revert another change too: remove reheap
again and have only Reheap
.
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.
Yes!
bb5e723
to
8906d9c
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.
LGTM
@@ -123,6 +124,8 @@ func setupTxPoolWithConfig(config *params.ChainConfig) (*TxPool, *ecdsa.PrivateK | |||
key, _ := crypto.GenerateKey() | |||
pool := NewTxPool(testTxPoolConfig, config, blockchain) | |||
|
|||
// wait for the pool to initialize | |||
<-pool.initDoneCh |
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.
I don't understand this change. What's the point of waiting the loop
function to start up here?
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.
Otherwise the resetState
function race with the loop function
* core: fix race conditions in txpool * core: fixed races in the txpool * core: rebased on master * core: move reheap mutex * core: renamed mutex * core: revert Reheap changes
* core: fix race conditions in txpool * core: fixed races in the txpool * core: rebased on master * core: move reheap mutex * core: renamed mutex * core: revert Reheap changes
This PR fixes several race conditions in the txpool:
txList.SetBasefee()
,txlist.Removed()
andtxlist.Reheap()
on who is allowed to reheap the listtxList
on updating thetxlist.stales
countertxpool.loop()
and reseting the txpool's blockchain between teststxpool.chain.gaslimit
from within a test