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

feat: Reduce bundle sizes, remove polyfills #10877

Merged
merged 18 commits into from
Dec 20, 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
1 change: 0 additions & 1 deletion boxes/boxes/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"typescript-eslint": "^8.11.0",
"vite": "^6.0.3",
"vite-plugin-node-polyfills": "^0.22.0",
"vite-plugin-strip-block": "^1.0.1",
"vite-plugin-top-level-await": "^1.4.4"
}
}
2 changes: 0 additions & 2 deletions boxes/boxes/vite/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import { PolyfillOptions, nodePolyfills } from "vite-plugin-node-polyfills";
import topLevelAwait from "vite-plugin-top-level-await";
import stripBlock from "vite-plugin-strip-block";

// Unfortunate, but needed due to https://github.com/davidmyersdev/vite-plugin-node-polyfills/issues/81
// Suspected to be because of the yarn workspace setup, but not sure
Expand Down Expand Up @@ -31,7 +30,6 @@ export default defineConfig({
},
},
plugins: [
stripBlock({ start: "testing-only-start", end: "testing-only-end" }),
react(),
nodePolyfillsFix({ include: ["buffer", "process", "path"] }),
topLevelAwait(),
Expand Down
8 changes: 0 additions & 8 deletions boxes/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12043,13 +12043,6 @@ __metadata:
languageName: node
linkType: hard

"vite-plugin-strip-block@npm:^1.0.1":
version: 1.0.1
resolution: "vite-plugin-strip-block@npm:1.0.1"
checksum: 10c0/4302a035fbcaff8c5cfdffeedfd7c61d9b7198aeac1123cdadc00770db1d4828e7b780ce3a84106c786e771eb47c60289a694283c95702819f6f909c21bc3bbe
languageName: node
linkType: hard

"vite-plugin-top-level-await@npm:^1.4.4":
version: 1.4.4
resolution: "vite-plugin-top-level-await@npm:1.4.4"
Expand Down Expand Up @@ -12187,7 +12180,6 @@ __metadata:
typescript-eslint: "npm:^8.11.0"
vite: "npm:^6.0.3"
vite-plugin-node-polyfills: "npm:^0.22.0"
vite-plugin-strip-block: "npm:^1.0.1"
vite-plugin-top-level-await: "npm:^1.4.4"
languageName: unknown
linkType: soft
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/bb-prover/src/prover/bb_private_kernel_prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
convertPrivateKernelTailToPublicInputsToWitnessMap,
getPrivateKernelResetArtifactName,
} from '@aztec/noir-protocol-circuits-types';
import { WASMSimulator } from '@aztec/simulator';
import { WASMSimulatorWithBlobs } from '@aztec/simulator';
import { type NoirCompiledCircuit } from '@aztec/types/noir';

