Skip to content

Commit 0ac8b4c

Browse files
authored
feat: RPC improvements (#600)
* feat: RPC improvements * feat: Add networks routes * chore: format * chore: clippy * chore: Improvements * chore: add intergration tests * chore: Improvements * chore: Improvements * chore: Improvements
1 parent f350048 commit 0ac8b4c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+7294
-1145
lines changed

docs/configuration/index.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ This table lists the environment variables and their default values.
6565
| `PROVIDER_RETRY_BASE_DELAY_MS` | `100` | `<delay in milliseconds>` | Base delay between retry attempts in milliseconds. |
6666
| `PROVIDER_RETRY_MAX_DELAY_MS` | `2000` | `<delay in milliseconds>` | Maximum delay between retry attempts in milliseconds. |
6767
| `PROVIDER_MAX_FAILOVERS` | `3` | `<number of failovers>` | Maximum number of failovers (switching to different providers). |
68+
| `PROVIDER_FAILURE_THRESHOLD` | `3` | `<number>` | Number of consecutive failures before a provider is temporarily paused. When a provider reaches this threshold, it will be paused for the duration specified by `PROVIDER_PAUSE_DURATION_SECS`. Supports legacy env var `RPC_FAILURE_THRESHOLD`. |
69+
| `PROVIDER_PAUSE_DURATION_SECS` | `60` | `<seconds>` | Duration in seconds that a provider remains paused after reaching the failure threshold. During this time, the relayer will attempt to use other available providers. Supports legacy env var `RPC_PAUSE_DURATION_SECS`. |
70+
| `PROVIDER_FAILURE_EXPIRATION_SECS` | `60` | `<seconds>` | Duration in seconds after which individual failure records are considered stale and automatically removed. This allows providers to naturally recover over time even without explicit success calls. Failures older than this duration are not counted toward the failure threshold. |
6871
| `ENABLE_SWAGGER` | `false` | `true, false` | Enable or disable Swagger UI for API documentation. |
6972
| `KEYSTORE_PASSPHRASE` | `` | `<keystore passphrase>` | Passphrase for the keystore file used for signing transactions. |
7073
| `BACKGROUND_WORKER_TRANSACTION_REQUEST_CONCURRENCY` | `50` | `<any positive number>` | Maximum number of concurrent transaction request jobs that can be processed simultaneously. |
@@ -99,6 +102,9 @@ PROVIDER_MAX_RETRIES=3
99102
PROVIDER_RETRY_BASE_DELAY_MS=100
100103
PROVIDER_RETRY_MAX_DELAY_MS=2000
101104
PROVIDER_MAX_FAILOVERS=3
105+
PROVIDER_FAILURE_THRESHOLD=3
106+
PROVIDER_PAUSE_DURATION_SECS=60
107+
PROVIDER_FAILURE_EXPIRATION_SECS=60
102108
ENABLE_SWAGGER=false
103109
KEYSTORE_PASSPHRASE=your_keystore_passphrase
104110
STORAGE_ENCRYPTION_KEY=X67aXacJB+krEldv9i2w7NCSFwwOzVV/1ELM2KJJjQw=
@@ -299,6 +305,23 @@ For backward compatibility, string arrays are still supported:
299305
"custom_rpc_urls": ["https://your-rpc.example.com"]
300306
```
301307

308+
#### Provider Health Management
309+
310+
The relayer automatically tracks the health of RPC providers and manages failover:
311+
312+
* **Failure Tracking**: When a provider fails, the failure is recorded with a timestamp. Failures older than `PROVIDER_FAILURE_EXPIRATION_SECS` (default: 60 seconds) are automatically considered stale and removed.
313+
314+
* **Automatic Pausing**: When a provider reaches `PROVIDER_FAILURE_THRESHOLD` (default: 3) failures within the expiration window, it is automatically paused for `PROVIDER_PAUSE_DURATION_SECS` (default: 60 seconds). During this pause period, the relayer will attempt to use other available providers.
315+
316+
* **Automatic Recovery**: After the pause duration expires, the provider becomes available again. Additionally, if all failures expire (older than `PROVIDER_FAILURE_EXPIRATION_SECS`), the provider automatically recovers even if it hasn't reached the pause expiration time.
317+
318+
* **Fallback Behavior**: If all non-paused providers are unavailable, the relayer will fall back to paused providers as a last resort, ensuring maximum availability.
319+
320+
You can configure these behaviors using the environment variables:
321+
* `PROVIDER_FAILURE_THRESHOLD`: Number of failures before pausing (default: 3)
322+
* `PROVIDER_PAUSE_DURATION_SECS`: How long to pause a failed provider (default: 60 seconds)
323+
* `PROVIDER_FAILURE_EXPIRATION_SECS`: How long failures are remembered (default: 60 seconds)
324+
302325
<Callout type='warn'>
303326

304327

0 commit comments

Comments
 (0)