Skip to content

Commit

Permalink
chore!: Sequencer no longer proves (#7860)
Browse files Browse the repository at this point in the history
Removes the code path where the sequencer would submit proofs for a
given block, so this reponsibility is now exclusive of the prover-node.
This allows us to remove the prover instance from the aztec node
altogether, and drop the `PROVER_DISABLED` and `SEQ_SKIP_SUBMIT_PROOFS`
env vars since are no longer needed.

Since the sequencer still needs to submit block roots as it is
publishing tx effects instead of tx objects, we keep using the
orchestrator as a means to assemble an L2Block using simulated circuits,
relying on a block simulator backed by the `TestCircuitProver`. We
should be able to remove this altogether once we migrate to tx objects.
  • Loading branch information
spalladino authored Aug 13, 2024
1 parent cd36be4 commit 7168290
Show file tree
Hide file tree
Showing 22 changed files with 151 additions and 178 deletions.
9 changes: 1 addition & 8 deletions yarn-project/aztec-node/src/aztec-node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ export type AztecNodeConfig = ArchiverConfig &
SequencerClientConfig &
ProverClientConfig &
WorldStateConfig &
Pick<ProverClientConfig, 'bbBinaryPath' | 'bbWorkingDirectory' | 'realProofs'> &
P2PConfig & {
/** Whether the sequencer is disabled for this node. */
disableSequencer: boolean;

/** Whether the prover is disabled for this node. */
disableProver: boolean;
};

export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
Expand All @@ -37,11 +35,6 @@ export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
description: 'Whether the sequencer is disabled for this node.',
...booleanConfigHelper(),
},
disableProver: {
env: 'PROVER_DISABLED',
description: 'Whether the prover is disabled for this node.',
...booleanConfigHelper(),
},
};

