Skip to content
Open
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
10 changes: 6 additions & 4 deletions yarn-project/aztec-node/src/aztec-node/server.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { TestCircuitVerifier } from '@aztec/bb-prover';
import { EpochCache } from '@aztec/epoch-cache';
import type { RollupContract } from '@aztec/ethereum/contracts';
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
Expand Down Expand Up @@ -198,7 +197,8 @@ describe('aztec node', () => {
globalVariablesBuilder,
epochCache,
getPackageVersion() ?? '',
new TestCircuitVerifier(),
undefined,
undefined,
);
});

Expand Down Expand Up @@ -715,7 +715,8 @@ describe('aztec node', () => {
globalVariablesBuilder,
epochCache,
getPackageVersion() ?? '',
new TestCircuitVerifier(),
undefined,
undefined,
undefined,
undefined,
undefined,
Expand Down Expand Up @@ -903,7 +904,8 @@ describe('aztec node', () => {
globalVariablesBuilder,
epochCache,
getPackageVersion() ?? '',
new TestCircuitVerifier(),
undefined,
undefined,
undefined,
undefined,
undefined,
Expand Down
72 changes: 35 additions & 37 deletions yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Archiver, createArchiver } from '@aztec/archiver';
import { BBCircuitVerifier, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
import { BBCircuitVerifier, BatchChonkVerifier, QueuedIVCVerifier } from '@aztec/bb-prover';
import { TestCircuitVerifier } from '@aztec/bb-prover/test';
import { type BlobClientInterface, createBlobClientWithFileStores } from '@aztec/blob-client/client';
import { Blob } from '@aztec/blob-lib';
import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
Expand Down Expand Up @@ -150,7 +151,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
protected readonly globalVariableBuilder: GlobalVariableBuilderInterface,
protected readonly epochCache: EpochCacheInterface,
protected readonly packageVersion: string,
private proofVerifier: ClientProtocolCircuitVerifier,
private peerChonkVerifier: ClientProtocolCircuitVerifier | undefined,
private rpcChonkVerifier: ClientProtocolCircuitVerifier | undefined,
private telemetry: TelemetryClient = getTelemetryClient(),
private log = createLogger('node'),
private blobClient?: BlobClientInterface,
Expand All @@ -172,6 +174,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
}
}

/** @internal Exposed for testing — returns the RPC proof verifier, if any. */
public getProofVerifier(): ClientProtocolCircuitVerifier | undefined {
return this.rpcChonkVerifier;
}

public async getWorldStateSyncStatus(): Promise<WorldStateSyncStatus> {
const status = await this.worldStateSynchronizer.status();
return status.syncSummary;
Expand Down Expand Up @@ -306,10 +313,17 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
options.prefilledPublicData,
telemetry,
);
const circuitVerifier =
config.realProofs || config.debugForceTxProofVerification
? await BBCircuitVerifier.new(config)
: new TestCircuitVerifier(config.proverTestVerificationDelayMs);
const useRealVerifiers = config.realProofs || config.debugForceTxProofVerification;
let peerChonkVerifier: ClientProtocolCircuitVerifier | undefined;
let rpcChonkVerifier: ClientProtocolCircuitVerifier | undefined;
if (useRealVerifiers) {
peerChonkVerifier = await BatchChonkVerifier.new(config, config.bbPeerVerifyBatchSize, 'peer');
const rpcVerifier = await BBCircuitVerifier.new(config);
rpcChonkVerifier = new QueuedIVCVerifier(rpcVerifier, config.bbRpcVerifyConcurrency);
} else {
peerChonkVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
rpcChonkVerifier = new TestCircuitVerifier(config.proverTestVerificationDelayMs);
}

let debugLogStore: DebugLogStore;
if (!config.realProofs) {
Expand All @@ -323,8 +337,6 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
debugLogStore = new NullDebugLogStore();
}

const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);

const proverOnly = config.enableProverNode && config.disableValidator;
if (proverOnly) {
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
Expand All @@ -334,7 +346,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
const p2pClient = await createP2PClient(
config,
archiver,
proofVerifier,
peerChonkVerifier,
worldStateSynchronizer,
epochCache,
packageVersion,
Expand Down Expand Up @@ -575,7 +587,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
globalVariableBuilder,
epochCache,
packageVersion,
proofVerifier,
peerChonkVerifier,
rpcChonkVerifier,
telemetry,
log,
blobClient,
Expand Down Expand Up @@ -922,7 +935,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
await tryStop(this.validatorsSentinel);
await tryStop(this.epochPruneWatcher);
await tryStop(this.slasherClient);
await tryStop(this.proofVerifier);
await Promise.all([tryStop(this.peerChonkVerifier), tryStop(this.rpcChonkVerifier)]);
await tryStop(this.sequencer);
await tryStop(this.proverNode);
await tryStop(this.p2pClient);
Expand Down Expand Up @@ -1046,11 +1059,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
referenceBlock: BlockParameter,
blockHash: BlockHash,
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
// The Noir circuit checks the archive membership proof against `anchor_block_header.last_archive.root`,
// which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
// So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
const committedDb = await this.getWorldState(referenceBlock);
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [blockHash]);
return pathAndIndex === undefined
? undefined
Expand Down Expand Up @@ -1312,7 +1321,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
{ isSimulation, skipFeeEnforcement }: { isSimulation?: boolean; skipFeeEnforcement?: boolean } = {},
): Promise<TxValidationResult> {
const db = this.worldStateSynchronizer.getCommitted();
const verifier = isSimulation ? undefined : this.proofVerifier;
const verifier = isSimulation ? undefined : this.rpcChonkVerifier;

// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
Expand Down Expand Up @@ -1361,7 +1370,15 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
archiver.updateConfig(config);
}
if (newConfig.realProofs !== this.config.realProofs) {
this.proofVerifier = config.realProofs ? await BBCircuitVerifier.new(newConfig) : new TestCircuitVerifier();
await Promise.all([tryStop(this.peerChonkVerifier), tryStop(this.rpcChonkVerifier)]);
if (newConfig.realProofs) {
this.peerChonkVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbPeerVerifyBatchSize, 'peer');
const rpcVerifier = await BBCircuitVerifier.new(newConfig);
this.rpcChonkVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.bbRpcVerifyConcurrency);
} else {
this.peerChonkVerifier = new TestCircuitVerifier();
this.rpcChonkVerifier = new TestCircuitVerifier();
}
}

