go-ethereum/core/txpool
Péter Szilágyi 542c861b4f
core/txpool, eth/catalyst: fix racy simulator due to txpool background reset (#28837)
This PR fixes an issues in the new simulated backend. The root cause is the fact that the transaction pool has an internal reset operation that runs on a background thread.

When a new transaction is added to the pool via the RPC, the transaction is added to a non-executable queue and will be moved to its final location on a background thread. If the machine is overloaded (or simply due to timing issues), it can happen that the simulated backend will try to produce the next block, whilst the pool has not yet marked the newly added transaction executable. This will cause the block to not contain the transaction. This is an issue because we want determinism from the simulator: add a tx, mine a block. It should be in there.

The PR fixes it by adding a Sync function to the txpool, which waits for the current reset operation (if any) to finish, and then runs an entire round of reset on top. The new round is needed because resets are only triggered by new head events, so newly added transactions will not trigger the outer resets that we can wait on. The transaction pool would eventually internally do a reset even on transaction addition, but there's no easy way to wait on that and there's no meaningful reason to bubble that across everything. A clean outer reset will at worse be a small noop goroutine.
2024-01-23 20:59:38 +01:00
..
blobpool all: use uint256 in state (#28598) 2024-01-23 14:51:58 +01:00
legacypool all: use uint256 in state (#28598) 2024-01-23 14:51:58 +01:00
errors.go core/txpool: fix typos (#28213) 2023-09-28 09:48:14 +08:00
subpool.go core, eth, miner: start propagating and consuming blob txs (#28243) 2023-10-04 12:36:36 +03:00
txpool.go core/txpool, eth/catalyst: fix racy simulator due to txpool background reset (#28837) 2024-01-23 20:59:38 +01:00
validation.go all: use uint256 in state (#28598) 2024-01-23 14:51:58 +01:00