Skip to content

Conversation

@Eric-Warehime
Copy link
Contributor

Description

Closes: #XXXX

Fixes the following race condition, which is verified when running the included test with the -race flag. As shown in the trace we need to make this thread safe because it can be called from goroutines within the txpool.

758676962391	2025-09-24T01:22:42.391Z	WARNING: DATA RACE
1758676962391	2025-09-24T01:22:42.391Z	Write at 0x00c002156478 by goroutine 327:
1758676962391	2025-09-24T01:22:42.391Z	  github.com/cosmos/evm/mempool.(*Blockchain).NotifyNewBlock()
1758676962391	2025-09-24T01:22:42.391Z	      github.com/cosmos/[email protected]/mempool/blockchain.go:176 +0x337
1758676962391	2025-09-24T01:22:42.391Z	  github.com/cosmos/evm/mempool.(*ExperimentalEVMMempool).SetEventBus.func1()
1758676962391	2025-09-24T01:22:42.391Z	      github.com/cosmos/[email protected]/mempool/mempool.go:399 +0x89
1758676962391	2025-09-24T01:22:42.391Z	  github.com/cosmos/evm/mempool.(*Blockchain).NotifyNewBlock()
1758676962391	2025-09-24T01:22:42.391Z	      github.com/cosmos/[email protected]/mempool/blockchain.go:177 +0x417
...
1758676962393	2025-09-24T01:22:42.393Z	Previous read at 0x00c002156478 by goroutine 191:
1758676962393	2025-09-24T01:22:42.393Z	  github.com/cosmos/evm/mempool.(*Blockchain).StateAt()
1758676962393	2025-09-24T01:22:42.393Z	      <autogenerated>:1 +0x65
1758676962393	2025-09-24T01:22:42.393Z	  github.com/cosmos/evm/mempool/txpool.(*TxPool).loop()
1758676962393	2025-09-24T01:22:42.393Z	      github.com/cosmos/[email protected]/mempool/txpool/txpool.go:191 +0x323
1758676962393	2025-09-24T01:22:42.393Z	  github.com/cosmos/evm/mempool/txpool.New.gowrap1()
1758676962393	2025-09-24T01:22:42.393Z	      github.com/cosmos/[email protected]/mempool/txpool/txpool.go:117 +0x44


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the main branch

@Eric-Warehime Eric-Warehime changed the title bug!: Fix race condition in mempool blockchain impl fix!: Fix race condition in mempool blockchain impl Sep 24, 2025
@Eric-Warehime Eric-Warehime added this pull request to the merge queue Sep 24, 2025
Merged via the queue into main with commit 8fb8d35 Sep 24, 2025
20 checks passed
@Eric-Warehime Eric-Warehime deleted the eric/fix-mempool-race-condition branch September 24, 2025 22:42
zsystm pushed a commit to zsystm/evm that referenced this pull request Nov 2, 2025
* Fix race condition in mempool blockchain impl

* Add test for race condition

* Update changelog

* Fix lint

* Update changelog entry

* Update test

* Add timeout to systemtests

* Revert "Add timeout to systemtests"

This reverts commit 8412abb.

---------

Co-authored-by: Alex | Interchain Labs <[email protected]>
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.

4 participants