this.config = newConfig;
Expand Down Expand Up @@ -1659,25 +1676,6 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
return snapshot;
}

/** Resolves a block parameter to a block number. */
protected async resolveBlockNumber(block: BlockParameter): Promise<BlockNumber> {
if (block === 'latest') {
return BlockNumber(await this.blockSource.getBlockNumber());
}
if (BlockHash.isBlockHash(block)) {
const initialBlockHash = await this.#getInitialHeaderHash();
if (block.equals(initialBlockHash)) {
return BlockNumber.ZERO;
}
const header = await this.blockSource.getBlockHeaderByHash(block);
if (!header) {
throw new Error(`Block hash ${block.toString()} not found.`);
}
return header.getBlockNumber();
}
return block as BlockNumber;
}

/**
* Ensure we fully sync the world state
* @returns A promise that fulfils once the world state is synced
Expand Down
1 change: 1 addition & 0 deletions yarn-project/bb-prover/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"@aztec/telemetry-client": "workspace:^",
"@aztec/world-state": "workspace:^",
"commander": "^12.1.0",
"msgpackr": "^1.11.2",
"pako": "^2.1.0",
"source-map-support": "^0.5.21",
"tslib": "^2.4.0"
Expand Down
5 changes: 4 additions & 1 deletion yarn-project/bb-prover/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ export interface BBConfig {
bbWorkingDirectory: string;
/** Whether to skip tmp dir cleanup for debugging purposes */
bbSkipCleanup: boolean;
numConcurrentIVCVerifiers: number;
bbIVCConcurrency: number;
/** Max concurrent verifications for the RPC verifier (QueuedIVCVerifier concurrency). Defaults to BB_NUM_IVC_VERIFIERS or 8. */
bbRpcVerifyConcurrency: number;
/** Max batch size for the peer chonk verifier (BatchChonkVerifier batch size). Defaults to BB_NUM_IVC_VERIFIERS or 8. */
bbPeerVerifyBatchSize: number;
}

export interface ACVMConfig {
Expand Down
Loading
Loading