-
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 write concurrency in txpool #19835
Conversation
core/tx_pool.go
Outdated
@@ -420,9 +420,6 @@ func (pool *TxPool) SetGasPrice(price *big.Int) { | |||
// Nonce returns the next nonce of an account, with all transactions executable | |||
// by the pool already applied on top. | |||
func (pool *TxPool) Nonce(addr common.Address) uint64 { | |||
pool.mu.RLock() | |||
defer pool.mu.RUnlock() | |||
|
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.
pool.pendingNonces
is set in pool.reset(...)
.
@fjl done |
core/tx_noncer.go
Outdated
|
||
// compareAndSet inserts or updates a new virtual nonce into the virtual state | ||
// database if the compare callback is true. | ||
func (txn *txNoncer) compareAndSet(addr common.Address, nonce uint64, compare func(uint64, uint64) bool) { |
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.
Passing a compare
method in here seems really convoluted, especially since all instances use the same logic anyway. Let's just rename compareAndSet
to setIfLower
, get rid of compare
altogether and do the comparison internally.
@karalabe Fixed, please take another look. |
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
Fixes #19834