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

fix concurrent issue of local account set in legacypool #270

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

andyzhang2023
Copy link
Contributor

@andyzhang2023 andyzhang2023 commented Mar 13, 2025

Description

There is an concurrent map read & write issue on legacypool.locals when --txpool.nolocals=false. It causes panic.
Here's how it happend:

  1. the legacypool.locals accounts map is written here, with flag --txpool.nolocals=false.
  2. the legacypool.locals accounts map is then accessed by the Pending() method concurrently here, with a none-nil minTip.

Rationale

2025-03-13 09:11:46.019	fatal error: concurrent map read and map write
2025-03-13 09:11:46.022	
2025-03-13 09:11:46.022	goroutine 8573 [running]:
2025-03-13 09:11:46.022	github.com/ethereum/go-ethereum/core/txpool/legacypool.(*accountSet).contains(...)
2025-03-13 09:11:46.022		github.com/ethereum/go-ethereum/core/txpool/legacypool/legacypool.go:2080
2025-03-13 09:11:46.022	github.com/ethereum/go-ethereum/core/txpool/legacypool.(*LegacyPool).Pending(0xc000362780, {0xc00992afc0, 0xc02bfaab80, 0xc02bfaaba0, 0x1, 0x0})
2025-03-13 09:11:46.022		github.com/ethereum/go-ethereum/core/txpool/legacypool/legacypool.go:708 +0x705
2025-03-13 09:11:46.022	github.com/ethereum/go-ethereum/core/txpool.(*TxPool).Pending(0xc00736b9e0, {0xc00992afc0, 0xc02bfaab80, 0xc02bfaaba0, 0x1, 0x0})
2025-03-13 09:11:46.022		github.com/ethereum/go-ethereum/core/txpool/txpool.go:407 +0xcd
2025-03-13 09:11:46.022	github.com/ethereum/go-ethereum/miner.(*worker).fillTransactions(0xc00c887440, 0xc017ea7098, 0xc012a248f0)
2025-03-13 09:11:46.022		github.com/ethereum/go-ethereum/miner/worker.go:1293 +0x22c
2025-03-13 09:11:46.022	github.com/ethereum/go-ethereum/miner.(*worker).generateWork(0xc00c887440, 0xc0168ff080)
2025-03-13 09:11:46.022		github.com/ethereum/go-ethereum/miner/worker.go:1452 +0xb52
2025-03-13 09:11:46.022	github.com/ethereum/go-ethereum/miner.(*worker).opLoop(0xc00c887440)
2025-03-13 09:11:46.022		github.com/ethereum/go-ethereum/miner/worker.go:678 +0x7f
2025-03-13 09:11:46.022	created by github.com/ethereum/go-ethereum/miner.newWorker in goroutine 1
2025-03-13 09:11:46.022		github.com/ethereum/go-ethereum/miner/worker.go:343 +0x9f6
2025-03-13 09:11:46.022	

Example

How to replay it:

  1. start a miner node with op-geth flat: --txpool.nolocals=false
  2. keep sending transactions to the miner via RPC API, so the transactions will be added into the pool as local ones.
    The node should panic after a few minutes.

@github-actions github-actions bot requested review from redhdx and welkin22 March 13, 2025 23:24
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.

1 participant