Skip to content

Cache resolved web3 provider endpoints#1831

Merged
YoshihitoAso merged 2 commits into
dev-26.6from
failover-cache
May 29, 2026
Merged

Cache resolved web3 provider endpoints#1831
YoshihitoAso merged 2 commits into
dev-26.6from
failover-cache

Conversation

@YoshihitoAso
Copy link
Copy Markdown
Member

@YoshihitoAso YoshihitoAso commented May 28, 2026

📌 Description

This pull request introduces an endpoint URI cache for both FailOverHTTPProvider and AsyncFailOverHTTPProvider to optimize fail-over behavior and reduce unnecessary database lookups. It also adds a keep-alive HTTP session manager for async providers to improve connection reuse and efficiency.

✅ Related Issues

None

🔄 Changes

Fail-over provider improvements:

  • Added a short-term cache for resolved endpoint URIs in both FailOverHTTPProvider and AsyncFailOverHTTPProvider, avoiding redundant database queries and improving performance during fail-over. The cache is automatically invalidated on connection errors or expiration.
  • Refactored endpoint resolution and cache management logic into dedicated methods for clarity and maintainability.

Async provider connection management:

  • Introduced KeepAliveHTTPSessionManager to ensure async HTTP sessions use keep-alive connections, reducing overhead for RPC-heavy workloads.
  • Updated async fail-over provider to use the new session manager for connection pooling and cache management.

📌 Checklist

  • I have added tests where necessary.
  • I have updated the documentation where necessary.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 29, 2026

Coverage

Coverage Report •
FileStmtsMissBranchBrPartCoverMissing
app/utils
   web3_utils.py31282663073%119, 126–129, 134–135, 138, 143–145, 149–152, 171–173, 177–178, 182–183, 187–188, 193–196, 199–200, 202, 210, 225–226, 237, 322, 330–331, 346–351, 353, 360–365, 367, 386–390, 395, 399–400, 403–407, 409–410, 414, 437–438, 456–458, 504, 508–509, 512–516, 523
tests/app/utils
   web3_provider_cache_test.py100040100% 
TOTAL374571470352464796% 

Tests Skipped Failures Errors Time
1281 0 💤 0 ❌ 0 🔥 10m 45s ⏱️

@YoshihitoAso YoshihitoAso marked this pull request as ready for review May 29, 2026 00:18
@YoshihitoAso YoshihitoAso marked this pull request as draft May 29, 2026 01:07
@YoshihitoAso YoshihitoAso marked this pull request as ready for review May 29, 2026 04:19
@github-actions github-actions Bot requested a review from purplesmoke05 May 29, 2026 04:19
@YoshihitoAso YoshihitoAso merged commit 608f16a into dev-26.6 May 29, 2026
13 checks passed
@YoshihitoAso YoshihitoAso deleted the failover-cache branch May 29, 2026 04:19
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.

2 participants