Skip to content

Commit

Permalink
feat: unify queues in proxy (#976)
Browse files Browse the repository at this point in the history
* wip: unify queues in proxy

* fix: remove prints, update documentation

* fix: remove sleep

* docs: update changelog

* feat: use struct for queue, add methods for context, move functions to utils

* docs: add separator for structs, add doc comments

* feat: use VecDequeue instead of Vec for queues

* fix: add concurrent to makefile installation

* rename set_available_worker, use assert instead of if

* fix: use constant for interval time

* fix: fix docs, remove unused scope, remove _ from var

* fix: changelog entry

* feat: use u128 for request_id

* docs: update {add, get}_available_worker documentation

* fix: use mayus for structs sections, rename get_available_worker, add info logs, fix documentation
  • Loading branch information
SantiagoPittella authored Nov 26, 2024
1 parent d50c50d commit 3fefe18
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 150 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Changes

- Refactored `miden-tx-prover` proxy load balancing strategy (#976).
- [BREAKING] Better error display when queues are full in the prover service (#967).
- [BREAKING] Remove `AccountBuilder::build_testing` and make `Account::initialize_from_components` private (#969).
- [BREAKING] Add error messages to errors and implement `core::error::Error` (#974).
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ bench-tx: ## Run transaction benchmarks

.PHONY: install-tx-prover
install-tx-prover: ## Install transaction prover's CLI
cargo install --path bin/tx-prover --bin miden-tx-prover --locked
cargo install --path bin/tx-prover --bin miden-tx-prover --locked --features concurrent

.PHONY: install-tx-prover-testing
install-tx-prover-testing: ## Install transaction prover's CLI intended for testing purposes
cargo install --path bin/tx-prover --bin miden-tx-prover --locked --features testing
cargo install --path bin/tx-prover --bin miden-tx-prover --locked --features concurrent,testing
2 changes: 1 addition & 1 deletion bin/tx-prover/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A service for generating Miden transaction proofs on-demand. The binary enables

The worker is a gRPC service that can receive transaction witnesses and returns the proof. It can only handle one request at a time and returns an error if is already in use.

The proxy uses [Cloudflare's Pingora crate](https://crates.io/crates/pingora), which provides features to create a modular proxy. It is meant to handle multiple workers with a queue for each one, load balancing incoming requests in a round-robin manner. Further information about Pingora and its features can be found in the [official GitHub repository](https://github.com/cloudflare/pingora).
The proxy uses [Cloudflare's Pingora crate](https://crates.io/crates/pingora), which provides features to create a modular proxy. It is meant to handle multiple workers with a queue, assigning a worker to each request and retrying if the worker is not available. Further information about Pingora and its features can be found in the [official GitHub repository](https://github.com/cloudflare/pingora).

Additionally, the library can be imported to utilize `RemoteTransactionProver`, a client struct that can be used to interact with the prover service from a Rust codebase.

Expand Down
11 changes: 4 additions & 7 deletions bin/tx-prover/src/commands/proxy.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use clap::Parser;
use pingora::{
apps::HttpServerOptions, lb::LoadBalancer as PingoraLoadBalancer, prelude::Opt, server::Server,
};
use pingora::{apps::HttpServerOptions, lb::Backend, prelude::Opt, server::Server};
use pingora_proxy::http_proxy_service;

use crate::{proxy::LoadBalancer, utils::load_config_from_file};
Expand All @@ -24,10 +22,9 @@ impl StartProxy {
let workers = proxy_config
.workers
.iter()
.map(|worker| format!("{}:{}", worker.host, worker.port));

let workers =
PingoraLoadBalancer::try_from_iter(workers).expect("PROVER_WORKERS is invalid");
.map(|worker| format!("{}:{}", worker.host, worker.port))
.map(|worker| Backend::new(&worker).expect("Failed to create backend"))
.collect::<Vec<Backend>>();

let worker_lb = LoadBalancer::new(workers, &proxy_config);

Expand Down
Loading

0 comments on commit 3fefe18

Please sign in to comment.