import { encode } from '@msgpack/msgpack';
Expand All @@ -53,7 +53,7 @@ import { readFromOutputDirectory } from './client_ivc_proof_utils.js';
* TODO(#7368): this class grew 'organically' aka it could use a look at its resposibilities
*/
export class BBNativePrivateKernelProver implements PrivateKernelProver {
private simulator = new WASMSimulator();
private simulator = new WASMSimulatorWithBlobs();

private verificationKeys: Map<ClientProtocolArtifact, Promise<VerificationKeyData>> = new Map<
ClientProtocolArtifact,
Expand Down
24 changes: 13 additions & 11 deletions yarn-project/bb-prover/src/prover/bb_prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,37 @@ import {
AGGREGATION_OBJECT_LENGTH,
AVM_PROOF_LENGTH_IN_FIELDS,
type AvmCircuitInputs,
type BaseOrMergeRollupPublicInputs,
type BaseParityInputs,
type BlockMergeRollupInputs,
type BlockRootOrBlockMergePublicInputs,
type BlockRootRollupInputs,
type EmptyBlockRootRollupInputs,
EmptyNestedCircuitInputs,
EmptyNestedData,
Fr,
type KernelCircuitPublicInputs,
type MergeRollupInputs,
NESTED_RECURSIVE_PROOF_LENGTH,
type ParityPublicInputs,
type PrivateBaseRollupInputs,
type PrivateKernelEmptyInputData,
PrivateKernelEmptyInputs,
Proof,
type PublicBaseRollupInputs,
RECURSIVE_PROOF_LENGTH,
RecursiveProof,
type RootParityInputs,
type RootRollupInputs,
type RootRollupPublicInputs,
TUBE_PROOF_LENGTH,
type TubeInputs,
type VerificationKeyAsFields,
type VerificationKeyData,
makeRecursiveProofFromBinary,
} from '@aztec/circuits.js';
import {
type BaseOrMergeRollupPublicInputs,
type BlockMergeRollupInputs,
type BlockRootOrBlockMergePublicInputs,
type BlockRootRollupInputs,
type EmptyBlockRootRollupInputs,
type MergeRollupInputs,
type PrivateBaseRollupInputs,
type PublicBaseRollupInputs,
type RootRollupInputs,
type RootRollupPublicInputs,
type TubeInputs,
} from '@aztec/circuits.js/rollup';
import { runInDirectory } from '@aztec/foundation/fs';
import { createLogger } from '@aztec/foundation/log';
import { BufferReader } from '@aztec/foundation/serialize';
Expand Down
28 changes: 15 additions & 13 deletions yarn-project/bb-prover/src/test/test_circuit_prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,34 @@ import {
AVM_PROOF_LENGTH_IN_FIELDS,
AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS,
type AvmCircuitInputs,
type BaseOrMergeRollupPublicInputs,
type BaseParityInputs,
type BlockMergeRollupInputs,
type BlockRootOrBlockMergePublicInputs,
type BlockRootRollupInputs,
type EmptyBlockRootRollupInputs,
EmptyNestedData,
type KernelCircuitPublicInputs,
type MergeRollupInputs,
NESTED_RECURSIVE_PROOF_LENGTH,
type ParityPublicInputs,
type PrivateBaseRollupInputs,
type PrivateKernelEmptyInputData,
PrivateKernelEmptyInputs,
type Proof,
type PublicBaseRollupInputs,
RECURSIVE_PROOF_LENGTH,
type RootParityInputs,
type RootRollupInputs,
type RootRollupPublicInputs,
TUBE_PROOF_LENGTH,
type TubeInputs,
VerificationKeyData,
makeEmptyRecursiveProof,
makeRecursiveProof,
} from '@aztec/circuits.js';
import {
type BaseOrMergeRollupPublicInputs,
type BlockMergeRollupInputs,
type BlockRootOrBlockMergePublicInputs,
type BlockRootRollupInputs,
type EmptyBlockRootRollupInputs,
type MergeRollupInputs,
type PrivateBaseRollupInputs,
type PublicBaseRollupInputs,
type RootRollupInputs,
type RootRollupPublicInputs,
type TubeInputs,
} from '@aztec/circuits.js/rollup';
import { createLogger } from '@aztec/foundation/log';
import { sleep } from '@aztec/foundation/sleep';
import { Timer } from '@aztec/foundation/timer';
Expand Down Expand Up @@ -63,7 +65,7 @@ import {
convertSimulatedPublicBaseRollupInputsToWitnessMap,
convertSimulatedPublicBaseRollupOutputsFromWitnessMap,
} from '@aztec/noir-protocol-circuits-types';
import { type SimulationProvider, WASMSimulator, emitCircuitSimulationStats } from '@aztec/simulator';
import { type SimulationProvider, WASMSimulatorWithBlobs, emitCircuitSimulationStats } from '@aztec/simulator';
import { type TelemetryClient, trackSpan } from '@aztec/telemetry-client';

import { type WitnessMap } from '@noir-lang/types';
Expand All @@ -76,7 +78,7 @@ import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
* Simulates circuits using the most efficient method and performs no proving.
*/
export class TestCircuitProver implements ServerCircuitProver {
private wasmSimulator = new WASMSimulator();
private wasmSimulator = new WASMSimulatorWithBlobs();
private instrumentation: ProverInstrumentation;
private logger = createLogger('bb-prover:test-prover');

Expand Down
3 changes: 2 additions & 1 deletion yarn-project/circuit-types/src/interfaces/epoch-prover.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type BlockHeader, type Fr, type Proof, type RootRollupPublicInputs } from '@aztec/circuits.js';
import { type BlockHeader, type Fr, type Proof } from '@aztec/circuits.js';
import { type RootRollupPublicInputs } from '@aztec/circuits.js/rollup';

import { type L2Block } from '../l2_block.js';
import { type BlockBuilder } from './block-builder.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
BaseOrMergeRollupPublicInputs,
NESTED_RECURSIVE_PROOF_LENGTH,
VerificationKeyData,
makeRecursiveProof,
} from '@aztec/circuits.js';
import { NESTED_RECURSIVE_PROOF_LENGTH, VerificationKeyData, makeRecursiveProof } from '@aztec/circuits.js';
import { BaseOrMergeRollupPublicInputs } from '@aztec/circuits.js/rollup';
import { type JsonRpcTestContext, createJsonRpcTestSetup } from '@aztec/foundation/json-rpc/test';

import { type ProvingJobSource, ProvingJobSourceSchema } from './proving-job-source.js';
Expand Down
24 changes: 13 additions & 11 deletions yarn-project/circuit-types/src/interfaces/proving-job.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import {
AVM_PROOF_LENGTH_IN_FIELDS,
AvmCircuitInputs,
BaseOrMergeRollupPublicInputs,
BaseParityInputs,
BlockMergeRollupInputs,
BlockRootOrBlockMergePublicInputs,
BlockRootRollupInputs,
EmptyBlockRootRollupInputs,
KernelCircuitPublicInputs,
MergeRollupInputs,
NESTED_RECURSIVE_PROOF_LENGTH,
ParityPublicInputs,
PrivateBaseRollupInputs,
PrivateKernelEmptyInputData,
PublicBaseRollupInputs,
RECURSIVE_PROOF_LENGTH,
RecursiveProof,
RootParityInputs,
RootRollupInputs,
RootRollupPublicInputs,
TUBE_PROOF_LENGTH,
TubeInputs,
VerificationKeyData,
} from '@aztec/circuits.js';
import {
BaseOrMergeRollupPublicInputs,
BlockMergeRollupInputs,
BlockRootOrBlockMergePublicInputs,
BlockRootRollupInputs,
EmptyBlockRootRollupInputs,
MergeRollupInputs,
PrivateBaseRollupInputs,
PublicBaseRollupInputs,
RootRollupInputs,
RootRollupPublicInputs,
TubeInputs,
} from '@aztec/circuits.js/rollup';
import { type ZodFor } from '@aztec/foundation/schemas';

import { z } from 'zod';
Expand Down
20 changes: 11 additions & 9 deletions yarn-project/circuit-types/src/interfaces/server_circuit_prover.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
import {
type AVM_PROOF_LENGTH_IN_FIELDS,
type AvmCircuitInputs,
type BaseOrMergeRollupPublicInputs,
type BaseParityInputs,
type KernelCircuitPublicInputs,
type NESTED_RECURSIVE_PROOF_LENGTH,
type ParityPublicInputs,
type PrivateKernelEmptyInputData,
type RECURSIVE_PROOF_LENGTH,
type RootParityInputs,
type TUBE_PROOF_LENGTH,
} from '@aztec/circuits.js';
import {
type BaseOrMergeRollupPublicInputs,
type BlockMergeRollupInputs,
type BlockRootOrBlockMergePublicInputs,
type BlockRootRollupInputs,
type EmptyBlockRootRollupInputs,
type KernelCircuitPublicInputs,
type MergeRollupInputs,
type NESTED_RECURSIVE_PROOF_LENGTH,
type ParityPublicInputs,
type PrivateBaseRollupInputs,
type PrivateKernelEmptyInputData,
type PublicBaseRollupInputs,
type RECURSIVE_PROOF_LENGTH,
type RootParityInputs,
type RootRollupInputs,
type RootRollupPublicInputs,
type TUBE_PROOF_LENGTH,
type TubeInputs,
} from '@aztec/circuits.js';
} from '@aztec/circuits.js/rollup';

