Skip to content

Commit

Permalink
feat: Add status check to prover agent (#8248)
Browse files Browse the repository at this point in the history
Adds a status check and an endpoint for querying current jobs to the
prover agent:

```
$ curl -XPOST -d'{"method": "prover_getCurrentJobs"}' http://localhost:8085/
{"result":[{"id":"ab3f1629","type":"ROOT_PARITY"}]}
```
  • Loading branch information
spalladino authored Aug 28, 2024
1 parent 5e9749f commit 7b3006a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
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;
}

0 comments on commit 7b3006a

Please sign in to comment.