Skip to content

Commit

Permalink
feat: Epoch orchestrator
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed Sep 18, 2024
1 parent a098d41 commit 59cd9bb
Show file tree
Hide file tree
Showing 122 changed files with 3,207 additions and 104 deletions.
3 changes: 3 additions & 0 deletions yarn-project/accounts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
"parser": {
"syntax": "typescript",
"decorators": true
},
"transform": {
"decoratorVersion": "2022-03"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/archiver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
"parser": {
"syntax": "typescript",
"decorators": true
},
"transform": {
"decoratorVersion": "2022-03"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/aztec-faucet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
"parser": {
"syntax": "typescript",
"decorators": true
},
"transform": {
"decoratorVersion": "2022-03"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/aztec-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
"parser": {
"syntax": "typescript",
"decorators": true
},
"transform": {
"decoratorVersion": "2022-03"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/aztec-node/src/aztec-node/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,14 @@ describe('aztec node', () => {
maxBlockNumber: new MaxBlockNumber(true, new Fr(1)),
getSize: () => 1,
toBuffer: () => Fr.ZERO.toBuffer(),
equals: () => true,
};

validMaxBlockNumberMetadata.data.forRollup!.rollupValidationRequests = {
maxBlockNumber: new MaxBlockNumber(true, new Fr(5)),
getSize: () => 1,
toBuffer: () => Fr.ZERO.toBuffer(),
equals: () => true,
};

lastBlockNumber = 3;
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/aztec.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
"parser": {
"syntax": "typescript",
"decorators": true
},
"transform": {
"decoratorVersion": "2022-03"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/aztec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@
"parser": {
"syntax": "typescript",
"decorators": true
},
"transform": {
"decoratorVersion": "2022-03"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/bb-prover/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"parser": {
"syntax": "typescript",
"decorators": true
},
"transform": {
"decoratorVersion": "2022-03"
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions yarn-project/bb-prover/src/prover/bb_prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
type PublicKernelNonTailRequest,
type PublicKernelTailRequest,
type ServerCircuitProver,
TubeProofAndVK,
makePublicInputsAndRecursiveProof,
} from '@aztec/circuit-types';
import { type CircuitProvingStats, type CircuitWitnessGenerationStats } from '@aztec/circuit-types/stats';
Expand Down Expand Up @@ -662,9 +663,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
return await this.runInDirectory(operation);
}

public async getTubeProof(
input: TubeInputs,
): Promise<{ tubeVK: VerificationKeyData; tubeProof: RecursiveProof<typeof TUBE_PROOF_LENGTH> }> {
public async getTubeProof(input: TubeInputs): Promise<TubeProofAndVK> {
// this probably is gonna need to call client ivc
const operation = async (bbWorkingDirectory: string) => {
logger.debug(`createTubeProof: ${bbWorkingDirectory}`);
Expand All @@ -688,7 +687,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
} fields`,
);

return { tubeVK, tubeProof };
return { verificationKey: tubeVK, proof: tubeProof, type: 'tube-proof' };
};
return await this.runInDirectory(operation);
}
Expand Down
9 changes: 4 additions & 5 deletions yarn-project/bb-prover/src/test/test_circuit_prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
type PublicKernelNonTailRequest,
type PublicKernelTailRequest,
type ServerCircuitProver,
TubeProofAndVK,
makePublicInputsAndRecursiveProof,
} from '@aztec/circuit-types';
import {
Expand Down Expand Up @@ -261,13 +262,11 @@ export class TestCircuitProver implements ServerCircuitProver {
);
}

public async getTubeProof(
_tubeInput: TubeInputs,
): Promise<{ tubeVK: VerificationKeyData; tubeProof: RecursiveProof<typeof TUBE_PROOF_LENGTH> }> {
public async getTubeProof(_tubeInput: TubeInputs): Promise<TubeProofAndVK> {
await this.delay();
return {
tubeVK: VerificationKeyData.makeFake(),
tubeProof: makeEmptyRecursiveProof(TUBE_PROOF_LENGTH),
verificationKey: VerificationKeyData.makeFake(),
proof: makeEmptyRecursiveProof(TUBE_PROOF_LENGTH),
};
}

Expand Down
3 changes: 3 additions & 0 deletions yarn-project/bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"parser": {
"syntax": "typescript",
"decorators": true
},
"transform": {
"decoratorVersion": "2022-03"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"parser": {
"syntax": "typescript",
"decorators": true
},
"transform": {
"decoratorVersion": "2022-03"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/circuit-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"parser": {
"syntax": "typescript",
"decorators": true
},
"transform": {
"decoratorVersion": "2022-03"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createDebugLogger } from '@aztec/foundation/log';
import { type IndexedTreeLeafPreimage } from '@aztec/foundation/trees';

import { type L2Block } from '../l2_block.js';
import { type MerkleTreeId } from '../merkle_tree_id.js';
import { type MerkleTreeId, type TreeHeights } from '../merkle_tree_id.js';
import { type SiblingPath } from '../sibling_path/sibling_path.js';

/**
Expand Down Expand Up @@ -198,11 +198,11 @@ export interface MerkleTreeOperations {
* @param subtreeHeight - Height of the subtree.
* @returns The witness data for the leaves to be updated when inserting the new ones.
*/
batchInsert<TreeHeight extends number, SubtreeSiblingPathHeight extends number, ID extends IndexedTreeId>(
batchInsert<SubtreeSiblingPathHeight extends number, ID extends IndexedTreeId>(
treeId: ID,
leaves: Buffer[],
subtreeHeight: number,
): Promise<BatchInsertionResult<TreeHeight, SubtreeSiblingPathHeight>>;
): Promise<BatchInsertionResult<TreeHeights[ID], SubtreeSiblingPathHeight>>;
}

/** Operations on merkle trees world state that can modify the underlying store. */
Expand Down
43 changes: 35 additions & 8 deletions yarn-project/circuit-types/src/interfaces/proving-job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
type KernelCircuitPublicInputs,
type MergeRollupInputs,
type NESTED_RECURSIVE_PROOF_LENGTH,
type ParityPublicInputs,
type PrivateKernelEmptyInputData,
type Proof,
type PublicKernelCircuitPublicInputs,
Expand All @@ -26,21 +27,25 @@ import {

import type { PublicKernelNonTailRequest, PublicKernelTailRequest } from '../tx/processed_tx.js';

type PublicInputs<T> = { inputs: T };

export type AvmProofAndVerificationKey = {
proof: Proof;
verificationKey: AvmVerificationKeyData;
};

export type PublicInputsAndRecursiveProof<T> = {
inputs: T;
export type PublicInputsAndRecursiveProof<T> = PublicInputs<T> & NestedRecursiveProofAndVK;

export type PublicInputsAndTubeProof<T> = PublicInputs<T> & TubeProofAndVK;

export type NestedRecursiveProofAndVK = {
proof: RecursiveProof<typeof NESTED_RECURSIVE_PROOF_LENGTH>;
verificationKey: VerificationKeyData;
};

export type PublicInputsAndTubeProof<T> = {
inputs: T;
proof: RecursiveProof<typeof TUBE_PROOF_LENGTH>;
export type TubeProofAndVK = {
verificationKey: VerificationKeyData;
proof: RecursiveProof<typeof TUBE_PROOF_LENGTH>;
};

export function makePublicInputsAndRecursiveProof<T>(
Expand Down Expand Up @@ -76,7 +81,8 @@ export enum ProvingRequestType {

BASE_PARITY,
ROOT_PARITY,
// Recursive Client IVC verification to connect private -> public or rollup

/** Recursive Client IVC verification to connect private to public or rollup */
TUBE_PROOF,
}

Expand Down Expand Up @@ -132,6 +138,25 @@ export type ProvingRequest =
inputs: TubeInputs;
};

export type SimulationRequestPublicInputs = {
[ProvingRequestType.PRIVATE_KERNEL_EMPTY]: KernelCircuitPublicInputs;
[ProvingRequestType.PUBLIC_VM]: null;

[ProvingRequestType.PUBLIC_KERNEL_NON_TAIL]: PublicKernelCircuitPublicInputs;
[ProvingRequestType.PUBLIC_KERNEL_TAIL]: KernelCircuitPublicInputs;

[ProvingRequestType.BASE_ROLLUP]: BaseOrMergeRollupPublicInputs;
[ProvingRequestType.MERGE_ROLLUP]: BaseOrMergeRollupPublicInputs;
[ProvingRequestType.BLOCK_ROOT_ROLLUP]: BlockRootOrBlockMergePublicInputs;
[ProvingRequestType.BLOCK_MERGE_ROLLUP]: BlockRootOrBlockMergePublicInputs;
[ProvingRequestType.ROOT_ROLLUP]: RootRollupPublicInputs;

[ProvingRequestType.BASE_PARITY]: ParityPublicInputs;
[ProvingRequestType.ROOT_PARITY]: ParityPublicInputs;

[ProvingRequestType.TUBE_PROOF]: null;
};

export type ProvingRequestPublicInputs = {
[ProvingRequestType.PRIVATE_KERNEL_EMPTY]: PublicInputsAndRecursiveProof<KernelCircuitPublicInputs>;
[ProvingRequestType.PUBLIC_VM]: AvmProofAndVerificationKey;
Expand All @@ -147,10 +172,12 @@ export type ProvingRequestPublicInputs = {

[ProvingRequestType.BASE_PARITY]: RootParityInput<typeof RECURSIVE_PROOF_LENGTH>;
[ProvingRequestType.ROOT_PARITY]: RootParityInput<typeof NESTED_RECURSIVE_PROOF_LENGTH>;
// TODO(#7369) properly structure tube proof flow
[ProvingRequestType.TUBE_PROOF]: { tubeVK: VerificationKeyData; tubeProof: RecursiveProof<typeof TUBE_PROOF_LENGTH> };

[ProvingRequestType.TUBE_PROOF]: TubeProofAndVK;
};

export type SimulationRequestResult<T extends ProvingRequestType> = SimulationRequestPublicInputs[T];

export type ProvingRequestResult<T extends ProvingRequestType> = ProvingRequestPublicInputs[T];

export interface ProvingJobSource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
type PublicInputsAndTubeProof,
type PublicKernelNonTailRequest,
type PublicKernelTailRequest,
type TubeProofAndVK,
type Tx,
} from '@aztec/circuit-types';
import {
Expand All @@ -20,13 +21,11 @@ import {
type PrivateKernelEmptyInputData,
type PublicKernelCircuitPublicInputs,
type RECURSIVE_PROOF_LENGTH,
type RecursiveProof,
type RootParityInput,
type RootParityInputs,
type RootRollupInputs,
type RootRollupPublicInputs,
type TubeInputs,
type VerificationKeyData,
} from '@aztec/circuits.js';

/**
Expand Down Expand Up @@ -67,11 +66,7 @@ export interface ServerCircuitProver {
* Get a recursively verified client IVC proof (making it a compatible honk proof for the rest of the rollup).
* @param input - Input to the circuit.
*/
getTubeProof(
tubeInput: TubeInputs,
signal?: AbortSignal,
epochNumber?: number,
): Promise<{ tubeVK: VerificationKeyData; tubeProof: RecursiveProof<typeof RECURSIVE_PROOF_LENGTH> }>;
getTubeProof(tubeInput: TubeInputs, signal?: AbortSignal, epochNumber?: number): Promise<TubeProofAndVK>;

/**
* Creates a proof for the given input.
Expand Down
19 changes: 19 additions & 0 deletions yarn-project/circuit-types/src/merkle_tree_id.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import {
ARCHIVE_HEIGHT,
ARCHIVE_TREE_ID,
L1_TO_L2_MESSAGE_TREE_ID,
L1_TO_L2_MSG_TREE_HEIGHT,
NOTE_HASH_TREE_HEIGHT,
NOTE_HASH_TREE_ID,
NULLIFIER_TREE_HEIGHT,
NULLIFIER_TREE_ID,
PUBLIC_DATA_TREE_HEIGHT,
PUBLIC_DATA_TREE_ID,
} from '@aztec/circuits.js';

Expand All @@ -21,3 +26,17 @@ export enum MerkleTreeId {
export const merkleTreeIds = () => {
return Object.values(MerkleTreeId).filter((v): v is MerkleTreeId => !isNaN(Number(v)));
};

const TREE_HEIGHTS = {
[MerkleTreeId.NOTE_HASH_TREE]: NOTE_HASH_TREE_HEIGHT,
[MerkleTreeId.ARCHIVE]: ARCHIVE_HEIGHT,
[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: L1_TO_L2_MSG_TREE_HEIGHT,
[MerkleTreeId.NULLIFIER_TREE]: NULLIFIER_TREE_HEIGHT,
[MerkleTreeId.PUBLIC_DATA_TREE]: PUBLIC_DATA_TREE_HEIGHT,
} as const;

export type TreeHeights = typeof TREE_HEIGHTS;

export function getTreeHeight<TID extends MerkleTreeId>(treeId: TID): TreeHeights[TID] {
return TREE_HEIGHTS[treeId];
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class SiblingPath<N extends number> {
* Returns the path buffer underlying the sibling path.
* @returns The Buffer array representation of this object.
*/
public toBufferArray(): Buffer[] {
public toBufferArray(): Tuple<Buffer, N> {
return this.data;
}

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuit-types/src/tx/processed_tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export type AvmProvingRequest = {
kernelRequest: PublicKernelNonTailRequest;
};

export type PublicProvingRequest = AvmProvingRequest | PublicKernelRequest;
export type PublicProvingRequest = AvmProvingRequest | PublicKernelTailRequest;

/**
* Represents a tx that has been processed by the sequencer public processor,
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/circuits.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
"parser": {
"syntax": "typescript",
"decorators": true
},
"transform": {
"decoratorVersion": "2022-03"
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions yarn-project/circuits.js/src/structs/content_commitment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ export class ContentCommitment {
return serialized;
}

equals(other: ContentCommitment): boolean {
return (
this.numTxs.equals(other.numTxs) &&
this.txsEffectsHash.equals(other.txsEffectsHash) &&
this.inHash.equals(other.inHash) &&
this.outHash.equals(other.outHash)
);
}

static fromBuffer(buffer: Buffer | BufferReader): ContentCommitment {
const reader = BufferReader.asReader(buffer);

Expand Down
Loading

0 comments on commit 59cd9bb

Please sign in to comment.