Skip to content
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

Merged
merged 3 commits into from
Jul 17, 2019

Conversation

rjl493456442
Copy link
Member

Fixes #19834

@rjl493456442 rjl493456442 added this to the 1.9.1 milestone Jul 15, 2019
@fjl fjl changed the title core: fix write coucurrency in txpool core: fix write concurrency in txpool Jul 16, 2019
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()

Copy link
Contributor

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(...).

@rjl493456442
Copy link
Member Author

@fjl done


// 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) {
Copy link
Member

@karalabe karalabe Jul 17, 2019

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.

@rjl493456442
Copy link
Member Author

@karalabe Fixed, please take another look.

Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@karalabe karalabe merged commit 8f80caf into ethereum:master Jul 17, 2019
@gzliudan gzliudan mentioned this pull request May 10, 2024
19 tasks
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

geth1.9.0 Program interrupt and quit
3 participants