3 releases
0.6.2 | Nov 8, 2024 |
---|---|
0.6.1 | Nov 8, 2024 |
0.6.0 | Nov 6, 2024 |
#1053 in Network programming
1,477 downloads per month
Used in 2 crates
1MB
20K
SLoC
Miden transaction prover
A service for generating Miden transaction proofs on-demand. The binary enables spawning workers and a proxy for Miden's remote transaction prover service.
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, 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.
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.
Installation
To build the service from a local version, from the root of the workspace you can run:
make install-tx-prover
The CLI can be installed from the source code using specific git revisions with cargo install
. Note that since these aren't official releases we cannot provide much support for any issues you run into, so consider this for advanced users only.
Note that for the prover worker you might need to enable the testing
feature in case the transactions were executed with reduced proof-of-work requirements (or otherwise, the proving process will fail). This step will also generate the necessary protobuf-related files. You can achieve that by generating the binary with:
make install-tx-prover-testing
Worker
To start the worker service you will need to run:
miden-tx-prover start-worker --host 0.0.0.0 --port 8082
This will spawn a worker using the hosts and ports defined in the command options. In case that one of the values is not present, it will default to 0.0.0.0
for the host and 50051
for the port.
Proxy
First, you need to create a configuration file for the proxy with:
miden-tx-prover init
This will create the miden-tx-prover.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, and add workers. An example of a valid configuration is:
# Host of the proxy server
host = "0.0.0.0"
# Port of the proxy server
port = 8082
# Timeout for a new request to be completed
timeout_secs = 100
# Timeout for establishing a connection to the worker
connection_timeout_secs = 10
# Maximum amount of items that a queue can handle
max_queue_items = 10
# Maximum amount of retries that a request can take
max_retries_per_request = 1
# Maximum amount of requests that a given IP address can make per second
max_req_per_sec = 5
[[workers]]
host = "0.0.0.0"
port = 8083
[[workers]]
host = "0.0.0.0"
port = 8084
To add more workers, you will need to add more items with the [[workers]]
tags.
Then, to start the proxy service, you will need to run:
miden-tx-prover start-proxy
This command will start the proxy using the workers defined in the configuration file to send transaction witness to prove.
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 the following worker in a round-robin fashion. The amount of retries is configurable changing the max_retries_per_request
value in the configuration file.
Both the worker and the proxy will use the info
log level by default, but it can be changed by setting the RUST_LOG
environment variable.
Features
Description of this crate's feature:
Features | Description |
---|---|
std |
Enable usage of Rust's std , use --no-default-features for no-std support. |
concurrent |
Enables concurrent code to speed up runtime execution. |
async |
Enables the RemoteTransactionProver struct, that implements an async version of TransactionProver trait. |
testing |
Enables testing utilities and reduces proof-of-work requirements to speed up tests' runtimes. |
Using RemoteTransactionProver
To use the RemoteTransactionProver
struct, enable async
. Additionally, when compiling for wasm32-unknown-unknown
, disable default features.
[dependencies]
miden-tx-prover = { version = "0.6", features = ["async"], default-features = false } # Uses tonic-web-wasm-client transport
miden-tx-prover = { version = "0.6", features = ["async"] } # Uses tonic's Channel transport
Dependencies
~48–84MB
~1.5M SLoC