-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add pre check for rate limit (#194)
* feat: pre-check for ip/connection rate limit * clean up docs * fix * do pre-check in `validate` fn * ok_or * add tests and simplify validate
- Loading branch information
Showing
6 changed files
with
106 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
extensions: | ||
client: | ||
endpoints: | ||
- wss://acala-rpc.dwellir.com | ||
- wss://acala-rpc-0.aca-api.network | ||
health_check: | ||
interval_sec: 10 # check interval, default is 10s | ||
healthy_response_time_ms: 500 # max response time to be considered healthy, default is 500ms | ||
health_method: system_health | ||
response: # response contains { isSyncing: false } | ||
!contains | ||
- - isSyncing | ||
- !eq false | ||
event_bus: | ||
substrate_api: | ||
stale_timeout_seconds: 180 # rotate endpoint if no new blocks for 3 minutes | ||
telemetry: | ||
provider: none | ||
cache: | ||
default_ttl_seconds: 60 | ||
default_size: 500 | ||
merge_subscription: | ||
keep_alive_seconds: 60 | ||
server: | ||
port: 9944 | ||
listen_address: '0.0.0.0' | ||
max_connections: 2000 | ||
http_methods: | ||
- path: /health | ||
method: system_health | ||
- path: /liveness | ||
method: chain_getBlockHash | ||
cors: all | ||
rate_limit: # these are for demo purpose only, please adjust to your needs | ||
connection: # 20 RPC requests per second per connection | ||
burst: 20 | ||
period_secs: 1 | ||
ip: # 500 RPC requests per 10 seconds per ip | ||
burst: 500 | ||
period_secs: 10 | ||
# use X-Forwarded-For header to get real ip, if available (e.g. behind a load balancer). | ||
# WARNING: Use with caution, as this xff header can be forged. | ||
use_xff: true # default is false | ||
|
||
middlewares: | ||
methods: | ||
- delay | ||
- response | ||
- inject_params | ||
- cache | ||
- upstream | ||
subscriptions: | ||
- merge_subscription | ||
- upstream | ||
|
||
rpcs: tests/rpc_configs/big_rate_limit_weight.yml |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
methods: | ||
- method: eth_chainId | ||
cache: | ||
size: 1 | ||
rate_limit_weight: 21 |