Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add env vars for proxy configurations #1120

Merged
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f5e701e
feat: add env vars for proxy configurations
SantiagoPittella Feb 3, 2025
1f373db
docs: update changelog
SantiagoPittella Feb 3, 2025
b2379f1
feat: remove toml file and init command
SantiagoPittella Feb 3, 2025
0d5a621
remove env var arguments from start-worker command
SantiagoPittella Feb 4, 2025
0d4ea4f
review: remove env support for start-proxy command
SantiagoPittella Feb 4, 2025
ecbf0f5
review: remove figment and dotenvy
SantiagoPittella Feb 4, 2025
ba5bace
review: use MPS_ as env vars prefix
SantiagoPittella Feb 4, 2025
38befc7
rename vars in .env with MPS_ prefix
SantiagoPittella Feb 4, 2025
c4fb6d2
docs: update readme
SantiagoPittella Feb 4, 2025
795b212
Merge branch 'next' into santiagopittella-proxy-configs-through-env-vars
SantiagoPittella Feb 4, 2025
e4fe076
fix docs and remove unused dependency
SantiagoPittella Feb 4, 2025
d4ff777
review: merge ProxyConfig and StartProxy structs
SantiagoPittella Feb 5, 2025
9732563
review: update changelog entry
SantiagoPittella Feb 5, 2025
3697ff7
review: improve env file section of the readme
SantiagoPittella Feb 6, 2025
b169aff
review: improve commands documentation
SantiagoPittella Feb 6, 2025
ba17e63
docs: update add/remove workers section of the readme
SantiagoPittella Feb 6, 2025
816bdfc
fix: start proxy command was bad formatted
SantiagoPittella Feb 6, 2025
c8e6265
review: mark the change as breaking
SantiagoPittella Feb 6, 2025
e5181cd
review: add missing backticks in readme
SantiagoPittella Feb 6, 2025
ff9e61b
review: rename polling time frequency
SantiagoPittella Feb 6, 2025
54709bb
review: update comment of worker polling time
SantiagoPittella Feb 6, 2025
c96863b
review: update comment of timeout time
SantiagoPittella Feb 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Renamed the protobuf file of the transaction prover to `tx_prover.proto` (#1110).
- [BREAKING] Renamed `AccountData` to `AccountFile` (#1116).
- Implement transaction batch prover in Rust (#1112).
- Added environment variables to the `miden-proving-service` (#1120).
bobbinth marked this conversation as resolved.
Show resolved Hide resolved

## 0.7.2 (2025-01-28) - `miden-objects` crate only

Expand Down
82 changes: 0 additions & 82 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions bin/proving-service/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
MPS_HOST="0.0.0.0"
MPS_PORT="8082"
MPS_WORKERS_UPDATE_PORT="8083"
MPS_TIMEOUT_SECS="100"
MPS_CONNECTION_TIMEOUT_SECS="10"
MPS_MAX_QUEUE_ITEMS="10"
MPS_MAX_RETRIES_PER_REQUEST="1"
MPS_MAX_REQ_PER_SEC="5"
MPS_AVAILABLE_WORKERS_POLLING_TIME_MS="20"
MPS_HEALTH_CHECK_INTERVAL_SECS="1"
MPS_PROMETHEUS_HOST="127.0.0.1"
MPS_PROMETHEUS_PORT="6192"
RUST_LOG="info"
4 changes: 1 addition & 3 deletions bin/proving-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ concurrent = ["miden-tx/concurrent"]
async-trait = "0.1"
axum = { version = "0.7" }
bytes = "1.0"
clap = { version = "4.5", features = ["derive"] }
figment = { version = "0.10", features = ["toml", "env"] }
clap = { version = "4.5", features = ["derive", "env"] }
miden-lib = { workspace = true, default-features = false }
miden-objects = { workspace = true, default-features = false, features = ["std"] }
miden-tx = { workspace = true, default-features = false, features = ["std"] }
Expand All @@ -43,7 +42,6 @@ serde = { version = "1.0", features = ["derive"] }
serde_qs = { version = "0.13" }
tokio = { version = "1.38", features = ["full"] }
tokio-stream = { version = "0.1", features = [ "net" ]}
toml = { version = "0.8" }
thiserror = { workspace = true }
tonic = { version = "0.12", default-features = false, features = ["codegen", "prost", "transport"] }
tonic-health = { version = "0.12" }
Expand Down
49 changes: 25 additions & 24 deletions bin/proving-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,48 +28,49 @@ This will spawn a worker using the hosts and ports defined in the command option

## Proxy

First, you need to create a configuration file for the proxy with:
To start the proxy service, you will need to run:

```bash
miden-proving-service init
miden-proving-service start-proxy [worker1],[worker2],...,[workerN]
miden-proving-service start-proxy 0.0.0.0:8084 0.0.0.0:8085
```
bobbinth marked this conversation as resolved.
Show resolved Hide resolved

This will create the `miden-proving-service.toml` file in your current directory. This file will hold the configuration for the proxy. You can modify the configuration by changing the host and ports of the services, the maximum size of the queue, among other options. An example configuration is:
This command will start the proxy using the workers passed as arguments. The workers should be in the format `host:port`. If no workers are passed, the proxy will start without any workers and will not be able to handle any requests until one is added through the `miden-proving-service add-worker` command.

You can customize the proxy service by setting the following environment variables:

```toml
```bash
# Host of the proxy server
host = "0.0.0.0"
MPS_HOST="0.0.0.0"
# Port of the proxy server
port = 8082
MPS_PORT="8082"
# Host of the workers update endpoint
MPS_WORKERS_UPDATE_PORT="8083"
# Timeout for a new request to be completed
timeout_secs = 100
MPS_TIMEOUT_SECS="100"
# Timeout for establishing a connection to the worker
connection_timeout_secs = 10
MPS_CONNECTION_TIMEOUT_SECS="10"
# Maximum amount of items that a queue can handle
max_queue_items = 10
MPS_MAX_QUEUE_ITEMS="10"
# Maximum amount of retries that a request can take
max_retries_per_request = 1
MPS_MAX_RETRIES_PER_REQUEST="1"
# Maximum amount of requests that a given IP address can make per second
max_req_per_sec = 5
MPS_MAX_REQ_PER_SEC="5"
# Time to wait before checking the availability of workers
available_workers_polling_time_ms = 20
MPS_AVAILABLE_WORKERS_POLLING_TIME_MS="20"
# Interval to check the health of the workers
health_check_interval_secs = 1
MPS_HEALTH_CHECK_INTERVAL_SECS="1"
# Host of the metrics server
prometheus_host = "127.0.0.1"
MPS_PROMETHEUS_HOST="127.0.0.1"
# Port of the metrics server
prometheus_port = 6192
```

Then, to start the proxy service, you will need to run:

```bash
miden-proving-service start-proxy [worker1] [worker2] ... [workerN]
MPS_PROMETHEUS_PORT="6192"
# Log level
RUST_LOG="info"
```

This command will start the proxy using the workers passed as arguments. The workers should be in the format `host:port`. If no workers are passed, the proxy will start without any workers and will not be able to handle any requests until one is added through the `miden-proving-service add-worker` command.
An example `.env` file is provided in the crate's root directory.
bobbinth marked this conversation as resolved.
Show resolved Hide resolved

At the moment, when a worker added to the proxy stops working and can not connect to it for a request, the connection is marked as retriable meaning that the proxy will try reaching another worker. The number of retries is configurable via the `max_retries_per_request` value in the configuration file.
At the moment, when a worker added to the proxy stops working and can not connect to it for a request, the connection is marked as retriable meaning that the proxy will try reaching another worker. The number of retries is configurable via the `MPS_MAX_RETRIES_PER_REQUEST` environmental variable.

## Updating workers on a running proxy

Expand Down Expand Up @@ -120,7 +121,7 @@ If Docker is not an option, Jaeger can also be set up directly on your machine o

## Metrics

The proxy includes a service that exposes metrics to be consumed by [Prometheus](https://prometheus.io/docs/introduction/overview/). This service is always enabled and uses the host and port defined in the `miden-proving-service.toml` file.
The proxy includes a service that exposes metrics to be consumed by [Prometheus](https://prometheus.io/docs/introduction/overview/). This service is always enabled and uses the host and port defined in the `.env` file through the `MPS_PROMETHEUS_HOST` and `MPS_PROMETHEUS_PORT` variables.

The metrics architecture works by having the proxy expose metrics at an endpoint (`/metrics`) in a format Prometheus can read. Prometheus periodically scrapes this endpoint, adds timestamps to the metrics, and stores them in its time-series database. Then, we can use tools like Grafana to query Prometheus and visualize these metrics in configurable dashboards.

Expand Down
48 changes: 0 additions & 48 deletions bin/proving-service/src/commands/init.rs

This file was deleted.

Loading
Loading