import type { Tx } from '../tx/tx.js';
import { type ProofAndVerificationKey, type PublicInputsAndRecursiveProof } from './proving-job.js';
Expand Down
4 changes: 3 additions & 1 deletion yarn-project/circuits.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"./constants": "./dest/constants.js",
"./contract": "./dest/contract/index.js",
"./merkle": "./dest/merkle/index.js",
"./simulation": "./dest/simulator/index.js"
"./simulation": "./dest/simulator/index.js",
"./blobs": "./dest/structs/blobs/index.js",
"./rollup": "./dest/structs/rollup/index.js"
},
"typedocOptions": {
"entryPoints": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Blob } from '@aztec/foundation/blob';
import { randomInt } from '@aztec/foundation/crypto';

import { BLOBS_PER_BLOCK, BLOB_PUBLIC_INPUTS } from '../constants.gen.js';
import { makeBlobPublicInputs, makeBlockBlobPublicInputs } from '../tests/factories.js';
import { BLOBS_PER_BLOCK, BLOB_PUBLIC_INPUTS } from '../../constants.gen.js';
import { makeBlobPublicInputs, makeBlockBlobPublicInputs } from '../../tests/factories.js';
import { Fr } from '../index.js';
import { BlobPublicInputs, BlockBlobPublicInputs } from './blob_public_inputs.js';
import { Fr } from './index.js';

