Add lock to StuckTxDetector & InMemoryStoreManager - #539
Open
dimriou wants to merge 4 commits into
Open
Conversation
Contributor
|
dimriou
marked this pull request as ready for review
August 26, 2026 09:58
product-security-plaid-production
Bot
requested review from
LunkRat,
ilija42 and
pavel-raykov
August 26, 2026 09:59
pavel-raykov
approved these changes
Aug 26, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves TXM concurrency safety by adding locking around shared in-memory state, and simplifies stuck-transaction detection by removing the unused dual-broadcast HTTP-based detection path.
Changes:
- Add a mutex to
stuckTxDetectorto protectlastPurgeMapand validate concurrent calls via a new test. - Add an
RWMutexand a safe accessor (GetStoreSafe) toInMemoryStoreManager, and update call sites/tests to avoid direct map access. - Remove the deprecated
DualBroadcastDetectionimplementation and related types/imports fromstuck_tx_detector.go.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/txm/txm_test.go | Updates test to use GetStoreSafe rather than direct map access. |
| pkg/txm/stuck_tx_detector.go | Adds locking for lastPurgeMap and removes the dual-broadcast HTTP detection code. |
| pkg/txm/stuck_tx_detector_test.go | Adds a concurrency regression test for timeBasedDetection. |
| pkg/txm/storage/inmemory_store_manager.go | Introduces RWMutex, makes the map private, and adds GetStoreSafe to safely access stores. |
| pkg/txm/storage/inmemory_store_manager_test.go | Updates tests to use GetStoreSafe and validate stable store instances. |
| pkg/txm/clientwrappers/dualbroadcast/meta_error_handler_test.go | Updates tests to use GetStoreSafe rather than direct map access. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
60
to
64
| func (s *stuckTxDetector) timeBasedDetection(tx *types.Transaction) bool { | ||
| s.mu.Lock() | ||
| defer s.mu.Unlock() | ||
|
|
||
| threshold := (s.config.BlockTime * time.Duration(s.config.StuckTxBlockThreshold)) |
jmank88
approved these changes
Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.