Skip to content
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 status check to prover agent #8248

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docker-compose.provernet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ services:
condition: service_healthy
command: [ "start", "--prover" ]
restart: on-failure:5
healthcheck:
test: [ "CMD", "curl", "-fSs", "http://127.0.0.1:$AZTEC_PORT/status" ]
interval: 3s
timeout: 30s
start_period: 20s

# Simple watcher that logs the latest block numbers every few seconds using the CLI and the bot's PXE
aztec-block-watcher:
Expand Down
8 changes: 6 additions & 2 deletions yarn-project/aztec/src/cli/cmds/start_prover_agent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { BBNativeRollupProver, TestCircuitProver } from '@aztec/bb-prover';
import { type ServerCircuitProver } from '@aztec/circuit-types';
import { type ProverClientConfig, proverClientConfigMappings } from '@aztec/prover-client';
import { ProverAgent, createProvingJobSourceClient } from '@aztec/prover-client/prover-agent';
import {
ProverAgent,
createProverAgentRpcServer,
createProvingJobSourceClient,
} from '@aztec/prover-client/prover-agent';
import {
type TelemetryClientConfig,
createAndStartTelemetryClient,
Expand Down Expand Up @@ -43,5 +47,5 @@ export const startProverAgent: ServiceStarter = async (options, signalHandlers,

signalHandlers.push(() => agent.stop());

return Promise.resolve([]);
return [{ prover: createProverAgentRpcServer(agent) }];
};
4 changes: 4 additions & 0 deletions yarn-project/prover-client/src/prover-agent/prover-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export class ProverAgent {
return this.runningPromise?.isRunning() ?? false;
}

getCurrentJobs(): { id: string; type: string }[] {
return Array.from(this.inFlightPromises.values()).map(({ id, type }) => ({ id, type: ProvingRequestType[type] }));
}

start(jobSource: ProvingJobSource): void {
if (this.runningPromise) {
throw new Error('Agent is already running');
Expand Down
24 changes: 24 additions & 0 deletions yarn-project/prover-client/src/prover-agent/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { type ProvingJobSource } from '@aztec/circuit-types';
import {
AvmCircuitInputs,
AztecAddress,
BaseOrMergeRollupPublicInputs,
BaseParityInputs,
BaseRollupInputs,
BlockMergeRollupInputs,
BlockRootOrBlockMergePublicInputs,
BlockRootRollupInputs,
EthAddress,
Fr,
Header,
KernelCircuitPublicInputs,
Expand All @@ -28,6 +30,7 @@ import {
import { createJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client';
import { JsonRpcServer } from '@aztec/foundation/json-rpc/server';

import { type ProverAgent } from './prover-agent.js';
import { ProvingError } from './proving-error.js';

export function createProvingJobSourceServer(queue: ProvingJobSource): JsonRpcServer {
Expand Down Expand Up @@ -104,3 +107,24 @@ export function createProvingJobSourceClient(
fetch,
) as ProvingJobSource;
}

/**
* Wrap a ProverAgent instance with a JSON RPC HTTP server.
* @param node - The ProverNode
* @returns An JSON-RPC HTTP server
*/
export function createProverAgentRpcServer(agent: ProverAgent) {
const rpc = new JsonRpcServer(
agent,
{
AztecAddress,
EthAddress,
Fr,
Header,
},
{},
// disable methods
['start', 'stop', 'setCircuitProver', 'work', 'getProof'],
);
return rpc;
}
Loading