Skip to content

fix: Strict timeout statemachine#2160

Merged
nimrod-teich merged 8 commits into
mainfrom
strict-timeout-statemachine
Dec 31, 2025
Merged

fix: Strict timeout statemachine#2160
nimrod-teich merged 8 commits into
mainfrom
strict-timeout-statemachine

Conversation

@Tomelia1999

@Tomelia1999 Tomelia1999 commented Dec 30, 2025

Copy link
Copy Markdown
Contributor

Description

Closes: #XXXX


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...

  • read the contribution guide
  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the main branch
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Note

Strengthens timeout handling in SmartRouterRelayStateMachine to prevent retries after the processing context expires and addresses a race where gotResults could win over processingCtx.Done().

  • Adds checkAndHandleTimeout helper and prioritizes timeout checks before the select loop and before all retry spawn points (batchUpdate errors, gotResults retry, ticker) with a final backup on processingCtx.Done()
  • Sends termination instructions immediately on timeout and improves logging context
  • Introduces SmartRouterRelaySenderMockWithTimeout for configurable timeouts
  • Adds tests validating strict timeout enforcement, continued retries when context is valid, and that timeout wins races with gotResults

Written by Cursor Bugbot for commit 9b59dc7. This will update automatically on new commits. Configure here.

@github-actions

github-actions Bot commented Dec 30, 2025

Copy link
Copy Markdown

Test Results

    6 files  ±0    129 suites  ±0   33m 34s ⏱️ - 1m 13s
3 001 tests +6  2 992 ✅ +7  1 💤 ±0  2 ❌ ±0  6 🔥  - 1 
3 081 runs  +6  3 072 ✅ +7  1 💤 ±0  2 ❌ ±0  6 🔥  - 1 

For more details on these failures and errors, see this check.

Results for commit 9b59dc7. ± Comparison against base commit ae6d527.

