// Specification of the user facing gRPC API.
syntax = "proto3";
package remote_prover;

import "google/protobuf/empty.proto";

// PROVER SERVICE
// ================================================================================================

service Api {
    // Generates a proof for the requested payload.
    rpc Prove(ProofRequest) returns (Proof) {}
}

// Enumeration of supported proof types.
enum ProofType {
    // Proof for a single transaction.
    TRANSACTION = 0;

    // Proof covering a batch of transactions.
    BATCH = 1;

    // Proof for entire block validity.
    BLOCK = 2;
}

// Request message for proof generation containing payload and proof type metadata.
message ProofRequest {
    // Type of proof being requested, determines payload interpretation
    ProofType proof_type = 1;

    // Serialized payload requiring proof generation. The encoding format is
    // type-specific:
    // - TRANSACTION: TransactionInputs encoded.
    // - BATCH: ProposedBatch encoded.
    // - BLOCK: BlockProofRequest encoded.
    bytes payload = 2;
}

// Response message containing the generated proof.
message Proof {
    // Serialized proof bytes.
    // - TRANSACTION: Returns an encoded ProvenTransaction.
    // - BATCH: Returns an encoded ProvenBatch.
    // - BLOCK: Returns an encoded BlockProof.
    bytes payload = 1;
}

// PROXY STATUS SERVICE
// ================================================================================================

service ProxyStatusApi {
    // Returns the status of the proxy.
    rpc Status(google.protobuf.Empty) returns (ProxyStatus) {}
}

// Status of an individual worker in the proxy.
message ProxyWorkerStatus {
    // The name of the worker.
    string name = 1;
    // The version of the worker.
    string version = 2;
    // The health status of the worker.
    WorkerHealthStatus status = 3;
}

// Health status of a worker.
enum WorkerHealthStatus {
    // The worker's health status is unknown.
    // This value is used when the proxy is not able to determine the health status of the worker.
    // It is only a temporary state and the proxy will eventually determine the health status of the worker.
    UNKNOWN = 0;
    // The worker is healthy.
    // This value is used when the worker is able to successfully process requests.
    HEALTHY = 1;
    // The worker is unhealthy.
    // This value is used when the worker is not receiving requests or is not able to successfully process requests.
    UNHEALTHY = 2;
}

// Response message containing the status of the proxy.
message ProxyStatus {
    // The version of the proxy.
    string version = 1;
    // The proof type supported by this proxy.
    ProofType supported_proof_type = 2;
    // The list of workers managed by this proxy.
    repeated ProxyWorkerStatus workers = 3;
}

// WORKER STATUS SERVICE
// ================================================================================================

service WorkerStatusApi {
    // Returns the status of the worker.
    rpc Status(google.protobuf.Empty) returns (WorkerStatus) {}
}

// Response message containing the status of the worker.
message WorkerStatus {
    // The version of the worker.
    string version = 1;
    // The proof type supported by this worker.
    ProofType supported_proof_type = 2;
}
