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

fix: Properly schedule the tube proof and don't prove it twice #7913

Merged
merged 3 commits into from
Aug 12, 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
15 changes: 2 additions & 13 deletions yarn-project/bb-prover/src/prover/bb_prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
type RootRollupInputs,
type RootRollupPublicInputs,
TUBE_PROOF_LENGTH,
TubeInputs,
type TubeInputs,
type VerificationKeyAsFields,
type VerificationKeyData,
makeRecursiveProofFromBinary,
Expand Down Expand Up @@ -226,16 +226,6 @@ export class BBNativeRollupProver implements ServerCircuitProver {
kernelRequest.inputs.previousKernel.vk,
);

// PUBLIC KERNEL: kernel request should be nonempty at start of public kernel proving but it is not
// TODO(#7369): We should properly enqueue the tube in the public kernel lifetime
if (!kernelRequest.inputs.previousKernel.clientIvcProof.isEmpty()) {
const { tubeVK, tubeProof } = await this.getTubeProof(
new TubeInputs(kernelRequest.inputs.previousKernel.clientIvcProof),
);
kernelRequest.inputs.previousKernel.vk = tubeVK;
kernelRequest.inputs.previousKernel.proof = tubeProof;
}

await this.verifyWithKey(
kernelRequest.inputs.previousKernel.vk,
kernelRequest.inputs.previousKernel.proof.binaryProof,
Expand Down Expand Up @@ -289,8 +279,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs>> {
// We may need to convert the recursive proof into fields format
logger.debug(`kernel Data proof: ${baseRollupInput.kernelData.proof}`);
logger.info(`in getBaseRollupProof`);
logger.info(`Number of public inputs in baseRollupInput: ${baseRollupInput.kernelData.vk.numPublicInputs}`);
logger.debug(`Number of public inputs in baseRollupInput: ${baseRollupInput.kernelData.vk.numPublicInputs}`);
baseRollupInput.kernelData.proof = await this.ensureValidProof(
baseRollupInput.kernelData.proof,
'BaseRollupArtifact',
Expand Down
3 changes: 2 additions & 1 deletion yarn-project/circuit-types/src/stats/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ export type CircuitName =
| 'public-kernel-tail'
| 'avm-circuit'
| 'empty-nested'
| 'private-kernel-empty';
| 'private-kernel-empty'
| 'tube-circuit';

/** Stats for circuit simulation. */
export type CircuitSimulationStats = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';

import { ClientIvcProof } from '../client_ivc_proof.js';
import { PublicCallData } from './public_call_data.js';
import { PublicKernelData } from './public_kernel_data.js';

Expand All @@ -13,8 +12,6 @@ export class PublicKernelCircuitPrivateInputs {
* Kernels are recursive and this is the data from the previous kernel.
*/
public readonly previousKernel: PublicKernelData,

public readonly clientIvcProof: ClientIvcProof,
/**
* Public calldata assembled from the execution result and proof.
*/
Expand All @@ -26,7 +23,7 @@ export class PublicKernelCircuitPrivateInputs {
* @returns - Buffer representation of the object.
*/
toBuffer() {
return serializeToBuffer(this.previousKernel, this.clientIvcProof, this.publicCall);
return serializeToBuffer(this.previousKernel, this.publicCall);
}

/**
Expand All @@ -45,9 +42,8 @@ export class PublicKernelCircuitPrivateInputs {
static fromBuffer(buffer: BufferReader | Buffer) {
const reader = BufferReader.asReader(buffer);
const previousKernel = reader.readObject(PublicKernelData);
const clientIvcProof = reader.readObject(ClientIvcProof);
const publicCall = reader.readObject(PublicCallData);
return new PublicKernelCircuitPrivateInputs(previousKernel, clientIvcProof, publicCall);
return new PublicKernelCircuitPrivateInputs(previousKernel, publicCall);
}

/**
Expand Down
7 changes: 1 addition & 6 deletions yarn-project/circuits.js/src/tests/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
BaseParityInputs,
BaseRollupInputs,
CallContext,
ClientIvcProof,
CombineHints,
CombinedAccumulatedData,
CombinedConstantData,
Expand Down Expand Up @@ -660,11 +659,7 @@ export function makePublicCallData(seed = 1, full = false): PublicCallData {
* @returns Public kernel inputs.
*/
export function makePublicKernelCircuitPrivateInputs(seed = 1): PublicKernelCircuitPrivateInputs {
return new PublicKernelCircuitPrivateInputs(
makePublicKernelData(seed),
ClientIvcProof.empty(),
makePublicCallData(seed + 0x1000),
);
return new PublicKernelCircuitPrivateInputs(makePublicKernelData(seed), makePublicCallData(seed + 0x1000));
}

export function makeCombineHints(seed = 1): CombineHints {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
type RootRollupPublicInputs,
StateDiffHints,
type StateReference,
type TUBE_PROOF_LENGTH,
VK_TREE_HEIGHT,
type VerificationKeyAsFields,
type VerificationKeyData,
Expand All @@ -61,7 +60,7 @@ export type TreeNames = BaseTreeNames | 'L1ToL2MessageTree' | 'Archive';
// Builds the base rollup inputs, updating the contract, nullifier, and data trees in the process
export async function buildBaseRollupInput(
tx: ProcessedTx,
proof: RecursiveProof<typeof TUBE_PROOF_LENGTH>,
proof: RecursiveProof<typeof NESTED_RECURSIVE_PROOF_LENGTH>,
globalVariables: GlobalVariables,
db: MerkleTreeOperations,
kernelVk: VerificationKeyData,
Expand Down
Loading
Loading