♻️ This comment has been updated with latest results.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Comment thread protocol/rpcsmartrouter/smartrouter_relay_state_machine.go
Comment thread protocol/rpcsmartrouter/smartrouter_relay_state_machine.go
@nimrod-teich nimrod-teich merged commit ac492c9 into main Dec 31, 2025
19 of 21 checks passed
@nimrod-teich nimrod-teich deleted the strict-timeout-statemachine branch December 31, 2025 11:57
Tomelia1999 added a commit that referenced this pull request Dec 31, 2025
commit ac492c9
Author: Tomelia1999 <76162525+Tomelia1999@users.noreply.github.com>
Date:   Wed Dec 31 13:57:00 2025 +0200

    fix: Strict timeout statemachine (#2160)

    * update the state machine to check if global context timer is done

    * unit test

    * adding timeout verification in the begining of the stetMachine

    ---------

    Co-authored-by: Nim Rod <nimrod.teich@gmail.com>

commit 3c21210
Author: Nim Rod <nimrod.teich@gmail.com>
Date:   Wed Dec 31 13:56:47 2025 +0200

    fix: Hiesen tests failing randomly  (#2166)

    * fix: only add WebSocket URLs for API interfaces that support them

    REST API only supports HTTP/HTTPS, not WebSocket. Previously,
    CreateChainLibMocks was unconditionally adding ws:// URLs for all
    non-gRPC interfaces, causing test failures with:
      ERR URL scheme should be (http/https), got: ws apiInterface=rest

    Now WebSocket URLs are only added for JsonRPC and TendermintRPC
    interfaces which actually support WebSocket connections.

    * fix: set Enabled: true for test Endpoints to prevent provider blocking

    When creating Endpoint structs in tests without setting Enabled: true,
    the Go zero-value (false) causes all endpoints to be considered
    disabled, immediately blocking providers with:
      'purging provider after all endpoints are disabled'

    This fix adds Enabled: true to all Endpoint configurations in:
    - rpcconsumer_server_test.go
    - rpcsmartrouter_server_test.go
    - rpcsmartrouter_test.go

commit ae6d527
Author: Nim Rod <nimrod.teich@gmail.com>
Date:   Wed Dec 31 12:33:58 2025 +0200

    fix: add type assertion checks to satisfy forcetypeassert linter (#2164)

commit cf3ac0d
Author: Nim Rod <nimrod.teich@gmail.com>
Date:   Wed Dec 31 11:59:59 2025 +0200

    fix: use dynamic ports in tests to avoid address conflicts (#2162)

    Replace hardcoded port 54321 with dynamically allocated ports using
    net.Listen on :0 to prevent 'address already in use' errors when
    tests run in parallel or when ports are occupied.

    Changes:
    - Add getFreePort() helper function to both test files
    - Update createRpcConsumer() and createRpcSmartRouter() to use dynamic ports

commit f87a634
Author: NadavLevi <30565624+NadavLevi@users.noreply.github.com>
Date:   Wed Dec 31 11:59:49 2025 +0200

    feat(processingCtx): default processing ctx timeout can be set through flag (#2161)

commit 77c514f
Author: NadavLevi <30565624+NadavLevi@users.noreply.github.com>
Date:   Tue Dec 30 16:48:11 2025 +0200

    perf: add early return optimization to LavaFormatLog (#2155)

commit f3e59ef
Author: NadavLevi <30565624+NadavLevi@users.noreply.github.com>
Date:   Tue Dec 30 16:47:55 2025 +0200

    perf: implement double-check locking in cacheAddonAddresses (#2156)

    * perf: implement double-check locking in cacheAddonAddresses

    Replace simple write lock with double-check locking pattern to reduce
    lock contention in cacheAddonAddresses. This allows multiple concurrent
    readers on cache hits (fast path) while maintaining thread safety for
    cache misses (write path).

    Performance improvement:
    - Cache hits: RLock only (allows concurrent access)
    - Cache misses: RLock check → upgrade to Lock → double-check → populate

    This significantly reduces lock wait times when the cache is already
    populated, which is the common case during steady-state operation.

    * refactor: enhance cacheAddonAddresses with improved double-check locking

    Updated the cacheAddonAddresses method to utilize a more efficient double-check locking pattern. This change reduces lock contention by allowing concurrent reads on cache hits while ensuring thread safety during cache misses. The implementation includes cloning the extensions to prevent aliasing and optimizes the cache population process. This refactor aims to improve performance during steady-state operations.

    ---------

    Co-authored-by: avitenzer <tenzer@clara.co.uk>

commit f466762
Author: NadavLevi <30565624+NadavLevi@users.noreply.github.com>
Date:   Tue Dec 30 16:16:42 2025 +0200

    fix(smart-router): skip block gap warning when expectedBH is MaxInt64 (#2157)
nimrod-teich pushed a commit that referenced this pull request Dec 31, 2025
* Adding a fix for redundent retries when pairingListEmpty

* Squashed commit of the following:

commit ac492c9
Author: Tomelia1999 <76162525+Tomelia1999@users.noreply.github.com>
Date:   Wed Dec 31 13:57:00 2025 +0200

    fix: Strict timeout statemachine (#2160)

    * update the state machine to check if global context timer is done

    * unit test

    * adding timeout verification in the begining of the stetMachine

    ---------

    Co-authored-by: Nim Rod <nimrod.teich@gmail.com>

commit 3c21210
Author: Nim Rod <nimrod.teich@gmail.com>
Date:   Wed Dec 31 13:56:47 2025 +0200

    fix: Hiesen tests failing randomly  (#2166)

    * fix: only add WebSocket URLs for API interfaces that support them

    REST API only supports HTTP/HTTPS, not WebSocket. Previously,
    CreateChainLibMocks was unconditionally adding ws:// URLs for all
    non-gRPC interfaces, causing test failures with:
      ERR URL scheme should be (http/https), got: ws apiInterface=rest

    Now WebSocket URLs are only added for JsonRPC and TendermintRPC
    interfaces which actually support WebSocket connections.

    * fix: set Enabled: true for test Endpoints to prevent provider blocking

    When creating Endpoint structs in tests without setting Enabled: true,
    the Go zero-value (false) causes all endpoints to be considered
    disabled, immediately blocking providers with:
      'purging provider after all endpoints are disabled'

    This fix adds Enabled: true to all Endpoint configurations in:
    - rpcconsumer_server_test.go
    - rpcsmartrouter_server_test.go
    - rpcsmartrouter_test.go

commit ae6d527
Author: Nim Rod <nimrod.teich@gmail.com>
Date:   Wed Dec 31 12:33:58 2025 +0200

    fix: add type assertion checks to satisfy forcetypeassert linter (#2164)

commit cf3ac0d
Author: Nim Rod <nimrod.teich@gmail.com>
Date:   Wed Dec 31 11:59:59 2025 +0200

    fix: use dynamic ports in tests to avoid address conflicts (#2162)

    Replace hardcoded port 54321 with dynamically allocated ports using
    net.Listen on :0 to prevent 'address already in use' errors when
    tests run in parallel or when ports are occupied.

    Changes:
    - Add getFreePort() helper function to both test files
    - Update createRpcConsumer() and createRpcSmartRouter() to use dynamic ports

commit f87a634
Author: NadavLevi <30565624+NadavLevi@users.noreply.github.com>
Date:   Wed Dec 31 11:59:49 2025 +0200

    feat(processingCtx): default processing ctx timeout can be set through flag (#2161)

commit 77c514f
Author: NadavLevi <30565624+NadavLevi@users.noreply.github.com>
Date:   Tue Dec 30 16:48:11 2025 +0200

    perf: add early return optimization to LavaFormatLog (#2155)

commit f3e59ef
Author: NadavLevi <30565624+NadavLevi@users.noreply.github.com>
Date:   Tue Dec 30 16:47:55 2025 +0200

    perf: implement double-check locking in cacheAddonAddresses (#2156)

    * perf: implement double-check locking in cacheAddonAddresses

    Replace simple write lock with double-check locking pattern to reduce
    lock contention in cacheAddonAddresses. This allows multiple concurrent
    readers on cache hits (fast path) while maintaining thread safety for
    cache misses (write path).

    Performance improvement:
    - Cache hits: RLock only (allows concurrent access)
    - Cache misses: RLock check → upgrade to Lock → double-check → populate

    This significantly reduces lock wait times when the cache is already
    populated, which is the common case during steady-state operation.

    * refactor: enhance cacheAddonAddresses with improved double-check locking

    Updated the cacheAddonAddresses method to utilize a more efficient double-check locking pattern. This change reduces lock contention by allowing concurrent reads on cache hits while ensuring thread safety during cache misses. The implementation includes cloning the extensions to prevent aliasing and optimizes the cache population process. This refactor aims to improve performance during steady-state operations.

    ---------

    Co-authored-by: avitenzer <tenzer@clara.co.uk>

commit f466762
Author: NadavLevi <30565624+NadavLevi@users.noreply.github.com>
Date:   Tue Dec 30 16:16:42 2025 +0200

    fix(smart-router): skip block gap warning when expectedBH is MaxInt64 (#2157)

---------

Co-authored-by: avitenzer <tenzer@clara.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants