Privacy Protocol Relayer (Rust)
High-performance relayer service for Privacy Protocol. It accepts proof payloads over HTTP, validates anti-theft and fee constraints, batches requests, and submits pool transactions on-chain (withdraw / executeAction).
Features
POST /relayJSON API for relay intake.GET /relay/:request_idstatus API (queued/submitted+ tx hash when available).Anti-theft check:
public_inputs[RELAYER_INDEX]must match relayer wallet address.Fee check: request fee must cover
estimated_gas_cost * 1.1.Smart batching worker:
submit immediately when queue length reaches batch size
submit when oldest request exceeds max wait
sleep when queue is empty
Nonce management with retry for transient RPC errors.
Graceful shutdown and mempool persistence to disk.
Flashbots integration point marked with TODO in chain submission path.
Quick Start
Copy env template:
Fill
.envvalues.Run:
Server starts on RELAYER_BIND_ADDR (default 0.0.0.0:8787).
Tests
Run:
Included tests cover:
relay intake acceptance and queueing
anti-theft relayer address rejection
worker submission and mempool acknowledgement
API
POST /relay
POST /relayRequest:
Response:
Error codes:
400malformed payload/public inputs403relayer address mismatch (anti-theft check failed)422simulation failed or fee too low500internal error
GET /health
GET /healthResponse:
GET /relay/:request_id
GET /relay/:request_idResponse:
Contract/Circuit Assumptions
The proving flow is expected to provide at least:
one public input containing relayer address (bytes32-encoded address)
one public input containing relayer fee in wei (
uint256)
Relay metadata is expected to include:
operation:withdraworexecuteActionoperation-specific fields required to build the target pool call
Set indices via:
RELAYER_PUBLIC_INPUT_RELAYER_INDEXRELAYER_PUBLIC_INPUT_FEE_INDEX
Persistence
Pending queue state is written to RELAYER_MEMPOOL_PATH on enqueue and after successful batch acknowledgements. On restart, queue state is restored from this file.
Last updated