From 91b7d2efd3bdebdc01996493bce4b9d71c54ad42 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Sun, 13 Nov 2022 18:39:49 +0000 Subject: [PATCH] improve development instructions --- README.md | 10 ++++++++-- config/example.toml | 11 ++++++++--- docker-compose.yml | 11 +---------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index f8f13637..1778b8e8 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,12 @@ All other requests are sent to an RPC server on the latest block (alchemy, moral Each server has different limits to configure. The `soft_limit` is the number of parallel active requests where a server starts to slow down. The `hard_limit` is where a server starts giving rate limits or other errors. +## Quick development + +1. Run `docker-compose up -d` to start the database and caches. See `docker-compose.yml` for details. +2. Copy `./config/example.toml` to `./config/development.toml` and change settings to match your setup. +3. Run `cargo` commands: + ``` $ cargo run --release -- --help ``` @@ -28,10 +34,10 @@ Options: --help display usage information ``` -Start the server with the defaults (listen on `http://localhost:8544` and use `./config/example.toml` which proxies to a bunch of public nodes: +Start the server with the defaults (listen on `http://localhost:8544` and use `./config/development.toml` which uses the database and cache running under docker and proxies to a bunch of public nodes: ``` -cargo run --release -- --config ./config/example.toml +cargo run --release ``` ## Common commands diff --git a/config/example.toml b/config/example.toml index 12742d20..548c7006 100644 --- a/config/example.toml +++ b/config/example.toml @@ -1,21 +1,25 @@ [app] chain_id = 1 +# a database is optional. it is used for user authentication and accounting # TODO: how do we find the optimal db_max_connections? too high actually ends up being slower db_max_connections = 99 -db_url = "mysql://MYSQL_USER:MYSQL_PASSWORD@MYSQL_DOMAIN:MYSQL_PORT/MYSQL_DB" +db_url = "mysql://root:dev_web3_proxy@127.0.0.1:13306/dev_web3_proxy" min_sum_soft_limit = 2_000 min_synced_rpcs = 2 +# redis is optional. it is used for rate limits set by `hard_limit` # TODO: how do we find the optimal redis_max_connections? too high actually ends up being slower volatile_redis_max_connections = 300 -volatile_redis_url = "redis://REDIS_DOMAIN:REDIS_PORT/" +volatile_redis_url = "redis://127.0.0.1:16380/" redirect_public_url = "https://llamanodes.com/public-rpc" +# redirect_rpc_key_url only does something if db_url is set redirect_rpc_key_url = "https://llamanodes.com/dashboard/keys?key={rpc_key_id}" -sentry_url = "https://SENTRY_KEY_A.ingest.sentry.io/SENTRY_KEY_B" +# sentry is optional. it is used for browsing error logs +# sentry_url = "https://SENTRY_KEY_A.ingest.sentry.io/SENTRY_KEY_B" # public limits are when no key is used. these are instead grouped by ip # 0 = block all public requests @@ -26,6 +30,7 @@ public_requests_per_period = 200 # 10GB of cache response_cache_max_bytes = 10_000_000_000 +# allowed_origin_requests_per_period changes the min_sum_soft_limit for requests with the specified (AND SPOOFABLE) Origin header [app.allowed_origin_requests_per_period] "https://chainlist.org" = 1_000 diff --git a/docker-compose.yml b/docker-compose.yml index fcac11c9..88d69521 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,13 +29,4 @@ services: file: docker-compose.common.yml service: volatile_redis ports: - - 16380:6379 - # dev-eth: - # extends: - # file: docker-compose.common.yml - # service: web3-proxy - # volumes: - # - ./config/example.toml:/config.toml - # ports: - # - 8544:8544 # proxy (should be behind something handling HTTPS) - # - 8543:8543 # prometheus + - 127.0.0.1:16379:6379