/**
Expand Down
17 changes: 0 additions & 17 deletions yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
LogType,
MerkleTreeId,
NullifierMembershipWitness,
type ProverClient,
type ProverConfig,
PublicDataWitness,
PublicSimulationOutput,
Expand Down Expand Up @@ -59,7 +58,6 @@ import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
import { getCanonicalInstanceDeployer } from '@aztec/protocol-contracts/instance-deployer';
import { getCanonicalKeyRegistryAddress } from '@aztec/protocol-contracts/key-registry';
import { getCanonicalMultiCallEntrypointAddress } from '@aztec/protocol-contracts/multi-call-entrypoint';
import { createProverClient } from '@aztec/prover-client';
import {
AggregateTxValidator,
DataTxValidator,
Expand Down Expand Up @@ -105,7 +103,6 @@ export class AztecNodeService implements AztecNode {
protected readonly version: number,
protected readonly globalVariableBuilder: GlobalVariableBuilder,
protected readonly merkleTreesDb: AztecKVStore,
private readonly prover: ProverClient | undefined,
private txValidator: TxValidator,
private telemetry: TelemetryClient,
private log = createDebugLogger('aztec:node'),
Expand Down Expand Up @@ -169,12 +166,6 @@ export class AztecNodeService implements AztecNode {

const simulationProvider = await createSimulationProvider(config, log);

const prover = await createProverClient(config, telemetry);

if (!prover && !config.disableSequencer) {
throw new Error("Can't start a sequencer without a prover");
}

// now create the sequencer
const sequencer = config.disableSequencer
? undefined
Expand All @@ -185,7 +176,6 @@ export class AztecNodeService implements AztecNode {
archiver,
archiver,
archiver,
prover!,
simulationProvider,
telemetry,
);
Expand All @@ -204,7 +194,6 @@ export class AztecNodeService implements AztecNode {
config.version,
getGlobalVariableBuilder(config),
store,
prover,
txValidator,
telemetry,
log,
Expand All @@ -219,10 +208,6 @@ export class AztecNodeService implements AztecNode {
return this.sequencer;
}

public getProver(): ProverClient | undefined {
return this.prover;
}

public getBlockSource(): L2BlockSource {
return this.blockSource;
}
Expand Down Expand Up @@ -381,7 +366,6 @@ export class AztecNodeService implements AztecNode {
await this.p2pClient.stop();
await this.worldStateSynchronizer.stop();
await this.blockSource.stop();
await this.prover?.stop();
this.log.info(`Stopped`);
}

Expand Down Expand Up @@ -771,7 +755,6 @@ export class AztecNodeService implements AztecNode {
public async setConfig(config: Partial<SequencerConfig & ProverConfig>): Promise<void> {
const newConfig = { ...this.config, ...config };
this.sequencer?.updateSequencerConfig(config);
await this.prover?.updateProverConfig(config);

if (newConfig.realProofs !== this.config.realProofs) {
const proofVerifier = config.realProofs ? await BBCircuitVerifier.new(newConfig) : new TestCircuitVerifier();
Expand Down
20 changes: 0 additions & 20 deletions yarn-project/aztec/src/cli/cmds/start_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { type PXE } from '@aztec/circuit-types';
import { NULL_KEY } from '@aztec/ethereum';
import { type ServerList } from '@aztec/foundation/json-rpc/server';
import { type LogFn } from '@aztec/foundation/log';
import { createProvingJobSourceServer } from '@aztec/prover-client/prover-agent';
import {
type TelemetryClientConfig,
createAndStartTelemetryClient,
Expand Down Expand Up @@ -33,9 +32,6 @@ export const startNode = async (
};

if (options.proverNode) {
// TODO(palla/prover-node) We need to tweak the semantics of disableProver so that it doesn't inject
// a null prover into the sequencer, but instead injects a circuit simulator, which is what the
// sequencer ultimately needs.
userLog(`Running a Prover Node within a Node is not yet supported`);
process.exit(1);
}
Expand Down Expand Up @@ -87,24 +83,13 @@ export const startNode = async (
}
}

if (!options.prover) {
userLog(`Prover is disabled, using mocked proofs`);
nodeConfig.disableProver = true;
}

if (nodeConfig.p2pEnabled) {
// ensure bootstrapNodes is an array
if (nodeConfig.bootstrapNodes && typeof nodeConfig.bootstrapNodes === 'string') {
nodeConfig.bootstrapNodes = (nodeConfig.bootstrapNodes as string).split(',');
}
}

if (!nodeConfig.disableSequencer && nodeConfig.disableProver) {
// TODO(palla/prover-node) Sequencer should not need a prover unless we are running the prover
// within it, it should just need a circuit simulator. We need to refactor the sequencer so it can accept either.
throw new Error('Cannot run a sequencer without a prover');
}

const telemetryConfig = extractRelevantOptions<TelemetryClientConfig>(options, telemetryClientConfigMappings);
const telemetryClient = createAndStartTelemetryClient(telemetryConfig);

Expand All @@ -115,11 +100,6 @@ export const startNode = async (
// Add node to services list
services.push({ node: nodeServer });

if (!nodeConfig.disableProver) {
const provingJobSource = createProvingJobSourceServer(node.getProver()!.getProvingJobSource());
services.push({ provingJobSource });
}

// Add node stop function to signal handlers
signalHandlers.push(node.stop);

Expand Down
4 changes: 2 additions & 2 deletions yarn-project/bb-prover/src/test/test_circuit_prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ import { SimulatedPublicKernelArtifactMapping } from '../mappings/mappings.js';
import { mapPublicKernelToCircuitName } from '../stats.js';

/**
* A class for use in testing situations (e2e, unit test etc)
* Simulates circuits using the most efficient method and performs no proving
* A class for use in testing situations (e2e, unit test, etc) and temporarily for assembling a block in the sequencer.
* Simulates circuits using the most efficient method and performs no proving.
*/
export class TestCircuitProver implements ServerCircuitProver {
private wasmSimulator = new WASMSimulator();
Expand Down
48 changes: 26 additions & 22 deletions yarn-project/circuit-types/src/interfaces/block-prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,52 @@ export type ProvingTicket = {
provingPromise: Promise<ProvingResult>;
};

export type BlockResult = {
export type SimulationBlockResult = {
block: L2Block;
};

export type ProvingBlockResult = SimulationBlockResult & {
proof: Proof;
aggregationObject: Fr[];
};

/**
* The interface to the block prover.
* Provides the ability to generate proofs and build rollups.
*/
export interface BlockProver {
/** Receives processed txs as part of block simulation or proving. */
export interface ProcessedTxHandler {
/**
* Cancels any block that is currently being built and prepares for a new one to be built
* Add a processed transaction to the current block.
* @param tx - The transaction to be added.
*/
addNewTx(tx: ProcessedTx): Promise<void>;
}

/** The interface to a block simulator. Generates an L2 block out of a set of processed txs by calling into the Aztec circuits. */
export interface BlockSimulator extends ProcessedTxHandler {
/**
* Prepares to build a new block.
* @param numTxs - The complete size of the block, must be a power of 2
* @param globalVariables - The global variables for this block
* @param l1ToL2Messages - The set of L1 to L2 messages to be included in this block
* @param emptyTx - An instance of an empty transaction to be used in this block
*/
startNewBlock(numTxs: number, globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<ProvingTicket>;

/**
* Add a processed transaction to the current block
* @param tx - The transaction to be added
*/
addNewTx(tx: ProcessedTx): Promise<void>;

/**
* Cancels the block currently being proven. Proofs already bring built may continue but further proofs should not be started.
*/
/** Cancels the block currently being processed. Processes already in progress built may continue but further proofs should not be started. */
cancelBlock(): void;

/**
* Performs the final archive tree insertion for this block and returns the L2Block and Proof instances
*/
finaliseBlock(): Promise<BlockResult>;
/** Performs the final archive tree insertion for this block and returns the L2Block. */
finaliseBlock(): Promise<SimulationBlockResult>;

/**
* Mark the block as having all the transactions it is going to contain.
* Will pad the block to it's complete size with empty transactions and prove all the way to the root rollup.
* Will pad the block to its complete size with empty transactions and prove all the way to the root rollup.
*/
setBlockCompleted(): Promise<void>;
}

/** The interface to a block prover. Generates a root rollup proof out of a set of processed txs by recursively proving Aztec circuits. */
export interface BlockProver extends BlockSimulator {
/** Returns an identifier for the prover or zero if not set. */
getProverId(): Fr;

/** Performs the final archive tree insertion for this block and returns the L2Block. */
finaliseBlock(): Promise<ProvingBlockResult>;
}
2 changes: 0 additions & 2 deletions yarn-project/circuit-types/src/interfaces/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,4 @@ export interface SequencerConfig {
maxBlockSizeInBytes?: number;
/** Whether to require every tx to have a fee payer */
enforceFees?: boolean;
/** Temporary flag to skip submitting proofs, so a prover-node takes care of it. */
sequencerSkipSubmitProofs?: boolean;
}
4 changes: 1 addition & 3 deletions yarn-project/end-to-end/src/e2e_prover_node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
} from '@aztec/aztec.js';
import { StatefulTestContract, TestContract } from '@aztec/noir-contracts.js';
import { createProverNode } from '@aztec/prover-node';
import { type SequencerClientConfig } from '@aztec/sequencer-client';

import { sendL1ToL2Message } from './fixtures/l1_to_l2_messaging.js';
import {
Expand Down Expand Up @@ -46,8 +45,7 @@ describe('e2e_prover_node', () => {

beforeAll(async () => {
logger = createDebugLogger('aztec:e2e_prover_node');
const config: Partial<SequencerClientConfig> = { sequencerSkipSubmitProofs: true };
snapshotManager = createSnapshotManager(`e2e_prover_node`, process.env.E2E_DATA_PATH, config);
snapshotManager = createSnapshotManager(`e2e_prover_node`, process.env.E2E_DATA_PATH);

const testContractOpts = { contractAddressSalt: Fr.ONE, universalDeploy: true };
await snapshotManager.snapshot(
Expand Down
5 changes: 0 additions & 5 deletions yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types';
import { getCanonicalAuthRegistry } from '@aztec/protocol-contracts/auth-registry';
import { FeeJuiceAddress, getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
import { getCanonicalKeyRegistry } from '@aztec/protocol-contracts/key-registry';
import { type ProverClient } from '@aztec/prover-client';
import { PXEService, type PXEServiceConfig, createPXEService, getPXEServiceConfig } from '@aztec/pxe';
import { type SequencerClient } from '@aztec/sequencer-client';
import { createAndStartTelemetryClient, getConfigEnvVars as getTelemetryConfig } from '@aztec/telemetry-client/start';
Expand Down Expand Up @@ -305,8 +304,6 @@ export type EndToEndContext = {
logger: DebugLogger;
/** The cheat codes. */
cheatCodes: CheatCodes;
/** Proving jobs */
prover: ProverClient | undefined;
/** Function to stop the started services. */
teardown: () => Promise<void>;
};
Expand Down Expand Up @@ -383,7 +380,6 @@ export async function setup(
config.l1PublishRetryIntervalMS = 100;
const aztecNode = await AztecNodeService.createAndSync(config, telemetry);
const sequencer = aztecNode.getSequencer();
const prover = aztecNode.getProver();

logger.verbose('Creating a pxe...');

Expand Down Expand Up @@ -438,7 +434,6 @@ export async function setup(
logger,
cheatCodes,
sequencer,
prover,
teardown,
};
}
Expand Down
3 changes: 2 additions & 1 deletion yarn-project/prover-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"type": "module",
"exports": {
".": "./dest/index.js",
"./prover-agent": "./dest/prover-agent/index.js"
"./prover-agent": "./dest/prover-agent/index.js",
"./orchestrator": "./dest/orchestrator/index.js"
},
"typedocOptions": {
"entryPoints": [
Expand Down
9 changes: 1 addition & 8 deletions yarn-project/prover-client/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type ProverConfig, proverConfigMappings } from '@aztec/circuit-types';
import { type ConfigMappingsType, booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';
import { type ConfigMappingsType, getConfigFromMappings } from '@aztec/foundation/config';

/**
* The prover configuration.
Expand All @@ -13,8 +13,6 @@ export type ProverClientConfig = ProverConfig & {
bbWorkingDirectory: string;
/** The path to the bb binary */
bbBinaryPath: string;
/** True to disable proving altogether. */
disableProver: boolean;
};

export const proverClientConfigMappings: ConfigMappingsType<ProverClientConfig> = {
Expand All @@ -34,11 +32,6 @@ export const proverClientConfigMappings: ConfigMappingsType<ProverClientConfig>
env: 'BB_BINARY_PATH',
description: 'The path to the bb binary',
},
disableProver: {
env: 'PROVER_DISABLED',
description: 'Whether to disable proving.',
...booleanConfigHelper(),
},
...proverConfigMappings,
};

Expand Down
1 change: 1 addition & 0 deletions yarn-project/prover-client/src/orchestrator/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ProvingOrchestrator } from './orchestrator.js';
4 changes: 2 additions & 2 deletions yarn-project/prover-client/src/orchestrator/orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {
import {
BlockProofError,
type BlockProver,
type BlockResult,
PROVING_STATUS,
type ProvingBlockResult,
type ProvingResult,
type ProvingTicket,
type PublicInputsAndRecursiveProof,
Expand Down Expand Up @@ -450,7 +450,7 @@ export class ProvingOrchestrator implements BlockProver {

this.provingState.block = l2Block;

const blockResult: BlockResult = {
const blockResult: ProvingBlockResult = {
proof: this.provingState.finalProof,
aggregationObject: this.provingState.finalAggregationObject,
block: l2Block,
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/prover-client/src/tx-prover/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import { type ProverClientConfig } from '../config.js';
import { TxProver } from './tx-prover.js';

export function createProverClient(config: ProverClientConfig, telemetry: TelemetryClient = new NoopTelemetryClient()) {
return config.disableProver ? undefined : TxProver.new(config, telemetry);
return TxProver.new(config, telemetry);
}
2 changes: 2 additions & 0 deletions yarn-project/sequencer-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
},
"dependencies": {
"@aztec/bb-prover": "workspace:^",
"@aztec/circuit-types": "workspace:^",
"@aztec/circuits.js": "workspace:^",
"@aztec/ethereum": "workspace:^",
Expand All @@ -34,6 +35,7 @@
"@aztec/noir-protocol-circuits-types": "workspace:^",
"@aztec/p2p": "workspace:^",
"@aztec/protocol-contracts": "workspace:^",
"@aztec/prover-client": "workspace:^",
"@aztec/simulator": "workspace:^",
"@aztec/telemetry-client": "workspace:^",
"@aztec/types": "workspace:^",
Expand Down
Loading

0 comments on commit 7168290

Please sign in to comment.