Skip to content
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: 4 additions & 1 deletion yarn-project/aztec/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export function injectAztecCommands(program: Command, userLog: LogFn, debugLogge
if (options.node) {
const { startNode } = await import('./cmds/start_node.js');
services = await startNode(options, signalHandlers, userLog);
} else if (options.proofVerifier) {
const { startProofVerifier } = await import('./cmds/start_proof_verifier.js');
services = await startProofVerifier(options, signalHandlers, userLog);
} else if (options.bot) {
const { startBot } = await import('./cmds/start_bot.js');
services = await startBot(options, signalHandlers, userLog);
Expand All @@ -101,7 +104,7 @@ export function injectAztecCommands(program: Command, userLog: LogFn, debugLogge
userLog(`Cannot run a standalone sequencer without a node`);
process.exit(1);
} else {
userLog(`No module specified to start ${JSON.stringify(options, null, 2)}`);
userLog(`No module specified to start`);
process.exit(1);
}
}
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec/terraform/proof-verifier/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ variable "ROLLUP_CONTRACT_ADDRESS" {

variable "PROOF_VERIFIER_POLL_INTERVAL_MS" {
type = "number"
default = 10000
default = 60000
}
7 changes: 3 additions & 4 deletions yarn-project/proof-verifier/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type ProofVerifierConfig = {
/** The L1 chain ID */
l1ChainId: number;
/** Start block number */
l1StartBlock: bigint;
l1StartBlock: number;
/** The address of the Rollup contract */
rollupAddress: EthAddress;
/** How often to poll L1 for proof submission */
Expand All @@ -40,9 +40,8 @@ export const proofVerifierConfigMappings: ConfigMappingsType<ProofVerifierConfig
},
l1StartBlock: {
env: 'PROOF_VERIFIER_L1_START_BLOCK',
parseEnv: (val: string) => BigInt(val),
description: 'Start block number',
defaultValue: 1n,
...numberConfigHelper(1),
},
rollupAddress: {
env: 'ROLLUP_CONTRACT_ADDRESS',
Expand All @@ -52,7 +51,7 @@ export const proofVerifierConfigMappings: ConfigMappingsType<ProofVerifierConfig
pollIntervalMs: {
env: 'PROOF_VERIFIER_POLL_INTERVAL_MS',
description: 'How often to poll L1 for proof submission',
...numberConfigHelper(10_000),
...numberConfigHelper(60_000),
},
bbBinaryPath: {
env: 'BB_BINARY_PATH',
Expand Down
40 changes: 34 additions & 6 deletions yarn-project/proof-verifier/src/proof_verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { type PublicClient, createPublicClient, http } from 'viem';

import { type ProofVerifierConfig } from './config.js';

const EXPECTED_PROOF_SIZE = 13988;

export class ProofVerifier {
private runningPromise: RunningPromise;
private synchedToL1Block = 0n;
Expand All @@ -27,7 +29,7 @@ export class ProofVerifier {
valueType: ValueType.INT,
description: 'The number of proofs verified by the block verifier bot',
});
this.synchedToL1Block = config.l1StartBlock - 1n;
this.synchedToL1Block = BigInt(config.l1StartBlock - 1);
}

static async new(config: ProofVerifierConfig, telemetryClient: TelemetryClient): Promise<ProofVerifier> {
Expand All @@ -42,6 +44,7 @@ export class ProofVerifier {
}

start() {
this.logger.info(`Starting proof verifier monitoring rollup=${this.config.rollupAddress}`);
this.runningPromise.start();
}

Expand All @@ -58,24 +61,49 @@ export class ProofVerifier {
startBlock,
);

if (retrievedData.length === 0) {
this.logger.debug(`No proofs found since L1 block ${startBlock}`);
return;
} else {
this.logger.debug(`Fetched ${retrievedData.length} proofs since L1 block ${startBlock}`);
}

for (const { l2BlockNumber, txHash, proof, proverId } of retrievedData) {
this.logger.debug(
`Proof size ${proof.buffer.length} for L2 block proverId=${proverId} l2Block=${l2BlockNumber} l1Tx=${txHash}`,
);

const invalidProofFormat = proof.buffer.length < EXPECTED_PROOF_SIZE;
if (invalidProofFormat) {
this.logger.warn(
`Invalid proof format detected: proof length=${proof.buffer.length}bytes proverId=${proverId} l2Block=${l2BlockNumber} l1Tx=${txHash}`,
);
}

try {
await this.verifier.verifyProofForCircuit('RootRollupArtifact', proof);
this.logger.info(`Verified proof for L2 block proverId=${proverId} l2Block=${l2BlockNumber} l1Tx=${txHash}`);

this.proofVerified.add(1, {
[Attributes.ROLLUP_PROVER_ID]: proverId.toString(),
[Attributes.OK]: true,
[Attributes.STATUS]: 'valid',
});
} catch (err) {
this.logger.warn(
`Failed to verify proof for L2 block proverId=${proverId} l2Block=${l2BlockNumber} l1Tx=${txHash}`,
);

this.proofVerified.add(1, {
[Attributes.ROLLUP_PROVER_ID]: proverId.toString(),
[Attributes.OK]: false,
});
if (invalidProofFormat) {
this.proofVerified.add(1, {
[Attributes.ROLLUP_PROVER_ID]: proverId.toString(),
[Attributes.STATUS]: 'invalid_proof_format',
});
} else {
this.proofVerified.add(1, {
[Attributes.ROLLUP_PROVER_ID]: proverId.toString(),
[Attributes.STATUS]: 'invalid',
});
}
}
}

Expand Down