describe('BlobPublicInputs', () => {
let blobPI: BlobPublicInputs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Fr } from '@aztec/foundation/fields';
import { BufferReader, FieldReader, type Tuple, serializeToBuffer } from '@aztec/foundation/serialize';
import { type FieldsOf } from '@aztec/foundation/types';

import { BLOBS_PER_BLOCK } from '../constants.gen.js';
import { BLOBS_PER_BLOCK } from '../../constants.gen.js';

// The prefix to the EVM blobHash, defined here: https://eips.ethereum.org/EIPS/eip-4844#specification
// Also defined in yarn-project/foundation/src/blob/index.ts, which can't take in our circuits.js constants
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/circuits.js/src/structs/blobs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './blob_public_inputs.js';
export * from './sponge_blob.js';
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { poseidon2Hash } from '@aztec/foundation/crypto';
import { Fr } from '@aztec/foundation/fields';

import { SPONGE_BLOB_LENGTH } from '../constants.gen.js';
import { makeSpongeBlob } from '../tests/factories.js';
import { SPONGE_BLOB_LENGTH } from '../../constants.gen.js';
import { makeSpongeBlob } from '../../tests/factories.js';
import { SpongeBlob } from './sponge_blob.js';

describe('SpongeBlob', () => {
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/structs/block_header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { z } from 'zod';
import { BLOCK_HEADER_LENGTH, GeneratorIndex } from '../constants.gen.js';
import { ContentCommitment } from './content_commitment.js';
import { GlobalVariables } from './global_variables.js';
import { AppendOnlyTreeSnapshot } from './rollup/append_only_tree_snapshot.js';
import { StateReference } from './state_reference.js';
import { AppendOnlyTreeSnapshot } from './trees/append_only_tree_snapshot.js';

/** A header of an L2 block. */
export class BlockHeader {
Expand Down
21 changes: 0 additions & 21 deletions yarn-project/circuits.js/src/structs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export * from '@aztec/foundation/eth-address';
export * from './avm/avm.js';
export * from './avm/avm_accumulated_data.js';
export * from './avm/avm_circuit_public_inputs.js';
export * from './blob_public_inputs.js';
export * from './call_context.js';
export * from './client_ivc_proof.js';
export * from './complete_address.js';
Expand Down Expand Up @@ -69,28 +68,8 @@ export * from './read_request.js';
export * from './read_request_hints/index.js';
export * from './recursive_proof.js';
export * from './revert_code.js';
export * from './rollup/append_only_tree_snapshot.js';
export * from './rollup/avm_proof_data.js';
export * from './rollup/base_or_merge_rollup_public_inputs.js';
export * from './rollup/base_rollup_hints.js';
export * from './rollup/block_merge_rollup.js';
export * from './rollup/block_root_or_block_merge_public_inputs.js';
export * from './rollup/constant_rollup_data.js';
export * from './rollup/empty_block_root_rollup_inputs.js';
export * from './rollup/block_root_rollup.js';
export * from './rollup/merge_rollup.js';
export * from './rollup/previous_rollup_block_data.js';
export * from './rollup/previous_rollup_data.js';
export * from './rollup/private_base_rollup_inputs.js';
export * from './rollup/private_tube_data.js';
export * from './rollup/public_base_rollup_inputs.js';
export * from './rollup/public_tube_data.js';
export * from './rollup/root_rollup.js';
export * from './rollup/state_diff_hints.js';
export * from './rollup/tube_inputs.js';
export * from './rollup_validation_requests.js';
export * from './scoped_key_validation_request_and_generator.js';
export * from './sponge_blob.js';
export * from './shared.js';
export * from './state_reference.js';
export * from './tree_leaf_read_request.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/
import { z } from 'zod';

import { PARTIAL_STATE_REFERENCE_LENGTH } from '../constants.gen.js';
import { AppendOnlyTreeSnapshot } from './rollup/append_only_tree_snapshot.js';
import { AppendOnlyTreeSnapshot } from './trees/append_only_tree_snapshot.js';

/**
* Stores snapshots of trees which are commonly needed by base or merge rollup circuits.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { bufferSchemaFor } from '@aztec/foundation/schemas';
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';

import { SpongeBlob } from '../blobs/sponge_blob.js';
import { PartialStateReference } from '../partial_state_reference.js';
import { RollupTypes } from '../shared.js';
import { SpongeBlob } from '../sponge_blob.js';
import { ConstantRollupData } from './constant_rollup_data.js';

/**
Expand Down
Loading
Loading