Skip to content

Add lock to StuckTxDetector & InMemoryStoreManager - #539

Open
dimriou wants to merge 4 commits into
developfrom
oev-1708_fix_stuck_tx_detector
Open

Add lock to StuckTxDetector & InMemoryStoreManager#539
dimriou wants to merge 4 commits into
developfrom
oev-1708_fix_stuck_tx_detector

Conversation

@dimriou

@dimriou dimriou commented Aug 26, 2026

Copy link
Copy Markdown
Contributor
  • StuckTxDetector now supports multiple addresses safely.
  • Remove unused detection method along with its types.
  • Add lock to InMemoryStoreManager for future usages

@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

⚠️ API Diff Results - github.com/smartcontractkit/chainlink-evm

⚠️ Breaking Changes (8)

pkg/txm (6)
  • APIResponse — 🗑️ Removed

  • APIStatusCancelled — 🗑️ Removed

  • APIStatusFailed — 🗑️ Removed

  • APIStatusIncluded — 🗑️ Removed

  • APIStatusPending — 🗑️ Removed

  • APIStatusUnknown — 🗑️ Removed

pkg/txm.(*stuckTxDetector) (1)
  • DualBroadcastDetection — 🗑️ Removed
pkg/txm/storage.InMemoryStoreManager (1)
  • InMemoryStoreMap — 🗑️ Removed

✅ Compatible Changes (1)

pkg/txm/storage.(*InMemoryStoreManager) (1)
  • GetStoreSafe — ➕ Added

📄 View full apidiff report

@dimriou dimriou changed the title Add lock to StuckTxDetector Add lock to StuckTxDetector & InMemoryStoreManager Aug 26, 2026
@dimriou
dimriou marked this pull request as ready for review August 26, 2026 09:58
@dimriou
dimriou requested review from a team as code owners August 26, 2026 09:58
Copilot AI lite review requested due to automatic review settings August 26, 2026 09:58
@dimriou
dimriou requested a review from a team as a code owner August 26, 2026 09:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 stuckTxDetector to protect lastPurgeMap and validate concurrent calls via a new test.
  • Add an RWMutex and a safe accessor (GetStoreSafe) to InMemoryStoreManager, and update call sites/tests to avoid direct map access.
  • Remove the deprecated DualBroadcastDetection implementation and related types/imports from stuck_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))
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