-
Notifications
You must be signed in to change notification settings - Fork 58
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
feat: add env vars for proxy configurations #1120
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Looks good. Not a full review yet, but I left some comments inline.
bin/proving-service/README.md
Outdated
# Host of the proxy server | ||
host = "0.0.0.0" | ||
PROXY_HOST="0.0.0.0" | ||
# Port of the proxy server | ||
port = 8082 | ||
PROXY_PORT="8082" | ||
# Host of the workers update endpoint | ||
PROXY_WORKERS_UPDATE_PORT="8083" | ||
# Timeout for a new request to be completed | ||
timeout_secs = 100 | ||
PROXY_TIMEOUT_SECS="100" | ||
# Timeout for establishing a connection to the worker | ||
connection_timeout_secs = 10 | ||
PROXY_CONNECTION_TIMEOUT_SECS="10" | ||
# Maximum amount of items that a queue can handle | ||
max_queue_items = 10 | ||
PROXY_MAX_QUEUE_ITEMS="10" | ||
# Maximum amount of retries that a request can take | ||
max_retries_per_request = 1 | ||
PROXY_MAX_RETRIES_PER_REQUEST="1" | ||
# Maximum amount of requests that a given IP address can make per second | ||
max_req_per_sec = 5 | ||
PROXY_MAX_REQ_PER_SEC="5" | ||
# Time to wait before checking the availability of workers | ||
available_workers_polling_time_ms = 20 | ||
PROXY_AVAILABLE_WORKERS_POLLING_TIME_MS="20" | ||
# Interval to check the health of the workers | ||
health_check_interval_secs = 1 | ||
PROXY_HEALTH_CHECK_INTERVAL_SECS="1" | ||
# Host of the metrics server | ||
prometheus_host = "127.0.0.1" | ||
PROXY_PROMETHEUS_HOST="127.0.0.1" | ||
# Port of the metrics server | ||
prometheus_port = 6192 | ||
PROXY_PROMETHEUS_PORT="6192" | ||
# Log level | ||
RUST_LOG="info" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we only use clap
then I would suggest either directly copying --help
output here, or only documenting the important ones and tell the user to check out more options with --help
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have this as command options, but are used to create the ProxyConfig
struct. ATM, I;ve removed the TOML file and we are trying to create the ProxyConfig
struct with the env vars or default values if not present. But since we don't have it as options, --help
is not printing them.
Though I can change it to be part of the command if we consider that is it more useful that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo the default should always be cli
unless there is a compelling reason not to. I would make these all clap
variables with these default values, and with the env args set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would basically mean that we merge StartProxy
command and ProxyConfig
structs, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct yes, at least from the external API sense.
One might still keep the ProxyConfig
struct to decouple the cli interface from the proxy code but whether or not that's applicable depends.
A good illustration of this ^^ is the node where currently each component has its own config, as well as a "normalized" variant for miden-node start node
. When we refactor that we'll keep component config structs (but without toml support). Then its up to the clap/main binary code to convert between the cli args and the component config as it sees fit. e.g.
let cli_args = clap::parse()?;
let proxy_handle = Proxy {
endpoint: cli_args.endpoint,
timeout: cli_args.timeout,
request: RequestLimits {
retries: cli_args.requests.max_retries,
...
},
...
}.spawn();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you! I left some comments inline. After these are addressed, we are good to merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you! I left a few more comments inline.
Also, I noticed that --help
does not work on any of the commands except for start-proxy
. Could we fix this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Leaving some minor suggestions, feel free to disregard if an alternative is preferred
CHANGELOG.md
Outdated
@@ -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). | |||
- Refactored config file for `miden-proving-service` to be based on environment variables (#1120). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think this might have to be [BREAKING]
bin/proving-service/README.md
Outdated
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. | ||
You can customize the proxy service by setting environment variables. Possible customizations can be found by running `miden-proving-service start-proxy --help`. | ||
|
||
An example `.env` file is provided in the crate's root directory. To use the variables from a file in any Unix-like operating system, you can run source <your-file>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example `.env` file is provided in the crate's root directory. To use the variables from a file in any Unix-like operating system, you can run source <your-file>. | |
An example `.env` file is provided in the crate's root directory. To use the variables from a file in any Unix-like operating system, you can run `source <your-file>`. |
pub timeout_secs: u64, | ||
#[derive(Debug, Parser)] | ||
pub(crate) struct ProxyConfig { | ||
/// Time in milliseconds to poll available workers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Considering the health check setting is called health_check_interval_secs
, I'd suggest renaming this variable to use a similar convention. Could be something like available_workers_polling_interval_ms
or maybe availability_check_interval_ms
.
Also, this setting is for polling for availability and assigning tasks, right? If so it would be good to specify int he doc comment:
/// Time in milliseconds to poll available workers. | |
/// Interval in milliseconds at which the system polls for available workers to assign new tasks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I just update the var to available_workers_polling_interval_ms
.
/// Port of the proxy. | ||
#[clap(long, default_value = "8082", env = "MPS_PORT")] | ||
pub(crate) port: u16, | ||
/// Maximum time in seconds to complete the entire request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Maximum time in seconds to complete the entire request. | |
/// Maximum time in seconds allowed for a request to complete. Once exceeded, the request is aborted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you!
closes #1026