From b229420a6f85d9b3b30675a6d06f2dbb07be8f61 Mon Sep 17 00:00:00 2001 From: thunkar Date: Thu, 19 Dec 2024 11:07:07 +0000 Subject: [PATCH 01/14] wip --- .../noir-protocol-circuits/package.json | 3 +- .../noir-protocol-circuits/yarn.lock | 25 +++--------- yarn-project/end-to-end/package.json | 1 + .../end-to-end/src/e2e_prover/full.test.ts | 24 ++++++++--- .../foundation/src/testing/files/index.ts | 13 ------ .../noir-protocol-circuits-types/package.json | 3 +- .../src/execution/client.ts | 40 ++++--------------- .../src/execution/server.ts | 17 ++++---- .../src/scripts/cleanup_artifacts.ts | 19 +++++++++ yarn-project/protocol-contracts/package.json | 2 + .../src/scripts/cleanup_artifacts.ts | 19 +++++++++ yarn-project/yarn.lock | 2 +- 12 files changed, 87 insertions(+), 81 deletions(-) create mode 100644 yarn-project/noir-protocol-circuits-types/src/scripts/cleanup_artifacts.ts create mode 100644 yarn-project/protocol-contracts/src/scripts/cleanup_artifacts.ts diff --git a/noir-projects/noir-protocol-circuits/package.json b/noir-projects/noir-protocol-circuits/package.json index 2f5efb48850..9979306ee73 100644 --- a/noir-projects/noir-protocol-circuits/package.json +++ b/noir-projects/noir-protocol-circuits/package.json @@ -4,5 +4,6 @@ "main": "index.js", "dependencies": { "@iarna/toml": "^2.2.5" - } + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } diff --git a/noir-projects/noir-protocol-circuits/yarn.lock b/noir-projects/noir-protocol-circuits/yarn.lock index 54bdbaad9b2..f411a21e2d6 100644 --- a/noir-projects/noir-protocol-circuits/yarn.lock +++ b/noir-projects/noir-protocol-circuits/yarn.lock @@ -1,21 +1,8 @@ -# This file is generated by running "yarn install" inside your project. -# Manual changes might be lost - proceed with caution! +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 -__metadata: - version: 8 - cacheKey: 10c0 -"@iarna/toml@npm:^2.2.5": - version: 2.2.5 - resolution: "@iarna/toml@npm:2.2.5" - checksum: 10c0/d095381ad4554aca233b7cf5a91f243ef619e5e15efd3157bc640feac320545450d14b394aebbf6f02a2047437ced778ae598d5879a995441ab7b6c0b2c2f201 - languageName: node - linkType: hard - -"noir-protocol-circuits-generator@workspace:.": - version: 0.0.0-use.local - resolution: "noir-protocol-circuits-generator@workspace:." - dependencies: - "@iarna/toml": "npm:^2.2.5" - languageName: unknown - linkType: soft +"@iarna/toml@^2.2.5": + version "2.2.5" + resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.5.tgz#b32366c89b43c6f8cefbdefac778b9c828e3ba8c" + integrity sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg== diff --git a/yarn-project/end-to-end/package.json b/yarn-project/end-to-end/package.json index 4a96cb434a0..b84ebb2f27e 100644 --- a/yarn-project/end-to-end/package.json +++ b/yarn-project/end-to-end/package.json @@ -53,6 +53,7 @@ "@aztec/telemetry-client": "workspace:^", "@aztec/types": "workspace:^", "@aztec/world-state": "workspace:^", + "@iarna/toml": "^2.2.5", "@jest/globals": "^29.5.0", "@noble/curves": "^1.0.0", "@swc/core": "^1.4.11", diff --git a/yarn-project/end-to-end/src/e2e_prover/full.test.ts b/yarn-project/end-to-end/src/e2e_prover/full.test.ts index 8d9566d48ff..5dc3e6563a9 100644 --- a/yarn-project/end-to-end/src/e2e_prover/full.test.ts +++ b/yarn-project/end-to-end/src/e2e_prover/full.test.ts @@ -1,8 +1,9 @@ import { type AztecAddress, EthAddress, retryUntil } from '@aztec/aztec.js'; -import { isGenerateTestDataEnabled } from '@aztec/foundation/testing'; -import { switchGenerateProtocolCircuitTestData } from '@aztec/foundation/testing/files'; +import { getTestData, isGenerateTestDataEnabled } from '@aztec/foundation/testing'; +import { updateProtocolCircuitSampleInputs } from '@aztec/foundation/testing/files'; import { RewardDistributorAbi, RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts'; +import TOML from '@iarna/toml'; import '@jest/globals'; import { type Chain, type GetContractReturnType, type HttpTransport, type PublicClient, getContract } from 'viem'; @@ -164,8 +165,6 @@ describe('full_prover', () => { it('generates sample Prover.toml files if generate test data is on', async () => { if (!isGenerateTestDataEnabled() || realProofs) { return; - } else { - switchGenerateProtocolCircuitTestData(); } // Create the two transactions @@ -246,7 +245,22 @@ describe('full_prover', () => { // And wait for the first pair of txs to be proven logger.info(`Awaiting proof for the previous epoch`); await Promise.all(txs.map(tx => tx.wait({ timeout: 300, interval: 10, proven: true, provenTimeout: 1500 }))); - switchGenerateProtocolCircuitTestData(); + + [ + 'private-kernel-init', + 'private-kernel-inner', + 'private-kernel-tail', + 'private-kernel-tail-to-public', + 'private-kernel-reset', + 'rollup-base-private', + 'rollup-base-public', + 'rollup-merge', + 'rollup-block-root', + 'rollup-root', + ].map(circuitName => { + const inputs = getTestData(circuitName); + updateProtocolCircuitSampleInputs(circuitName, TOML.stringify(inputs as any)); + }); }); it('rejects txs with invalid proofs', async () => { diff --git a/yarn-project/foundation/src/testing/files/index.ts b/yarn-project/foundation/src/testing/files/index.ts index a610bc9b473..04ff3dbff30 100644 --- a/yarn-project/foundation/src/testing/files/index.ts +++ b/yarn-project/foundation/src/testing/files/index.ts @@ -5,16 +5,6 @@ import { createConsoleLogger } from '../../log/console.js'; import { fileURLToPath } from '../../url/index.js'; import { isGenerateTestDataEnabled } from '../test_data.js'; -let generateProtocolCircuitTestData = false; - -/** - * This is separate so Prover.tomls don't get edited everytime any test is run, - * Only full.test updates prover tomls, then switches this off. - */ -export function switchGenerateProtocolCircuitTestData() { - generateProtocolCircuitTestData = !generateProtocolCircuitTestData; -} - /** Writes the contents specified to the target file if test data generation is enabled. */ export function writeTestData(targetFileFromRepoRoot: string, contents: string | Buffer) { if (!isGenerateTestDataEnabled()) { @@ -56,9 +46,6 @@ export function updateInlineTestData(targetFileFromRepoRoot: string, itemName: s * To re-gen, run 'AZTEC_GENERATE_TEST_DATA=1 FAKE_PROOFS=1 yarn workspace @aztec/end-to-end test full.test' */ export function updateProtocolCircuitSampleInputs(circuitName: string, value: string) { - if (!isGenerateTestDataEnabled() || !generateProtocolCircuitTestData) { - return; - } const logger = createConsoleLogger('aztec:testing:test_data'); const targetFileFromRepoRoot = `noir-projects/noir-protocol-circuits/crates/${circuitName}/Prover.toml`; const targetFile = getPathToFile(targetFileFromRepoRoot); diff --git a/yarn-project/noir-protocol-circuits-types/package.json b/yarn-project/noir-protocol-circuits-types/package.json index c2d868456a8..42bdabeec8c 100644 --- a/yarn-project/noir-protocol-circuits-types/package.json +++ b/yarn-project/noir-protocol-circuits-types/package.json @@ -13,12 +13,14 @@ ], "scripts": { "build": "yarn clean && yarn generate && tsc -b", + "build:keep-debug-symbols": "yarn clean && yarn generate && tsc -b", "clean": "rm -rf ./dest .tsbuildinfo src/types artifacts", "formatting": "run -T prettier --check ./src && run -T eslint ./src", "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src", "formatting:fix:types": "NODE_OPTIONS='--max-old-space-size=8096' run -T eslint --fix ./src/types && run -T prettier -w ./src/types", "generate": "yarn generate:copy-artifacts && yarn generate:vk-hashes && yarn generate:noir-circuits && yarn generate:reset-data", "generate:copy-artifacts": "mkdir -p ./artifacts && cp -r ../../noir-projects/noir-protocol-circuits/target/* ./artifacts && node --no-warnings --loader ts-node/esm src/scripts/generate_declaration_files.ts ", + "generate:cleanup-artifacts": "node --no-warnings --loader ts-node/esm src/scripts/cleanup_artifacts.ts", "generate:vk-hashes": "node --no-warnings --loader ts-node/esm src/scripts/generate_vk_hashes.ts", "generate:noir-circuits": "node --no-warnings --loader ts-node/esm src/scripts/generate_ts_from_abi.ts && run -T prettier -w ./src/types", "generate:reset-data": "node --no-warnings --loader ts-node/esm src/scripts/generate_private_kernel_reset_data.ts && run -T prettier -w src/private_kernel_reset_data.ts", @@ -68,7 +70,6 @@ "@aztec/circuits.js": "workspace:^", "@aztec/foundation": "workspace:^", "@aztec/types": "workspace:^", - "@iarna/toml": "^2.2.5", "@noir-lang/acvm_js": "portal:../../noir/packages/acvm_js", "@noir-lang/noir_codegen": "portal:../../noir/packages/noir_codegen", "@noir-lang/noir_js": "file:../../noir/packages/noir_js", diff --git a/yarn-project/noir-protocol-circuits-types/src/execution/client.ts b/yarn-project/noir-protocol-circuits-types/src/execution/client.ts index cfa768c1742..b040a7db31f 100644 --- a/yarn-project/noir-protocol-circuits-types/src/execution/client.ts +++ b/yarn-project/noir-protocol-circuits-types/src/execution/client.ts @@ -8,6 +8,7 @@ import { type PrivateKernelTailCircuitPrivateInputs, type PrivateKernelTailCircuitPublicInputs, } from '@aztec/circuits.js'; +import { pushTestData } from '@aztec/foundation/testing'; import { type CompiledCircuit, type InputMap, Noir, type WitnessMap } from '@noir-lang/noir_js'; import { type Abi, abiDecode, abiEncode } from '@noir-lang/noirc_abi'; @@ -43,16 +44,6 @@ import { getPrivateKernelResetArtifactName } from '../utils/private_kernel_reset /* eslint-disable camelcase */ -// Utility function with self-contained dynamic imports, so it can be stripped from browser bundles -// This is only ever used in testing, so it's safe to do so -/* testing-only-start */ -async function updateProtocolCircuitSampleInputs(circuitName: string, inputs: any) { - const { updateProtocolCircuitSampleInputs } = await import('@aztec/foundation/testing/files'); - const TOML = await import('@iarna/toml'); - updateProtocolCircuitSampleInputs(circuitName, TOML.stringify(inputs)); -} -/* testing-only-end */ - /** * Executes the init private kernel. * @param privateKernelInitCircuitPrivateInputs - The private inputs to the initial private kernel. @@ -72,10 +63,7 @@ export async function executeInit( ), }; - // Allow bundlers to remove this code - /* testing-only-start */ - await updateProtocolCircuitSampleInputs('private-kernel-init', inputs); - /* testing-only-end */ + pushTestData('private-kernel-init', inputs); const returnType = await executePrivateKernelInitWithACVM( inputs.tx_request, @@ -110,10 +98,7 @@ export async function executeInner( ), }; - // Allow bundlers to remove this code - /* testing-only-start */ - await updateProtocolCircuitSampleInputs('private-kernel-inner', inputs); - /* testing-only-end */ + pushTestData('private-kernel-inner', inputs); const returnType = await executePrivateKernelInnerWithACVM( inputs.previous_kernel, @@ -155,7 +140,7 @@ export async function executeReset< const artifact = SimulatedClientCircuitArtifacts[getPrivateKernelResetArtifactName(dimensions)]; const program = new Noir(artifact as CompiledCircuit); if (untrimmedPrivateKernelResetCircuitPrivateInputs) { - await updateResetCircuitSampleInputs(untrimmedPrivateKernelResetCircuitPrivateInputs); + updateResetCircuitSampleInputs(untrimmedPrivateKernelResetCircuitPrivateInputs); } const args: InputMap = { previous_kernel: mapPrivateKernelDataToNoir(privateKernelResetCircuitPrivateInputs.previousKernel), @@ -181,10 +166,7 @@ export async function executeTail( previous_kernel_public_inputs: mapPrivateKernelCircuitPublicInputsToNoir(privateInputs.previousKernel.publicInputs), }; - // Allow bundlers to remove this code - /* testing-only-start */ - await updateProtocolCircuitSampleInputs('private-kernel-tail', inputs); - /* testing-only-end */ + pushTestData('private-kernel-tail', inputs); const returnType = await executePrivateKernelTailWithACVM( inputs.previous_kernel, @@ -209,10 +191,7 @@ export async function executeTailForPublic( previous_kernel_public_inputs: mapPrivateKernelCircuitPublicInputsToNoir(privateInputs.previousKernel.publicInputs), }; - // Allow bundlers to remove this code - /* testing-only-start */ - await updateProtocolCircuitSampleInputs('private-kernel-tail-to-public', inputs); - /* testing-only-end */ + pushTestData('private-kernel-tail-to-public', inputs); const returnType = await executePrivateKernelTailToPublicWithACVM( inputs.previous_kernel, @@ -420,7 +399,7 @@ export function convertPrivateKernelTailForPublicOutputsFromWitnessMap( return mapPrivateKernelTailCircuitPublicInputsForPublicFromNoir(returnType); } -async function updateResetCircuitSampleInputs( +function updateResetCircuitSampleInputs( privateKernelResetCircuitPrivateInputs: PrivateKernelResetCircuitPrivateInputs, ) { const inputs = { @@ -431,8 +410,5 @@ async function updateResetCircuitSampleInputs( hints: mapPrivateKernelResetHintsToNoir(privateKernelResetCircuitPrivateInputs.hints), }; - // Allow bundlers to remove this code - /* testing-only-start */ - await updateProtocolCircuitSampleInputs('private-kernel-reset', inputs); - /* testing-only-end */ + pushTestData('private-kernel-reset', inputs); } diff --git a/yarn-project/noir-protocol-circuits-types/src/execution/server.ts b/yarn-project/noir-protocol-circuits-types/src/execution/server.ts index 5396265eea0..b21c973dc74 100644 --- a/yarn-project/noir-protocol-circuits-types/src/execution/server.ts +++ b/yarn-project/noir-protocol-circuits-types/src/execution/server.ts @@ -15,9 +15,8 @@ import { type RootRollupInputs, type RootRollupPublicInputs, } from '@aztec/circuits.js'; -import { updateProtocolCircuitSampleInputs } from '@aztec/foundation/testing/files'; +import { pushTestData } from '@aztec/foundation/testing'; -import TOML from '@iarna/toml'; import { type WitnessMap } from '@noir-lang/acvm_js'; import { abiDecode, abiEncode } from '@noir-lang/noirc_abi'; @@ -89,7 +88,7 @@ export function convertPrivateBaseRollupInputsToWitnessMap(inputs: PrivateBaseRo export function convertSimulatedPrivateBaseRollupInputsToWitnessMap(inputs: PrivateBaseRollupInputs): WitnessMap { const mapped = mapPrivateBaseRollupInputsToNoir(inputs); - updateProtocolCircuitSampleInputs('rollup-base-private', TOML.stringify({ inputs: mapped })); + pushTestData('rollup-base-private', { inputs: mapped }); const initialWitnessMap = abiEncode(SimulatedServerCircuitArtifacts.PrivateBaseRollupArtifact.abi, { inputs: mapped as any, }); @@ -104,7 +103,7 @@ export function convertPublicBaseRollupInputsToWitnessMap(inputs: PublicBaseRoll export function convertSimulatedPublicBaseRollupInputsToWitnessMap(inputs: PublicBaseRollupInputs): WitnessMap { const mapped = mapPublicBaseRollupInputsToNoir(inputs); - updateProtocolCircuitSampleInputs('rollup-base-public', TOML.stringify({ inputs: mapped })); + pushTestData('rollup-base-public', { inputs: mapped }); const initialWitnessMap = abiEncode(SimulatedServerCircuitArtifacts.PublicBaseRollupArtifact.abi, { inputs: mapped as any, }); @@ -118,7 +117,7 @@ export function convertSimulatedPublicBaseRollupInputsToWitnessMap(inputs: Publi */ export function convertMergeRollupInputsToWitnessMap(inputs: MergeRollupInputs): WitnessMap { const mapped = mapMergeRollupInputsToNoir(inputs); - updateProtocolCircuitSampleInputs('rollup-merge', TOML.stringify({ inputs: mapped })); + pushTestData('rollup-merge', { inputs: mapped }); const initialWitnessMap = abiEncode(ServerCircuitArtifacts.MergeRollupArtifact.abi, { inputs: mapped as any }); return initialWitnessMap; } @@ -130,7 +129,7 @@ export function convertMergeRollupInputsToWitnessMap(inputs: MergeRollupInputs): */ export function convertBlockRootRollupInputsToWitnessMap(inputs: BlockRootRollupInputs): WitnessMap { const mapped = mapBlockRootRollupInputsToNoir(inputs); - updateProtocolCircuitSampleInputs('rollup-block-root', TOML.stringify({ inputs: mapped })); + pushTestData('rollup-block-root', { inputs: mapped }); const initialWitnessMap = abiEncode(ServerCircuitArtifacts.BlockRootRollupArtifact.abi, { inputs: mapped as any }); return initialWitnessMap; } @@ -142,7 +141,7 @@ export function convertBlockRootRollupInputsToWitnessMap(inputs: BlockRootRollup */ export function convertSimulatedBlockRootRollupInputsToWitnessMap(inputs: BlockRootRollupInputs): WitnessMap { const mapped = mapBlockRootRollupInputsToNoir(inputs); - updateProtocolCircuitSampleInputs('rollup-block-root', TOML.stringify({ inputs: mapped })); + pushTestData('rollup-block-root', { inputs: mapped }); const initialWitnessMap = abiEncode(SimulatedServerCircuitArtifacts.BlockRootRollupArtifact.abi, { inputs: mapped as any, }); @@ -169,7 +168,7 @@ export function convertEmptyBlockRootRollupInputsToWitnessMap(inputs: EmptyBlock */ export function convertBlockMergeRollupInputsToWitnessMap(inputs: BlockMergeRollupInputs): WitnessMap { const mapped = mapBlockMergeRollupInputsToNoir(inputs); - updateProtocolCircuitSampleInputs('rollup-block-merge', TOML.stringify({ inputs: mapped })); + pushTestData('rollup-block-merge', { inputs: mapped }); const initialWitnessMap = abiEncode(ServerCircuitArtifacts.BlockMergeRollupArtifact.abi, { inputs: mapped as any }); return initialWitnessMap; } @@ -181,7 +180,7 @@ export function convertBlockMergeRollupInputsToWitnessMap(inputs: BlockMergeRoll */ export function convertRootRollupInputsToWitnessMap(inputs: RootRollupInputs): WitnessMap { const mapped = mapRootRollupInputsToNoir(inputs); - updateProtocolCircuitSampleInputs('rollup-root', TOML.stringify({ inputs: mapped })); + pushTestData('rollup-root', { inputs: mapped }); const initialWitnessMap = abiEncode(ServerCircuitArtifacts.RootRollupArtifact.abi, { inputs: mapped as any }); return initialWitnessMap; } diff --git a/yarn-project/noir-protocol-circuits-types/src/scripts/cleanup_artifacts.ts b/yarn-project/noir-protocol-circuits-types/src/scripts/cleanup_artifacts.ts new file mode 100644 index 00000000000..1317b093ee6 --- /dev/null +++ b/yarn-project/noir-protocol-circuits-types/src/scripts/cleanup_artifacts.ts @@ -0,0 +1,19 @@ +import { fileURLToPath } from '@aztec/foundation/url'; + +import { readFile, readdir, writeFile } from 'fs/promises'; +import { join } from 'path'; + +async function cleanupArtifacts(target: string) { + const files = await readdir(target); + for (const file of files) { + if (!file.endsWith('.json')) { + continue; + } + const fileData = JSON.parse((await readFile(join(target, file), 'utf8')).toString()); + fileData.file_map = {}; + fileData.debug_symbols = {}; + await writeFile(join(target, file), JSON.stringify(fileData)); + } +} + +await cleanupArtifacts(fileURLToPath(new URL('../../artifacts', import.meta.url).href)); diff --git a/yarn-project/protocol-contracts/package.json b/yarn-project/protocol-contracts/package.json index 6292c2878be..6995b1bcf0e 100644 --- a/yarn-project/protocol-contracts/package.json +++ b/yarn-project/protocol-contracts/package.json @@ -20,7 +20,9 @@ }, "scripts": { "build": "yarn clean && yarn generate && tsc -b", + "build:keep-debug-symbols": "yarn clean && yarn generate && tsc -b", "generate": "yarn generate:data", + "generate:cleanup_artifacts": "node --no-warnings --loader ts-node/esm src/scripts/cleanup_artifacts.ts", "generate:data": "node --no-warnings --loader ts-node/esm src/scripts/generate_data.ts && run -T prettier -w src/protocol_contract_data.ts", "build:dev": "tsc -b --watch", "build:ts": "tsc -b", diff --git a/yarn-project/protocol-contracts/src/scripts/cleanup_artifacts.ts b/yarn-project/protocol-contracts/src/scripts/cleanup_artifacts.ts new file mode 100644 index 00000000000..1317b093ee6 --- /dev/null +++ b/yarn-project/protocol-contracts/src/scripts/cleanup_artifacts.ts @@ -0,0 +1,19 @@ +import { fileURLToPath } from '@aztec/foundation/url'; + +import { readFile, readdir, writeFile } from 'fs/promises'; +import { join } from 'path'; + +async function cleanupArtifacts(target: string) { + const files = await readdir(target); + for (const file of files) { + if (!file.endsWith('.json')) { + continue; + } + const fileData = JSON.parse((await readFile(join(target, file), 'utf8')).toString()); + fileData.file_map = {}; + fileData.debug_symbols = {}; + await writeFile(join(target, file), JSON.stringify(fileData)); + } +} + +await cleanupArtifacts(fileURLToPath(new URL('../../artifacts', import.meta.url).href)); diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 9f7fdbb12f1..c77d7c1fe86 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -553,6 +553,7 @@ __metadata: "@aztec/telemetry-client": "workspace:^" "@aztec/types": "workspace:^" "@aztec/world-state": "workspace:^" + "@iarna/toml": "npm:^2.2.5" "@jest/globals": "npm:^29.5.0" "@noble/curves": "npm:^1.0.0" "@swc/core": "npm:^1.4.11" @@ -881,7 +882,6 @@ __metadata: "@aztec/kv-store": "workspace:^" "@aztec/merkle-tree": "workspace:^" "@aztec/types": "workspace:^" - "@iarna/toml": "npm:^2.2.5" "@jest/globals": "npm:^29.5.0" "@noir-lang/acvm_js": "portal:../../noir/packages/acvm_js" "@noir-lang/noir_codegen": "portal:../../noir/packages/noir_codegen" From 0726e05d3a86df965f0bef61be4614ba1af2da1b Mon Sep 17 00:00:00 2001 From: thunkar Date: Thu, 19 Dec 2024 14:05:05 +0000 Subject: [PATCH 02/14] fix --- yarn-project/end-to-end/src/e2e_prover/full.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_prover/full.test.ts b/yarn-project/end-to-end/src/e2e_prover/full.test.ts index 5dc3e6563a9..b9534142cbc 100644 --- a/yarn-project/end-to-end/src/e2e_prover/full.test.ts +++ b/yarn-project/end-to-end/src/e2e_prover/full.test.ts @@ -257,8 +257,8 @@ describe('full_prover', () => { 'rollup-merge', 'rollup-block-root', 'rollup-root', - ].map(circuitName => { - const inputs = getTestData(circuitName); + ].forEach(circuitName => { + const [inputs] = getTestData(circuitName); updateProtocolCircuitSampleInputs(circuitName, TOML.stringify(inputs as any)); }); }); From dfed8c77af27f8e647e9925b8467c0a21370eb2c Mon Sep 17 00:00:00 2001 From: thunkar Date: Thu, 19 Dec 2024 14:11:17 +0000 Subject: [PATCH 03/14] protection --- yarn-project/end-to-end/src/e2e_prover/full.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_prover/full.test.ts b/yarn-project/end-to-end/src/e2e_prover/full.test.ts index b9534142cbc..010717e3283 100644 --- a/yarn-project/end-to-end/src/e2e_prover/full.test.ts +++ b/yarn-project/end-to-end/src/e2e_prover/full.test.ts @@ -258,8 +258,10 @@ describe('full_prover', () => { 'rollup-block-root', 'rollup-root', ].forEach(circuitName => { - const [inputs] = getTestData(circuitName); - updateProtocolCircuitSampleInputs(circuitName, TOML.stringify(inputs as any)); + const data = getTestData(circuitName); + if (data) { + updateProtocolCircuitSampleInputs(circuitName, TOML.stringify(data[0] as any)); + } }); }); From 80ec92a0cdbac437df92692082eca604a40325e5 Mon Sep 17 00:00:00 2001 From: thunkar Date: Thu, 19 Dec 2024 14:52:25 +0000 Subject: [PATCH 04/14] fix --- .../acir_tests/browser-test-app/yarn.lock | 6 +- barretenberg/acir_tests/sol-test/package.json | 3 +- barretenberg/acir_tests/sol-test/yarn.lock | 274 +++++++----------- 3 files changed, 115 insertions(+), 168 deletions(-) diff --git a/barretenberg/acir_tests/browser-test-app/yarn.lock b/barretenberg/acir_tests/browser-test-app/yarn.lock index d209e4296d3..34e3a5e03a7 100644 --- a/barretenberg/acir_tests/browser-test-app/yarn.lock +++ b/barretenberg/acir_tests/browser-test-app/yarn.lock @@ -6,8 +6,8 @@ __metadata: cacheKey: 10c0 "@aztec/bb.js@file:../../ts::locator=browser-test-app%40workspace%3A.": - version: 0.67.0 - resolution: "@aztec/bb.js@file:../../ts#../../ts::hash=e236e3&locator=browser-test-app%40workspace%3A." + version: 0.67.1 + resolution: "@aztec/bb.js@file:../../ts#../../ts::hash=5bd502&locator=browser-test-app%40workspace%3A." dependencies: comlink: "npm:^4.4.1" commander: "npm:^12.1.0" @@ -17,7 +17,7 @@ __metadata: tslib: "npm:^2.4.0" bin: bb.js: ./dest/node/main.js - checksum: 10c0/4ca2234f9d1a4b59a60733979f97c5ca09f508e4d3091bf33755ee6a80f03f733e393ea848b812bc73bc1f0673a3d92f96462a1cbd5aa01eeca4e9d5a3be367f + checksum: 10c0/6bb7b89ed4e7d74f9a0ce8522c8a3b21bd77da3b039d45fdc2012640b85d0321211a95b060e95a9adf0a4222d8b4ec818d9f006e40406bd4bfa2c3ab53d7eabb languageName: node linkType: hard diff --git a/barretenberg/acir_tests/sol-test/package.json b/barretenberg/acir_tests/sol-test/package.json index a13cd369c14..de1fdf8a961 100644 --- a/barretenberg/acir_tests/sol-test/package.json +++ b/barretenberg/acir_tests/sol-test/package.json @@ -10,5 +10,6 @@ "dependencies": { "ethers": "^6.8.1", "solc": "^0.8.27" - } + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } diff --git a/barretenberg/acir_tests/sol-test/yarn.lock b/barretenberg/acir_tests/sol-test/yarn.lock index 293b9d13679..9bc6faad6c9 100644 --- a/barretenberg/acir_tests/sol-test/yarn.lock +++ b/barretenberg/acir_tests/sol-test/yarn.lock @@ -1,169 +1,115 @@ -# This file is generated by running "yarn install" inside your project. -# Manual changes might be lost - proceed with caution! - -__metadata: - version: 8 - cacheKey: 10c0 - -"@adraffy/ens-normalize@npm:1.10.0": - version: 1.10.0 - resolution: "@adraffy/ens-normalize@npm:1.10.0" - checksum: 10c0/78ae700847a2516d5a0ae12c4e23d09392a40c67e73b137eb7189f51afb1601c8d18784aeda2ed288a278997824dc924d1f398852c21d41ee2c4c564f2fb4d26 - languageName: node - linkType: hard - -"@noble/curves@npm:1.2.0": - version: 1.2.0 - resolution: "@noble/curves@npm:1.2.0" +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@adraffy/ens-normalize@1.10.1": + version "1.10.1" + resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz#63430d04bd8c5e74f8d7d049338f1cd9d4f02069" + integrity sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw== + +"@noble/curves@1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.2.0.tgz#92d7e12e4e49b23105a2555c6984d41733d65c35" + integrity sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw== dependencies: - "@noble/hashes": "npm:1.3.2" - checksum: 10c0/0bac7d1bbfb3c2286910b02598addd33243cb97c3f36f987ecc927a4be8d7d88e0fcb12b0f0ef8a044e7307d1844dd5c49bb724bfa0a79c8ec50ba60768c97f6 - languageName: node - linkType: hard - -"@noble/hashes@npm:1.3.2": - version: 1.3.2 - resolution: "@noble/hashes@npm:1.3.2" - checksum: 10c0/2482cce3bce6a596626f94ca296e21378e7a5d4c09597cbc46e65ffacc3d64c8df73111f2265444e36a3168208628258bbbaccba2ef24f65f58b2417638a20e7 - languageName: node - linkType: hard - -"@types/node@npm:18.15.13": - version: 18.15.13 - resolution: "@types/node@npm:18.15.13" - checksum: 10c0/6e5f61c559e60670a7a8fb88e31226ecc18a21be103297ca4cf9848f0a99049dae77f04b7ae677205f2af494f3701b113ba8734f4b636b355477a6534dbb8ada - languageName: node - linkType: hard - -"aes-js@npm:4.0.0-beta.5": - version: 4.0.0-beta.5 - resolution: "aes-js@npm:4.0.0-beta.5" - checksum: 10c0/444f4eefa1e602cbc4f2a3c644bc990f93fd982b148425fee17634da510586fc09da940dcf8ace1b2d001453c07ff042e55f7a0482b3cc9372bf1ef75479090c - languageName: node - linkType: hard - -"command-exists@npm:^1.2.8": - version: 1.2.9 - resolution: "command-exists@npm:1.2.9" - checksum: 10c0/75040240062de46cd6cd43e6b3032a8b0494525c89d3962e280dde665103f8cc304a8b313a5aa541b91da2f5a9af75c5959dc3a77893a2726407a5e9a0234c16 - languageName: node - linkType: hard - -"commander@npm:^8.1.0": - version: 8.3.0 - resolution: "commander@npm:8.3.0" - checksum: 10c0/8b043bb8322ea1c39664a1598a95e0495bfe4ca2fad0d84a92d7d1d8d213e2a155b441d2470c8e08de7c4a28cf2bc6e169211c49e1b21d9f7edc6ae4d9356060 - languageName: node - linkType: hard - -"ethers@npm:^6.8.1": - version: 6.8.1 - resolution: "ethers@npm:6.8.1" + "@noble/hashes" "1.3.2" + +"@noble/hashes@1.3.2": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39" + integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== + +"@types/node@22.7.5": + version "22.7.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.5.tgz#cfde981727a7ab3611a481510b473ae54442b92b" + integrity sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ== dependencies: - "@adraffy/ens-normalize": "npm:1.10.0" - "@noble/curves": "npm:1.2.0" - "@noble/hashes": "npm:1.3.2" - "@types/node": "npm:18.15.13" - aes-js: "npm:4.0.0-beta.5" - tslib: "npm:2.4.0" - ws: "npm:8.5.0" - checksum: 10c0/2fb05a0377c7d251ef160ddb5ab8553311c81fd1b7931426d6492d2652704a6ac5c4ff277a5aa6b2e64fe8bbfeec0b0e98263049d2ce44bf2286a72cefc3204b - languageName: node - linkType: hard - -"follow-redirects@npm:^1.12.1": - version: 1.15.3 - resolution: "follow-redirects@npm:1.15.3" - peerDependenciesMeta: - debug: - optional: true - checksum: 10c0/915a2cf22e667bdf47b1a43cc6b7dce14d95039e9bbf9a24d0e739abfbdfa00077dd43c86d4a7a19efefcc7a99af144920a175eedc3888d268af5df67c272ee5 - languageName: node - linkType: hard - -"headless-test@workspace:.": - version: 0.0.0-use.local - resolution: "headless-test@workspace:." + undici-types "~6.19.2" + +aes-js@4.0.0-beta.5: + version "4.0.0-beta.5" + resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-4.0.0-beta.5.tgz#8d2452c52adedebc3a3e28465d858c11ca315873" + integrity sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q== + +command-exists@^1.2.8: + version "1.2.9" + resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.9.tgz#c50725af3808c8ab0260fd60b01fbfa25b954f69" + integrity sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w== + +commander@^8.1.0: + version "8.3.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66" + integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww== + +ethers@^6.8.1: + version "6.13.4" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.4.tgz#bd3e1c3dc1e7dc8ce10f9ffb4ee40967a651b53c" + integrity sha512-21YtnZVg4/zKkCQPjrDj38B1r4nQvTZLopUGMLQ1ePU2zV/joCfDC3t3iKQjWRzjjjbzR+mdAIoikeBRNkdllA== dependencies: - ethers: "npm:^6.8.1" - solc: "npm:^0.8.27" - languageName: unknown - linkType: soft - -"js-sha3@npm:0.8.0": - version: 0.8.0 - resolution: "js-sha3@npm:0.8.0" - checksum: 10c0/43a21dc7967c871bd2c46cb1c2ae97441a97169f324e509f382d43330d8f75cf2c96dba7c806ab08a425765a9c847efdd4bffbac2d99c3a4f3de6c0218f40533 - languageName: node - linkType: hard - -"memorystream@npm:^0.3.1": - version: 0.3.1 - resolution: "memorystream@npm:0.3.1" - checksum: 10c0/4bd164657711d9747ff5edb0508b2944414da3464b7fe21ac5c67cf35bba975c4b446a0124bd0f9a8be54cfc18faf92e92bd77563a20328b1ccf2ff04e9f39b9 - languageName: node - linkType: hard - -"os-tmpdir@npm:~1.0.2": - version: 1.0.2 - resolution: "os-tmpdir@npm:1.0.2" - checksum: 10c0/f438450224f8e2687605a8dd318f0db694b6293c5d835ae509a69e97c8de38b6994645337e5577f5001115470414638978cc49da1cdcc25106dad8738dc69990 - languageName: node - linkType: hard - -"semver@npm:^5.5.0": - version: 5.7.2 - resolution: "semver@npm:5.7.2" - bin: - semver: bin/semver - checksum: 10c0/e4cf10f86f168db772ae95d86ba65b3fd6c5967c94d97c708ccb463b778c2ee53b914cd7167620950fc07faf5a564e6efe903836639e512a1aa15fbc9667fa25 - languageName: node - linkType: hard - -"solc@npm:^0.8.27": - version: 0.8.27 - resolution: "solc@npm:0.8.27" + "@adraffy/ens-normalize" "1.10.1" + "@noble/curves" "1.2.0" + "@noble/hashes" "1.3.2" + "@types/node" "22.7.5" + aes-js "4.0.0-beta.5" + tslib "2.7.0" + ws "8.17.1" + +follow-redirects@^1.12.1: + version "1.15.9" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1" + integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ== + +js-sha3@0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" + integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== + +memorystream@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2" + integrity sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw== + +os-tmpdir@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + integrity sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g== + +semver@^5.5.0: + version "5.7.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" + integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== + +solc@^0.8.27: + version "0.8.28" + resolved "https://registry.yarnpkg.com/solc/-/solc-0.8.28.tgz#43f129ce31572625593677cc3ff53eb32100148c" + integrity sha512-AFCiJ+b4RosyyNhnfdVH4ZR1+TxiL91iluPjw0EJslIu4LXGM9NYqi2z5y8TqochC4tcH9QsHfwWhOIC9jPDKA== dependencies: - command-exists: "npm:^1.2.8" - commander: "npm:^8.1.0" - follow-redirects: "npm:^1.12.1" - js-sha3: "npm:0.8.0" - memorystream: "npm:^0.3.1" - semver: "npm:^5.5.0" - tmp: "npm:0.0.33" - bin: - solcjs: solc.js - checksum: 10c0/6b7bed9531c6e1f1efcd30eb4ef4a741954bafb79b4d016faa728992990c8ca36a16d38118e3eeb39a205e834557c519e75cf4188a6212ac871e9755663c478d - languageName: node - linkType: hard - -"tmp@npm:0.0.33": - version: 0.0.33 - resolution: "tmp@npm:0.0.33" + command-exists "^1.2.8" + commander "^8.1.0" + follow-redirects "^1.12.1" + js-sha3 "0.8.0" + memorystream "^0.3.1" + semver "^5.5.0" + tmp "0.0.33" + +tmp@0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== dependencies: - os-tmpdir: "npm:~1.0.2" - checksum: 10c0/69863947b8c29cabad43fe0ce65cec5bb4b481d15d4b4b21e036b060b3edbf3bc7a5541de1bacb437bb3f7c4538f669752627fdf9b4aaf034cebd172ba373408 - languageName: node - linkType: hard - -"tslib@npm:2.4.0": - version: 2.4.0 - resolution: "tslib@npm:2.4.0" - checksum: 10c0/eb19bda3ae545b03caea6a244b34593468e23d53b26bf8649fbc20fce43e9b21a71127fd6d2b9662c0fe48ee6ff668ead48fd00d3b88b2b716b1c12edae25b5d - languageName: node - linkType: hard - -"ws@npm:8.5.0": - version: 8.5.0 - resolution: "ws@npm:8.5.0" - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: 10c0/0baeee03e97865accda8fad51e8e5fa17d19b8e264529efdf662bbba2acc1c7f1de8316287e6df5cb639231a96009e6d5234b57e6ff36ee2d04e49a0995fec2f - languageName: node - linkType: hard + os-tmpdir "~1.0.2" + +tslib@2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.7.0.tgz#d9b40c5c40ab59e8738f297df3087bf1a2690c01" + integrity sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA== + +undici-types@~6.19.2: + version "6.19.8" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" + integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== + +ws@8.17.1: + version "8.17.1" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b" + integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ== From b675332c2e212fa76b8e59bf6735ca58023265e3 Mon Sep 17 00:00:00 2001 From: thunkar Date: Thu, 19 Dec 2024 14:53:57 +0000 Subject: [PATCH 05/14] fix --- yarn-project/noir-protocol-circuits-types/package.json | 2 +- yarn-project/noir-protocol-circuits-types/package.local.json | 2 +- yarn-project/protocol-contracts/package.json | 2 +- yarn-project/protocol-contracts/package.local.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/yarn-project/noir-protocol-circuits-types/package.json b/yarn-project/noir-protocol-circuits-types/package.json index 42bdabeec8c..ab93b96dbc5 100644 --- a/yarn-project/noir-protocol-circuits-types/package.json +++ b/yarn-project/noir-protocol-circuits-types/package.json @@ -12,7 +12,7 @@ "./package.local.json" ], "scripts": { - "build": "yarn clean && yarn generate && tsc -b", + "build": "yarn clean && yarn generate && yarn generate:cleanup_artifacts && tsc -b", "build:keep-debug-symbols": "yarn clean && yarn generate && tsc -b", "clean": "rm -rf ./dest .tsbuildinfo src/types artifacts", "formatting": "run -T prettier --check ./src && run -T eslint ./src", diff --git a/yarn-project/noir-protocol-circuits-types/package.local.json b/yarn-project/noir-protocol-circuits-types/package.local.json index d496e249715..e0bb9b86711 100644 --- a/yarn-project/noir-protocol-circuits-types/package.local.json +++ b/yarn-project/noir-protocol-circuits-types/package.local.json @@ -1,6 +1,6 @@ { "scripts": { - "build": "yarn clean && yarn generate && tsc -b", + "build": "yarn clean && yarn generate && yarn generate:cleanup_artifacts && tsc -b", "clean": "rm -rf ./dest .tsbuildinfo src/types artifacts" }, "files": ["dest", "src", "artifacts", "!*.test.*"] diff --git a/yarn-project/protocol-contracts/package.json b/yarn-project/protocol-contracts/package.json index 6995b1bcf0e..934417bfbbe 100644 --- a/yarn-project/protocol-contracts/package.json +++ b/yarn-project/protocol-contracts/package.json @@ -19,7 +19,7 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "build": "yarn clean && yarn generate && tsc -b", + "build": "yarn clean && yarn generate && yarn generate:cleanup_artifacts && tsc -b", "build:keep-debug-symbols": "yarn clean && yarn generate && tsc -b", "generate": "yarn generate:data", "generate:cleanup_artifacts": "node --no-warnings --loader ts-node/esm src/scripts/cleanup_artifacts.ts", diff --git a/yarn-project/protocol-contracts/package.local.json b/yarn-project/protocol-contracts/package.local.json index 5d1ffe82a09..55e849c064c 100644 --- a/yarn-project/protocol-contracts/package.local.json +++ b/yarn-project/protocol-contracts/package.local.json @@ -1,6 +1,6 @@ { "scripts": { - "build": "yarn clean && yarn generate && tsc -b", + "build": "yarn clean && yarn generate && yarn generate:cleanup_artifacts && tsc -b", "build:dev": "tsc -b --watch", "build:ts": "tsc -b", "clean": "rm -rf ./dest .tsbuildinfo ./artifacts" From 7a4678226a8384a324effb376b48a0bec00d7360 Mon Sep 17 00:00:00 2001 From: thunkar Date: Thu, 19 Dec 2024 15:22:02 +0000 Subject: [PATCH 06/14] fix --- .../noir-protocol-circuits-types/package.json | 2 +- .../package.local.json | 2 +- .../src/client.ts | 2 +- .../src/execution/client.ts | 2 +- .../noir-protocol-circuits-types/src/index.ts | 2 +- .../src/utils/client/foreign_call_handler.ts | 30 +++++++++++++++++++ .../{ => server}/foreign_call_handler.ts | 0 yarn-project/protocol-contracts/package.json | 4 +-- .../protocol-contracts/package.local.json | 2 +- 9 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 yarn-project/noir-protocol-circuits-types/src/utils/client/foreign_call_handler.ts rename yarn-project/noir-protocol-circuits-types/src/utils/{ => server}/foreign_call_handler.ts (100%) diff --git a/yarn-project/noir-protocol-circuits-types/package.json b/yarn-project/noir-protocol-circuits-types/package.json index ab93b96dbc5..b5503ab9b33 100644 --- a/yarn-project/noir-protocol-circuits-types/package.json +++ b/yarn-project/noir-protocol-circuits-types/package.json @@ -12,7 +12,7 @@ "./package.local.json" ], "scripts": { - "build": "yarn clean && yarn generate && yarn generate:cleanup_artifacts && tsc -b", + "build": "yarn clean && yarn generate && yarn generate:cleanup-artifacts && tsc -b", "build:keep-debug-symbols": "yarn clean && yarn generate && tsc -b", "clean": "rm -rf ./dest .tsbuildinfo src/types artifacts", "formatting": "run -T prettier --check ./src && run -T eslint ./src", diff --git a/yarn-project/noir-protocol-circuits-types/package.local.json b/yarn-project/noir-protocol-circuits-types/package.local.json index e0bb9b86711..e77a0ffe2c4 100644 --- a/yarn-project/noir-protocol-circuits-types/package.local.json +++ b/yarn-project/noir-protocol-circuits-types/package.local.json @@ -1,6 +1,6 @@ { "scripts": { - "build": "yarn clean && yarn generate && yarn generate:cleanup_artifacts && tsc -b", + "build": "yarn clean && yarn generate && yarn generate:cleanup-artifacts && tsc -b", "clean": "rm -rf ./dest .tsbuildinfo src/types artifacts" }, "files": ["dest", "src", "artifacts", "!*.test.*"] diff --git a/yarn-project/noir-protocol-circuits-types/src/client.ts b/yarn-project/noir-protocol-circuits-types/src/client.ts index db2b21ae601..47ac9e9a9be 100644 --- a/yarn-project/noir-protocol-circuits-types/src/client.ts +++ b/yarn-project/noir-protocol-circuits-types/src/client.ts @@ -20,5 +20,5 @@ export { ClientCircuitArtifacts, type ClientProtocolArtifact } from './artifacts export { getPrivateKernelResetArtifactName } from './utils/private_kernel_reset.js'; export { maxPrivateKernelResetDimensions, privateKernelResetDimensionsConfig } from './private_kernel_reset_data.js'; -export { foreignCallHandler } from './utils/foreign_call_handler.js'; +export { foreignCallHandler } from './utils/server/foreign_call_handler.js'; export { ClientCircuitVks, getVKIndex, getVKTreeRoot, getVKSiblingPath } from './vks.js'; diff --git a/yarn-project/noir-protocol-circuits-types/src/execution/client.ts b/yarn-project/noir-protocol-circuits-types/src/execution/client.ts index b040a7db31f..795e3773dc1 100644 --- a/yarn-project/noir-protocol-circuits-types/src/execution/client.ts +++ b/yarn-project/noir-protocol-circuits-types/src/execution/client.ts @@ -38,8 +38,8 @@ import { PrivateKernelTailToPublic as executePrivateKernelTailToPublicWithACVM, PrivateKernelTail as executePrivateKernelTailWithACVM, } from '../types/index.js'; +import { foreignCallHandler } from '../utils/client/foreign_call_handler.js'; import { type DecodedInputs } from '../utils/decoded_inputs.js'; -import { foreignCallHandler } from '../utils/foreign_call_handler.js'; import { getPrivateKernelResetArtifactName } from '../utils/private_kernel_reset.js'; /* eslint-disable camelcase */ diff --git a/yarn-project/noir-protocol-circuits-types/src/index.ts b/yarn-project/noir-protocol-circuits-types/src/index.ts index 22bb7a5a041..553be46a7de 100644 --- a/yarn-project/noir-protocol-circuits-types/src/index.ts +++ b/yarn-project/noir-protocol-circuits-types/src/index.ts @@ -3,5 +3,5 @@ export * from './execution/index.js'; export { getPrivateKernelResetArtifactName } from './utils/private_kernel_reset.js'; export { maxPrivateKernelResetDimensions, privateKernelResetDimensionsConfig } from './private_kernel_reset_data.js'; -export { foreignCallHandler } from './utils/foreign_call_handler.js'; +export { foreignCallHandler } from './utils/server/foreign_call_handler.js'; export * from './vks.js'; diff --git a/yarn-project/noir-protocol-circuits-types/src/utils/client/foreign_call_handler.ts b/yarn-project/noir-protocol-circuits-types/src/utils/client/foreign_call_handler.ts new file mode 100644 index 00000000000..dfe2d76e7d4 --- /dev/null +++ b/yarn-project/noir-protocol-circuits-types/src/utils/client/foreign_call_handler.ts @@ -0,0 +1,30 @@ +import { Fr } from '@aztec/circuits.js'; +import { applyStringFormatting, createLogger } from '@aztec/foundation/log'; + +import { type ForeignCallInput, type ForeignCallOutput } from '@noir-lang/acvm_js'; +import { strict as assert } from 'assert'; + +function fromACVMField(field: string): Fr { + return Fr.fromBuffer(Buffer.from(field.slice(2), 'hex')); +} + +function toACVMField(field: Fr): string { + return `0x${field.toBuffer().toString('hex')}`; +} + +export function foreignCallHandler(name: string, args: ForeignCallInput[]): Promise { + // ForeignCallInput is actually a string[], so the args are string[][]. + const log = createLogger('noir-protocol-circuits:oracle'); + + if (name === 'debugLog') { + assert(args.length === 3, 'expected 3 arguments for debugLog: msg, fields_length, fields'); + const [msgRaw, _ignoredFieldsSize, fields] = args; + const msg: string = msgRaw.map(acvmField => String.fromCharCode(fromACVMField(acvmField).toNumber())).join(''); + const fieldsFr: Fr[] = fields.map((field: string) => fromACVMField(field)); + log.verbose('debug_log ' + applyStringFormatting(msg, fieldsFr)); + } else { + throw Error(`unexpected oracle during execution: ${name}`); + } + + return Promise.resolve([]); +} diff --git a/yarn-project/noir-protocol-circuits-types/src/utils/foreign_call_handler.ts b/yarn-project/noir-protocol-circuits-types/src/utils/server/foreign_call_handler.ts similarity index 100% rename from yarn-project/noir-protocol-circuits-types/src/utils/foreign_call_handler.ts rename to yarn-project/noir-protocol-circuits-types/src/utils/server/foreign_call_handler.ts diff --git a/yarn-project/protocol-contracts/package.json b/yarn-project/protocol-contracts/package.json index 934417bfbbe..05001587256 100644 --- a/yarn-project/protocol-contracts/package.json +++ b/yarn-project/protocol-contracts/package.json @@ -19,10 +19,10 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "build": "yarn clean && yarn generate && yarn generate:cleanup_artifacts && tsc -b", + "build": "yarn clean && yarn generate && yarn generate:cleanup-artifacts && tsc -b", "build:keep-debug-symbols": "yarn clean && yarn generate && tsc -b", "generate": "yarn generate:data", - "generate:cleanup_artifacts": "node --no-warnings --loader ts-node/esm src/scripts/cleanup_artifacts.ts", + "generate:cleanup-artifacts": "node --no-warnings --loader ts-node/esm src/scripts/cleanup_artifacts.ts", "generate:data": "node --no-warnings --loader ts-node/esm src/scripts/generate_data.ts && run -T prettier -w src/protocol_contract_data.ts", "build:dev": "tsc -b --watch", "build:ts": "tsc -b", diff --git a/yarn-project/protocol-contracts/package.local.json b/yarn-project/protocol-contracts/package.local.json index 55e849c064c..14231e1aa44 100644 --- a/yarn-project/protocol-contracts/package.local.json +++ b/yarn-project/protocol-contracts/package.local.json @@ -1,6 +1,6 @@ { "scripts": { - "build": "yarn clean && yarn generate && yarn generate:cleanup_artifacts && tsc -b", + "build": "yarn clean && yarn generate && yarn generate:cleanup-artifacts && tsc -b", "build:dev": "tsc -b --watch", "build:ts": "tsc -b", "clean": "rm -rf ./dest .tsbuildinfo ./artifacts" From cec0e8589591c87c130746cc59436b4f2a4667c4 Mon Sep 17 00:00:00 2001 From: thunkar Date: Thu, 19 Dec 2024 15:35:07 +0000 Subject: [PATCH 07/14] fmt --- .../src/utils/client/foreign_call_handler.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/yarn-project/noir-protocol-circuits-types/src/utils/client/foreign_call_handler.ts b/yarn-project/noir-protocol-circuits-types/src/utils/client/foreign_call_handler.ts index dfe2d76e7d4..e01c95a83f9 100644 --- a/yarn-project/noir-protocol-circuits-types/src/utils/client/foreign_call_handler.ts +++ b/yarn-project/noir-protocol-circuits-types/src/utils/client/foreign_call_handler.ts @@ -8,10 +8,6 @@ function fromACVMField(field: string): Fr { return Fr.fromBuffer(Buffer.from(field.slice(2), 'hex')); } -function toACVMField(field: Fr): string { - return `0x${field.toBuffer().toString('hex')}`; -} - export function foreignCallHandler(name: string, args: ForeignCallInput[]): Promise { // ForeignCallInput is actually a string[], so the args are string[][]. const log = createLogger('noir-protocol-circuits:oracle'); From 63b36bdee84877e8aff6c041db7325053c1798cb Mon Sep 17 00:00:00 2001 From: thunkar Date: Thu, 19 Dec 2024 23:24:16 +0000 Subject: [PATCH 08/14] not-so-surgical extraction of blobs --- .../bb-prover/src/prover/bb_prover.ts | 24 +- .../bb-prover/src/test/test_circuit_prover.ts | 24 +- .../src/interfaces/epoch-prover.ts | 3 +- .../src/interfaces/proving-job-source.test.ts | 8 +- .../src/interfaces/proving-job.ts | 24 +- .../src/interfaces/server_circuit_prover.ts | 24 +- yarn-project/circuits.js/package.json | 4 +- .../{ => blobs}/blob_public_inputs.test.ts | 6 +- .../structs/{ => blobs}/blob_public_inputs.ts | 2 +- .../circuits.js/src/structs/blobs/index.ts | 2 + .../structs/{ => blobs}/sponge_blob.test.ts | 4 +- .../src/structs/{ => blobs}/sponge_blob.ts | 0 .../circuits.js/src/structs/block_header.ts | 2 +- yarn-project/circuits.js/src/structs/index.ts | 21 - .../src/structs/partial_state_reference.ts | 2 +- .../base_or_merge_rollup_public_inputs.ts | 2 +- .../src/structs/rollup/base_rollup_hints.ts | 2 +- ...block_root_or_block_merge_public_inputs.ts | 4 +- .../src/structs/rollup/block_root_rollup.ts | 2 +- .../structs/rollup/constant_rollup_data.ts | 2 +- .../rollup/empty_block_root_rollup_inputs.ts | 2 +- .../circuits.js/src/structs/rollup/index.ts | 18 + .../src/structs/rollup/root_rollup.ts | 4 +- .../src/structs/state_reference.ts | 2 +- .../circuits.js/src/structs/tree_snapshots.ts | 2 +- .../append_only_tree_snapshot.ts | 0 .../circuits.js/src/structs/trees/index.ts | 1 + .../circuits.js/src/tests/factories.ts | 35 +- yarn-project/ethereum/package.json | 3 +- .../src/conversion/client.ts | 856 ++++++ .../src/conversion/common.ts | 738 +++++ .../src/conversion/server.ts | 966 +++++++ .../{ => conversion}/type_conversion.test.ts | 5 +- .../src/execution/client.ts | 6 +- .../src/execution/server.ts | 24 +- .../src/type_conversion.ts | 2373 ----------------- .../src/utils/server/foreign_call_handler.ts | 3 +- .../src/block_builder/light.test.ts | 18 +- .../orchestrator/block-building-helpers.ts | 28 +- .../src/orchestrator/block-proving-state.ts | 5 +- .../src/orchestrator/epoch-proving-state.ts | 3 +- .../src/orchestrator/orchestrator.ts | 14 +- .../src/orchestrator/tx-proving-state.ts | 12 +- .../agent-queue-rpc-integration.test.ts | 3 +- .../src/prover-agent/memory-proving-queue.ts | 18 +- .../proving_broker/broker_prover_facade.ts | 24 +- .../src/test/bb_prover_base_rollup.test.ts | 12 +- .../prover-client/src/test/mock_prover.ts | 22 +- .../pxe/src/pxe_service/error_enriching.ts | 5 +- .../pxe/src/pxe_service/pxe_service.ts | 24 +- .../src/pxe_service/test/pxe_service.test.ts | 2 +- 51 files changed, 2797 insertions(+), 2593 deletions(-) rename yarn-project/circuits.js/src/structs/{ => blobs}/blob_public_inputs.test.ts (95%) rename yarn-project/circuits.js/src/structs/{ => blobs}/blob_public_inputs.ts (99%) create mode 100644 yarn-project/circuits.js/src/structs/blobs/index.ts rename yarn-project/circuits.js/src/structs/{ => blobs}/sponge_blob.test.ts (93%) rename yarn-project/circuits.js/src/structs/{ => blobs}/sponge_blob.ts (100%) create mode 100644 yarn-project/circuits.js/src/structs/rollup/index.ts rename yarn-project/circuits.js/src/structs/{rollup => trees}/append_only_tree_snapshot.ts (100%) create mode 100644 yarn-project/noir-protocol-circuits-types/src/conversion/client.ts create mode 100644 yarn-project/noir-protocol-circuits-types/src/conversion/common.ts create mode 100644 yarn-project/noir-protocol-circuits-types/src/conversion/server.ts rename yarn-project/noir-protocol-circuits-types/src/{ => conversion}/type_conversion.test.ts (95%) delete mode 100644 yarn-project/noir-protocol-circuits-types/src/type_conversion.ts diff --git a/yarn-project/bb-prover/src/prover/bb_prover.ts b/yarn-project/bb-prover/src/prover/bb_prover.ts index 62391579ed8..534d01395a3 100644 --- a/yarn-project/bb-prover/src/prover/bb_prover.ts +++ b/yarn-project/bb-prover/src/prover/bb_prover.ts @@ -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 { + BaseOrMergeRollupPublicInputs, + BlockMergeRollupInputs, + BlockRootOrBlockMergePublicInputs, + BlockRootRollupInputs, + EmptyBlockRootRollupInputs, + MergeRollupInputs, + PrivateBaseRollupInputs, + PublicBaseRollupInputs, + RootRollupInputs, + RootRollupPublicInputs, + TubeInputs, +} from '@aztec/circuits.js/rollup'; import { runInDirectory } from '@aztec/foundation/fs'; import { createLogger } from '@aztec/foundation/log'; import { BufferReader } from '@aztec/foundation/serialize'; diff --git a/yarn-project/bb-prover/src/test/test_circuit_prover.ts b/yarn-project/bb-prover/src/test/test_circuit_prover.ts index 5ed9dfad7d5..b80cb16c1ad 100644 --- a/yarn-project/bb-prover/src/test/test_circuit_prover.ts +++ b/yarn-project/bb-prover/src/test/test_circuit_prover.ts @@ -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 { + BaseOrMergeRollupPublicInputs, + BlockMergeRollupInputs, + BlockRootOrBlockMergePublicInputs, + BlockRootRollupInputs, + EmptyBlockRootRollupInputs, + MergeRollupInputs, + PrivateBaseRollupInputs, + PublicBaseRollupInputs, + RootRollupInputs, + RootRollupPublicInputs, + TubeInputs, +} from '@aztec/circuits.js/rollup'; import { createLogger } from '@aztec/foundation/log'; import { sleep } from '@aztec/foundation/sleep'; import { Timer } from '@aztec/foundation/timer'; diff --git a/yarn-project/circuit-types/src/interfaces/epoch-prover.ts b/yarn-project/circuit-types/src/interfaces/epoch-prover.ts index 4774741ebf1..59d251739e2 100644 --- a/yarn-project/circuit-types/src/interfaces/epoch-prover.ts +++ b/yarn-project/circuit-types/src/interfaces/epoch-prover.ts @@ -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 { RootRollupPublicInputs } from '@aztec/circuits.js/rollup'; import { type L2Block } from '../l2_block.js'; import { type BlockBuilder } from './block-builder.js'; diff --git a/yarn-project/circuit-types/src/interfaces/proving-job-source.test.ts b/yarn-project/circuit-types/src/interfaces/proving-job-source.test.ts index e372b6bef03..f27fe8fb85e 100644 --- a/yarn-project/circuit-types/src/interfaces/proving-job-source.test.ts +++ b/yarn-project/circuit-types/src/interfaces/proving-job-source.test.ts @@ -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'; diff --git a/yarn-project/circuit-types/src/interfaces/proving-job.ts b/yarn-project/circuit-types/src/interfaces/proving-job.ts index 8c2b44b98a0..618016bfc7e 100644 --- a/yarn-project/circuit-types/src/interfaces/proving-job.ts +++ b/yarn-project/circuit-types/src/interfaces/proving-job.ts @@ -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'; diff --git a/yarn-project/circuit-types/src/interfaces/server_circuit_prover.ts b/yarn-project/circuit-types/src/interfaces/server_circuit_prover.ts index aa0c60c7f2f..f60d9779db1 100644 --- a/yarn-project/circuit-types/src/interfaces/server_circuit_prover.ts +++ b/yarn-project/circuit-types/src/interfaces/server_circuit_prover.ts @@ -1,26 +1,28 @@ import { type AVM_PROOF_LENGTH_IN_FIELDS, type AvmCircuitInputs, - type BaseOrMergeRollupPublicInputs, type BaseParityInputs, - 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'; +import { + BaseOrMergeRollupPublicInputs, + BlockMergeRollupInputs, + BlockRootOrBlockMergePublicInputs, + BlockRootRollupInputs, + EmptyBlockRootRollupInputs, + MergeRollupInputs, + PrivateBaseRollupInputs, + PublicBaseRollupInputs, + RootRollupInputs, + RootRollupPublicInputs, + TubeInputs, +} from '@aztec/circuits.js/rollup'; import type { Tx } from '../tx/tx.js'; import { type ProofAndVerificationKey, type PublicInputsAndRecursiveProof } from './proving-job.js'; diff --git a/yarn-project/circuits.js/package.json b/yarn-project/circuits.js/package.json index aaf5bfa4abd..3f556edd8e3 100644 --- a/yarn-project/circuits.js/package.json +++ b/yarn-project/circuits.js/package.json @@ -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": [ diff --git a/yarn-project/circuits.js/src/structs/blob_public_inputs.test.ts b/yarn-project/circuits.js/src/structs/blobs/blob_public_inputs.test.ts similarity index 95% rename from yarn-project/circuits.js/src/structs/blob_public_inputs.test.ts rename to yarn-project/circuits.js/src/structs/blobs/blob_public_inputs.test.ts index 9dc9c42d7be..7624b088a5e 100644 --- a/yarn-project/circuits.js/src/structs/blob_public_inputs.test.ts +++ b/yarn-project/circuits.js/src/structs/blobs/blob_public_inputs.test.ts @@ -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; diff --git a/yarn-project/circuits.js/src/structs/blob_public_inputs.ts b/yarn-project/circuits.js/src/structs/blobs/blob_public_inputs.ts similarity index 99% rename from yarn-project/circuits.js/src/structs/blob_public_inputs.ts rename to yarn-project/circuits.js/src/structs/blobs/blob_public_inputs.ts index bbec9f51eaf..537bace933d 100644 --- a/yarn-project/circuits.js/src/structs/blob_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/blobs/blob_public_inputs.ts @@ -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 diff --git a/yarn-project/circuits.js/src/structs/blobs/index.ts b/yarn-project/circuits.js/src/structs/blobs/index.ts new file mode 100644 index 00000000000..f382b204680 --- /dev/null +++ b/yarn-project/circuits.js/src/structs/blobs/index.ts @@ -0,0 +1,2 @@ +export * from './blob_public_inputs.js'; +export * from './sponge_blob.js'; diff --git a/yarn-project/circuits.js/src/structs/sponge_blob.test.ts b/yarn-project/circuits.js/src/structs/blobs/sponge_blob.test.ts similarity index 93% rename from yarn-project/circuits.js/src/structs/sponge_blob.test.ts rename to yarn-project/circuits.js/src/structs/blobs/sponge_blob.test.ts index 574eb15f69c..573e0e7f7a3 100644 --- a/yarn-project/circuits.js/src/structs/sponge_blob.test.ts +++ b/yarn-project/circuits.js/src/structs/blobs/sponge_blob.test.ts @@ -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', () => { diff --git a/yarn-project/circuits.js/src/structs/sponge_blob.ts b/yarn-project/circuits.js/src/structs/blobs/sponge_blob.ts similarity index 100% rename from yarn-project/circuits.js/src/structs/sponge_blob.ts rename to yarn-project/circuits.js/src/structs/blobs/sponge_blob.ts diff --git a/yarn-project/circuits.js/src/structs/block_header.ts b/yarn-project/circuits.js/src/structs/block_header.ts index edfcabe8f78..dcb57c0b04d 100644 --- a/yarn-project/circuits.js/src/structs/block_header.ts +++ b/yarn-project/circuits.js/src/structs/block_header.ts @@ -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 { diff --git a/yarn-project/circuits.js/src/structs/index.ts b/yarn-project/circuits.js/src/structs/index.ts index 4df382c6b57..68d640ebf13 100644 --- a/yarn-project/circuits.js/src/structs/index.ts +++ b/yarn-project/circuits.js/src/structs/index.ts @@ -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'; @@ -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'; diff --git a/yarn-project/circuits.js/src/structs/partial_state_reference.ts b/yarn-project/circuits.js/src/structs/partial_state_reference.ts index 7e212e71262..1db9147bedb 100644 --- a/yarn-project/circuits.js/src/structs/partial_state_reference.ts +++ b/yarn-project/circuits.js/src/structs/partial_state_reference.ts @@ -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. diff --git a/yarn-project/circuits.js/src/structs/rollup/base_or_merge_rollup_public_inputs.ts b/yarn-project/circuits.js/src/structs/rollup/base_or_merge_rollup_public_inputs.ts index afd619bdf9a..1d9611e1c67 100644 --- a/yarn-project/circuits.js/src/structs/rollup/base_or_merge_rollup_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/rollup/base_or_merge_rollup_public_inputs.ts @@ -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'; /** diff --git a/yarn-project/circuits.js/src/structs/rollup/base_rollup_hints.ts b/yarn-project/circuits.js/src/structs/rollup/base_rollup_hints.ts index aedc17a3ee2..5450a3c25cf 100644 --- a/yarn-project/circuits.js/src/structs/rollup/base_rollup_hints.ts +++ b/yarn-project/circuits.js/src/structs/rollup/base_rollup_hints.ts @@ -3,10 +3,10 @@ import { bufferToHex, hexToBuffer } from '@aztec/foundation/string'; import { type FieldsOf } from '@aztec/foundation/types'; import { ARCHIVE_HEIGHT } from '../../constants.gen.js'; +import { SpongeBlob } from '../blobs/sponge_blob.js'; import { MembershipWitness } from '../membership_witness.js'; import { PartialStateReference } from '../partial_state_reference.js'; import { PublicDataHint } from '../public_data_hint.js'; -import { SpongeBlob } from '../sponge_blob.js'; import { ConstantRollupData } from './constant_rollup_data.js'; import { PrivateBaseStateDiffHints, PublicBaseStateDiffHints } from './state_diff_hints.js'; diff --git a/yarn-project/circuits.js/src/structs/rollup/block_root_or_block_merge_public_inputs.ts b/yarn-project/circuits.js/src/structs/rollup/block_root_or_block_merge_public_inputs.ts index 6b53806f48b..895824df0e0 100644 --- a/yarn-project/circuits.js/src/structs/rollup/block_root_or_block_merge_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/rollup/block_root_or_block_merge_public_inputs.ts @@ -6,9 +6,9 @@ import { bufferToHex, hexToBuffer } from '@aztec/foundation/string'; import { type FieldsOf } from '@aztec/foundation/types'; import { AZTEC_MAX_EPOCH_DURATION } from '../../constants.gen.js'; -import { BlockBlobPublicInputs } from '../blob_public_inputs.js'; +import { BlockBlobPublicInputs } from '../blobs/blob_public_inputs.js'; import { GlobalVariables } from '../global_variables.js'; -import { AppendOnlyTreeSnapshot } from './append_only_tree_snapshot.js'; +import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js'; /** * Output of the block root and block merge rollup circuits. diff --git a/yarn-project/circuits.js/src/structs/rollup/block_root_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/block_root_rollup.ts index d12e42a5416..f85856c37ad 100644 --- a/yarn-project/circuits.js/src/structs/rollup/block_root_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/block_root_rollup.ts @@ -13,7 +13,7 @@ import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, } from '../../constants.gen.js'; import { RootParityInput } from '../parity/root_parity_input.js'; -import { AppendOnlyTreeSnapshot } from './append_only_tree_snapshot.js'; +import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js'; import { PreviousRollupData } from './previous_rollup_data.js'; /** diff --git a/yarn-project/circuits.js/src/structs/rollup/constant_rollup_data.ts b/yarn-project/circuits.js/src/structs/rollup/constant_rollup_data.ts index 5065e997097..eacfbf46ebd 100644 --- a/yarn-project/circuits.js/src/structs/rollup/constant_rollup_data.ts +++ b/yarn-project/circuits.js/src/structs/rollup/constant_rollup_data.ts @@ -3,7 +3,7 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { type FieldsOf } from '@aztec/foundation/types'; import { GlobalVariables } from '../global_variables.js'; -import { AppendOnlyTreeSnapshot } from './append_only_tree_snapshot.js'; +import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js'; /** * Data which is forwarded through the base rollup circuits unchanged. diff --git a/yarn-project/circuits.js/src/structs/rollup/empty_block_root_rollup_inputs.ts b/yarn-project/circuits.js/src/structs/rollup/empty_block_root_rollup_inputs.ts index f4355e835a7..bdeba458fbd 100644 --- a/yarn-project/circuits.js/src/structs/rollup/empty_block_root_rollup_inputs.ts +++ b/yarn-project/circuits.js/src/structs/rollup/empty_block_root_rollup_inputs.ts @@ -5,7 +5,7 @@ import { bufferToHex, hexToBuffer } from '@aztec/foundation/string'; import { type FieldsOf } from '@aztec/foundation/types'; import { GlobalVariables } from '../global_variables.js'; -import { AppendOnlyTreeSnapshot } from './append_only_tree_snapshot.js'; +import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js'; /** * Represents inputs of the empty block root rollup circuit. diff --git a/yarn-project/circuits.js/src/structs/rollup/index.ts b/yarn-project/circuits.js/src/structs/rollup/index.ts new file mode 100644 index 00000000000..8801d9fad2f --- /dev/null +++ b/yarn-project/circuits.js/src/structs/rollup/index.ts @@ -0,0 +1,18 @@ +export * from './avm_proof_data.js'; +export * from './base_or_merge_rollup_public_inputs.js'; +export * from './base_rollup_hints.js'; +export * from './block_merge_rollup.js'; +export * from './block_root_or_block_merge_public_inputs.js'; +export * from './constant_rollup_data.js'; +export * from './empty_block_root_rollup_inputs.js'; +export * from './block_root_rollup.js'; +export * from './merge_rollup.js'; +export * from './previous_rollup_block_data.js'; +export * from './previous_rollup_data.js'; +export * from './private_base_rollup_inputs.js'; +export * from './private_tube_data.js'; +export * from './public_base_rollup_inputs.js'; +export * from './public_tube_data.js'; +export * from './root_rollup.js'; +export * from './state_diff_hints.js'; +export * from './tube_inputs.js'; diff --git a/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts index 1398b68e08a..b5eab3be568 100644 --- a/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts @@ -5,8 +5,8 @@ import { bufferToHex, hexToBuffer } from '@aztec/foundation/string'; import { type FieldsOf } from '@aztec/foundation/types'; import { AZTEC_MAX_EPOCH_DURATION } from '../../constants.gen.js'; -import { BlockBlobPublicInputs } from '../blob_public_inputs.js'; -import { AppendOnlyTreeSnapshot } from './append_only_tree_snapshot.js'; +import { BlockBlobPublicInputs } from '../blobs/blob_public_inputs.js'; +import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js'; import { FeeRecipient } from './block_root_or_block_merge_public_inputs.js'; import { PreviousRollupBlockData } from './previous_rollup_block_data.js'; diff --git a/yarn-project/circuits.js/src/structs/state_reference.ts b/yarn-project/circuits.js/src/structs/state_reference.ts index 12945a22e58..4f550dd63b4 100644 --- a/yarn-project/circuits.js/src/structs/state_reference.ts +++ b/yarn-project/circuits.js/src/structs/state_reference.ts @@ -6,7 +6,7 @@ import { z } from 'zod'; import { STATE_REFERENCE_LENGTH } from '../constants.gen.js'; import { PartialStateReference } from './partial_state_reference.js'; -import { AppendOnlyTreeSnapshot } from './rollup/append_only_tree_snapshot.js'; +import { AppendOnlyTreeSnapshot } from './trees/append_only_tree_snapshot.js'; /** * Stores snapshots of all the trees but archive. diff --git a/yarn-project/circuits.js/src/structs/tree_snapshots.ts b/yarn-project/circuits.js/src/structs/tree_snapshots.ts index c55e24be1b5..0a85f9f5383 100644 --- a/yarn-project/circuits.js/src/structs/tree_snapshots.ts +++ b/yarn-project/circuits.js/src/structs/tree_snapshots.ts @@ -4,7 +4,7 @@ import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/ import { inspect } from 'util'; import { TREE_SNAPSHOTS_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 all the trees but archive. diff --git a/yarn-project/circuits.js/src/structs/rollup/append_only_tree_snapshot.ts b/yarn-project/circuits.js/src/structs/trees/append_only_tree_snapshot.ts similarity index 100% rename from yarn-project/circuits.js/src/structs/rollup/append_only_tree_snapshot.ts rename to yarn-project/circuits.js/src/structs/trees/append_only_tree_snapshot.ts diff --git a/yarn-project/circuits.js/src/structs/trees/index.ts b/yarn-project/circuits.js/src/structs/trees/index.ts index 4143138abab..5d2659eec7c 100644 --- a/yarn-project/circuits.js/src/structs/trees/index.ts +++ b/yarn-project/circuits.js/src/structs/trees/index.ts @@ -1,2 +1,3 @@ export * from './nullifier_leaf.js'; export * from './public_data_leaf.js'; +export * from './append_only_tree_snapshot.js'; diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index a606dfb8684..b9d2eb28a1a 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -20,17 +20,14 @@ import { ARCHIVE_HEIGHT, AVM_PROOF_LENGTH_IN_FIELDS, AZTEC_MAX_EPOCH_DURATION, - AppendOnlyTreeSnapshot, AvmCircuitInputs, AvmContractInstanceHint, AvmExecutionHints, BLOBS_PER_BLOCK, - BaseOrMergeRollupPublicInputs, BaseParityInputs, CallContext, CombinedAccumulatedData, CombinedConstantData, - ConstantRollupData, ContractStorageRead, ContractStorageUpdateRequest, FIELDS_PER_BLOB, @@ -63,7 +60,6 @@ import { MAX_UNENCRYPTED_LOGS_PER_TX, MaxBlockNumber, MembershipWitness, - MergeRollupInputs, NESTED_RECURSIVE_PROOF_LENGTH, NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, @@ -81,7 +77,6 @@ import { PartialPrivateTailPublicInputsForRollup, PartialStateReference, Point, - PreviousRollupData, PrivateCallRequest, PrivateCircuitPublicInputs, PrivateKernelTailCircuitPublicInputs, @@ -99,8 +94,6 @@ import { RollupTypes, RootParityInput, RootParityInputs, - RootRollupInputs, - RootRollupPublicInputs, ScopedLogHash, StateReference, TUBE_PROOF_LENGTH, @@ -116,6 +109,8 @@ import { computePublicBytecodeCommitment, makeRecursiveProof, } from '../index.js'; +import { BlobPublicInputs, BlockBlobPublicInputs } from '../structs/blobs/blob_public_inputs.js'; +import { Poseidon2Sponge, SpongeBlob } from '../structs/blobs/sponge_blob.js'; import { BlockHeader } from '../structs/block_header.js'; import { ContentCommitment, NUM_BYTES_PER_SHA256 } from '../structs/content_commitment.js'; import { Gas } from '../structs/gas.js'; @@ -130,44 +125,44 @@ import { AvmEnqueuedCallHint, AvmNullifierReadTreeHint, AvmNullifierWriteTreeHint, - AvmProofData, AvmPublicDataReadTreeHint, AvmPublicDataWriteTreeHint, - BlobPublicInputs, - BlockBlobPublicInputs, CountedPublicCallRequest, - Poseidon2Sponge, - PrivateBaseRollupHints, - PrivateBaseRollupInputs, - PrivateBaseStateDiffHints, PrivateLog, PrivateLogData, PrivateToAvmAccumulatedData, PrivateToAvmAccumulatedDataArrayLengths, PrivateToPublicAccumulatedData, PrivateToPublicKernelCircuitPublicInputs, - PrivateTubeData, - PublicBaseRollupHints, - PublicBaseRollupInputs, - PublicBaseStateDiffHints, PublicDataWrite, - PublicTubeData, ScopedL2ToL1Message, - SpongeBlob, TreeSnapshots, TxConstantData, VkWitnessData, } from '../structs/index.js'; import { KernelCircuitPublicInputs } from '../structs/kernel/kernel_circuit_public_inputs.js'; +import { AvmProofData } from '../structs/rollup/avm_proof_data.js'; +import { BaseOrMergeRollupPublicInputs } from '../structs/rollup/base_or_merge_rollup_public_inputs.js'; +import { PrivateBaseRollupHints, PublicBaseRollupHints } from '../structs/rollup/base_rollup_hints.js'; import { BlockMergeRollupInputs } from '../structs/rollup/block_merge_rollup.js'; import { BlockRootOrBlockMergePublicInputs, FeeRecipient, } from '../structs/rollup/block_root_or_block_merge_public_inputs.js'; import { BlockRootRollupInputs } from '../structs/rollup/block_root_rollup.js'; +import { ConstantRollupData } from '../structs/rollup/constant_rollup_data.js'; import { EmptyBlockRootRollupInputs } from '../structs/rollup/empty_block_root_rollup_inputs.js'; +import { MergeRollupInputs } from '../structs/rollup/merge_rollup.js'; import { PreviousRollupBlockData } from '../structs/rollup/previous_rollup_block_data.js'; +import { PreviousRollupData } from '../structs/rollup/previous_rollup_data.js'; +import { PrivateBaseRollupInputs } from '../structs/rollup/private_base_rollup_inputs.js'; +import { PrivateTubeData } from '../structs/rollup/private_tube_data.js'; +import { PublicBaseRollupInputs } from '../structs/rollup/public_base_rollup_inputs.js'; +import { PublicTubeData } from '../structs/rollup/public_tube_data.js'; +import { RootRollupInputs, RootRollupPublicInputs } from '../structs/rollup/root_rollup.js'; +import { PrivateBaseStateDiffHints, PublicBaseStateDiffHints } from '../structs/rollup/state_diff_hints.js'; import { RollupValidationRequests } from '../structs/rollup_validation_requests.js'; +import { AppendOnlyTreeSnapshot } from '../structs/trees/append_only_tree_snapshot.js'; /** * Creates an arbitrary side effect object with the given seed. diff --git a/yarn-project/ethereum/package.json b/yarn-project/ethereum/package.json index aa01b556c17..1a5d81a38a8 100644 --- a/yarn-project/ethereum/package.json +++ b/yarn-project/ethereum/package.json @@ -5,7 +5,8 @@ "exports": { ".": "./dest/index.js", "./test": "./dest/test/index.js", - "./contracts": "./dest/contracts/index.js" + "./contracts": "./dest/contracts/index.js", + "./l1-contract-addresses": "./dest/l1_contract_addresses.js" }, "typedocOptions": { "entryPoints": [ diff --git a/yarn-project/noir-protocol-circuits-types/src/conversion/client.ts b/yarn-project/noir-protocol-circuits-types/src/conversion/client.ts new file mode 100644 index 00000000000..5ac5dbc4918 --- /dev/null +++ b/yarn-project/noir-protocol-circuits-types/src/conversion/client.ts @@ -0,0 +1,856 @@ +import { + CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS, + CallContext, + CountedPublicCallRequest, + Fr, + FunctionData, + type KeyValidationHint, + KeyValidationRequest, + KeyValidationRequestAndGenerator, + LogHash, + MAX_CONTRACT_CLASS_LOGS_PER_TX, + MAX_ENQUEUED_CALLS_PER_TX, + MAX_KEY_VALIDATION_REQUESTS_PER_TX, + MAX_L2_TO_L1_MSGS_PER_TX, + MAX_NOTE_HASHES_PER_TX, + MAX_NOTE_HASH_READ_REQUESTS_PER_TX, + MAX_NULLIFIERS_PER_TX, + MAX_NULLIFIER_READ_REQUESTS_PER_TX, + MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, + MAX_PRIVATE_LOGS_PER_TX, + type NOTE_HASH_TREE_HEIGHT, + type NULLIFIER_TREE_HEIGHT, + NoteHash, + type NoteHashReadRequestHints, + Nullifier, + type NullifierLeafPreimage, + type NullifierReadRequestHints, + PartialPrivateTailPublicInputsForPublic, + PartialPrivateTailPublicInputsForRollup, + type PendingReadHint, + PrivateAccumulatedData, + type PrivateCallData, + PrivateCallRequest, + type PrivateCircuitPublicInputs, + PrivateKernelCircuitPublicInputs, + type PrivateKernelData, + type PrivateKernelResetHints, + PrivateKernelTailCircuitPublicInputs, + PrivateLogData, + PrivateToPublicAccumulatedData, + PrivateValidationRequests, + type PublicKeys, + ReadRequest, + type ReadRequestStatus, + RollupValidationRequests, + ScopedKeyValidationRequestAndGenerator, + ScopedLogHash, + ScopedNoteHash, + ScopedNullifier, + ScopedPrivateLogData, + ScopedReadRequest, + type SettledReadHint, + type TransientDataIndexHint, + TxConstantData, + type TxRequest, +} from '@aztec/circuits.js'; +import { mapTuple } from '@aztec/foundation/serialize'; + +import type { + CallContext as CallContextNoir, + Counted as CountedPublicCallRequestNoir, + FixedLengthArray, + FunctionData as FunctionDataNoir, + KernelCircuitPublicInputs as KernelCircuitPublicInputsNoir, + KeyValidationHint as KeyValidationHintNoir, + KeyValidationRequestAndGenerator as KeyValidationRequestAndGeneratorNoir, + KeyValidationRequest as KeyValidationRequestsNoir, + LogHash as LogHashNoir, + NoteHashLeafPreimage as NoteHashLeafPreimageNoir, + NoteHash as NoteHashNoir, + NoteHashReadRequestHints as NoteHashReadRequestHintsNoir, + NoteHashSettledReadHint as NoteHashSettledReadHintNoir, + Nullifier as NullifierNoir, + NullifierReadRequestHints as NullifierReadRequestHintsNoir, + NullifierSettledReadHint as NullifierSettledReadHintNoir, + PendingReadHint as PendingReadHintNoir, + PrivateAccumulatedData as PrivateAccumulatedDataNoir, + PrivateCallDataWithoutPublicInputs as PrivateCallDataWithoutPublicInputsNoir, + PrivateCallRequest as PrivateCallRequestNoir, + PrivateCircuitPublicInputs as PrivateCircuitPublicInputsNoir, + PrivateKernelCircuitPublicInputs as PrivateKernelCircuitPublicInputsNoir, + PrivateKernelDataWithoutPublicInputs as PrivateKernelDataWithoutPublicInputsNoir, + PrivateKernelResetHints as PrivateKernelResetHintsNoir, + PrivateLogData as PrivateLogDataNoir, + PrivateToPublicAccumulatedData as PrivateToPublicAccumulatedDataNoir, + PrivateToPublicKernelCircuitPublicInputs as PrivateToPublicKernelCircuitPublicInputsNoir, + PrivateValidationRequests as PrivateValidationRequestsNoir, + PublicKeys as PublicKeysNoir, + ReadRequest as ReadRequestNoir, + ReadRequestStatus as ReadRequestStatusNoir, + RollupValidationRequests as RollupValidationRequestsNoir, + ScopedKeyValidationRequestAndGenerator as ScopedKeyValidationRequestAndGeneratorNoir, + ScopedLogHash as ScopedLogHashNoir, + ScopedNoteHash as ScopedNoteHashNoir, + ScopedNullifier as ScopedNullifierNoir, + Scoped as ScopedPrivateLogDataNoir, + ScopedReadRequest as ScopedReadRequestNoir, + TransientDataIndexHint as TransientDataIndexHintNoir, + TxConstantData as TxConstantDataNoir, + TxRequest as TxRequestNoir, +} from '../types/index.js'; +import { + mapAztecAddressFromNoir, + mapAztecAddressToNoir, + mapCombinedAccumulatedDataFromNoir, + mapFieldFromNoir, + mapFieldToNoir, + mapFunctionSelectorFromNoir, + mapFunctionSelectorToNoir, + mapGasFromNoir, + mapGrumpkinScalarToNoir, + mapHeaderFromNoir, + mapHeaderToNoir, + mapL2ToL1MessageToNoir, + mapMaxBlockNumberFromNoir, + mapMaxBlockNumberToNoir, + mapMembershipWitnessToNoir, + mapNullifierLeafPreimageToNoir, + mapNumberFromNoir, + mapNumberToNoir, + mapOptionalNumberFromNoir, + mapOptionalNumberToNoir, + mapPointFromNoir, + mapPointToNoir, + mapPrivateLogFromNoir, + mapPrivateLogToNoir, + mapPublicCallRequestFromNoir, + mapPublicCallRequestToNoir, + mapScopedL2ToL1MessageFromNoir, + mapScopedL2ToL1MessageToNoir, + mapTupleFromNoir, + mapTxContextFromNoir, + mapTxContextToNoir, + mapVerificationKeyToNoir, + mapWrappedFieldToNoir, +} from './common.js'; + +/* eslint-disable camelcase */ + +/** + * Maps a function data to a noir function data. + * @param functionData - The function data. + * @returns The noir function data. + */ +export function mapFunctionDataToNoir(functionData: FunctionData): FunctionDataNoir { + return { + selector: mapFunctionSelectorToNoir(functionData.selector), + is_private: functionData.isPrivate, + }; +} + +/** + * Maps a tx request to a noir tx request. + * @param txRequest - The tx request. + * @returns The noir tx request. + */ +export function mapTxRequestToNoir(txRequest: TxRequest): TxRequestNoir { + return { + origin: mapAztecAddressToNoir(txRequest.origin), + args_hash: mapFieldToNoir(txRequest.argsHash), + tx_context: mapTxContextToNoir(txRequest.txContext), + function_data: mapFunctionDataToNoir(txRequest.functionData), + }; +} + +function mapNoteHashToNoir(noteHash: NoteHash): NoteHashNoir { + return { + value: mapFieldToNoir(noteHash.value), + counter: mapNumberToNoir(noteHash.counter), + }; +} + +function mapNoteHashFromNoir(noteHash: NoteHashNoir) { + return new NoteHash(mapFieldFromNoir(noteHash.value), mapNumberFromNoir(noteHash.counter)); +} + +function mapScopedNoteHashToNoir(noteHash: ScopedNoteHash): ScopedNoteHashNoir { + return { + note_hash: mapNoteHashToNoir(noteHash.noteHash), + contract_address: mapAztecAddressToNoir(noteHash.contractAddress), + }; +} + +function mapScopedNoteHashFromNoir(noteHash: ScopedNoteHashNoir) { + return new ScopedNoteHash( + mapNoteHashFromNoir(noteHash.note_hash), + mapAztecAddressFromNoir(noteHash.contract_address), + ); +} + +function mapNullifierToNoir(nullifier: Nullifier): NullifierNoir { + return { + value: mapFieldToNoir(nullifier.value), + counter: mapNumberToNoir(nullifier.counter), + note_hash: mapFieldToNoir(nullifier.noteHash), + }; +} + +function mapNullifierFromNoir(nullifier: NullifierNoir) { + return new Nullifier( + mapFieldFromNoir(nullifier.value), + mapNumberFromNoir(nullifier.counter), + mapFieldFromNoir(nullifier.note_hash), + ); +} + +function mapScopedNullifierToNoir(nullifier: ScopedNullifier): ScopedNullifierNoir { + return { + nullifier: mapNullifierToNoir(nullifier.nullifier), + contract_address: mapAztecAddressToNoir(nullifier.contractAddress), + }; +} + +function mapScopedNullifierFromNoir(nullifier: ScopedNullifierNoir) { + return new ScopedNullifier( + mapNullifierFromNoir(nullifier.nullifier), + mapAztecAddressFromNoir(nullifier.contract_address), + ); +} + +function mapPrivateLogDataToNoir(data: PrivateLogData): PrivateLogDataNoir { + return { + log: mapPrivateLogToNoir(data.log), + note_hash_counter: mapNumberToNoir(data.noteHashCounter), + counter: mapNumberToNoir(data.counter), + }; +} + +function mapPrivateLogDataFromNoir(data: PrivateLogDataNoir) { + return new PrivateLogData( + mapPrivateLogFromNoir(data.log), + mapNumberFromNoir(data.note_hash_counter), + mapNumberFromNoir(data.counter), + ); +} + +function mapScopedPrivateLogDataToNoir(data: ScopedPrivateLogData): ScopedPrivateLogDataNoir { + return { + inner: mapPrivateLogDataToNoir(data.inner), + contract_address: mapAztecAddressToNoir(data.contractAddress), + }; +} + +function mapScopedPrivateLogDataFromNoir(data: ScopedPrivateLogDataNoir) { + return new ScopedPrivateLogData( + mapPrivateLogDataFromNoir(data.inner), + mapAztecAddressFromNoir(data.contract_address), + ); +} + +/** + * Maps a LogHash to a noir LogHash. + * @param logHash - The LogHash. + * @returns The noir log hash. + */ +function mapLogHashToNoir(logHash: LogHash): LogHashNoir { + return { + value: mapFieldToNoir(logHash.value), + counter: mapNumberToNoir(logHash.counter), + length: mapFieldToNoir(logHash.length), + }; +} + +/** + * Maps a noir LogHash to a LogHash. + * @param logHash - The noir LogHash. + * @returns The TS log hash. + */ +function mapLogHashFromNoir(logHash: LogHashNoir): LogHash { + return new LogHash( + mapFieldFromNoir(logHash.value), + mapNumberFromNoir(logHash.counter), + mapFieldFromNoir(logHash.length), + ); +} + +/** + * Maps a ts ScopedLogHash to a noir ScopedLogHash. + * @param logHash - The ts LogHash. + * @returns The noir log hash. + */ +function mapScopedLogHashToNoir(scopedLogHash: ScopedLogHash): ScopedLogHashNoir { + return { + log_hash: mapLogHashToNoir(scopedLogHash.logHash), + contract_address: mapAztecAddressToNoir(scopedLogHash.contractAddress), + }; +} + +/** + * Maps a noir ScopedLogHash to a ts ScopedLogHash. + * @param logHash - The noir LogHash. + * @returns The TS log hash. + */ +function mapScopedLogHashFromNoir(scopedLogHash: ScopedLogHashNoir): ScopedLogHash { + return new ScopedLogHash( + mapLogHashFromNoir(scopedLogHash.log_hash), + mapAztecAddressFromNoir(scopedLogHash.contract_address), + ); +} + +/** + * Maps a noir ReadRequest to ReadRequest. + * @param readRequest - The noir ReadRequest. + * @returns The TS ReadRequest. + */ +function mapReadRequestFromNoir(readRequest: ReadRequestNoir): ReadRequest { + return new ReadRequest(mapFieldFromNoir(readRequest.value), mapNumberFromNoir(readRequest.counter)); +} + +function mapScopedReadRequestToNoir(scopedReadRequest: ScopedReadRequest): ScopedReadRequestNoir { + return { + read_request: mapReadRequestToNoir(scopedReadRequest.readRequest), + contract_address: mapAztecAddressToNoir(scopedReadRequest.contractAddress), + }; +} + +/** + * Maps a noir ReadRequest to ReadRequest. + * @param readRequest - The noir ReadRequest. + * @returns The TS ReadRequest. + */ +export function mapScopedReadRequestFromNoir(scoped: ScopedReadRequestNoir): ScopedReadRequest { + return new ScopedReadRequest( + mapReadRequestFromNoir(scoped.read_request), + mapAztecAddressFromNoir(scoped.contract_address), + ); +} + +/** + * Maps a KeyValidationRequest to a noir KeyValidationRequest. + * @param request - The KeyValidationRequest. + * @returns The noir KeyValidationRequest. + */ +export function mapKeyValidationRequestToNoir(request: KeyValidationRequest): KeyValidationRequestsNoir { + return { + pk_m: mapPointToNoir(request.pkM), + sk_app: mapFieldToNoir(request.skApp), + }; +} + +export function mapKeyValidationRequestAndGeneratorToNoir( + request: KeyValidationRequestAndGenerator, +): KeyValidationRequestAndGeneratorNoir { + return { + request: mapKeyValidationRequestToNoir(request.request), + sk_app_generator: mapFieldToNoir(request.skAppGenerator), + }; +} + +/** + * Maps a noir KeyValidationRequest to KeyValidationRequest. + * @param request - The noir KeyValidationRequest. + * @returns The TS KeyValidationRequest. + */ +function mapKeyValidationRequestFromNoir(request: KeyValidationRequestsNoir): KeyValidationRequest { + return new KeyValidationRequest(mapPointFromNoir(request.pk_m), mapFieldFromNoir(request.sk_app)); +} + +function mapKeyValidationRequestAndGeneratorFromNoir( + request: KeyValidationRequestAndGeneratorNoir, +): KeyValidationRequestAndGenerator { + return new KeyValidationRequestAndGenerator( + mapKeyValidationRequestFromNoir(request.request), + mapFieldFromNoir(request.sk_app_generator), + ); +} + +function mapScopedKeyValidationRequestAndGeneratorToNoir( + request: ScopedKeyValidationRequestAndGenerator, +): ScopedKeyValidationRequestAndGeneratorNoir { + return { + request: mapKeyValidationRequestAndGeneratorToNoir(request.request), + contract_address: mapAztecAddressToNoir(request.contractAddress), + }; +} + +function mapScopedKeyValidationRequestAndGeneratorFromNoir( + request: ScopedKeyValidationRequestAndGeneratorNoir, +): ScopedKeyValidationRequestAndGenerator { + return new ScopedKeyValidationRequestAndGenerator( + mapKeyValidationRequestAndGeneratorFromNoir(request.request), + mapAztecAddressFromNoir(request.contract_address), + ); +} + +/** + * Maps a call context to a noir call context. + * @param callContext - The call context. + * @returns The noir call context. + */ +export function mapCallContextFromNoir(callContext: CallContextNoir): CallContext { + return new CallContext( + mapAztecAddressFromNoir(callContext.msg_sender), + mapAztecAddressFromNoir(callContext.contract_address), + mapFunctionSelectorFromNoir(callContext.function_selector), + callContext.is_static_call, + ); +} + +/** + * Maps a call context to a noir call context. + * @param callContext - The call context. + * @returns The noir call context. + */ +export function mapCallContextToNoir(callContext: CallContext): CallContextNoir { + return { + msg_sender: mapAztecAddressToNoir(callContext.msgSender), + contract_address: mapAztecAddressToNoir(callContext.contractAddress), + function_selector: mapFunctionSelectorToNoir(callContext.functionSelector), + is_static_call: callContext.isStaticCall, + }; +} + +function mapPrivateCallRequestFromNoir(callRequest: PrivateCallRequestNoir) { + return new PrivateCallRequest( + mapCallContextFromNoir(callRequest.call_context), + mapFieldFromNoir(callRequest.args_hash), + mapFieldFromNoir(callRequest.returns_hash), + mapNumberFromNoir(callRequest.start_side_effect_counter), + mapNumberFromNoir(callRequest.end_side_effect_counter), + ); +} + +function mapPrivateCallRequestToNoir(callRequest: PrivateCallRequest): PrivateCallRequestNoir { + return { + call_context: mapCallContextToNoir(callRequest.callContext), + args_hash: mapFieldToNoir(callRequest.argsHash), + returns_hash: mapFieldToNoir(callRequest.returnsHash), + start_side_effect_counter: mapNumberToNoir(callRequest.startSideEffectCounter), + end_side_effect_counter: mapNumberToNoir(callRequest.endSideEffectCounter), + }; +} + +function mapCountedPublicCallRequestFromNoir(request: CountedPublicCallRequestNoir) { + return new CountedPublicCallRequest(mapPublicCallRequestFromNoir(request.inner), mapNumberFromNoir(request.counter)); +} + +function mapCountedPublicCallRequestToNoir(request: CountedPublicCallRequest): CountedPublicCallRequestNoir { + return { + inner: mapPublicCallRequestToNoir(request.inner), + counter: mapNumberToNoir(request.counter), + }; +} + +/** + * Maps a ReadRequest to a noir ReadRequest. + * @param readRequest - The read request. + * @returns The noir ReadRequest. + */ +function mapReadRequestToNoir(readRequest: ReadRequest): ReadRequestNoir { + return { + value: mapFieldToNoir(readRequest.value), + counter: mapNumberToNoir(readRequest.counter), + }; +} + +export function mapRollupValidationRequestsToNoir( + rollupValidationRequests: RollupValidationRequests, +): RollupValidationRequestsNoir { + return { + max_block_number: mapMaxBlockNumberToNoir(rollupValidationRequests.maxBlockNumber), + }; +} + +export function mapRollupValidationRequestsFromNoir( + rollupValidationRequests: RollupValidationRequestsNoir, +): RollupValidationRequests { + return new RollupValidationRequests(mapMaxBlockNumberFromNoir(rollupValidationRequests.max_block_number)); +} + +function mapPrivateValidationRequestsToNoir(requests: PrivateValidationRequests): PrivateValidationRequestsNoir { + return { + for_rollup: mapRollupValidationRequestsToNoir(requests.forRollup), + note_hash_read_requests: mapTuple(requests.noteHashReadRequests, mapScopedReadRequestToNoir), + nullifier_read_requests: mapTuple(requests.nullifierReadRequests, mapScopedReadRequestToNoir), + scoped_key_validation_requests_and_generators: mapTuple( + requests.scopedKeyValidationRequestsAndGenerators, + mapScopedKeyValidationRequestAndGeneratorToNoir, + ), + split_counter: mapOptionalNumberToNoir(requests.splitCounter), + }; +} + +function mapPrivateValidationRequestsFromNoir(requests: PrivateValidationRequestsNoir) { + return new PrivateValidationRequests( + mapRollupValidationRequestsFromNoir(requests.for_rollup), + mapTupleFromNoir( + requests.note_hash_read_requests, + MAX_NOTE_HASH_READ_REQUESTS_PER_TX, + mapScopedReadRequestFromNoir, + ), + mapTupleFromNoir( + requests.nullifier_read_requests, + MAX_NULLIFIER_READ_REQUESTS_PER_TX, + mapScopedReadRequestFromNoir, + ), + mapTupleFromNoir( + requests.scoped_key_validation_requests_and_generators, + MAX_KEY_VALIDATION_REQUESTS_PER_TX, + mapScopedKeyValidationRequestAndGeneratorFromNoir, + ), + mapOptionalNumberFromNoir(requests.split_counter), + ); +} + +export function mapPrivateAccumulatedDataFromNoir( + privateAccumulatedData: PrivateAccumulatedDataNoir, +): PrivateAccumulatedData { + return new PrivateAccumulatedData( + mapTupleFromNoir(privateAccumulatedData.note_hashes, MAX_NOTE_HASHES_PER_TX, mapScopedNoteHashFromNoir), + mapTupleFromNoir(privateAccumulatedData.nullifiers, MAX_NULLIFIERS_PER_TX, mapScopedNullifierFromNoir), + mapTupleFromNoir(privateAccumulatedData.l2_to_l1_msgs, MAX_L2_TO_L1_MSGS_PER_TX, mapScopedL2ToL1MessageFromNoir), + mapTupleFromNoir(privateAccumulatedData.private_logs, MAX_PRIVATE_LOGS_PER_TX, mapScopedPrivateLogDataFromNoir), + mapTupleFromNoir( + privateAccumulatedData.contract_class_logs_hashes, + MAX_CONTRACT_CLASS_LOGS_PER_TX, + mapScopedLogHashFromNoir, + ), + mapTupleFromNoir( + privateAccumulatedData.public_call_requests, + MAX_ENQUEUED_CALLS_PER_TX, + mapCountedPublicCallRequestFromNoir, + ), + mapTupleFromNoir( + privateAccumulatedData.private_call_stack, + MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, + mapPrivateCallRequestFromNoir, + ), + ); +} + +export function mapPrivateAccumulatedDataToNoir(data: PrivateAccumulatedData): PrivateAccumulatedDataNoir { + return { + note_hashes: mapTuple(data.noteHashes, mapScopedNoteHashToNoir), + nullifiers: mapTuple(data.nullifiers, mapScopedNullifierToNoir), + l2_to_l1_msgs: mapTuple(data.l2ToL1Msgs, mapScopedL2ToL1MessageToNoir), + private_logs: mapTuple(data.privateLogs, mapScopedPrivateLogDataToNoir), + contract_class_logs_hashes: mapTuple(data.contractClassLogsHashes, mapScopedLogHashToNoir), + public_call_requests: mapTuple(data.publicCallRequests, mapCountedPublicCallRequestToNoir), + private_call_stack: mapTuple(data.privateCallStack, mapPrivateCallRequestToNoir), + }; +} + +/** + * Maps private circuit public inputs to noir private circuit public inputs. + * @param privateCircuitPublicInputs - The private circuit public inputs. + * @returns The noir private circuit public inputs. + */ +export function mapPrivateCircuitPublicInputsToNoir( + privateCircuitPublicInputs: PrivateCircuitPublicInputs, +): PrivateCircuitPublicInputsNoir { + return { + max_block_number: mapMaxBlockNumberToNoir(privateCircuitPublicInputs.maxBlockNumber), + call_context: mapCallContextToNoir(privateCircuitPublicInputs.callContext), + args_hash: mapFieldToNoir(privateCircuitPublicInputs.argsHash), + returns_hash: mapFieldToNoir(privateCircuitPublicInputs.returnsHash), + note_hash_read_requests: mapTuple(privateCircuitPublicInputs.noteHashReadRequests, mapReadRequestToNoir), + nullifier_read_requests: mapTuple(privateCircuitPublicInputs.nullifierReadRequests, mapReadRequestToNoir), + key_validation_requests_and_generators: mapTuple( + privateCircuitPublicInputs.keyValidationRequestsAndGenerators, + mapKeyValidationRequestAndGeneratorToNoir, + ), + note_hashes: mapTuple(privateCircuitPublicInputs.noteHashes, mapNoteHashToNoir), + nullifiers: mapTuple(privateCircuitPublicInputs.nullifiers, mapNullifierToNoir), + private_call_requests: mapTuple(privateCircuitPublicInputs.privateCallRequests, mapPrivateCallRequestToNoir), + public_call_requests: mapTuple(privateCircuitPublicInputs.publicCallRequests, mapCountedPublicCallRequestToNoir), + public_teardown_call_request: mapPublicCallRequestToNoir(privateCircuitPublicInputs.publicTeardownCallRequest), + l2_to_l1_msgs: mapTuple(privateCircuitPublicInputs.l2ToL1Msgs, mapL2ToL1MessageToNoir), + private_logs: mapTuple(privateCircuitPublicInputs.privateLogs, mapPrivateLogDataToNoir), + contract_class_logs_hashes: mapTuple(privateCircuitPublicInputs.contractClassLogsHashes, mapLogHashToNoir), + start_side_effect_counter: mapFieldToNoir(privateCircuitPublicInputs.startSideEffectCounter), + end_side_effect_counter: mapFieldToNoir(privateCircuitPublicInputs.endSideEffectCounter), + historical_header: mapHeaderToNoir(privateCircuitPublicInputs.historicalHeader), + tx_context: mapTxContextToNoir(privateCircuitPublicInputs.txContext), + min_revertible_side_effect_counter: mapFieldToNoir(privateCircuitPublicInputs.minRevertibleSideEffectCounter), + is_fee_payer: privateCircuitPublicInputs.isFeePayer, + }; +} + +export function mapPublicKeysToNoir(publicKeys: PublicKeys): PublicKeysNoir { + return { + npk_m: { + inner: mapPointToNoir(publicKeys.masterNullifierPublicKey), + }, + ivpk_m: { + inner: mapPointToNoir(publicKeys.masterIncomingViewingPublicKey), + }, + ovpk_m: { + inner: mapPointToNoir(publicKeys.masterOutgoingViewingPublicKey), + }, + tpk_m: { + inner: mapPointToNoir(publicKeys.masterTaggingPublicKey), + }, + }; +} + +/** + * Maps a noir function data to a function data. + * @param functionData - The noir function data. + * @returns The function data. + */ +export function mapFunctionDataFromNoir(functionData: FunctionDataNoir): FunctionData { + return new FunctionData(mapFunctionSelectorFromNoir(functionData.selector), functionData.is_private); +} + +/** + * Maps a private call data to a noir private call data. + * @param privateCallData - The private call data. + * @returns The noir private call data. + */ +export function mapPrivateCallDataToNoir(privateCallData: PrivateCallData): PrivateCallDataWithoutPublicInputsNoir { + return { + vk: mapVerificationKeyToNoir(privateCallData.vk, CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS), + function_leaf_membership_witness: mapMembershipWitnessToNoir(privateCallData.functionLeafMembershipWitness), + contract_class_artifact_hash: mapFieldToNoir(privateCallData.contractClassArtifactHash), + contract_class_public_bytecode_commitment: mapFieldToNoir(privateCallData.contractClassPublicBytecodeCommitment), + public_keys: mapPublicKeysToNoir(privateCallData.publicKeys), + salted_initialization_hash: mapWrappedFieldToNoir(privateCallData.saltedInitializationHash), + protocol_contract_sibling_path: mapTuple(privateCallData.protocolContractSiblingPath, mapFieldToNoir), + acir_hash: mapFieldToNoir(privateCallData.acirHash), + }; +} + +function mapTxConstantDataFromNoir(data: TxConstantDataNoir) { + return new TxConstantData( + mapHeaderFromNoir(data.historical_header), + mapTxContextFromNoir(data.tx_context), + mapFieldFromNoir(data.vk_tree_root), + mapFieldFromNoir(data.protocol_contract_tree_root), + ); +} + +function mapTxConstantDataToNoir(data: TxConstantData): TxConstantDataNoir { + return { + historical_header: mapHeaderToNoir(data.historicalHeader), + tx_context: mapTxContextToNoir(data.txContext), + vk_tree_root: mapFieldToNoir(data.vkTreeRoot), + protocol_contract_tree_root: mapFieldToNoir(data.protocolContractTreeRoot), + }; +} + +export function mapPrivateKernelCircuitPublicInputsFromNoir( + inputs: PrivateKernelCircuitPublicInputsNoir, +): PrivateKernelCircuitPublicInputs { + return new PrivateKernelCircuitPublicInputs( + mapTxConstantDataFromNoir(inputs.constants), + mapFieldFromNoir(inputs.min_revertible_side_effect_counter), + mapPrivateValidationRequestsFromNoir(inputs.validation_requests), + mapPrivateAccumulatedDataFromNoir(inputs.end), + mapPublicCallRequestFromNoir(inputs.public_teardown_call_request), + mapAztecAddressFromNoir(inputs.fee_payer), + inputs.is_private_only, + ); +} + +export function mapPrivateKernelCircuitPublicInputsToNoir( + inputs: PrivateKernelCircuitPublicInputs, +): PrivateKernelCircuitPublicInputsNoir { + return { + constants: mapTxConstantDataToNoir(inputs.constants), + validation_requests: mapPrivateValidationRequestsToNoir(inputs.validationRequests), + end: mapPrivateAccumulatedDataToNoir(inputs.end), + min_revertible_side_effect_counter: mapFieldToNoir(inputs.minRevertibleSideEffectCounter), + public_teardown_call_request: mapPublicCallRequestToNoir(inputs.publicTeardownCallRequest), + fee_payer: mapAztecAddressToNoir(inputs.feePayer), + is_private_only: inputs.isPrivateOnly, + }; +} + +/** + * Maps a private kernel inner data to a noir private kernel inner data. + * @param privateKernelInnerData - The private kernel inner data. + * @returns The noir private kernel inner data. + */ +export function mapPrivateKernelDataToNoir( + privateKernelInnerData: PrivateKernelData, +): PrivateKernelDataWithoutPublicInputsNoir { + return { + vk: mapVerificationKeyToNoir(privateKernelInnerData.vk, CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS), + vk_index: mapFieldToNoir(new Fr(privateKernelInnerData.vkIndex)), + vk_path: mapTuple(privateKernelInnerData.vkPath, mapFieldToNoir), + }; +} + +export function mapPrivateKernelTailCircuitPublicInputsForRollupFromNoir( + inputs: KernelCircuitPublicInputsNoir, +): PrivateKernelTailCircuitPublicInputs { + const forRollup = new PartialPrivateTailPublicInputsForRollup(mapCombinedAccumulatedDataFromNoir(inputs.end)); + return new PrivateKernelTailCircuitPublicInputs( + mapTxConstantDataFromNoir(inputs.constants), + mapRollupValidationRequestsFromNoir(inputs.rollup_validation_requests), + mapGasFromNoir(inputs.gas_used), + mapAztecAddressFromNoir(inputs.fee_payer), + undefined, + forRollup, + ); +} + +export function mapPrivateToPublicAccumulatedDataFromNoir(data: PrivateToPublicAccumulatedDataNoir) { + return new PrivateToPublicAccumulatedData( + mapTupleFromNoir(data.note_hashes, MAX_NOTE_HASHES_PER_TX, mapFieldFromNoir), + mapTupleFromNoir(data.nullifiers, MAX_NULLIFIERS_PER_TX, mapFieldFromNoir), + mapTupleFromNoir(data.l2_to_l1_msgs, MAX_L2_TO_L1_MSGS_PER_TX, mapScopedL2ToL1MessageFromNoir), + mapTupleFromNoir(data.private_logs, MAX_PRIVATE_LOGS_PER_TX, mapPrivateLogFromNoir), + mapTupleFromNoir(data.contract_class_logs_hashes, MAX_CONTRACT_CLASS_LOGS_PER_TX, mapScopedLogHashFromNoir), + mapTupleFromNoir(data.public_call_requests, MAX_ENQUEUED_CALLS_PER_TX, mapPublicCallRequestFromNoir), + ); +} + +export function mapPrivateKernelTailCircuitPublicInputsForPublicFromNoir( + inputs: PrivateToPublicKernelCircuitPublicInputsNoir, +): PrivateKernelTailCircuitPublicInputs { + const forPublic = new PartialPrivateTailPublicInputsForPublic( + mapPrivateToPublicAccumulatedDataFromNoir(inputs.non_revertible_accumulated_data), + mapPrivateToPublicAccumulatedDataFromNoir(inputs.revertible_accumulated_data), + mapPublicCallRequestFromNoir(inputs.public_teardown_call_request), + ); + return new PrivateKernelTailCircuitPublicInputs( + mapTxConstantDataFromNoir(inputs.constants), + mapRollupValidationRequestsFromNoir(inputs.rollup_validation_requests), + mapGasFromNoir(inputs.gas_used), + mapAztecAddressFromNoir(inputs.fee_payer), + forPublic, + ); +} + +function mapTransientDataIndexHintToNoir(indexHint: TransientDataIndexHint): TransientDataIndexHintNoir { + return { + nullifier_index: mapNumberToNoir(indexHint.nullifierIndex), + note_hash_index: mapNumberToNoir(indexHint.noteHashIndex), + }; +} + +function mapReadRequestStatusToNoir(readRequestStatus: ReadRequestStatus): ReadRequestStatusNoir { + return { + state: mapNumberToNoir(readRequestStatus.state), + hint_index: mapNumberToNoir(readRequestStatus.hintIndex), + }; +} + +function mapPendingReadHintToNoir(hint: PendingReadHint): PendingReadHintNoir { + return { + read_request_index: mapNumberToNoir(hint.readRequestIndex), + pending_value_index: mapNumberToNoir(hint.pendingValueIndex), + }; +} + +function mapNoteHashLeafPreimageToNoir(noteHashLeafValue: Fr): NoteHashLeafPreimageNoir { + return { + value: mapFieldToNoir(noteHashLeafValue), + }; +} + +function mapNoteHashSettledReadHintToNoir( + hint: SettledReadHint, +): NoteHashSettledReadHintNoir { + return { + read_request_index: mapNumberToNoir(hint.readRequestIndex), + membership_witness: mapMembershipWitnessToNoir(hint.membershipWitness), + leaf_preimage: mapNoteHashLeafPreimageToNoir(hint.leafPreimage), + }; +} + +function mapNullifierSettledReadHintToNoir( + hint: SettledReadHint, +): NullifierSettledReadHintNoir { + return { + read_request_index: mapNumberToNoir(hint.readRequestIndex), + membership_witness: mapMembershipWitnessToNoir(hint.membershipWitness), + leaf_preimage: mapNullifierLeafPreimageToNoir(hint.leafPreimage), + }; +} + +function mapNoteHashReadRequestHintsToNoir( + hints: NoteHashReadRequestHints, +): NoteHashReadRequestHintsNoir { + return { + read_request_statuses: mapTuple(hints.readRequestStatuses, mapReadRequestStatusToNoir), + pending_read_hints: hints.pendingReadHints.map(mapPendingReadHintToNoir) as FixedLengthArray< + PendingReadHintNoir, + PENDING + >, + settled_read_hints: hints.settledReadHints.map(mapNoteHashSettledReadHintToNoir) as FixedLengthArray< + NoteHashSettledReadHintNoir, + SETTLED + >, + }; +} + +function mapNullifierReadRequestHintsToNoir( + hints: NullifierReadRequestHints, +): NullifierReadRequestHintsNoir { + return { + read_request_statuses: mapTuple(hints.readRequestStatuses, mapReadRequestStatusToNoir), + pending_read_hints: hints.pendingReadHints.map(mapPendingReadHintToNoir) as FixedLengthArray< + PendingReadHintNoir, + PENDING + >, + settled_read_hints: hints.settledReadHints.map(settledHint => + mapNullifierSettledReadHintToNoir( + settledHint as SettledReadHint, + ), + ) as FixedLengthArray, + }; +} + +/** + * Maps a KeyValidationHint to noir. + * @param hint - The key validation hint. + * @returns The key validation hint mapped to noir types. + */ +export function mapKeyValidationHintToNoir(hint: KeyValidationHint): KeyValidationHintNoir { + return { + sk_m: mapGrumpkinScalarToNoir(hint.skM), + request_index: mapNumberToNoir(hint.requestIndex), + }; +} + +export function mapPrivateKernelResetHintsToNoir< + NH_RR_PENDING extends number, + NH_RR_SETTLED extends number, + NLL_RR_PENDING extends number, + NLL_RR_SETTLED extends number, + KEY_VALIDATION_REQUESTS extends number, + NUM_TRANSIENT_DATA_HINTS extends number, +>( + inputs: PrivateKernelResetHints< + NH_RR_PENDING, + NH_RR_SETTLED, + NLL_RR_PENDING, + NLL_RR_SETTLED, + KEY_VALIDATION_REQUESTS, + NUM_TRANSIENT_DATA_HINTS + >, +): PrivateKernelResetHintsNoir< + NH_RR_PENDING, + NH_RR_SETTLED, + NLL_RR_PENDING, + NLL_RR_SETTLED, + KEY_VALIDATION_REQUESTS, + NUM_TRANSIENT_DATA_HINTS +> { + return { + note_hash_read_request_hints: mapNoteHashReadRequestHintsToNoir(inputs.noteHashReadRequestHints), + nullifier_read_request_hints: mapNullifierReadRequestHintsToNoir(inputs.nullifierReadRequestHints), + key_validation_hints: inputs.keyValidationHints.map(mapKeyValidationHintToNoir) as FixedLengthArray< + KeyValidationHintNoir, + KEY_VALIDATION_REQUESTS + >, + transient_data_index_hints: inputs.transientDataIndexHints.map(mapTransientDataIndexHintToNoir) as FixedLengthArray< + TransientDataIndexHintNoir, + NUM_TRANSIENT_DATA_HINTS + >, + validation_requests_split_counter: mapNumberToNoir(inputs.validationRequestsSplitCounter), + }; +} diff --git a/yarn-project/noir-protocol-circuits-types/src/conversion/common.ts b/yarn-project/noir-protocol-circuits-types/src/conversion/common.ts new file mode 100644 index 00000000000..ff90122d373 --- /dev/null +++ b/yarn-project/noir-protocol-circuits-types/src/conversion/common.ts @@ -0,0 +1,738 @@ +import { + AppendOnlyTreeSnapshot, + AztecAddress, + BlockHeader, + CombinedAccumulatedData, + ContentCommitment, + EthAddress, + Fr, + FunctionSelector, + Gas, + GasFees, + GasSettings, + GlobalVariables, + GrumpkinScalar, + L2ToL1Message, + LogHash, + MAX_CONTRACT_CLASS_LOGS_PER_TX, + MAX_L2_TO_L1_MSGS_PER_TX, + MAX_NOTE_HASHES_PER_TX, + MAX_NULLIFIERS_PER_TX, + MAX_PRIVATE_LOGS_PER_TX, + MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + MAX_UNENCRYPTED_LOGS_PER_TX, + MaxBlockNumber, + type MembershipWitness, + NUM_BYTES_PER_SHA256, + type NullifierLeafPreimage, + OptionalNumber, + PartialStateReference, + Point, + PrivateLog, + PublicCallRequest, + type PublicDataTreeLeafPreimage, + PublicDataWrite, + ScopedL2ToL1Message, + ScopedLogHash, + StateReference, + TxContext, + type VerificationKeyAsFields, +} from '@aztec/circuits.js'; +import { toBufferBE } from '@aztec/foundation/bigint-buffer'; +import { type Tuple, mapTuple, toTruncField } from '@aztec/foundation/serialize'; + +import type { + AppendOnlyTreeSnapshot as AppendOnlyTreeSnapshotNoir, + BlockHeader as BlockHeaderNoir, + CombinedAccumulatedData as CombinedAccumulatedDataNoir, + ContentCommitment as ContentCommitmentNoir, + Field, + FixedLengthArray, + FunctionSelector as FunctionSelectorNoir, + GasFees as GasFeesNoir, + Gas as GasNoir, + GasSettings as GasSettingsNoir, + GlobalVariables as GlobalVariablesNoir, + EmbeddedCurveScalar as GrumpkinScalarNoir, + L2ToL1Message as L2ToL1MessageNoir, + LogHash as LogHashNoir, + MaxBlockNumber as MaxBlockNumberNoir, + MembershipWitness as MembershipWitnessNoir, + AztecAddress as NoirAztecAddress, + EthAddress as NoirEthAddress, + Field as NoirField, + EmbeddedCurvePoint as NoirPoint, + NullifierLeafPreimage as NullifierLeafPreimageNoir, + Option as OptionalNumberNoir, + PartialStateReference as PartialStateReferenceNoir, + Log as PrivateLogNoir, + PublicCallRequest as PublicCallRequestNoir, + PublicDataTreeLeafPreimage as PublicDataTreeLeafPreimageNoir, + PublicDataWrite as PublicDataWriteNoir, + ScopedL2ToL1Message as ScopedL2ToL1MessageNoir, + ScopedLogHash as ScopedLogHashNoir, + StateReference as StateReferenceNoir, + TxContext as TxContextNoir, + VerificationKey as VerificationKeyNoir, +} from '../types/index.js'; + +/* eslint-disable camelcase */ + +/** + * Maps a field to a noir field. + * @param field - The field. + * @returns The noir field. + */ +export function mapFieldToNoir(field: Fr): NoirField { + return field.toString(); +} + +/** + * Maps a noir field to a fr. + * @param field - The noir field. + * @returns The fr. + */ +export function mapFieldFromNoir(field: NoirField): Fr { + return Fr.fromHexString(field); +} + +/** Maps a field to a noir wrapped field type (ie any type implemented as struct with an inner Field). */ +export function mapWrappedFieldToNoir(field: Fr): { inner: NoirField } { + return { inner: mapFieldToNoir(field) }; +} + +/** Maps a noir wrapped field type (ie any type implemented as struct with an inner Field) to a typescript field. */ +export function mapWrappedFieldFromNoir(wrappedField: { inner: NoirField }): Fr { + return mapFieldFromNoir(wrappedField.inner); +} + +/** + * Maps a number coming from noir. + * @param number - The field representing the number. + * @returns The number + */ +export function mapNumberFromNoir(number: NoirField): number { + return Number(Fr.fromHexString(number).toBigInt()); +} + +export function mapNumberToNoir(number: number): NoirField { + return new Fr(BigInt(number)).toString(); +} + +/** + * Maps a point to a noir point. + * @param point - The point. + * @returns The noir point. + */ +export function mapPointToNoir(point: Point): NoirPoint { + return { + x: mapFieldToNoir(point.x), + y: mapFieldToNoir(point.y), + is_infinite: point.isInfinite, + }; +} + +/** + * Maps a noir point to a point. + * @param point - The noir point. + * @returns The point. + */ +export function mapPointFromNoir(point: NoirPoint): Point { + return new Point(mapFieldFromNoir(point.x), mapFieldFromNoir(point.y), point.is_infinite); +} + +/** + * Maps a GrumpkinScalar to a noir GrumpkinScalar. + * @param privateKey - The GrumpkinScalar. + * @returns The noir GrumpkinScalar. + */ +export function mapGrumpkinScalarToNoir(privateKey: GrumpkinScalar): GrumpkinScalarNoir { + return { + hi: mapFieldToNoir(privateKey.hi), + lo: mapFieldToNoir(privateKey.lo), + }; +} + +/** + * Maps a noir GrumpkinScalar to a GrumpkinScalar. + * @param privateKey - The noir GrumpkinScalar. + * @returns The GrumpkinScalar. + */ +export function mapGrumpkinScalarFromNoir(privateKey: GrumpkinScalarNoir): GrumpkinScalar { + return GrumpkinScalar.fromHighLow(mapFieldFromNoir(privateKey.hi), mapFieldFromNoir(privateKey.lo)); +} + +/** + * Maps an aztec address to a noir aztec address. + * @param address - The address. + * @returns The noir aztec address. + */ +export function mapAztecAddressToNoir(address: AztecAddress): NoirAztecAddress { + return { + inner: mapFieldToNoir(address.toField()), + }; +} + +/** + * Maps a noir aztec address to an aztec address. + * @param address - The noir aztec address. + * @returns The aztec address. + */ +export function mapAztecAddressFromNoir(address: NoirAztecAddress): AztecAddress { + return AztecAddress.fromField(mapFieldFromNoir(address.inner)); +} + +/** + * Maps an eth address to a noir eth address. + * @param address - The address. + * @returns The noir eth address. + */ +export function mapEthAddressToNoir(address: EthAddress): NoirEthAddress { + return { + inner: mapFieldToNoir(address.toField()), + }; +} + +/** + * Maps a noir eth address to an eth address. + * @param address - The noir eth address. + * @returns The eth address. + */ +export function mapEthAddressFromNoir(address: NoirEthAddress): EthAddress { + return EthAddress.fromField(mapFieldFromNoir(address.inner)); +} + +export function mapGasFromNoir(gasUsed: GasNoir): Gas { + return Gas.from({ + daGas: mapNumberFromNoir(gasUsed.da_gas), + l2Gas: mapNumberFromNoir(gasUsed.l2_gas), + }); +} + +export function mapGasToNoir(gasUsed: Gas): GasNoir { + return { + da_gas: mapNumberToNoir(gasUsed.daGas), + l2_gas: mapNumberToNoir(gasUsed.l2Gas), + }; +} + +export function mapGasSettingsFromNoir(gasSettings: GasSettingsNoir): GasSettings { + return new GasSettings( + mapGasFromNoir(gasSettings.gas_limits), + mapGasFromNoir(gasSettings.teardown_gas_limits), + mapGasFeesFromNoir(gasSettings.max_fees_per_gas), + mapGasFeesFromNoir(gasSettings.max_priority_fees_per_gas), + ); +} + +export function mapGasSettingsToNoir(gasSettings: GasSettings): GasSettingsNoir { + return { + gas_limits: mapGasToNoir(gasSettings.gasLimits), + teardown_gas_limits: mapGasToNoir(gasSettings.teardownGasLimits), + max_fees_per_gas: mapGasFeesToNoir(gasSettings.maxFeesPerGas), + max_priority_fees_per_gas: mapGasFeesToNoir(gasSettings.maxPriorityFeesPerGas), + }; +} + +export function mapGasFeesToNoir(gasFees: GasFees): GasFeesNoir { + return { + fee_per_da_gas: mapFieldToNoir(gasFees.feePerDaGas), + fee_per_l2_gas: mapFieldToNoir(gasFees.feePerL2Gas), + }; +} + +export function mapGasFeesFromNoir(gasFees: GasFeesNoir): GasFees { + return new GasFees(mapFieldFromNoir(gasFees.fee_per_da_gas), mapFieldFromNoir(gasFees.fee_per_l2_gas)); +} + +export function mapPrivateLogToNoir(log: PrivateLog): PrivateLogNoir { + return { + fields: mapTuple(log.fields, mapFieldToNoir), + }; +} + +export function mapPrivateLogFromNoir(log: PrivateLogNoir) { + return new PrivateLog(mapTupleFromNoir(log.fields, log.fields.length, mapFieldFromNoir)); +} + +/** + * Maps an array from noir types to a tuple of parsed types. + * @param noirArray - The noir array. + * @param length - The length of the tuple. + * @param mapper - The mapper function applied to each element. + * @returns The tuple. + */ +export function mapTupleFromNoir( + noirArray: T[], + length: N, + mapper: (item: T) => M, +): Tuple { + if (noirArray.length != length) { + throw new Error(`Expected ${length} items, got ${noirArray.length}`); + } + return Array.from({ length }, (_, idx) => mapper(noirArray[idx])) as Tuple; +} + +/** + * Maps a AOT snapshot to noir. + * @param snapshot - The circuits.js AOT snapshot. + * @returns The noir AOT snapshot. + */ +export function mapAppendOnlyTreeSnapshotFromNoir(snapshot: AppendOnlyTreeSnapshotNoir): AppendOnlyTreeSnapshot { + return new AppendOnlyTreeSnapshot( + mapFieldFromNoir(snapshot.root), + mapNumberFromNoir(snapshot.next_available_leaf_index), + ); +} + +/** + * Maps a AOT snapshot from noir to the circuits.js type. + * @param snapshot - The noir AOT snapshot. + * @returns The circuits.js AOT snapshot. + */ +export function mapAppendOnlyTreeSnapshotToNoir(snapshot: AppendOnlyTreeSnapshot): AppendOnlyTreeSnapshotNoir { + return { + root: mapFieldToNoir(snapshot.root), + next_available_leaf_index: mapFieldToNoir(new Fr(snapshot.nextAvailableLeafIndex)), + }; +} + +/** + * Maps a content commitment to Noir + * + */ +export function mapContentCommitmentToNoir(contentCommitment: ContentCommitment): ContentCommitmentNoir { + return { + num_txs: mapFieldToNoir(contentCommitment.numTxs), + blobs_hash: mapSha256HashToNoir(contentCommitment.blobsHash), + in_hash: mapSha256HashToNoir(contentCommitment.inHash), + out_hash: mapSha256HashToNoir(contentCommitment.outHash), + }; +} + +/** + * Maps a content commitment to Noir + * + */ +export function mapContentCommitmentFromNoir(contentCommitment: ContentCommitmentNoir): ContentCommitment { + return new ContentCommitment( + mapFieldFromNoir(contentCommitment.num_txs), + mapSha256HashFromNoir(contentCommitment.blobs_hash), + mapSha256HashFromNoir(contentCommitment.in_hash), + mapSha256HashFromNoir(contentCommitment.out_hash), + ); +} + +/** + * Maps a block header to Noir + * @param header - The block header. + * @returns BlockHeader. + */ +export function mapHeaderToNoir(header: BlockHeader): BlockHeaderNoir { + return { + last_archive: mapAppendOnlyTreeSnapshotToNoir(header.lastArchive), + content_commitment: mapContentCommitmentToNoir(header.contentCommitment), + state: mapStateReferenceToNoir(header.state), + global_variables: mapGlobalVariablesToNoir(header.globalVariables), + total_fees: mapFieldToNoir(header.totalFees), + total_mana_used: mapFieldToNoir(header.totalManaUsed), + }; +} + +/** + * Maps a block header from Noir. + * @param header - The block header. + * @returns BlockHeader. + */ +export function mapHeaderFromNoir(header: BlockHeaderNoir): BlockHeader { + return new BlockHeader( + mapAppendOnlyTreeSnapshotFromNoir(header.last_archive), + mapContentCommitmentFromNoir(header.content_commitment), + mapStateReferenceFromNoir(header.state), + mapGlobalVariablesFromNoir(header.global_variables), + mapFieldFromNoir(header.total_fees), + mapFieldFromNoir(header.total_mana_used), + ); +} + +/** + * Maps a SHA256 hash from noir to the parsed type. + * @param hash - The hash as it is represented in Noir (1 fields). + * @returns The hash represented as a 31 bytes long buffer. + */ +export function mapSha256HashFromNoir(hash: Field): Buffer { + return toBufferBE(mapFieldFromNoir(hash).toBigInt(), NUM_BYTES_PER_SHA256); +} + +/** + * Maps a sha256 to the representation used in noir. + * @param hash - The hash represented as a 32 bytes long buffer. + * @returns The hash as it is represented in Noir (1 field, truncated). + */ +export function mapSha256HashToNoir(hash: Buffer): Field { + return mapFieldToNoir(toTruncField(hash)); +} + +export function mapOptionalNumberToNoir(option: OptionalNumber): OptionalNumberNoir { + return { + _is_some: option.isSome, + _value: mapNumberToNoir(option.value), + }; +} + +export function mapOptionalNumberFromNoir(option: OptionalNumberNoir) { + return new OptionalNumber(option._is_some, mapNumberFromNoir(option._value)); +} + +export function mapMaxBlockNumberToNoir(maxBlockNumber: MaxBlockNumber): MaxBlockNumberNoir { + return { + _opt: { + _is_some: maxBlockNumber.isSome, + _value: mapFieldToNoir(maxBlockNumber.value), + }, + }; +} + +export function mapMaxBlockNumberFromNoir(maxBlockNumber: MaxBlockNumberNoir): MaxBlockNumber { + return new MaxBlockNumber(maxBlockNumber._opt._is_some, mapFieldFromNoir(maxBlockNumber._opt._value)); +} + +/** + * Maps a L2 to L1 message to a noir L2 to L1 message. + * @param message - The L2 to L1 message. + * @returns The noir L2 to L1 message. + */ +export function mapL2ToL1MessageToNoir(message: L2ToL1Message): L2ToL1MessageNoir { + return { + recipient: mapEthAddressToNoir(message.recipient), + content: mapFieldToNoir(message.content), + counter: mapNumberToNoir(message.counter), + }; +} + +export function mapL2ToL1MessageFromNoir(message: L2ToL1MessageNoir) { + return new L2ToL1Message( + mapEthAddressFromNoir(message.recipient), + mapFieldFromNoir(message.content), + mapNumberFromNoir(message.counter), + ); +} + +export function mapScopedL2ToL1MessageFromNoir(message: ScopedL2ToL1MessageNoir) { + return new ScopedL2ToL1Message( + mapL2ToL1MessageFromNoir(message.message), + mapAztecAddressFromNoir(message.contract_address), + ); +} + +/** + * Maps a function selector to a noir function selector. + * @param functionSelector - The function selector. + * @returns The noir function selector. + */ +export function mapFunctionSelectorToNoir(functionSelector: FunctionSelector): FunctionSelectorNoir { + return { + inner: mapFieldToNoir(functionSelector.toField()), + }; +} + +/** + * Maps a noir function selector to a function selector. + * @param functionSelector - The noir function selector. + * @returns The function selector. + */ +export function mapFunctionSelectorFromNoir(functionSelector: FunctionSelectorNoir): FunctionSelector { + return FunctionSelector.fromField(mapFieldFromNoir(functionSelector.inner)); +} + +export function mapPublicCallRequestFromNoir(request: PublicCallRequestNoir) { + return new PublicCallRequest( + mapAztecAddressFromNoir(request.msg_sender), + mapAztecAddressFromNoir(request.contract_address), + mapFunctionSelectorFromNoir(request.function_selector), + request.is_static_call, + mapFieldFromNoir(request.args_hash), + ); +} + +export function mapPublicCallRequestToNoir(request: PublicCallRequest): PublicCallRequestNoir { + return { + msg_sender: mapAztecAddressToNoir(request.msgSender), + contract_address: mapAztecAddressToNoir(request.contractAddress), + function_selector: mapFunctionSelectorToNoir(request.functionSelector), + is_static_call: request.isStaticCall, + args_hash: mapFieldToNoir(request.argsHash), + }; +} + +export function mapScopedL2ToL1MessageToNoir(message: ScopedL2ToL1Message): ScopedL2ToL1MessageNoir { + return { + message: mapL2ToL1MessageToNoir(message.message), + contract_address: mapAztecAddressToNoir(message.contractAddress), + }; +} + +export function mapVerificationKeyToNoir( + key: VerificationKeyAsFields, + length: N, +): VerificationKeyNoir { + if (key.key.length !== length) { + throw new Error(`Expected ${length} fields, got ${key.key.length}`); + } + return { + key: key.key.map(mapFieldToNoir) as FixedLengthArray, + hash: mapFieldToNoir(key.hash), + }; +} + +/** + * Maps global variables to the noir type. + * @param globalVariables - The global variables. + * @returns The noir global variables. + */ +export function mapGlobalVariablesToNoir(globalVariables: GlobalVariables): GlobalVariablesNoir { + return { + chain_id: mapFieldToNoir(globalVariables.chainId), + version: mapFieldToNoir(globalVariables.version), + block_number: mapFieldToNoir(globalVariables.blockNumber), + slot_number: mapFieldToNoir(globalVariables.slotNumber), + timestamp: mapFieldToNoir(globalVariables.timestamp), + coinbase: mapEthAddressToNoir(globalVariables.coinbase), + fee_recipient: mapAztecAddressToNoir(globalVariables.feeRecipient), + gas_fees: mapGasFeesToNoir(globalVariables.gasFees), + }; +} + +/** + * Maps global variables from the noir type. + * @param globalVariables - The noir global variables. + * @returns The global variables. + */ +export function mapGlobalVariablesFromNoir(globalVariables: GlobalVariablesNoir): GlobalVariables { + return new GlobalVariables( + mapFieldFromNoir(globalVariables.chain_id), + mapFieldFromNoir(globalVariables.version), + mapFieldFromNoir(globalVariables.block_number), + mapFieldFromNoir(globalVariables.slot_number), + mapFieldFromNoir(globalVariables.timestamp), + mapEthAddressFromNoir(globalVariables.coinbase), + mapAztecAddressFromNoir(globalVariables.fee_recipient), + mapGasFeesFromNoir(globalVariables.gas_fees), + ); +} + +/** + * Maps state reference to Noir. + * @param stateReference - The state reference. + * @returns Noir representation of state reference. + */ +export function mapStateReferenceToNoir(stateReference: StateReference): StateReferenceNoir { + return { + l1_to_l2_message_tree: mapAppendOnlyTreeSnapshotToNoir(stateReference.l1ToL2MessageTree), + partial: mapPartialStateReferenceToNoir(stateReference.partial), + }; +} + +/** + * Maps state reference from Noir. + * @param stateReference - The state reference. + * @returns State reference + */ +export function mapStateReferenceFromNoir(stateReference: StateReferenceNoir): StateReference { + return new StateReference( + mapAppendOnlyTreeSnapshotFromNoir(stateReference.l1_to_l2_message_tree), + mapPartialStateReferenceFromNoir(stateReference.partial), + ); +} + +/** + * Maps a nullifier leaf preimage to noir + * @param nullifierLeafPreimage - The nullifier leaf preimage. + * @returns The noir nullifier leaf preimage. + */ +export function mapNullifierLeafPreimageToNoir( + nullifierLeafPreimage: NullifierLeafPreimage, +): NullifierLeafPreimageNoir { + return { + nullifier: mapFieldToNoir(nullifierLeafPreimage.nullifier), + next_nullifier: mapFieldToNoir(nullifierLeafPreimage.nextNullifier), + next_index: mapNumberToNoir(Number(nullifierLeafPreimage.nextIndex)), + }; +} + +/** + * Maps partial state reference from Noir. + * @param partialStateReference - The state reference. + * @returns Partial state reference + */ +export function mapPartialStateReferenceFromNoir( + partialStateReference: PartialStateReferenceNoir, +): PartialStateReference { + return new PartialStateReference( + mapAppendOnlyTreeSnapshotFromNoir(partialStateReference.note_hash_tree), + mapAppendOnlyTreeSnapshotFromNoir(partialStateReference.nullifier_tree), + mapAppendOnlyTreeSnapshotFromNoir(partialStateReference.public_data_tree), + ); +} + +// function mapTreeSnapshotsFromNoir(snapshots: TreeSnapshotsNoir) { +// return new TreeSnapshots( +// mapAppendOnlyTreeSnapshotFromNoir(snapshots.l1_to_l2_message_tree), +// mapAppendOnlyTreeSnapshotFromNoir(snapshots.note_hash_tree), +// mapAppendOnlyTreeSnapshotFromNoir(snapshots.nullifier_tree), +// mapAppendOnlyTreeSnapshotFromNoir(snapshots.public_data_tree), +// ); +// } + +export function mapMembershipWitnessToNoir(witness: MembershipWitness): MembershipWitnessNoir { + const siblingPath = mapTuple(witness.siblingPath, mapFieldToNoir) as FixedLengthArray; + return { + leaf_index: witness.leafIndex.toString(), + sibling_path: siblingPath, + }; +} + +/** + * Maps a leaf preimage of the public data tree to noir. + */ +export function mapPublicDataTreePreimageToNoir(preimage: PublicDataTreeLeafPreimage): PublicDataTreeLeafPreimageNoir { + return { + slot: mapFieldToNoir(preimage.slot), + value: mapFieldToNoir(preimage.value), + next_slot: mapFieldToNoir(preimage.nextSlot), + next_index: mapNumberToNoir(Number(preimage.nextIndex)), + }; +} + +/** + * Maps a partial state reference to a noir partial state reference. + * @param partialStateReference - The partial state reference. + * @returns The noir partial state reference. + */ +export function mapPartialStateReferenceToNoir( + partialStateReference: PartialStateReference, +): PartialStateReferenceNoir { + return { + note_hash_tree: mapAppendOnlyTreeSnapshotToNoir(partialStateReference.noteHashTree), + nullifier_tree: mapAppendOnlyTreeSnapshotToNoir(partialStateReference.nullifierTree), + public_data_tree: mapAppendOnlyTreeSnapshotToNoir(partialStateReference.publicDataTree), + }; +} + +/** + * Maps a LogHash to a noir LogHash. + * @param logHash - The LogHash. + * @returns The noir log hash. + */ +function mapLogHashToNoir(logHash: LogHash): LogHashNoir { + return { + value: mapFieldToNoir(logHash.value), + counter: mapNumberToNoir(logHash.counter), + length: mapFieldToNoir(logHash.length), + }; +} + +/** + * Maps a noir LogHash to a LogHash. + * @param logHash - The noir LogHash. + * @returns The TS log hash. + */ +function mapLogHashFromNoir(logHash: LogHashNoir): LogHash { + return new LogHash( + mapFieldFromNoir(logHash.value), + mapNumberFromNoir(logHash.counter), + mapFieldFromNoir(logHash.length), + ); +} + +/** + * Maps a ts ScopedLogHash to a noir ScopedLogHash. + * @param logHash - The ts LogHash. + * @returns The noir log hash. + */ +export function mapScopedLogHashToNoir(scopedLogHash: ScopedLogHash): ScopedLogHashNoir { + return { + log_hash: mapLogHashToNoir(scopedLogHash.logHash), + contract_address: mapAztecAddressToNoir(scopedLogHash.contractAddress), + }; +} + +/** + * Maps a noir ScopedLogHash to a ts ScopedLogHash. + * @param logHash - The noir LogHash. + * @returns The TS log hash. + */ +function mapScopedLogHashFromNoir(scopedLogHash: ScopedLogHashNoir): ScopedLogHash { + return new ScopedLogHash( + mapLogHashFromNoir(scopedLogHash.log_hash), + mapAztecAddressFromNoir(scopedLogHash.contract_address), + ); +} + +function mapPublicDataWriteFromNoir(write: PublicDataWriteNoir) { + return new PublicDataWrite(mapFieldFromNoir(write.leaf_slot), mapFieldFromNoir(write.value)); +} + +export function mapPublicDataWriteToNoir(write: PublicDataWrite): PublicDataWriteNoir { + return { + leaf_slot: mapFieldToNoir(write.leafSlot), + value: mapFieldToNoir(write.value), + }; +} + +/** + * Maps combined accumulated data from noir to the parsed type. + * @param combinedAccumulatedData - The noir combined accumulated data. + * @returns The parsed combined accumulated data. + */ +export function mapCombinedAccumulatedDataFromNoir(combinedAccumulatedData: CombinedAccumulatedDataNoir) { + return new CombinedAccumulatedData( + mapTupleFromNoir(combinedAccumulatedData.note_hashes, MAX_NOTE_HASHES_PER_TX, mapFieldFromNoir), + mapTupleFromNoir(combinedAccumulatedData.nullifiers, MAX_NULLIFIERS_PER_TX, mapFieldFromNoir), + mapTupleFromNoir(combinedAccumulatedData.l2_to_l1_msgs, MAX_L2_TO_L1_MSGS_PER_TX, mapScopedL2ToL1MessageFromNoir), + mapTupleFromNoir(combinedAccumulatedData.private_logs, MAX_PRIVATE_LOGS_PER_TX, mapPrivateLogFromNoir), + mapTupleFromNoir( + combinedAccumulatedData.unencrypted_logs_hashes, + MAX_UNENCRYPTED_LOGS_PER_TX, + mapScopedLogHashFromNoir, + ), + mapTupleFromNoir( + combinedAccumulatedData.contract_class_logs_hashes, + MAX_CONTRACT_CLASS_LOGS_PER_TX, + mapScopedLogHashFromNoir, + ), + mapFieldFromNoir(combinedAccumulatedData.unencrypted_log_preimages_length), + mapFieldFromNoir(combinedAccumulatedData.contract_class_log_preimages_length), + mapTupleFromNoir( + combinedAccumulatedData.public_data_writes, + MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + mapPublicDataWriteFromNoir, + ), + ); +} + +/** + * Maps a tx context to a noir tx context. + * @param txContext - The tx context. + * @returns The noir tx context. + */ +export function mapTxContextToNoir(txContext: TxContext): TxContextNoir { + return { + chain_id: mapFieldToNoir(txContext.chainId), + version: mapFieldToNoir(txContext.version), + gas_settings: mapGasSettingsToNoir(txContext.gasSettings), + }; +} + +/** + * Maps a noir tx context to a tx context. + * @param txContext - The noir tx context. + * @returns The tx context. + */ +export function mapTxContextFromNoir(txContext: TxContextNoir): TxContext { + return new TxContext( + mapFieldFromNoir(txContext.chain_id), + mapFieldFromNoir(txContext.version), + mapGasSettingsFromNoir(txContext.gas_settings), + ); +} diff --git a/yarn-project/noir-protocol-circuits-types/src/conversion/server.ts b/yarn-project/noir-protocol-circuits-types/src/conversion/server.ts new file mode 100644 index 00000000000..edbc99b17e9 --- /dev/null +++ b/yarn-project/noir-protocol-circuits-types/src/conversion/server.ts @@ -0,0 +1,966 @@ +import { + type AVM_PROOF_LENGTH_IN_FIELDS, + AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS, + AZTEC_MAX_EPOCH_DURATION, + type AvmAccumulatedData, + type AvmCircuitPublicInputs, + BLOBS_PER_BLOCK, + type BaseParityInputs, + type CombinedAccumulatedData, + CombinedConstantData, + type EmptyNestedData, + Fr, + HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS, + KernelCircuitPublicInputs, + type MembershipWitness, + type NESTED_RECURSIVE_PROOF_LENGTH, + type NULLIFIER_TREE_HEIGHT, + type PUBLIC_DATA_TREE_HEIGHT, + ParityPublicInputs, + type PrivateKernelEmptyInputs, + type PrivateToAvmAccumulatedData, + type PrivateToAvmAccumulatedDataArrayLengths, + type PrivateToPublicAccumulatedData, + type PrivateToPublicKernelCircuitPublicInputs, + type PublicDataHint, + type RECURSIVE_PROOF_LENGTH, + type RecursiveProof, + RevertCode, + RollupValidationRequests, + type RootParityInput, + type RootParityInputs, + type TUBE_PROOF_LENGTH, + type TreeSnapshots, + type TxConstantData, + type VkWitnessData, +} from '@aztec/circuits.js'; +import { BlobPublicInputs, BlockBlobPublicInputs, Poseidon2Sponge, SpongeBlob } from '@aztec/circuits.js/blobs'; +import { + AvmProofData, + BaseOrMergeRollupPublicInputs, + BlockMergeRollupInputs, + BlockRootOrBlockMergePublicInputs, + BlockRootRollupInputs, + ConstantRollupData, + EmptyBlockRootRollupInputs, + FeeRecipient, + MergeRollupInputs, + PreviousRollupBlockData, + PreviousRollupData, + PrivateBaseRollupInputs, + PrivateBaseStateDiffHints, + PrivateTubeData, + PublicBaseRollupInputs, + PublicBaseStateDiffHints, + PublicTubeData, + RootRollupInputs, + RootRollupPublicInputs, +} from '@aztec/circuits.js/rollup'; +import { toHex } from '@aztec/foundation/bigint-buffer'; +import { mapTuple } from '@aztec/foundation/serialize'; + +import type { + AvmAccumulatedData as AvmAccumulatedDataNoir, + AvmCircuitPublicInputs as AvmCircuitPublicInputsNoir, + AvmProofData as AvmProofDataNoir, + BaseOrMergeRollupPublicInputs as BaseOrMergeRollupPublicInputsNoir, + BaseParityInputs as BaseParityInputsNoir, + BigNum, + BlobCommitment as BlobCommitmentNoir, + BlobPublicInputs as BlobPublicInputsNoir, + BlockBlobPublicInputs as BlockBlobPublicInputsNoir, + BlockMergeRollupInputs as BlockMergeRollupInputsNoir, + BlockRootOrBlockMergePublicInputs as BlockRootOrBlockMergePublicInputsNoir, + BlockRootRollupInputs as BlockRootRollupInputsNoir, + CombinedAccumulatedData as CombinedAccumulatedDataNoir, + CombinedConstantData as CombinedConstantDataNoir, + ConstantRollupData as ConstantRollupDataNoir, + EmptyBlockRootRollupInputs as EmptyBlockRootRollupInputsNoir, + EmptyNestedCircuitPublicInputs as EmptyNestedDataNoir, + FeeRecipient as FeeRecipientNoir, + FixedLengthArray, + KernelCircuitPublicInputs as KernelCircuitPublicInputsNoir, + MergeRollupInputs as MergeRollupInputsNoir, + Field as NoirField, + ParityPublicInputs as ParityPublicInputsNoir, + RootParityInput as ParityRootParityInputNoir, + Poseidon2 as Poseidon2SpongeNoir, + PreviousRollupBlockData as PreviousRollupBlockDataNoir, + PreviousRollupData as PreviousRollupDataNoir, + PrivateBaseRollupInputs as PrivateBaseRollupInputsNoir, + PrivateBaseStateDiffHints as PrivateBaseStateDiffHintsNoir, + PrivateKernelEmptyPrivateInputs as PrivateKernelEmptyPrivateInputsNoir, + PrivateToAvmAccumulatedDataArrayLengths as PrivateToAvmAccumulatedDataArrayLengthsNoir, + PrivateToAvmAccumulatedData as PrivateToAvmAccumulatedDataNoir, + PrivateToPublicAccumulatedData as PrivateToPublicAccumulatedDataNoir, + PrivateToPublicKernelCircuitPublicInputs as PrivateToPublicKernelCircuitPublicInputsNoir, + PrivateTubeData as PrivateTubeDataNoir, + PublicBaseRollupInputs as PublicBaseRollupInputsNoir, + PublicBaseStateDiffHints as PublicBaseStateDiffHintsNoir, + PublicDataHint as PublicDataHintNoir, + PublicTubeData as PublicTubeDataNoir, + RollupValidationRequests as RollupValidationRequestsNoir, + RootParityInputs as RootParityInputsNoir, + RootRollupInputs as RootRollupInputsNoir, + RootRollupParityInput as RootRollupParityInputNoir, + RootRollupPublicInputs as RootRollupPublicInputsNoir, + SpongeBlob as SpongeBlobNoir, + TreeSnapshots as TreeSnapshotsNoir, + TxConstantData as TxConstantDataNoir, + VkData as VkDataNoir, +} from '../types/index.js'; +import { + mapAppendOnlyTreeSnapshotFromNoir, + mapAppendOnlyTreeSnapshotToNoir, + mapAztecAddressFromNoir, + mapAztecAddressToNoir, + mapCombinedAccumulatedDataFromNoir, + mapEthAddressFromNoir, + mapEthAddressToNoir, + mapFieldFromNoir, + mapFieldToNoir, + mapGasFromNoir, + mapGasSettingsToNoir, + mapGasToNoir, + mapGlobalVariablesFromNoir, + mapGlobalVariablesToNoir, + mapHeaderFromNoir, + mapHeaderToNoir, + mapMaxBlockNumberFromNoir, + mapMaxBlockNumberToNoir, + mapMembershipWitnessToNoir, + mapNullifierLeafPreimageToNoir, + mapNumberFromNoir, + mapNumberToNoir, + mapPartialStateReferenceFromNoir, + mapPartialStateReferenceToNoir, + mapPrivateLogToNoir, + mapPublicCallRequestToNoir, + mapPublicDataTreePreimageToNoir, + mapPublicDataWriteToNoir, + mapScopedL2ToL1MessageToNoir, + mapScopedLogHashToNoir, + mapTupleFromNoir, + mapTxContextFromNoir, + mapTxContextToNoir, + mapVerificationKeyToNoir, +} from './common.js'; + +/* eslint-disable camelcase */ + +/** + * Maps a BigNum coming to/from noir. + * TODO(): Is BigInt the best way to represent this? + * @param number - The BigNum representing the number. + * @returns The number + */ +export function mapBLS12BigNumFromNoir(bignum: BigNum): bigint { + // TODO(Miranda): there's gotta be a better way to convert this + const paddedLimbs = [ + `0x` + bignum.limbs[2].substring(2).padStart(4, '0'), + bignum.limbs[1].substring(2).padStart(30, '0'), + bignum.limbs[0].substring(2).padStart(30, '0'), + ]; + return BigInt(paddedLimbs[0].concat(paddedLimbs[1], paddedLimbs[2])); +} + +export function mapBLS12BigNumToNoir(number: bigint): BigNum { + const hex = toHex(number, true); + return { + limbs: ['0x' + hex.substring(36), '0x' + hex.substring(6, 36), hex.substring(0, 6)], + }; +} + +export function mapFeeRecipientToNoir(feeRecipient: FeeRecipient): FeeRecipientNoir { + return { + recipient: mapEthAddressToNoir(feeRecipient.recipient), + value: mapFieldToNoir(feeRecipient.value), + }; +} + +export function mapFeeRecipientFromNoir(feeRecipient: FeeRecipientNoir): FeeRecipient { + return new FeeRecipient(mapEthAddressFromNoir(feeRecipient.recipient), mapFieldFromNoir(feeRecipient.value)); +} + +/** + * Maps poseidon sponge to noir. + * @param sponge - The circuits.js poseidon sponge. + * @returns The noir poseidon sponge. + */ +export function mapPoseidon2SpongeToNoir(sponge: Poseidon2Sponge): Poseidon2SpongeNoir { + return { + cache: mapTuple(sponge.cache, mapFieldToNoir), + state: mapTuple(sponge.state, mapFieldToNoir), + cache_size: mapNumberToNoir(sponge.cacheSize), + squeeze_mode: sponge.squeezeMode, + }; +} + +/** + * Maps poseidon sponge from noir. + * @param sponge - The noir poseidon sponge. + * @returns The circuits.js poseidon sponge. + */ +export function mapPoseidon2SpongeFromNoir(sponge: Poseidon2SpongeNoir): Poseidon2Sponge { + return new Poseidon2Sponge( + mapTupleFromNoir(sponge.cache, 3, mapFieldFromNoir), + mapTupleFromNoir(sponge.state, 4, mapFieldFromNoir), + mapNumberFromNoir(sponge.cache_size), + sponge.squeeze_mode, + ); +} + +/** + * Maps sponge blob to noir. + * @param spongeBlob - The circuits.js sponge blob. + * @returns The noir sponge blob. + */ +export function mapSpongeBlobToNoir(spongeBlob: SpongeBlob): SpongeBlobNoir { + return { + sponge: mapPoseidon2SpongeToNoir(spongeBlob.sponge), + fields: mapNumberToNoir(spongeBlob.fields), + expected_fields: mapNumberToNoir(spongeBlob.expectedFields), + }; +} + +/** + * Maps sponge blob from noir. + * @param spongeBlob - The noir sponge blob. + * @returns The circuits.js sponge blob. + */ +export function mapSpongeBlobFromNoir(spongeBlob: SpongeBlobNoir): SpongeBlob { + return new SpongeBlob( + mapPoseidon2SpongeFromNoir(spongeBlob.sponge), + mapNumberFromNoir(spongeBlob.fields), + mapNumberFromNoir(spongeBlob.expected_fields), + ); +} + +/** + * Maps blob commitment to noir. + * @param commitment - The circuits.js commitment. + * @returns The noir commitment. + */ +export function mapBlobCommitmentToNoir(commitment: [Fr, Fr]): BlobCommitmentNoir { + return { + inner: mapTuple(commitment, mapFieldToNoir), + }; +} + +/** + * Maps blob public inputs to noir. + * @param blobPublicInputs - The circuits.js blob public inputs. + * @returns The noir blob public inputs. + */ +export function mapBlobPublicInputsToNoir(blobPublicInputs: BlobPublicInputs): BlobPublicInputsNoir { + return { + z: mapFieldToNoir(blobPublicInputs.z), + y: mapBLS12BigNumToNoir(blobPublicInputs.y), + kzg_commitment: mapBlobCommitmentToNoir(blobPublicInputs.kzgCommitment), + }; +} + +/** + * Maps blob public inputs from noir. + * @param blobPublicInputs - The noir blob public inputs. + * @returns The circuits.js blob public inputs. + */ +export function mapBlobPublicInputsFromNoir(blobPublicInputs: BlobPublicInputsNoir): BlobPublicInputs { + return new BlobPublicInputs( + mapFieldFromNoir(blobPublicInputs.z), + mapBLS12BigNumFromNoir(blobPublicInputs.y), + mapTupleFromNoir(blobPublicInputs.kzg_commitment.inner, 2, mapFieldFromNoir), + ); +} + +/** + * Maps block blob public inputs to noir. + * @param blockBlobPublicInputs - The circuits.js block blob public inputs. + * @returns The noir block blob public inputs. + */ +export function mapBlockBlobPublicInputsToNoir( + blockBlobPublicInputs: BlockBlobPublicInputs, +): BlockBlobPublicInputsNoir { + return { + inner: mapTuple(blockBlobPublicInputs.inner, mapBlobPublicInputsToNoir), + }; +} + +/** + * Maps block blob public inputs from noir. + * @param blockBlobPublicInputs - The noir block blob public inputs. + * @returns The circuits.js block blob public inputs. + */ +export function mapBlockBlobPublicInputsFromNoir( + blockBlobPublicInputs: BlockBlobPublicInputsNoir, +): BlockBlobPublicInputs { + return new BlockBlobPublicInputs( + mapTupleFromNoir(blockBlobPublicInputs.inner, BLOBS_PER_BLOCK, mapBlobPublicInputsFromNoir), + ); +} + +function mapPublicDataHintToNoir(hint: PublicDataHint): PublicDataHintNoir { + return { + leaf_slot: mapFieldToNoir(hint.leafSlot), + value: mapFieldToNoir(hint.value), + membership_witness: mapMembershipWitnessToNoir(hint.membershipWitness), + leaf_preimage: mapPublicDataTreePreimageToNoir(hint.leafPreimage), + }; +} + +/** + * Maps a constant rollup data to a noir constant rollup data. + * @param constantRollupData - The circuits.js constant rollup data. + * @returns The noir constant rollup data. + */ +export function mapConstantRollupDataToNoir(constantRollupData: ConstantRollupData): ConstantRollupDataNoir { + return { + last_archive: mapAppendOnlyTreeSnapshotToNoir(constantRollupData.lastArchive), + vk_tree_root: mapFieldToNoir(constantRollupData.vkTreeRoot), + protocol_contract_tree_root: mapFieldToNoir(constantRollupData.protocolContractTreeRoot), + global_variables: mapGlobalVariablesToNoir(constantRollupData.globalVariables), + }; +} + +/** + * Maps a constant rollup data from noir to the circuits.js type. + * @param constantRollupData - The noir constant rollup data. + * @returns The circuits.js constant rollup data. + */ +export function mapConstantRollupDataFromNoir(constantRollupData: ConstantRollupDataNoir): ConstantRollupData { + return new ConstantRollupData( + mapAppendOnlyTreeSnapshotFromNoir(constantRollupData.last_archive), + mapFieldFromNoir(constantRollupData.vk_tree_root), + mapFieldFromNoir(constantRollupData.protocol_contract_tree_root), + mapGlobalVariablesFromNoir(constantRollupData.global_variables), + ); +} + +/** + * Maps a base or merge rollup public inputs to a noir base or merge rollup public inputs. + * @param baseOrMergeRollupPublicInputs - The base or merge rollup public inputs. + * @returns The noir base or merge rollup public inputs. + */ +export function mapBaseOrMergeRollupPublicInputsToNoir( + baseOrMergeRollupPublicInputs: BaseOrMergeRollupPublicInputs, +): BaseOrMergeRollupPublicInputsNoir { + return { + rollup_type: mapFieldToNoir(new Fr(baseOrMergeRollupPublicInputs.rollupType)), + num_txs: mapFieldToNoir(new Fr(baseOrMergeRollupPublicInputs.numTxs)), + constants: mapConstantRollupDataToNoir(baseOrMergeRollupPublicInputs.constants), + start: mapPartialStateReferenceToNoir(baseOrMergeRollupPublicInputs.start), + end: mapPartialStateReferenceToNoir(baseOrMergeRollupPublicInputs.end), + start_sponge_blob: mapSpongeBlobToNoir(baseOrMergeRollupPublicInputs.startSpongeBlob), + end_sponge_blob: mapSpongeBlobToNoir(baseOrMergeRollupPublicInputs.endSpongeBlob), + out_hash: mapFieldToNoir(baseOrMergeRollupPublicInputs.outHash), + accumulated_fees: mapFieldToNoir(baseOrMergeRollupPublicInputs.accumulatedFees), + accumulated_mana_used: mapFieldToNoir(baseOrMergeRollupPublicInputs.accumulatedManaUsed), + }; +} + +/** + * Maps block root or block merge rollup public inputs to a noir block root or block merge rollup public inputs. + * @param blockRootOrBlockMergePublicInputs - The block root or block merge rollup public inputs. + * @returns The noir block root or block merge rollup public inputs. + */ +export function mapBlockRootOrBlockMergePublicInputsToNoir( + blockRootOrBlockMergePublicInputs: BlockRootOrBlockMergePublicInputs, +): BlockRootOrBlockMergePublicInputsNoir { + return { + previous_archive: mapAppendOnlyTreeSnapshotToNoir(blockRootOrBlockMergePublicInputs.previousArchive), + new_archive: mapAppendOnlyTreeSnapshotToNoir(blockRootOrBlockMergePublicInputs.newArchive), + previous_block_hash: mapFieldToNoir(blockRootOrBlockMergePublicInputs.previousBlockHash), + end_block_hash: mapFieldToNoir(blockRootOrBlockMergePublicInputs.endBlockHash), + start_global_variables: mapGlobalVariablesToNoir(blockRootOrBlockMergePublicInputs.startGlobalVariables), + end_global_variables: mapGlobalVariablesToNoir(blockRootOrBlockMergePublicInputs.endGlobalVariables), + out_hash: mapFieldToNoir(blockRootOrBlockMergePublicInputs.outHash), + fees: mapTuple(blockRootOrBlockMergePublicInputs.fees, mapFeeRecipientToNoir), + vk_tree_root: mapFieldToNoir(blockRootOrBlockMergePublicInputs.vkTreeRoot), + protocol_contract_tree_root: mapFieldToNoir(blockRootOrBlockMergePublicInputs.protocolContractTreeRoot), + prover_id: mapFieldToNoir(blockRootOrBlockMergePublicInputs.proverId), + blob_public_inputs: mapTuple(blockRootOrBlockMergePublicInputs.blobPublicInputs, mapBlockBlobPublicInputsToNoir), + }; +} + +export function mapRecursiveProofToNoir(proof: RecursiveProof) { + return { + fields: mapTuple(proof.proof, mapFieldToNoir) as FixedLengthArray, + }; +} + +export function mapRootParityInputToNoir( + rootParityInput: RootParityInput, +): ParityRootParityInputNoir { + return { + proof: mapRecursiveProofToNoir(rootParityInput.proof), + verification_key: mapVerificationKeyToNoir(rootParityInput.verificationKey, HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS), + vk_path: mapTuple(rootParityInput.vkPath, mapFieldToNoir), + public_inputs: mapParityPublicInputsToNoir(rootParityInput.publicInputs), + }; +} + +export function mapParityPublicInputsToNoir(parityPublicInputs: ParityPublicInputs): ParityPublicInputsNoir { + return { + sha_root: mapFieldToNoir(parityPublicInputs.shaRoot), + converted_root: mapFieldToNoir(parityPublicInputs.convertedRoot), + vk_tree_root: mapFieldToNoir(parityPublicInputs.vkTreeRoot), + }; +} + +/** + * Maps a root rollup public inputs from noir. + * @param rootRollupPublicInputs - The noir root rollup public inputs. + * @returns The circuits.js root rollup public inputs. + */ +export function mapRootRollupPublicInputsFromNoir( + rootRollupPublicInputs: RootRollupPublicInputsNoir, +): RootRollupPublicInputs { + return new RootRollupPublicInputs( + mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.previous_archive), + mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.end_archive), + mapFieldFromNoir(rootRollupPublicInputs.previous_block_hash), + mapFieldFromNoir(rootRollupPublicInputs.end_block_hash), + mapFieldFromNoir(rootRollupPublicInputs.end_timestamp), + mapFieldFromNoir(rootRollupPublicInputs.end_block_number), + mapFieldFromNoir(rootRollupPublicInputs.out_hash), + mapTupleFromNoir(rootRollupPublicInputs.fees, AZTEC_MAX_EPOCH_DURATION, mapFeeRecipientFromNoir), + mapFieldFromNoir(rootRollupPublicInputs.vk_tree_root), + mapFieldFromNoir(rootRollupPublicInputs.protocol_contract_tree_root), + mapFieldFromNoir(rootRollupPublicInputs.prover_id), + mapTupleFromNoir( + rootRollupPublicInputs.blob_public_inputs, + AZTEC_MAX_EPOCH_DURATION, + mapBlockBlobPublicInputsFromNoir, + ), + ); +} + +/** + * Maps a parity public inputs from noir. + * @param parityPublicInputs - The noir parity public inputs. + * @returns The circuits.js parity public inputs. + */ +export function mapParityPublicInputsFromNoir(parityPublicInputs: ParityPublicInputsNoir): ParityPublicInputs { + return new ParityPublicInputs( + mapFieldFromNoir(parityPublicInputs.sha_root), + mapFieldFromNoir(parityPublicInputs.converted_root), + mapFieldFromNoir(parityPublicInputs.vk_tree_root), + ); +} + +export function mapTreeSnapshotsToNoir(snapshots: TreeSnapshots): TreeSnapshotsNoir { + return { + l1_to_l2_message_tree: mapAppendOnlyTreeSnapshotToNoir(snapshots.l1ToL2MessageTree), + note_hash_tree: mapAppendOnlyTreeSnapshotToNoir(snapshots.noteHashTree), + nullifier_tree: mapAppendOnlyTreeSnapshotToNoir(snapshots.nullifierTree), + public_data_tree: mapAppendOnlyTreeSnapshotToNoir(snapshots.publicDataTree), + }; +} + +export function mapPrivateToPublicAccumulatedDataToNoir( + data: PrivateToPublicAccumulatedData, +): PrivateToPublicAccumulatedDataNoir { + return { + note_hashes: mapTuple(data.noteHashes, mapFieldToNoir), + nullifiers: mapTuple(data.nullifiers, mapFieldToNoir), + l2_to_l1_msgs: mapTuple(data.l2ToL1Msgs, mapScopedL2ToL1MessageToNoir), + private_logs: mapTuple(data.privateLogs, mapPrivateLogToNoir), + contract_class_logs_hashes: mapTuple(data.contractClassLogsHashes, mapScopedLogHashToNoir), + public_call_requests: mapTuple(data.publicCallRequests, mapPublicCallRequestToNoir), + }; +} + +export function mapCombinedAccumulatedDataToNoir( + combinedAccumulatedData: CombinedAccumulatedData, +): CombinedAccumulatedDataNoir { + return { + note_hashes: mapTuple(combinedAccumulatedData.noteHashes, mapFieldToNoir), + nullifiers: mapTuple(combinedAccumulatedData.nullifiers, mapFieldToNoir), + l2_to_l1_msgs: mapTuple(combinedAccumulatedData.l2ToL1Msgs, mapScopedL2ToL1MessageToNoir), + private_logs: mapTuple(combinedAccumulatedData.privateLogs, mapPrivateLogToNoir), + unencrypted_logs_hashes: mapTuple(combinedAccumulatedData.unencryptedLogsHashes, mapScopedLogHashToNoir), + contract_class_logs_hashes: mapTuple(combinedAccumulatedData.contractClassLogsHashes, mapScopedLogHashToNoir), + unencrypted_log_preimages_length: mapFieldToNoir(combinedAccumulatedData.unencryptedLogPreimagesLength), + contract_class_log_preimages_length: mapFieldToNoir(combinedAccumulatedData.contractClassLogPreimagesLength), + public_data_writes: mapTuple(combinedAccumulatedData.publicDataWrites, mapPublicDataWriteToNoir), + }; +} + +function mapCombinedConstantDataFromNoir(combinedConstantData: CombinedConstantDataNoir): CombinedConstantData { + return new CombinedConstantData( + mapHeaderFromNoir(combinedConstantData.historical_header), + mapTxContextFromNoir(combinedConstantData.tx_context), + mapFieldFromNoir(combinedConstantData.vk_tree_root), + mapFieldFromNoir(combinedConstantData.protocol_contract_tree_root), + mapGlobalVariablesFromNoir(combinedConstantData.global_variables), + ); +} + +function mapCombinedConstantDataToNoir(combinedConstantData: CombinedConstantData): CombinedConstantDataNoir { + return { + historical_header: mapHeaderToNoir(combinedConstantData.historicalHeader), + tx_context: mapTxContextToNoir(combinedConstantData.txContext), + vk_tree_root: mapFieldToNoir(combinedConstantData.vkTreeRoot), + protocol_contract_tree_root: mapFieldToNoir(combinedConstantData.protocolContractTreeRoot), + global_variables: mapGlobalVariablesToNoir(combinedConstantData.globalVariables), + }; +} + +function mapTxConstantDataToNoir(data: TxConstantData): TxConstantDataNoir { + return { + historical_header: mapHeaderToNoir(data.historicalHeader), + tx_context: mapTxContextToNoir(data.txContext), + vk_tree_root: mapFieldToNoir(data.vkTreeRoot), + protocol_contract_tree_root: mapFieldToNoir(data.protocolContractTreeRoot), + }; +} + +export function mapPrivateToPublicKernelCircuitPublicInputsToNoir( + inputs: PrivateToPublicKernelCircuitPublicInputs, +): PrivateToPublicKernelCircuitPublicInputsNoir { + return { + constants: mapTxConstantDataToNoir(inputs.constants), + rollup_validation_requests: mapRollupValidationRequestsToNoir(inputs.rollupValidationRequests), + non_revertible_accumulated_data: mapPrivateToPublicAccumulatedDataToNoir(inputs.nonRevertibleAccumulatedData), + revertible_accumulated_data: mapPrivateToPublicAccumulatedDataToNoir(inputs.revertibleAccumulatedData), + public_teardown_call_request: mapPublicCallRequestToNoir(inputs.publicTeardownCallRequest), + gas_used: mapGasToNoir(inputs.gasUsed), + fee_payer: mapAztecAddressToNoir(inputs.feePayer), + }; +} + +export function mapKernelCircuitPublicInputsToNoir(inputs: KernelCircuitPublicInputs): KernelCircuitPublicInputsNoir { + return { + rollup_validation_requests: mapRollupValidationRequestsToNoir(inputs.rollupValidationRequests), + constants: mapCombinedConstantDataToNoir(inputs.constants), + end: mapCombinedAccumulatedDataToNoir(inputs.end), + start_state: mapPartialStateReferenceToNoir(inputs.startState), + revert_code: mapRevertCodeToNoir(inputs.revertCode), + gas_used: mapGasToNoir(inputs.gasUsed), + fee_payer: mapAztecAddressToNoir(inputs.feePayer), + }; +} + +function mapPrivateToAvmAccumulatedDataToNoir(data: PrivateToAvmAccumulatedData): PrivateToAvmAccumulatedDataNoir { + return { + note_hashes: mapTuple(data.noteHashes, mapFieldToNoir), + nullifiers: mapTuple(data.nullifiers, mapFieldToNoir), + l2_to_l1_msgs: mapTuple(data.l2ToL1Msgs, mapScopedL2ToL1MessageToNoir), + }; +} + +function mapPrivateToAvmAccumulatedDataArrayLengthsToNoir( + data: PrivateToAvmAccumulatedDataArrayLengths, +): PrivateToAvmAccumulatedDataArrayLengthsNoir { + return { + note_hashes: mapNumberToNoir(data.noteHashes), + nullifiers: mapNumberToNoir(data.nullifiers), + l2_to_l1_msgs: mapNumberToNoir(data.l2ToL1Msgs), + }; +} + +function mapAvmAccumulatedDataToNoir(data: AvmAccumulatedData): AvmAccumulatedDataNoir { + return { + note_hashes: mapTuple(data.noteHashes, mapFieldToNoir), + nullifiers: mapTuple(data.nullifiers, mapFieldToNoir), + l2_to_l1_msgs: mapTuple(data.l2ToL1Msgs, mapScopedL2ToL1MessageToNoir), + unencrypted_logs_hashes: mapTuple(data.unencryptedLogsHashes, mapScopedLogHashToNoir), + public_data_writes: mapTuple(data.publicDataWrites, mapPublicDataWriteToNoir), + }; +} + +function mapAvmCircuitPublicInputsToNoir(inputs: AvmCircuitPublicInputs): AvmCircuitPublicInputsNoir { + return { + global_variables: mapGlobalVariablesToNoir(inputs.globalVariables), + start_tree_snapshots: mapTreeSnapshotsToNoir(inputs.startTreeSnapshots), + start_gas_used: mapGasToNoir(inputs.startGasUsed), + gas_settings: mapGasSettingsToNoir(inputs.gasSettings), + fee_payer: mapAztecAddressToNoir(inputs.feePayer), + public_setup_call_requests: mapTuple(inputs.publicSetupCallRequests, mapPublicCallRequestToNoir), + public_app_logic_call_requests: mapTuple(inputs.publicAppLogicCallRequests, mapPublicCallRequestToNoir), + public_teardown_call_request: mapPublicCallRequestToNoir(inputs.publicTeardownCallRequest), + previous_non_revertible_accumulated_data_array_lengths: mapPrivateToAvmAccumulatedDataArrayLengthsToNoir( + inputs.previousNonRevertibleAccumulatedDataArrayLengths, + ), + previous_revertible_accumulated_data_array_lengths: mapPrivateToAvmAccumulatedDataArrayLengthsToNoir( + inputs.previousRevertibleAccumulatedDataArrayLengths, + ), + previous_non_revertible_accumulated_data: mapPrivateToAvmAccumulatedDataToNoir( + inputs.previousNonRevertibleAccumulatedData, + ), + previous_revertible_accumulated_data: mapPrivateToAvmAccumulatedDataToNoir( + inputs.previousRevertibleAccumulatedData, + ), + end_tree_snapshots: mapTreeSnapshotsToNoir(inputs.endTreeSnapshots), + end_gas_used: mapGasToNoir(inputs.endGasUsed), + accumulated_data: mapAvmAccumulatedDataToNoir(inputs.accumulatedData), + transaction_fee: mapFieldToNoir(inputs.transactionFee), + reverted: inputs.reverted, + }; +} + +/** + * Maps a block root or block merge rollup public inputs from noir to the circuits.js type. + * @param blockRootOrBlockMergePublicInputs - The noir lock root or block merge rollup public inputs. + * @returns The circuits.js block root or block merge rollup public inputs. + */ +export function mapBlockRootOrBlockMergePublicInputsFromNoir( + blockRootOrBlockMergePublicInputs: BlockRootOrBlockMergePublicInputsNoir, +): BlockRootOrBlockMergePublicInputs { + return new BlockRootOrBlockMergePublicInputs( + mapAppendOnlyTreeSnapshotFromNoir(blockRootOrBlockMergePublicInputs.previous_archive), + mapAppendOnlyTreeSnapshotFromNoir(blockRootOrBlockMergePublicInputs.new_archive), + mapFieldFromNoir(blockRootOrBlockMergePublicInputs.previous_block_hash), + mapFieldFromNoir(blockRootOrBlockMergePublicInputs.end_block_hash), + mapGlobalVariablesFromNoir(blockRootOrBlockMergePublicInputs.start_global_variables), + mapGlobalVariablesFromNoir(blockRootOrBlockMergePublicInputs.end_global_variables), + mapFieldFromNoir(blockRootOrBlockMergePublicInputs.out_hash), + mapTupleFromNoir(blockRootOrBlockMergePublicInputs.fees, AZTEC_MAX_EPOCH_DURATION, mapFeeRecipientFromNoir), + mapFieldFromNoir(blockRootOrBlockMergePublicInputs.vk_tree_root), + mapFieldFromNoir(blockRootOrBlockMergePublicInputs.protocol_contract_tree_root), + mapFieldFromNoir(blockRootOrBlockMergePublicInputs.prover_id), + mapTupleFromNoir( + blockRootOrBlockMergePublicInputs.blob_public_inputs, + AZTEC_MAX_EPOCH_DURATION, + mapBlockBlobPublicInputsFromNoir, + ), + ); +} + +/** + * Maps a previous rollup data from the circuits.js type to noir. + * @param previousRollupData - The circuits.js previous rollup data. + * @returns The noir previous rollup data. + */ +export function mapPreviousRollupDataToNoir(previousRollupData: PreviousRollupData): PreviousRollupDataNoir { + return { + base_or_merge_rollup_public_inputs: mapBaseOrMergeRollupPublicInputsToNoir( + previousRollupData.baseOrMergeRollupPublicInputs, + ), + proof: mapRecursiveProofToNoir(previousRollupData.proof), + vk: mapVerificationKeyToNoir(previousRollupData.vk, HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS), + vk_witness: { + leaf_index: mapFieldToNoir(new Fr(previousRollupData.vkWitness.leafIndex)), + sibling_path: mapTuple(previousRollupData.vkWitness.siblingPath, mapFieldToNoir), + }, + }; +} + +/** + * Maps a previous rollup data from the circuits.js type to noir. + * @param previousRollupData - The circuits.js previous rollup data. + * @returns The noir previous rollup data. + */ +export function mapPreviousRollupBlockDataToNoir( + previousRollupData: PreviousRollupBlockData, +): PreviousRollupBlockDataNoir { + return { + block_root_or_block_merge_public_inputs: mapBlockRootOrBlockMergePublicInputsToNoir( + previousRollupData.blockRootOrBlockMergePublicInputs, + ), + proof: mapRecursiveProofToNoir(previousRollupData.proof), + vk: mapVerificationKeyToNoir(previousRollupData.vk, HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS), + vk_witness: { + leaf_index: mapFieldToNoir(new Fr(previousRollupData.vkWitness.leafIndex)), + sibling_path: mapTuple(previousRollupData.vkWitness.siblingPath, mapFieldToNoir), + }, + }; +} + +export function mapRootRollupParityInputToNoir( + rootParityInput: RootParityInput, +): RootRollupParityInputNoir { + return { + proof: mapRecursiveProofToNoir(rootParityInput.proof), + verification_key: mapVerificationKeyToNoir(rootParityInput.verificationKey, HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS), + vk_path: mapTuple(rootParityInput.vkPath, mapFieldToNoir), + public_inputs: mapParityPublicInputsToNoir(rootParityInput.publicInputs), + }; +} + +/** + * Maps the block root rollup inputs to noir. + * @param rootRollupInputs - The circuits.js block root rollup inputs. + * @returns The noir block root rollup inputs. + */ +export function mapBlockRootRollupInputsToNoir(rootRollupInputs: BlockRootRollupInputs): BlockRootRollupInputsNoir { + return { + previous_rollup_data: mapTuple(rootRollupInputs.previousRollupData, mapPreviousRollupDataToNoir), + l1_to_l2_roots: mapRootRollupParityInputToNoir(rootRollupInputs.l1ToL2Roots), + l1_to_l2_messages: mapTuple(rootRollupInputs.newL1ToL2Messages, mapFieldToNoir), + l1_to_l2_message_subtree_sibling_path: mapTuple( + rootRollupInputs.newL1ToL2MessageTreeRootSiblingPath, + mapFieldToNoir, + ), + start_l1_to_l2_message_tree_snapshot: mapAppendOnlyTreeSnapshotToNoir( + rootRollupInputs.startL1ToL2MessageTreeSnapshot, + ), + start_archive_snapshot: mapAppendOnlyTreeSnapshotToNoir(rootRollupInputs.startArchiveSnapshot), + new_archive_sibling_path: mapTuple(rootRollupInputs.newArchiveSiblingPath, mapFieldToNoir), + previous_block_hash: mapFieldToNoir(rootRollupInputs.previousBlockHash), + prover_id: mapFieldToNoir(rootRollupInputs.proverId), + // @ts-expect-error - below line gives error 'Type instantiation is excessively deep and possibly infinite. ts(2589)' + blobs_fields: mapTuple(rootRollupInputs.blobFields, mapFieldToNoir), + blob_commitments: mapTuple(rootRollupInputs.blobCommitments, mapBlobCommitmentToNoir), + blobs_hash: mapFieldToNoir(rootRollupInputs.blobsHash), + }; +} + +/** + * Maps the empty block root rollup inputs to noir. + * @param rootRollupInputs - The circuits.js block root rollup inputs. + * @returns The noir block root rollup inputs. + */ +export function mapEmptyBlockRootRollupInputsToNoir( + rootRollupInputs: EmptyBlockRootRollupInputs, +): EmptyBlockRootRollupInputsNoir { + return { + archive: mapAppendOnlyTreeSnapshotToNoir(rootRollupInputs.archive), + block_hash: mapFieldToNoir(rootRollupInputs.blockHash), + global_variables: mapGlobalVariablesToNoir(rootRollupInputs.globalVariables), + vk_tree_root: mapFieldToNoir(rootRollupInputs.vkTreeRoot), + protocol_contract_tree_root: mapFieldToNoir(rootRollupInputs.protocolContractTreeRoot), + prover_id: mapFieldToNoir(rootRollupInputs.proverId), + }; +} + +/** + * Maps the root rollup inputs to noir. + * @param rootRollupInputs - The circuits.js root rollup inputs. + * @returns The noir root rollup inputs. + */ +export function mapRootRollupInputsToNoir(rootRollupInputs: RootRollupInputs): RootRollupInputsNoir { + return { + previous_rollup_data: mapTuple(rootRollupInputs.previousRollupData, mapPreviousRollupBlockDataToNoir), + prover_id: mapFieldToNoir(rootRollupInputs.proverId), + }; +} + +/** + * Maps a base or merge rollup public inputs from noir to the circuits.js type. + * @param baseOrMergeRollupPublicInputs - The noir base or merge rollup public inputs. + * @returns The circuits.js base or merge rollup public inputs. + */ +export function mapBaseOrMergeRollupPublicInputsFromNoir( + baseOrMergeRollupPublicInputs: BaseOrMergeRollupPublicInputsNoir, +): BaseOrMergeRollupPublicInputs { + return new BaseOrMergeRollupPublicInputs( + mapNumberFromNoir(baseOrMergeRollupPublicInputs.rollup_type), + mapNumberFromNoir(baseOrMergeRollupPublicInputs.num_txs), + mapConstantRollupDataFromNoir(baseOrMergeRollupPublicInputs.constants), + mapPartialStateReferenceFromNoir(baseOrMergeRollupPublicInputs.start), + mapPartialStateReferenceFromNoir(baseOrMergeRollupPublicInputs.end), + mapSpongeBlobFromNoir(baseOrMergeRollupPublicInputs.start_sponge_blob), + mapSpongeBlobFromNoir(baseOrMergeRollupPublicInputs.end_sponge_blob), + mapFieldFromNoir(baseOrMergeRollupPublicInputs.out_hash), + mapFieldFromNoir(baseOrMergeRollupPublicInputs.accumulated_fees), + mapFieldFromNoir(baseOrMergeRollupPublicInputs.accumulated_mana_used), + ); +} + +/** + * Maps private base state diff hints to a noir state diff hints. + * @param hints - The state diff hints. + * @returns The noir state diff hints. + */ +export function mapPrivateBaseStateDiffHintsToNoir(hints: PrivateBaseStateDiffHints): PrivateBaseStateDiffHintsNoir { + return { + nullifier_predecessor_preimages: mapTuple(hints.nullifierPredecessorPreimages, mapNullifierLeafPreimageToNoir), + nullifier_predecessor_membership_witnesses: mapTuple( + hints.nullifierPredecessorMembershipWitnesses, + (witness: MembershipWitness) => mapMembershipWitnessToNoir(witness), + ), + sorted_nullifiers: mapTuple(hints.sortedNullifiers, mapFieldToNoir), + sorted_nullifier_indexes: mapTuple(hints.sortedNullifierIndexes, (index: number) => mapNumberToNoir(index)), + note_hash_subtree_sibling_path: mapTuple(hints.noteHashSubtreeSiblingPath, mapFieldToNoir), + nullifier_subtree_sibling_path: mapTuple(hints.nullifierSubtreeSiblingPath, mapFieldToNoir), + fee_write_low_leaf_preimage: mapPublicDataTreePreimageToNoir(hints.feeWriteLowLeafPreimage), + fee_write_low_leaf_membership_witness: mapMembershipWitnessToNoir(hints.feeWriteLowLeafMembershipWitness), + fee_write_sibling_path: mapTuple(hints.feeWriteSiblingPath, mapFieldToNoir), + }; +} + +/** + * Maps public base state diff hints to a noir state diff hints. + * @param hints - The state diff hints. + * @returns The noir state diff hints. + */ +export function mapPublicBaseStateDiffHintsToNoir(hints: PublicBaseStateDiffHints): PublicBaseStateDiffHintsNoir { + return { + nullifier_predecessor_preimages: mapTuple(hints.nullifierPredecessorPreimages, mapNullifierLeafPreimageToNoir), + nullifier_predecessor_membership_witnesses: mapTuple( + hints.nullifierPredecessorMembershipWitnesses, + (witness: MembershipWitness) => mapMembershipWitnessToNoir(witness), + ), + sorted_nullifiers: mapTuple(hints.sortedNullifiers, mapFieldToNoir), + sorted_nullifier_indexes: mapTuple(hints.sortedNullifierIndexes, (index: number) => mapNumberToNoir(index)), + note_hash_subtree_sibling_path: mapTuple(hints.noteHashSubtreeSiblingPath, mapFieldToNoir), + nullifier_subtree_sibling_path: mapTuple(hints.nullifierSubtreeSiblingPath, mapFieldToNoir), + low_public_data_writes_preimages: mapTuple(hints.lowPublicDataWritesPreimages, mapPublicDataTreePreimageToNoir), + low_public_data_writes_witnesses: mapTuple( + hints.lowPublicDataWritesMembershipWitnesses, + (witness: MembershipWitness) => mapMembershipWitnessToNoir(witness), + ), + public_data_tree_sibling_paths: mapTuple(hints.publicDataTreeSiblingPaths, path => mapTuple(path, mapFieldToNoir)), + }; +} + +/** + * Maps base parity inputs to noir. + * @param inputs - The circuits.js base parity inputs. + * @returns The noir base parity inputs. + */ +export function mapBaseParityInputsToNoir(inputs: BaseParityInputs): BaseParityInputsNoir { + return { + msgs: mapTuple(inputs.msgs, mapFieldToNoir), + vk_tree_root: mapFieldToNoir(inputs.vkTreeRoot), + }; +} + +/** + * Maps root parity inputs to noir. + * @param inputs - The circuits.js root parity inputs. + * @returns The noir root parity inputs. + */ +export function mapRootParityInputsToNoir(inputs: RootParityInputs): RootParityInputsNoir { + return { + children: mapTuple(inputs.children, mapRootParityInputToNoir), + }; +} + +function mapPrivateTubeDataToNoir(data: PrivateTubeData): PrivateTubeDataNoir { + return { + public_inputs: mapKernelCircuitPublicInputsToNoir(data.publicInputs), + proof: mapRecursiveProofToNoir(data.proof), + vk_data: mapVkWitnessDataToNoir(data.vkData, HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS), + }; +} + +/** + * Maps the inputs to the base rollup to noir. + * @param input - The circuits.js base rollup inputs. + * @returns The noir base rollup inputs. + */ +export function mapPrivateBaseRollupInputsToNoir(inputs: PrivateBaseRollupInputs): PrivateBaseRollupInputsNoir { + return { + tube_data: mapPrivateTubeDataToNoir(inputs.tubeData), + start: mapPartialStateReferenceToNoir(inputs.hints.start), + start_sponge_blob: mapSpongeBlobToNoir(inputs.hints.startSpongeBlob), + state_diff_hints: mapPrivateBaseStateDiffHintsToNoir(inputs.hints.stateDiffHints), + + archive_root_membership_witness: mapMembershipWitnessToNoir(inputs.hints.archiveRootMembershipWitness), + constants: mapConstantRollupDataToNoir(inputs.hints.constants), + fee_payer_fee_juice_balance_read_hint: mapPublicDataHintToNoir(inputs.hints.feePayerFeeJuiceBalanceReadHint), + }; +} + +function mapVkWitnessDataToNoir(vkData: VkWitnessData, length: N): VkDataNoir { + return { + vk: mapVerificationKeyToNoir(vkData.vk.keyAsFields, length), + vk_index: mapFieldToNoir(new Fr(vkData.vkIndex)), + vk_path: mapTuple(vkData.vkPath, mapFieldToNoir), + }; +} + +function mapPublicTubeDataToNoir(data: PublicTubeData): PublicTubeDataNoir { + return { + public_inputs: mapPrivateToPublicKernelCircuitPublicInputsToNoir(data.publicInputs), + proof: mapRecursiveProofToNoir(data.proof), + vk_data: mapVkWitnessDataToNoir(data.vkData, HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS), + }; +} + +function mapAvmProofDataToNoir(data: AvmProofData): AvmProofDataNoir { + return { + public_inputs: mapAvmCircuitPublicInputsToNoir(data.publicInputs), + proof: mapRecursiveProofToNoir(data.proof), + vk_data: mapVkWitnessDataToNoir(data.vkData, AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS), + }; +} + +export function mapPublicBaseRollupInputsToNoir(inputs: PublicBaseRollupInputs): PublicBaseRollupInputsNoir { + return { + tube_data: mapPublicTubeDataToNoir(inputs.tubeData), + avm_proof_data: mapAvmProofDataToNoir(inputs.avmProofData), + start: mapPartialStateReferenceToNoir(inputs.hints.start), + start_sponge_blob: mapSpongeBlobToNoir(inputs.hints.startSpongeBlob), + state_diff_hints: mapPublicBaseStateDiffHintsToNoir(inputs.hints.stateDiffHints), + + archive_root_membership_witness: mapMembershipWitnessToNoir(inputs.hints.archiveRootMembershipWitness), + constants: mapConstantRollupDataToNoir(inputs.hints.constants), + }; +} + +export function mapEmptyKernelInputsToNoir(inputs: PrivateKernelEmptyInputs): PrivateKernelEmptyPrivateInputsNoir { + return { + empty_nested: mapEmptyNestedDataToNoir(inputs.emptyNested), + historical_header: mapHeaderToNoir(inputs.header), + chain_id: mapFieldToNoir(inputs.chainId), + version: mapFieldToNoir(inputs.version), + vk_tree_root: mapFieldToNoir(inputs.vkTreeRoot), + protocol_contract_tree_root: mapFieldToNoir(inputs.protocolContractTreeRoot), + }; +} + +function mapEmptyNestedDataToNoir(inputs: EmptyNestedData): EmptyNestedDataNoir { + return { + proof: mapRecursiveProofToNoir(inputs.proof), + vk: mapVerificationKeyToNoir(inputs.vk, HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS), + }; +} + +/** + * Maps the merge rollup inputs to noir. + * @param mergeRollupInputs - The circuits.js merge rollup inputs. + * @returns The noir merge rollup inputs. + */ +export function mapMergeRollupInputsToNoir(mergeRollupInputs: MergeRollupInputs): MergeRollupInputsNoir { + return { + previous_rollup_data: mapTuple(mergeRollupInputs.previousRollupData, mapPreviousRollupDataToNoir), + }; +} + +/** + * Maps the block merge rollup inputs to noir. + * @param mergeRollupInputs - The circuits.js block merge rollup inputs. + * @returns The noir block merge rollup inputs. + */ +export function mapBlockMergeRollupInputsToNoir(mergeRollupInputs: BlockMergeRollupInputs): BlockMergeRollupInputsNoir { + return { + previous_rollup_data: mapTuple(mergeRollupInputs.previousRollupData, mapPreviousRollupBlockDataToNoir), + }; +} + +export function mapRollupValidationRequestsToNoir( + rollupValidationRequests: RollupValidationRequests, +): RollupValidationRequestsNoir { + return { + max_block_number: mapMaxBlockNumberToNoir(rollupValidationRequests.maxBlockNumber), + }; +} + +export function mapRollupValidationRequestsFromNoir( + rollupValidationRequests: RollupValidationRequestsNoir, +): RollupValidationRequests { + return new RollupValidationRequests(mapMaxBlockNumberFromNoir(rollupValidationRequests.max_block_number)); +} + +export function mapRevertCodeFromNoir(revertCode: NoirField): RevertCode { + return RevertCode.fromField(mapFieldFromNoir(revertCode)); +} + +export function mapRevertCodeToNoir(revertCode: RevertCode): NoirField { + return mapFieldToNoir(revertCode.toField()); +} + +export function mapKernelCircuitPublicInputsFromNoir(inputs: KernelCircuitPublicInputsNoir) { + return new KernelCircuitPublicInputs( + mapRollupValidationRequestsFromNoir(inputs.rollup_validation_requests), + mapCombinedAccumulatedDataFromNoir(inputs.end), + mapCombinedConstantDataFromNoir(inputs.constants), + mapPartialStateReferenceFromNoir(inputs.start_state), + mapRevertCodeFromNoir(inputs.revert_code), + mapGasFromNoir(inputs.gas_used), + mapAztecAddressFromNoir(inputs.fee_payer), + ); +} diff --git a/yarn-project/noir-protocol-circuits-types/src/type_conversion.test.ts b/yarn-project/noir-protocol-circuits-types/src/conversion/type_conversion.test.ts similarity index 95% rename from yarn-project/noir-protocol-circuits-types/src/type_conversion.test.ts rename to yarn-project/noir-protocol-circuits-types/src/conversion/type_conversion.test.ts index 7bb7d82cd38..02fadc4d347 100644 --- a/yarn-project/noir-protocol-circuits-types/src/type_conversion.test.ts +++ b/yarn-project/noir-protocol-circuits-types/src/conversion/type_conversion.test.ts @@ -1,6 +1,7 @@ import { AztecAddress, EthAddress, Fr, FunctionData, FunctionSelector, Point } from '@aztec/circuits.js'; import { makeHeader } from '@aztec/circuits.js/testing'; +import { mapFunctionDataFromNoir, mapFunctionDataToNoir } from './client.js'; import { mapAztecAddressFromNoir, mapAztecAddressToNoir, @@ -8,15 +9,13 @@ import { mapEthAddressToNoir, mapFieldFromNoir, mapFieldToNoir, - mapFunctionDataFromNoir, - mapFunctionDataToNoir, mapFunctionSelectorFromNoir, mapFunctionSelectorToNoir, mapHeaderFromNoir, mapHeaderToNoir, mapPointFromNoir, mapPointToNoir, -} from './type_conversion.js'; +} from './common.js'; describe('Noir<>Circuits.js type conversion test suite', () => { describe('Round trip', () => { diff --git a/yarn-project/noir-protocol-circuits-types/src/execution/client.ts b/yarn-project/noir-protocol-circuits-types/src/execution/client.ts index 795e3773dc1..35dd960f42b 100644 --- a/yarn-project/noir-protocol-circuits-types/src/execution/client.ts +++ b/yarn-project/noir-protocol-circuits-types/src/execution/client.ts @@ -14,9 +14,7 @@ import { type CompiledCircuit, type InputMap, Noir, type WitnessMap } from '@noi import { type Abi, abiDecode, abiEncode } from '@noir-lang/noirc_abi'; import { ClientCircuitArtifacts, SimulatedClientCircuitArtifacts } from '../artifacts/client.js'; -import { type PrivateResetArtifact } from '../private_kernel_reset_data.js'; import { - mapFieldToNoir, mapPrivateCallDataToNoir, mapPrivateCircuitPublicInputsToNoir, mapPrivateKernelCircuitPublicInputsFromNoir, @@ -26,7 +24,9 @@ import { mapPrivateKernelTailCircuitPublicInputsForPublicFromNoir, mapPrivateKernelTailCircuitPublicInputsForRollupFromNoir, mapTxRequestToNoir, -} from '../type_conversion.js'; +} from '../conversion/client.js'; +import { mapFieldToNoir } from '../conversion/common.js'; +import { type PrivateResetArtifact } from '../private_kernel_reset_data.js'; import { type PrivateKernelInitReturnType, type PrivateKernelInnerReturnType, diff --git a/yarn-project/noir-protocol-circuits-types/src/execution/server.ts b/yarn-project/noir-protocol-circuits-types/src/execution/server.ts index b21c973dc74..b9c198477e3 100644 --- a/yarn-project/noir-protocol-circuits-types/src/execution/server.ts +++ b/yarn-project/noir-protocol-circuits-types/src/execution/server.ts @@ -1,20 +1,22 @@ import { - type BaseOrMergeRollupPublicInputs, type BaseParityInputs, - type BlockMergeRollupInputs, - type BlockRootOrBlockMergePublicInputs, - type BlockRootRollupInputs, - type EmptyBlockRootRollupInputs, type KernelCircuitPublicInputs, - type MergeRollupInputs, type ParityPublicInputs, - type PrivateBaseRollupInputs, type PrivateKernelEmptyInputs, - type PublicBaseRollupInputs, type RootParityInputs, - type RootRollupInputs, - type RootRollupPublicInputs, } from '@aztec/circuits.js'; +import { + BaseOrMergeRollupPublicInputs, + BlockMergeRollupInputs, + BlockRootOrBlockMergePublicInputs, + BlockRootRollupInputs, + EmptyBlockRootRollupInputs, + MergeRollupInputs, + PrivateBaseRollupInputs, + PublicBaseRollupInputs, + RootRollupInputs, + RootRollupPublicInputs, +} from '@aztec/circuits.js/rollup'; import { pushTestData } from '@aztec/foundation/testing'; import { type WitnessMap } from '@noir-lang/acvm_js'; @@ -37,7 +39,7 @@ import { mapRootParityInputsToNoir, mapRootRollupInputsToNoir, mapRootRollupPublicInputsFromNoir, -} from '../type_conversion.js'; +} from '../conversion/server.js'; import { type ParityBaseReturnType, type ParityRootReturnType, diff --git a/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts b/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts deleted file mode 100644 index e6dcafdeee5..00000000000 --- a/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts +++ /dev/null @@ -1,2373 +0,0 @@ -import { - type AVM_PROOF_LENGTH_IN_FIELDS, - AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS, - AZTEC_MAX_EPOCH_DURATION, - AppendOnlyTreeSnapshot, - type AvmAccumulatedData, - type AvmCircuitPublicInputs, - type AvmProofData, - AztecAddress, - BLOBS_PER_BLOCK, - BaseOrMergeRollupPublicInputs, - type BaseParityInputs, - BlobPublicInputs, - BlockBlobPublicInputs, - BlockHeader, - type BlockMergeRollupInputs, - BlockRootOrBlockMergePublicInputs, - type BlockRootRollupInputs, - CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS, - CallContext, - CombinedAccumulatedData, - CombinedConstantData, - ConstantRollupData, - ContentCommitment, - CountedPublicCallRequest, - type EmptyBlockRootRollupInputs, - type EmptyNestedData, - EthAddress, - FeeRecipient, - Fr, - FunctionData, - FunctionSelector, - Gas, - GasFees, - GasSettings, - GlobalVariables, - GrumpkinScalar, - HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS, - KernelCircuitPublicInputs, - type KeyValidationHint, - KeyValidationRequest, - KeyValidationRequestAndGenerator, - L2ToL1Message, - LogHash, - MAX_CONTRACT_CLASS_LOGS_PER_TX, - MAX_ENQUEUED_CALLS_PER_TX, - MAX_KEY_VALIDATION_REQUESTS_PER_TX, - MAX_L2_TO_L1_MSGS_PER_TX, - MAX_NOTE_HASHES_PER_TX, - MAX_NOTE_HASH_READ_REQUESTS_PER_TX, - MAX_NULLIFIERS_PER_TX, - MAX_NULLIFIER_READ_REQUESTS_PER_TX, - MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, - MAX_PRIVATE_LOGS_PER_TX, - MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - MAX_UNENCRYPTED_LOGS_PER_TX, - MaxBlockNumber, - type MembershipWitness, - type MergeRollupInputs, - type NESTED_RECURSIVE_PROOF_LENGTH, - type NOTE_HASH_TREE_HEIGHT, - type NULLIFIER_TREE_HEIGHT, - NUM_BYTES_PER_SHA256, - NoteHash, - type NoteHashReadRequestHints, - Nullifier, - type NullifierLeafPreimage, - type NullifierReadRequestHints, - OptionalNumber, - type PUBLIC_DATA_TREE_HEIGHT, - ParityPublicInputs, - PartialPrivateTailPublicInputsForPublic, - PartialPrivateTailPublicInputsForRollup, - PartialStateReference, - type PendingReadHint, - Point, - Poseidon2Sponge, - type PreviousRollupBlockData, - type PreviousRollupData, - PrivateAccumulatedData, - type PrivateBaseRollupInputs, - type PrivateBaseStateDiffHints, - type PrivateCallData, - PrivateCallRequest, - type PrivateCircuitPublicInputs, - PrivateKernelCircuitPublicInputs, - type PrivateKernelData, - type PrivateKernelEmptyInputs, - type PrivateKernelResetHints, - PrivateKernelTailCircuitPublicInputs, - PrivateLog, - PrivateLogData, - type PrivateToAvmAccumulatedData, - type PrivateToAvmAccumulatedDataArrayLengths, - PrivateToPublicAccumulatedData, - type PrivateToPublicKernelCircuitPublicInputs, - type PrivateTubeData, - PrivateValidationRequests, - type PublicBaseRollupInputs, - type PublicBaseStateDiffHints, - PublicCallRequest, - type PublicDataHint, - type PublicDataTreeLeafPreimage, - PublicDataWrite, - type PublicKeys, - type PublicTubeData, - type RECURSIVE_PROOF_LENGTH, - ReadRequest, - type ReadRequestStatus, - type RecursiveProof, - RevertCode, - RollupValidationRequests, - type RootParityInput, - type RootParityInputs, - type RootRollupInputs, - RootRollupPublicInputs, - ScopedKeyValidationRequestAndGenerator, - ScopedL2ToL1Message, - ScopedLogHash, - ScopedNoteHash, - ScopedNullifier, - ScopedPrivateLogData, - ScopedReadRequest, - type SettledReadHint, - SpongeBlob, - StateReference, - type TUBE_PROOF_LENGTH, - type TransientDataIndexHint, - type TreeSnapshots, - TxConstantData, - TxContext, - type TxRequest, - type VerificationKeyAsFields, - type VkWitnessData, -} from '@aztec/circuits.js'; -import { toBufferBE, toHex } from '@aztec/foundation/bigint-buffer'; -import { type Tuple, mapTuple, toTruncField } from '@aztec/foundation/serialize'; - -import type { - AppendOnlyTreeSnapshot as AppendOnlyTreeSnapshotNoir, - AvmAccumulatedData as AvmAccumulatedDataNoir, - AvmCircuitPublicInputs as AvmCircuitPublicInputsNoir, - AvmProofData as AvmProofDataNoir, - BaseOrMergeRollupPublicInputs as BaseOrMergeRollupPublicInputsNoir, - BaseParityInputs as BaseParityInputsNoir, - BigNum, - BlobCommitment as BlobCommitmentNoir, - BlobPublicInputs as BlobPublicInputsNoir, - BlockBlobPublicInputs as BlockBlobPublicInputsNoir, - BlockHeader as BlockHeaderNoir, - BlockMergeRollupInputs as BlockMergeRollupInputsNoir, - BlockRootOrBlockMergePublicInputs as BlockRootOrBlockMergePublicInputsNoir, - BlockRootRollupInputs as BlockRootRollupInputsNoir, - CallContext as CallContextNoir, - CombinedAccumulatedData as CombinedAccumulatedDataNoir, - CombinedConstantData as CombinedConstantDataNoir, - ConstantRollupData as ConstantRollupDataNoir, - ContentCommitment as ContentCommitmentNoir, - Counted as CountedPublicCallRequestNoir, - EmptyBlockRootRollupInputs as EmptyBlockRootRollupInputsNoir, - EmptyNestedCircuitPublicInputs as EmptyNestedDataNoir, - FeeRecipient as FeeRecipientNoir, - Field, - FixedLengthArray, - FunctionData as FunctionDataNoir, - FunctionSelector as FunctionSelectorNoir, - GasFees as GasFeesNoir, - Gas as GasNoir, - GasSettings as GasSettingsNoir, - GlobalVariables as GlobalVariablesNoir, - EmbeddedCurveScalar as GrumpkinScalarNoir, - KernelCircuitPublicInputs as KernelCircuitPublicInputsNoir, - KeyValidationHint as KeyValidationHintNoir, - KeyValidationRequestAndGenerator as KeyValidationRequestAndGeneratorNoir, - KeyValidationRequest as KeyValidationRequestsNoir, - L2ToL1Message as L2ToL1MessageNoir, - LogHash as LogHashNoir, - MaxBlockNumber as MaxBlockNumberNoir, - MembershipWitness as MembershipWitnessNoir, - MergeRollupInputs as MergeRollupInputsNoir, - AztecAddress as NoirAztecAddress, - EthAddress as NoirEthAddress, - Field as NoirField, - EmbeddedCurvePoint as NoirPoint, - NoteHashLeafPreimage as NoteHashLeafPreimageNoir, - NoteHash as NoteHashNoir, - NoteHashReadRequestHints as NoteHashReadRequestHintsNoir, - NoteHashSettledReadHint as NoteHashSettledReadHintNoir, - NullifierLeafPreimage as NullifierLeafPreimageNoir, - Nullifier as NullifierNoir, - NullifierReadRequestHints as NullifierReadRequestHintsNoir, - NullifierSettledReadHint as NullifierSettledReadHintNoir, - Option as OptionalNumberNoir, - ParityPublicInputs as ParityPublicInputsNoir, - RootParityInput as ParityRootParityInputNoir, - PartialStateReference as PartialStateReferenceNoir, - PendingReadHint as PendingReadHintNoir, - Poseidon2 as Poseidon2SpongeNoir, - PreviousRollupBlockData as PreviousRollupBlockDataNoir, - PreviousRollupData as PreviousRollupDataNoir, - PrivateAccumulatedData as PrivateAccumulatedDataNoir, - PrivateBaseRollupInputs as PrivateBaseRollupInputsNoir, - PrivateBaseStateDiffHints as PrivateBaseStateDiffHintsNoir, - PrivateCallDataWithoutPublicInputs as PrivateCallDataWithoutPublicInputsNoir, - PrivateCallRequest as PrivateCallRequestNoir, - PrivateCircuitPublicInputs as PrivateCircuitPublicInputsNoir, - PrivateKernelCircuitPublicInputs as PrivateKernelCircuitPublicInputsNoir, - PrivateKernelDataWithoutPublicInputs as PrivateKernelDataWithoutPublicInputsNoir, - PrivateKernelEmptyPrivateInputs as PrivateKernelEmptyPrivateInputsNoir, - PrivateKernelResetHints as PrivateKernelResetHintsNoir, - PrivateLogData as PrivateLogDataNoir, - Log as PrivateLogNoir, - PrivateToAvmAccumulatedDataArrayLengths as PrivateToAvmAccumulatedDataArrayLengthsNoir, - PrivateToAvmAccumulatedData as PrivateToAvmAccumulatedDataNoir, - PrivateToPublicAccumulatedData as PrivateToPublicAccumulatedDataNoir, - PrivateToPublicKernelCircuitPublicInputs as PrivateToPublicKernelCircuitPublicInputsNoir, - PrivateTubeData as PrivateTubeDataNoir, - PrivateValidationRequests as PrivateValidationRequestsNoir, - PublicBaseRollupInputs as PublicBaseRollupInputsNoir, - PublicBaseStateDiffHints as PublicBaseStateDiffHintsNoir, - PublicCallRequest as PublicCallRequestNoir, - PublicDataHint as PublicDataHintNoir, - PublicDataTreeLeafPreimage as PublicDataTreeLeafPreimageNoir, - PublicDataWrite as PublicDataWriteNoir, - PublicKeys as PublicKeysNoir, - PublicTubeData as PublicTubeDataNoir, - ReadRequest as ReadRequestNoir, - ReadRequestStatus as ReadRequestStatusNoir, - RollupValidationRequests as RollupValidationRequestsNoir, - RootParityInputs as RootParityInputsNoir, - RootRollupInputs as RootRollupInputsNoir, - RootRollupParityInput as RootRollupParityInputNoir, - RootRollupPublicInputs as RootRollupPublicInputsNoir, - ScopedKeyValidationRequestAndGenerator as ScopedKeyValidationRequestAndGeneratorNoir, - ScopedL2ToL1Message as ScopedL2ToL1MessageNoir, - ScopedLogHash as ScopedLogHashNoir, - ScopedNoteHash as ScopedNoteHashNoir, - ScopedNullifier as ScopedNullifierNoir, - Scoped as ScopedPrivateLogDataNoir, - ScopedReadRequest as ScopedReadRequestNoir, - SpongeBlob as SpongeBlobNoir, - StateReference as StateReferenceNoir, - TransientDataIndexHint as TransientDataIndexHintNoir, - TreeSnapshots as TreeSnapshotsNoir, - TxConstantData as TxConstantDataNoir, - TxContext as TxContextNoir, - TxRequest as TxRequestNoir, - VerificationKey as VerificationKeyNoir, - VkData as VkDataNoir, -} from './types/index.js'; - -/* eslint-disable camelcase */ - -/** - * Maps a field to a noir field. - * @param field - The field. - * @returns The noir field. - */ -export function mapFieldToNoir(field: Fr): NoirField { - return field.toString(); -} - -/** - * Maps a noir field to a fr. - * @param field - The noir field. - * @returns The fr. - */ -export function mapFieldFromNoir(field: NoirField): Fr { - return Fr.fromHexString(field); -} - -/** Maps a field to a noir wrapped field type (ie any type implemented as struct with an inner Field). */ -export function mapWrappedFieldToNoir(field: Fr): { inner: NoirField } { - return { inner: mapFieldToNoir(field) }; -} - -/** Maps a noir wrapped field type (ie any type implemented as struct with an inner Field) to a typescript field. */ -export function mapWrappedFieldFromNoir(wrappedField: { inner: NoirField }): Fr { - return mapFieldFromNoir(wrappedField.inner); -} - -/** - * Maps a number coming from noir. - * @param number - The field representing the number. - * @returns The number - */ -export function mapNumberFromNoir(number: NoirField): number { - return Number(Fr.fromHexString(number).toBigInt()); -} - -export function mapNumberToNoir(number: number): NoirField { - return new Fr(BigInt(number)).toString(); -} - -/** - * Maps a BigNum coming to/from noir. - * TODO(): Is BigInt the best way to represent this? - * @param number - The BigNum representing the number. - * @returns The number - */ -export function mapBLS12BigNumFromNoir(bignum: BigNum): bigint { - // TODO(Miranda): there's gotta be a better way to convert this - const paddedLimbs = [ - `0x` + bignum.limbs[2].substring(2).padStart(4, '0'), - bignum.limbs[1].substring(2).padStart(30, '0'), - bignum.limbs[0].substring(2).padStart(30, '0'), - ]; - return BigInt(paddedLimbs[0].concat(paddedLimbs[1], paddedLimbs[2])); -} - -export function mapBLS12BigNumToNoir(number: bigint): BigNum { - const hex = toHex(number, true); - return { - limbs: ['0x' + hex.substring(36), '0x' + hex.substring(6, 36), hex.substring(0, 6)], - }; -} - -/** - * Maps a point to a noir point. - * @param point - The point. - * @returns The noir point. - */ -export function mapPointToNoir(point: Point): NoirPoint { - return { - x: mapFieldToNoir(point.x), - y: mapFieldToNoir(point.y), - is_infinite: point.isInfinite, - }; -} - -/** - * Maps a noir point to a point. - * @param point - The noir point. - * @returns The point. - */ -export function mapPointFromNoir(point: NoirPoint): Point { - return new Point(mapFieldFromNoir(point.x), mapFieldFromNoir(point.y), point.is_infinite); -} - -/** - * Maps a GrumpkinScalar to a noir GrumpkinScalar. - * @param privateKey - The GrumpkinScalar. - * @returns The noir GrumpkinScalar. - */ -export function mapGrumpkinScalarToNoir(privateKey: GrumpkinScalar): GrumpkinScalarNoir { - return { - hi: mapFieldToNoir(privateKey.hi), - lo: mapFieldToNoir(privateKey.lo), - }; -} - -/** - * Maps a KeyValidationHint to noir. - * @param hint - The key validation hint. - * @returns The key validation hint mapped to noir types. - */ -export function mapKeyValidationHintToNoir(hint: KeyValidationHint): KeyValidationHintNoir { - return { - sk_m: mapGrumpkinScalarToNoir(hint.skM), - request_index: mapNumberToNoir(hint.requestIndex), - }; -} - -/** - * Maps a noir GrumpkinScalar to a GrumpkinScalar. - * @param privateKey - The noir GrumpkinScalar. - * @returns The GrumpkinScalar. - */ -export function mapGrumpkinScalarFromNoir(privateKey: GrumpkinScalarNoir): GrumpkinScalar { - return GrumpkinScalar.fromHighLow(mapFieldFromNoir(privateKey.hi), mapFieldFromNoir(privateKey.lo)); -} - -/** - * Maps an aztec address to a noir aztec address. - * @param address - The address. - * @returns The noir aztec address. - */ -export function mapAztecAddressToNoir(address: AztecAddress): NoirAztecAddress { - return { - inner: mapFieldToNoir(address.toField()), - }; -} - -/** - * Maps a noir aztec address to an aztec address. - * @param address - The noir aztec address. - * @returns The aztec address. - */ -export function mapAztecAddressFromNoir(address: NoirAztecAddress): AztecAddress { - return AztecAddress.fromField(mapFieldFromNoir(address.inner)); -} - -/** - * Maps an eth address to a noir eth address. - * @param address - The address. - * @returns The noir eth address. - */ -export function mapEthAddressToNoir(address: EthAddress): NoirEthAddress { - return { - inner: mapFieldToNoir(address.toField()), - }; -} - -/** - * Maps a noir eth address to an eth address. - * @param address - The noir eth address. - * @returns The eth address. - */ -export function mapEthAddressFromNoir(address: NoirEthAddress): EthAddress { - return EthAddress.fromField(mapFieldFromNoir(address.inner)); -} - -/** - * Maps a tx context to a noir tx context. - * @param txContext - The tx context. - * @returns The noir tx context. - */ -export function mapTxContextToNoir(txContext: TxContext): TxContextNoir { - return { - chain_id: mapFieldToNoir(txContext.chainId), - version: mapFieldToNoir(txContext.version), - gas_settings: mapGasSettingsToNoir(txContext.gasSettings), - }; -} - -/** - * Maps a noir tx context to a tx context. - * @param txContext - The noir tx context. - * @returns The tx context. - */ -export function mapTxContextFromNoir(txContext: TxContextNoir): TxContext { - return new TxContext( - mapFieldFromNoir(txContext.chain_id), - mapFieldFromNoir(txContext.version), - mapGasSettingsFromNoir(txContext.gas_settings), - ); -} - -/** - * Maps a function selector to a noir function selector. - * @param functionSelector - The function selector. - * @returns The noir function selector. - */ -export function mapFunctionSelectorToNoir(functionSelector: FunctionSelector): FunctionSelectorNoir { - return { - inner: mapFieldToNoir(functionSelector.toField()), - }; -} - -/** - * Maps a noir function selector to a function selector. - * @param functionSelector - The noir function selector. - * @returns The function selector. - */ -export function mapFunctionSelectorFromNoir(functionSelector: FunctionSelectorNoir): FunctionSelector { - return FunctionSelector.fromField(mapFieldFromNoir(functionSelector.inner)); -} - -/** - * Maps a function data to a noir function data. - * @param functionData - The function data. - * @returns The noir function data. - */ -export function mapFunctionDataToNoir(functionData: FunctionData): FunctionDataNoir { - return { - selector: mapFunctionSelectorToNoir(functionData.selector), - is_private: functionData.isPrivate, - }; -} - -/** - * Maps a noir function data to a function data. - * @param functionData - The noir function data. - * @returns The function data. - */ -export function mapFunctionDataFromNoir(functionData: FunctionDataNoir): FunctionData { - return new FunctionData(mapFunctionSelectorFromNoir(functionData.selector), functionData.is_private); -} - -/** - * Maps a tx request to a noir tx request. - * @param txRequest - The tx request. - * @returns The noir tx request. - */ -export function mapTxRequestToNoir(txRequest: TxRequest): TxRequestNoir { - return { - origin: mapAztecAddressToNoir(txRequest.origin), - args_hash: mapFieldToNoir(txRequest.argsHash), - tx_context: mapTxContextToNoir(txRequest.txContext), - function_data: mapFunctionDataToNoir(txRequest.functionData), - }; -} - -/** - * Maps a call context to a noir call context. - * @param callContext - The call context. - * @returns The noir call context. - */ -export function mapCallContextFromNoir(callContext: CallContextNoir): CallContext { - return new CallContext( - mapAztecAddressFromNoir(callContext.msg_sender), - mapAztecAddressFromNoir(callContext.contract_address), - mapFunctionSelectorFromNoir(callContext.function_selector), - callContext.is_static_call, - ); -} - -/** - * Maps a call context to a noir call context. - * @param callContext - The call context. - * @returns The noir call context. - */ -export function mapCallContextToNoir(callContext: CallContext): CallContextNoir { - return { - msg_sender: mapAztecAddressToNoir(callContext.msgSender), - contract_address: mapAztecAddressToNoir(callContext.contractAddress), - function_selector: mapFunctionSelectorToNoir(callContext.functionSelector), - is_static_call: callContext.isStaticCall, - }; -} - -export function mapGasSettingsFromNoir(gasSettings: GasSettingsNoir): GasSettings { - return new GasSettings( - mapGasFromNoir(gasSettings.gas_limits), - mapGasFromNoir(gasSettings.teardown_gas_limits), - mapGasFeesFromNoir(gasSettings.max_fees_per_gas), - mapGasFeesFromNoir(gasSettings.max_priority_fees_per_gas), - ); -} - -export function mapGasSettingsToNoir(gasSettings: GasSettings): GasSettingsNoir { - return { - gas_limits: mapGasToNoir(gasSettings.gasLimits), - teardown_gas_limits: mapGasToNoir(gasSettings.teardownGasLimits), - max_fees_per_gas: mapGasFeesToNoir(gasSettings.maxFeesPerGas), - max_priority_fees_per_gas: mapGasFeesToNoir(gasSettings.maxPriorityFeesPerGas), - }; -} - -function mapPrivateCallRequestFromNoir(callRequest: PrivateCallRequestNoir) { - return new PrivateCallRequest( - mapCallContextFromNoir(callRequest.call_context), - mapFieldFromNoir(callRequest.args_hash), - mapFieldFromNoir(callRequest.returns_hash), - mapNumberFromNoir(callRequest.start_side_effect_counter), - mapNumberFromNoir(callRequest.end_side_effect_counter), - ); -} - -function mapPrivateCallRequestToNoir(callRequest: PrivateCallRequest): PrivateCallRequestNoir { - return { - call_context: mapCallContextToNoir(callRequest.callContext), - args_hash: mapFieldToNoir(callRequest.argsHash), - returns_hash: mapFieldToNoir(callRequest.returnsHash), - start_side_effect_counter: mapNumberToNoir(callRequest.startSideEffectCounter), - end_side_effect_counter: mapNumberToNoir(callRequest.endSideEffectCounter), - }; -} - -function mapPublicCallRequestFromNoir(request: PublicCallRequestNoir) { - return new PublicCallRequest( - mapAztecAddressFromNoir(request.msg_sender), - mapAztecAddressFromNoir(request.contract_address), - mapFunctionSelectorFromNoir(request.function_selector), - request.is_static_call, - mapFieldFromNoir(request.args_hash), - ); -} - -function mapPublicCallRequestToNoir(request: PublicCallRequest): PublicCallRequestNoir { - return { - msg_sender: mapAztecAddressToNoir(request.msgSender), - contract_address: mapAztecAddressToNoir(request.contractAddress), - function_selector: mapFunctionSelectorToNoir(request.functionSelector), - is_static_call: request.isStaticCall, - args_hash: mapFieldToNoir(request.argsHash), - }; -} - -function mapCountedPublicCallRequestFromNoir(request: CountedPublicCallRequestNoir) { - return new CountedPublicCallRequest(mapPublicCallRequestFromNoir(request.inner), mapNumberFromNoir(request.counter)); -} - -function mapCountedPublicCallRequestToNoir(request: CountedPublicCallRequest): CountedPublicCallRequestNoir { - return { - inner: mapPublicCallRequestToNoir(request.inner), - counter: mapNumberToNoir(request.counter), - }; -} - -function mapNoteHashToNoir(noteHash: NoteHash): NoteHashNoir { - return { - value: mapFieldToNoir(noteHash.value), - counter: mapNumberToNoir(noteHash.counter), - }; -} - -function mapNoteHashFromNoir(noteHash: NoteHashNoir) { - return new NoteHash(mapFieldFromNoir(noteHash.value), mapNumberFromNoir(noteHash.counter)); -} - -function mapScopedNoteHashToNoir(noteHash: ScopedNoteHash): ScopedNoteHashNoir { - return { - note_hash: mapNoteHashToNoir(noteHash.noteHash), - contract_address: mapAztecAddressToNoir(noteHash.contractAddress), - }; -} - -function mapScopedNoteHashFromNoir(noteHash: ScopedNoteHashNoir) { - return new ScopedNoteHash( - mapNoteHashFromNoir(noteHash.note_hash), - mapAztecAddressFromNoir(noteHash.contract_address), - ); -} - -function mapNullifierToNoir(nullifier: Nullifier): NullifierNoir { - return { - value: mapFieldToNoir(nullifier.value), - counter: mapNumberToNoir(nullifier.counter), - note_hash: mapFieldToNoir(nullifier.noteHash), - }; -} - -function mapNullifierFromNoir(nullifier: NullifierNoir) { - return new Nullifier( - mapFieldFromNoir(nullifier.value), - mapNumberFromNoir(nullifier.counter), - mapFieldFromNoir(nullifier.note_hash), - ); -} - -function mapScopedNullifierToNoir(nullifier: ScopedNullifier): ScopedNullifierNoir { - return { - nullifier: mapNullifierToNoir(nullifier.nullifier), - contract_address: mapAztecAddressToNoir(nullifier.contractAddress), - }; -} - -function mapScopedNullifierFromNoir(nullifier: ScopedNullifierNoir) { - return new ScopedNullifier( - mapNullifierFromNoir(nullifier.nullifier), - mapAztecAddressFromNoir(nullifier.contract_address), - ); -} - -function mapPrivateLogToNoir(log: PrivateLog): PrivateLogNoir { - return { - fields: mapTuple(log.fields, mapFieldToNoir), - }; -} - -function mapPrivateLogFromNoir(log: PrivateLogNoir) { - return new PrivateLog(mapTupleFromNoir(log.fields, log.fields.length, mapFieldFromNoir)); -} - -function mapPrivateLogDataToNoir(data: PrivateLogData): PrivateLogDataNoir { - return { - log: mapPrivateLogToNoir(data.log), - note_hash_counter: mapNumberToNoir(data.noteHashCounter), - counter: mapNumberToNoir(data.counter), - }; -} - -function mapPrivateLogDataFromNoir(data: PrivateLogDataNoir) { - return new PrivateLogData( - mapPrivateLogFromNoir(data.log), - mapNumberFromNoir(data.note_hash_counter), - mapNumberFromNoir(data.counter), - ); -} - -function mapScopedPrivateLogDataToNoir(data: ScopedPrivateLogData): ScopedPrivateLogDataNoir { - return { - inner: mapPrivateLogDataToNoir(data.inner), - contract_address: mapAztecAddressToNoir(data.contractAddress), - }; -} - -function mapScopedPrivateLogDataFromNoir(data: ScopedPrivateLogDataNoir) { - return new ScopedPrivateLogData( - mapPrivateLogDataFromNoir(data.inner), - mapAztecAddressFromNoir(data.contract_address), - ); -} - -/** - * Maps a LogHash to a noir LogHash. - * @param logHash - The LogHash. - * @returns The noir log hash. - */ -function mapLogHashToNoir(logHash: LogHash): LogHashNoir { - return { - value: mapFieldToNoir(logHash.value), - counter: mapNumberToNoir(logHash.counter), - length: mapFieldToNoir(logHash.length), - }; -} - -/** - * Maps a noir LogHash to a LogHash. - * @param logHash - The noir LogHash. - * @returns The TS log hash. - */ -function mapLogHashFromNoir(logHash: LogHashNoir): LogHash { - return new LogHash( - mapFieldFromNoir(logHash.value), - mapNumberFromNoir(logHash.counter), - mapFieldFromNoir(logHash.length), - ); -} - -/** - * Maps a ts ScopedLogHash to a noir ScopedLogHash. - * @param logHash - The ts LogHash. - * @returns The noir log hash. - */ -function mapScopedLogHashToNoir(scopedLogHash: ScopedLogHash): ScopedLogHashNoir { - return { - log_hash: mapLogHashToNoir(scopedLogHash.logHash), - contract_address: mapAztecAddressToNoir(scopedLogHash.contractAddress), - }; -} - -/** - * Maps a noir ScopedLogHash to a ts ScopedLogHash. - * @param logHash - The noir LogHash. - * @returns The TS log hash. - */ -function mapScopedLogHashFromNoir(scopedLogHash: ScopedLogHashNoir): ScopedLogHash { - return new ScopedLogHash( - mapLogHashFromNoir(scopedLogHash.log_hash), - mapAztecAddressFromNoir(scopedLogHash.contract_address), - ); -} - -/** - * Maps a ReadRequest to a noir ReadRequest. - * @param readRequest - The read request. - * @returns The noir ReadRequest. - */ -function mapReadRequestToNoir(readRequest: ReadRequest): ReadRequestNoir { - return { - value: mapFieldToNoir(readRequest.value), - counter: mapNumberToNoir(readRequest.counter), - }; -} - -/** - * Maps a noir ReadRequest to ReadRequest. - * @param readRequest - The noir ReadRequest. - * @returns The TS ReadRequest. - */ -function mapReadRequestFromNoir(readRequest: ReadRequestNoir): ReadRequest { - return new ReadRequest(mapFieldFromNoir(readRequest.value), mapNumberFromNoir(readRequest.counter)); -} - -function mapScopedReadRequestToNoir(scopedReadRequest: ScopedReadRequest): ScopedReadRequestNoir { - return { - read_request: mapReadRequestToNoir(scopedReadRequest.readRequest), - contract_address: mapAztecAddressToNoir(scopedReadRequest.contractAddress), - }; -} - -/** - * Maps a noir ReadRequest to ReadRequest. - * @param readRequest - The noir ReadRequest. - * @returns The TS ReadRequest. - */ -export function mapScopedReadRequestFromNoir(scoped: ScopedReadRequestNoir): ScopedReadRequest { - return new ScopedReadRequest( - mapReadRequestFromNoir(scoped.read_request), - mapAztecAddressFromNoir(scoped.contract_address), - ); -} - -/** - * Maps a KeyValidationRequest to a noir KeyValidationRequest. - * @param request - The KeyValidationRequest. - * @returns The noir KeyValidationRequest. - */ -export function mapKeyValidationRequestToNoir(request: KeyValidationRequest): KeyValidationRequestsNoir { - return { - pk_m: mapPointToNoir(request.pkM), - sk_app: mapFieldToNoir(request.skApp), - }; -} - -export function mapKeyValidationRequestAndGeneratorToNoir( - request: KeyValidationRequestAndGenerator, -): KeyValidationRequestAndGeneratorNoir { - return { - request: mapKeyValidationRequestToNoir(request.request), - sk_app_generator: mapFieldToNoir(request.skAppGenerator), - }; -} - -/** - * Maps a noir KeyValidationRequest to KeyValidationRequest. - * @param request - The noir KeyValidationRequest. - * @returns The TS KeyValidationRequest. - */ -function mapKeyValidationRequestFromNoir(request: KeyValidationRequestsNoir): KeyValidationRequest { - return new KeyValidationRequest(mapPointFromNoir(request.pk_m), mapFieldFromNoir(request.sk_app)); -} - -function mapKeyValidationRequestAndGeneratorFromNoir( - request: KeyValidationRequestAndGeneratorNoir, -): KeyValidationRequestAndGenerator { - return new KeyValidationRequestAndGenerator( - mapKeyValidationRequestFromNoir(request.request), - mapFieldFromNoir(request.sk_app_generator), - ); -} - -function mapScopedKeyValidationRequestAndGeneratorToNoir( - request: ScopedKeyValidationRequestAndGenerator, -): ScopedKeyValidationRequestAndGeneratorNoir { - return { - request: mapKeyValidationRequestAndGeneratorToNoir(request.request), - contract_address: mapAztecAddressToNoir(request.contractAddress), - }; -} - -function mapScopedKeyValidationRequestAndGeneratorFromNoir( - request: ScopedKeyValidationRequestAndGeneratorNoir, -): ScopedKeyValidationRequestAndGenerator { - return new ScopedKeyValidationRequestAndGenerator( - mapKeyValidationRequestAndGeneratorFromNoir(request.request), - mapAztecAddressFromNoir(request.contract_address), - ); -} - -/** - * Maps a L2 to L1 message to a noir L2 to L1 message. - * @param message - The L2 to L1 message. - * @returns The noir L2 to L1 message. - */ -export function mapL2ToL1MessageToNoir(message: L2ToL1Message): L2ToL1MessageNoir { - return { - recipient: mapEthAddressToNoir(message.recipient), - content: mapFieldToNoir(message.content), - counter: mapNumberToNoir(message.counter), - }; -} - -function mapL2ToL1MessageFromNoir(message: L2ToL1MessageNoir) { - return new L2ToL1Message( - mapEthAddressFromNoir(message.recipient), - mapFieldFromNoir(message.content), - mapNumberFromNoir(message.counter), - ); -} - -function mapScopedL2ToL1MessageFromNoir(message: ScopedL2ToL1MessageNoir) { - return new ScopedL2ToL1Message( - mapL2ToL1MessageFromNoir(message.message), - mapAztecAddressFromNoir(message.contract_address), - ); -} - -function mapScopedL2ToL1MessageToNoir(message: ScopedL2ToL1Message): ScopedL2ToL1MessageNoir { - return { - message: mapL2ToL1MessageToNoir(message.message), - contract_address: mapAztecAddressToNoir(message.contractAddress), - }; -} - -/** - * Maps private circuit public inputs to noir private circuit public inputs. - * @param privateCircuitPublicInputs - The private circuit public inputs. - * @returns The noir private circuit public inputs. - */ -export function mapPrivateCircuitPublicInputsToNoir( - privateCircuitPublicInputs: PrivateCircuitPublicInputs, -): PrivateCircuitPublicInputsNoir { - return { - max_block_number: mapMaxBlockNumberToNoir(privateCircuitPublicInputs.maxBlockNumber), - call_context: mapCallContextToNoir(privateCircuitPublicInputs.callContext), - args_hash: mapFieldToNoir(privateCircuitPublicInputs.argsHash), - returns_hash: mapFieldToNoir(privateCircuitPublicInputs.returnsHash), - note_hash_read_requests: mapTuple(privateCircuitPublicInputs.noteHashReadRequests, mapReadRequestToNoir), - nullifier_read_requests: mapTuple(privateCircuitPublicInputs.nullifierReadRequests, mapReadRequestToNoir), - key_validation_requests_and_generators: mapTuple( - privateCircuitPublicInputs.keyValidationRequestsAndGenerators, - mapKeyValidationRequestAndGeneratorToNoir, - ), - note_hashes: mapTuple(privateCircuitPublicInputs.noteHashes, mapNoteHashToNoir), - nullifiers: mapTuple(privateCircuitPublicInputs.nullifiers, mapNullifierToNoir), - private_call_requests: mapTuple(privateCircuitPublicInputs.privateCallRequests, mapPrivateCallRequestToNoir), - public_call_requests: mapTuple(privateCircuitPublicInputs.publicCallRequests, mapCountedPublicCallRequestToNoir), - public_teardown_call_request: mapPublicCallRequestToNoir(privateCircuitPublicInputs.publicTeardownCallRequest), - l2_to_l1_msgs: mapTuple(privateCircuitPublicInputs.l2ToL1Msgs, mapL2ToL1MessageToNoir), - private_logs: mapTuple(privateCircuitPublicInputs.privateLogs, mapPrivateLogDataToNoir), - contract_class_logs_hashes: mapTuple(privateCircuitPublicInputs.contractClassLogsHashes, mapLogHashToNoir), - start_side_effect_counter: mapFieldToNoir(privateCircuitPublicInputs.startSideEffectCounter), - end_side_effect_counter: mapFieldToNoir(privateCircuitPublicInputs.endSideEffectCounter), - historical_header: mapHeaderToNoir(privateCircuitPublicInputs.historicalHeader), - tx_context: mapTxContextToNoir(privateCircuitPublicInputs.txContext), - min_revertible_side_effect_counter: mapFieldToNoir(privateCircuitPublicInputs.minRevertibleSideEffectCounter), - is_fee_payer: privateCircuitPublicInputs.isFeePayer, - }; -} - -/** - * Maps a private call data to a noir private call data. - * @param privateCallData - The private call data. - * @returns The noir private call data. - */ -export function mapPrivateCallDataToNoir(privateCallData: PrivateCallData): PrivateCallDataWithoutPublicInputsNoir { - return { - vk: mapVerificationKeyToNoir(privateCallData.vk, CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS), - function_leaf_membership_witness: mapMembershipWitnessToNoir(privateCallData.functionLeafMembershipWitness), - contract_class_artifact_hash: mapFieldToNoir(privateCallData.contractClassArtifactHash), - contract_class_public_bytecode_commitment: mapFieldToNoir(privateCallData.contractClassPublicBytecodeCommitment), - public_keys: mapPublicKeysToNoir(privateCallData.publicKeys), - salted_initialization_hash: mapWrappedFieldToNoir(privateCallData.saltedInitializationHash), - protocol_contract_sibling_path: mapTuple(privateCallData.protocolContractSiblingPath, mapFieldToNoir), - acir_hash: mapFieldToNoir(privateCallData.acirHash), - }; -} - -export function mapPublicKeysToNoir(publicKeys: PublicKeys): PublicKeysNoir { - return { - npk_m: { - inner: mapPointToNoir(publicKeys.masterNullifierPublicKey), - }, - ivpk_m: { - inner: mapPointToNoir(publicKeys.masterIncomingViewingPublicKey), - }, - ovpk_m: { - inner: mapPointToNoir(publicKeys.masterOutgoingViewingPublicKey), - }, - tpk_m: { - inner: mapPointToNoir(publicKeys.masterTaggingPublicKey), - }, - }; -} - -export function mapRevertCodeFromNoir(revertCode: NoirField): RevertCode { - return RevertCode.fromField(mapFieldFromNoir(revertCode)); -} - -export function mapRevertCodeToNoir(revertCode: RevertCode): NoirField { - return mapFieldToNoir(revertCode.toField()); -} - -/** - * Maps an array from noir types to a tuple of parsed types. - * @param noirArray - The noir array. - * @param length - The length of the tuple. - * @param mapper - The mapper function applied to each element. - * @returns The tuple. - */ -export function mapTupleFromNoir( - noirArray: T[], - length: N, - mapper: (item: T) => M, -): Tuple { - if (noirArray.length != length) { - throw new Error(`Expected ${length} items, got ${noirArray.length}`); - } - return Array.from({ length }, (_, idx) => mapper(noirArray[idx])) as Tuple; -} - -/** - * Maps a SHA256 hash from noir to the parsed type. - * @param hash - The hash as it is represented in Noir (1 fields). - * @returns The hash represented as a 31 bytes long buffer. - */ -export function mapSha256HashFromNoir(hash: Field): Buffer { - return toBufferBE(mapFieldFromNoir(hash).toBigInt(), NUM_BYTES_PER_SHA256); -} - -/** - * Maps a sha256 to the representation used in noir. - * @param hash - The hash represented as a 32 bytes long buffer. - * @returns The hash as it is represented in Noir (1 field, truncated). - */ -export function mapSha256HashToNoir(hash: Buffer): Field { - return mapFieldToNoir(toTruncField(hash)); -} - -function mapPublicDataWriteFromNoir(write: PublicDataWriteNoir) { - return new PublicDataWrite(mapFieldFromNoir(write.leaf_slot), mapFieldFromNoir(write.value)); -} - -function mapPublicDataWriteToNoir(write: PublicDataWrite): PublicDataWriteNoir { - return { - leaf_slot: mapFieldToNoir(write.leafSlot), - value: mapFieldToNoir(write.value), - }; -} - -function mapReadRequestStatusToNoir(readRequestStatus: ReadRequestStatus): ReadRequestStatusNoir { - return { - state: mapNumberToNoir(readRequestStatus.state), - hint_index: mapNumberToNoir(readRequestStatus.hintIndex), - }; -} - -function mapPendingReadHintToNoir(hint: PendingReadHint): PendingReadHintNoir { - return { - read_request_index: mapNumberToNoir(hint.readRequestIndex), - pending_value_index: mapNumberToNoir(hint.pendingValueIndex), - }; -} - -function mapNoteHashSettledReadHintToNoir( - hint: SettledReadHint, -): NoteHashSettledReadHintNoir { - return { - read_request_index: mapNumberToNoir(hint.readRequestIndex), - membership_witness: mapMembershipWitnessToNoir(hint.membershipWitness), - leaf_preimage: mapNoteHashLeafPreimageToNoir(hint.leafPreimage), - }; -} - -function mapNullifierSettledReadHintToNoir( - hint: SettledReadHint, -): NullifierSettledReadHintNoir { - return { - read_request_index: mapNumberToNoir(hint.readRequestIndex), - membership_witness: mapMembershipWitnessToNoir(hint.membershipWitness), - leaf_preimage: mapNullifierLeafPreimageToNoir(hint.leafPreimage), - }; -} - -function mapNoteHashReadRequestHintsToNoir( - hints: NoteHashReadRequestHints, -): NoteHashReadRequestHintsNoir { - return { - read_request_statuses: mapTuple(hints.readRequestStatuses, mapReadRequestStatusToNoir), - pending_read_hints: hints.pendingReadHints.map(mapPendingReadHintToNoir) as FixedLengthArray< - PendingReadHintNoir, - PENDING - >, - settled_read_hints: hints.settledReadHints.map(mapNoteHashSettledReadHintToNoir) as FixedLengthArray< - NoteHashSettledReadHintNoir, - SETTLED - >, - }; -} - -function mapNullifierReadRequestHintsToNoir( - hints: NullifierReadRequestHints, -): NullifierReadRequestHintsNoir { - return { - read_request_statuses: mapTuple(hints.readRequestStatuses, mapReadRequestStatusToNoir), - pending_read_hints: hints.pendingReadHints.map(mapPendingReadHintToNoir) as FixedLengthArray< - PendingReadHintNoir, - PENDING - >, - settled_read_hints: hints.settledReadHints.map(settledHint => - mapNullifierSettledReadHintToNoir( - settledHint as SettledReadHint, - ), - ) as FixedLengthArray, - }; -} - -function mapPublicDataHintToNoir(hint: PublicDataHint): PublicDataHintNoir { - return { - leaf_slot: mapFieldToNoir(hint.leafSlot), - value: mapFieldToNoir(hint.value), - membership_witness: mapMembershipWitnessToNoir(hint.membershipWitness), - leaf_preimage: mapPublicDataTreePreimageToNoir(hint.leafPreimage), - }; -} - -function mapOptionalNumberToNoir(option: OptionalNumber): OptionalNumberNoir { - return { - _is_some: option.isSome, - _value: mapNumberToNoir(option.value), - }; -} - -function mapOptionalNumberFromNoir(option: OptionalNumberNoir) { - return new OptionalNumber(option._is_some, mapNumberFromNoir(option._value)); -} - -function mapPrivateValidationRequestsToNoir(requests: PrivateValidationRequests): PrivateValidationRequestsNoir { - return { - for_rollup: mapRollupValidationRequestsToNoir(requests.forRollup), - note_hash_read_requests: mapTuple(requests.noteHashReadRequests, mapScopedReadRequestToNoir), - nullifier_read_requests: mapTuple(requests.nullifierReadRequests, mapScopedReadRequestToNoir), - scoped_key_validation_requests_and_generators: mapTuple( - requests.scopedKeyValidationRequestsAndGenerators, - mapScopedKeyValidationRequestAndGeneratorToNoir, - ), - split_counter: mapOptionalNumberToNoir(requests.splitCounter), - }; -} - -function mapPrivateValidationRequestsFromNoir(requests: PrivateValidationRequestsNoir) { - return new PrivateValidationRequests( - mapRollupValidationRequestsFromNoir(requests.for_rollup), - mapTupleFromNoir( - requests.note_hash_read_requests, - MAX_NOTE_HASH_READ_REQUESTS_PER_TX, - mapScopedReadRequestFromNoir, - ), - mapTupleFromNoir( - requests.nullifier_read_requests, - MAX_NULLIFIER_READ_REQUESTS_PER_TX, - mapScopedReadRequestFromNoir, - ), - mapTupleFromNoir( - requests.scoped_key_validation_requests_and_generators, - MAX_KEY_VALIDATION_REQUESTS_PER_TX, - mapScopedKeyValidationRequestAndGeneratorFromNoir, - ), - mapOptionalNumberFromNoir(requests.split_counter), - ); -} - -export function mapPrivateAccumulatedDataFromNoir( - privateAccumulatedData: PrivateAccumulatedDataNoir, -): PrivateAccumulatedData { - return new PrivateAccumulatedData( - mapTupleFromNoir(privateAccumulatedData.note_hashes, MAX_NOTE_HASHES_PER_TX, mapScopedNoteHashFromNoir), - mapTupleFromNoir(privateAccumulatedData.nullifiers, MAX_NULLIFIERS_PER_TX, mapScopedNullifierFromNoir), - mapTupleFromNoir(privateAccumulatedData.l2_to_l1_msgs, MAX_L2_TO_L1_MSGS_PER_TX, mapScopedL2ToL1MessageFromNoir), - mapTupleFromNoir(privateAccumulatedData.private_logs, MAX_PRIVATE_LOGS_PER_TX, mapScopedPrivateLogDataFromNoir), - mapTupleFromNoir( - privateAccumulatedData.contract_class_logs_hashes, - MAX_CONTRACT_CLASS_LOGS_PER_TX, - mapScopedLogHashFromNoir, - ), - mapTupleFromNoir( - privateAccumulatedData.public_call_requests, - MAX_ENQUEUED_CALLS_PER_TX, - mapCountedPublicCallRequestFromNoir, - ), - mapTupleFromNoir( - privateAccumulatedData.private_call_stack, - MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, - mapPrivateCallRequestFromNoir, - ), - ); -} - -export function mapPrivateAccumulatedDataToNoir(data: PrivateAccumulatedData): PrivateAccumulatedDataNoir { - return { - note_hashes: mapTuple(data.noteHashes, mapScopedNoteHashToNoir), - nullifiers: mapTuple(data.nullifiers, mapScopedNullifierToNoir), - l2_to_l1_msgs: mapTuple(data.l2ToL1Msgs, mapScopedL2ToL1MessageToNoir), - private_logs: mapTuple(data.privateLogs, mapScopedPrivateLogDataToNoir), - contract_class_logs_hashes: mapTuple(data.contractClassLogsHashes, mapScopedLogHashToNoir), - public_call_requests: mapTuple(data.publicCallRequests, mapCountedPublicCallRequestToNoir), - private_call_stack: mapTuple(data.privateCallStack, mapPrivateCallRequestToNoir), - }; -} - -export function mapGasFromNoir(gasUsed: GasNoir): Gas { - return Gas.from({ - daGas: mapNumberFromNoir(gasUsed.da_gas), - l2Gas: mapNumberFromNoir(gasUsed.l2_gas), - }); -} - -export function mapGasToNoir(gasUsed: Gas): GasNoir { - return { - da_gas: mapNumberToNoir(gasUsed.daGas), - l2_gas: mapNumberToNoir(gasUsed.l2Gas), - }; -} - -export function mapRollupValidationRequestsToNoir( - rollupValidationRequests: RollupValidationRequests, -): RollupValidationRequestsNoir { - return { - max_block_number: mapMaxBlockNumberToNoir(rollupValidationRequests.maxBlockNumber), - }; -} - -export function mapRollupValidationRequestsFromNoir( - rollupValidationRequests: RollupValidationRequestsNoir, -): RollupValidationRequests { - return new RollupValidationRequests(mapMaxBlockNumberFromNoir(rollupValidationRequests.max_block_number)); -} - -export function mapMaxBlockNumberToNoir(maxBlockNumber: MaxBlockNumber): MaxBlockNumberNoir { - return { - _opt: { - _is_some: maxBlockNumber.isSome, - _value: mapFieldToNoir(maxBlockNumber.value), - }, - }; -} - -export function mapMaxBlockNumberFromNoir(maxBlockNumber: MaxBlockNumberNoir): MaxBlockNumber { - return new MaxBlockNumber(maxBlockNumber._opt._is_some, mapFieldFromNoir(maxBlockNumber._opt._value)); -} - -function mapPrivateToPublicAccumulatedDataFromNoir(data: PrivateToPublicAccumulatedDataNoir) { - return new PrivateToPublicAccumulatedData( - mapTupleFromNoir(data.note_hashes, MAX_NOTE_HASHES_PER_TX, mapFieldFromNoir), - mapTupleFromNoir(data.nullifiers, MAX_NULLIFIERS_PER_TX, mapFieldFromNoir), - mapTupleFromNoir(data.l2_to_l1_msgs, MAX_L2_TO_L1_MSGS_PER_TX, mapScopedL2ToL1MessageFromNoir), - mapTupleFromNoir(data.private_logs, MAX_PRIVATE_LOGS_PER_TX, mapPrivateLogFromNoir), - mapTupleFromNoir(data.contract_class_logs_hashes, MAX_CONTRACT_CLASS_LOGS_PER_TX, mapScopedLogHashFromNoir), - mapTupleFromNoir(data.public_call_requests, MAX_ENQUEUED_CALLS_PER_TX, mapPublicCallRequestFromNoir), - ); -} - -function mapPrivateToPublicAccumulatedDataToNoir( - data: PrivateToPublicAccumulatedData, -): PrivateToPublicAccumulatedDataNoir { - return { - note_hashes: mapTuple(data.noteHashes, mapFieldToNoir), - nullifiers: mapTuple(data.nullifiers, mapFieldToNoir), - l2_to_l1_msgs: mapTuple(data.l2ToL1Msgs, mapScopedL2ToL1MessageToNoir), - private_logs: mapTuple(data.privateLogs, mapPrivateLogToNoir), - contract_class_logs_hashes: mapTuple(data.contractClassLogsHashes, mapScopedLogHashToNoir), - public_call_requests: mapTuple(data.publicCallRequests, mapPublicCallRequestToNoir), - }; -} - -function mapPrivateToAvmAccumulatedDataToNoir(data: PrivateToAvmAccumulatedData): PrivateToAvmAccumulatedDataNoir { - return { - note_hashes: mapTuple(data.noteHashes, mapFieldToNoir), - nullifiers: mapTuple(data.nullifiers, mapFieldToNoir), - l2_to_l1_msgs: mapTuple(data.l2ToL1Msgs, mapScopedL2ToL1MessageToNoir), - }; -} - -function mapPrivateToAvmAccumulatedDataArrayLengthsToNoir( - data: PrivateToAvmAccumulatedDataArrayLengths, -): PrivateToAvmAccumulatedDataArrayLengthsNoir { - return { - note_hashes: mapNumberToNoir(data.noteHashes), - nullifiers: mapNumberToNoir(data.nullifiers), - l2_to_l1_msgs: mapNumberToNoir(data.l2ToL1Msgs), - }; -} - -function mapAvmAccumulatedDataToNoir(data: AvmAccumulatedData): AvmAccumulatedDataNoir { - return { - note_hashes: mapTuple(data.noteHashes, mapFieldToNoir), - nullifiers: mapTuple(data.nullifiers, mapFieldToNoir), - l2_to_l1_msgs: mapTuple(data.l2ToL1Msgs, mapScopedL2ToL1MessageToNoir), - unencrypted_logs_hashes: mapTuple(data.unencryptedLogsHashes, mapScopedLogHashToNoir), - public_data_writes: mapTuple(data.publicDataWrites, mapPublicDataWriteToNoir), - }; -} - -/** - * Maps combined accumulated data from noir to the parsed type. - * @param combinedAccumulatedData - The noir combined accumulated data. - * @returns The parsed combined accumulated data. - */ -export function mapCombinedAccumulatedDataFromNoir(combinedAccumulatedData: CombinedAccumulatedDataNoir) { - return new CombinedAccumulatedData( - mapTupleFromNoir(combinedAccumulatedData.note_hashes, MAX_NOTE_HASHES_PER_TX, mapFieldFromNoir), - mapTupleFromNoir(combinedAccumulatedData.nullifiers, MAX_NULLIFIERS_PER_TX, mapFieldFromNoir), - mapTupleFromNoir(combinedAccumulatedData.l2_to_l1_msgs, MAX_L2_TO_L1_MSGS_PER_TX, mapScopedL2ToL1MessageFromNoir), - mapTupleFromNoir(combinedAccumulatedData.private_logs, MAX_PRIVATE_LOGS_PER_TX, mapPrivateLogFromNoir), - mapTupleFromNoir( - combinedAccumulatedData.unencrypted_logs_hashes, - MAX_UNENCRYPTED_LOGS_PER_TX, - mapScopedLogHashFromNoir, - ), - mapTupleFromNoir( - combinedAccumulatedData.contract_class_logs_hashes, - MAX_CONTRACT_CLASS_LOGS_PER_TX, - mapScopedLogHashFromNoir, - ), - mapFieldFromNoir(combinedAccumulatedData.unencrypted_log_preimages_length), - mapFieldFromNoir(combinedAccumulatedData.contract_class_log_preimages_length), - mapTupleFromNoir( - combinedAccumulatedData.public_data_writes, - MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - mapPublicDataWriteFromNoir, - ), - ); -} - -export function mapCombinedAccumulatedDataToNoir( - combinedAccumulatedData: CombinedAccumulatedData, -): CombinedAccumulatedDataNoir { - return { - note_hashes: mapTuple(combinedAccumulatedData.noteHashes, mapFieldToNoir), - nullifiers: mapTuple(combinedAccumulatedData.nullifiers, mapFieldToNoir), - l2_to_l1_msgs: mapTuple(combinedAccumulatedData.l2ToL1Msgs, mapScopedL2ToL1MessageToNoir), - private_logs: mapTuple(combinedAccumulatedData.privateLogs, mapPrivateLogToNoir), - unencrypted_logs_hashes: mapTuple(combinedAccumulatedData.unencryptedLogsHashes, mapScopedLogHashToNoir), - contract_class_logs_hashes: mapTuple(combinedAccumulatedData.contractClassLogsHashes, mapScopedLogHashToNoir), - unencrypted_log_preimages_length: mapFieldToNoir(combinedAccumulatedData.unencryptedLogPreimagesLength), - contract_class_log_preimages_length: mapFieldToNoir(combinedAccumulatedData.contractClassLogPreimagesLength), - public_data_writes: mapTuple(combinedAccumulatedData.publicDataWrites, mapPublicDataWriteToNoir), - }; -} - -function mapTxConstantDataFromNoir(data: TxConstantDataNoir) { - return new TxConstantData( - mapHeaderFromNoir(data.historical_header), - mapTxContextFromNoir(data.tx_context), - mapFieldFromNoir(data.vk_tree_root), - mapFieldFromNoir(data.protocol_contract_tree_root), - ); -} - -function mapTxConstantDataToNoir(data: TxConstantData): TxConstantDataNoir { - return { - historical_header: mapHeaderToNoir(data.historicalHeader), - tx_context: mapTxContextToNoir(data.txContext), - vk_tree_root: mapFieldToNoir(data.vkTreeRoot), - protocol_contract_tree_root: mapFieldToNoir(data.protocolContractTreeRoot), - }; -} - -function mapCombinedConstantDataFromNoir(combinedConstantData: CombinedConstantDataNoir): CombinedConstantData { - return new CombinedConstantData( - mapHeaderFromNoir(combinedConstantData.historical_header), - mapTxContextFromNoir(combinedConstantData.tx_context), - mapFieldFromNoir(combinedConstantData.vk_tree_root), - mapFieldFromNoir(combinedConstantData.protocol_contract_tree_root), - mapGlobalVariablesFromNoir(combinedConstantData.global_variables), - ); -} - -function mapCombinedConstantDataToNoir(combinedConstantData: CombinedConstantData): CombinedConstantDataNoir { - return { - historical_header: mapHeaderToNoir(combinedConstantData.historicalHeader), - tx_context: mapTxContextToNoir(combinedConstantData.txContext), - vk_tree_root: mapFieldToNoir(combinedConstantData.vkTreeRoot), - protocol_contract_tree_root: mapFieldToNoir(combinedConstantData.protocolContractTreeRoot), - global_variables: mapGlobalVariablesToNoir(combinedConstantData.globalVariables), - }; -} - -export function mapPrivateToPublicKernelCircuitPublicInputsToNoir( - inputs: PrivateToPublicKernelCircuitPublicInputs, -): PrivateToPublicKernelCircuitPublicInputsNoir { - return { - constants: mapTxConstantDataToNoir(inputs.constants), - rollup_validation_requests: mapRollupValidationRequestsToNoir(inputs.rollupValidationRequests), - non_revertible_accumulated_data: mapPrivateToPublicAccumulatedDataToNoir(inputs.nonRevertibleAccumulatedData), - revertible_accumulated_data: mapPrivateToPublicAccumulatedDataToNoir(inputs.revertibleAccumulatedData), - public_teardown_call_request: mapPublicCallRequestToNoir(inputs.publicTeardownCallRequest), - gas_used: mapGasToNoir(inputs.gasUsed), - fee_payer: mapAztecAddressToNoir(inputs.feePayer), - }; -} - -export function mapKernelCircuitPublicInputsFromNoir(inputs: KernelCircuitPublicInputsNoir) { - return new KernelCircuitPublicInputs( - mapRollupValidationRequestsFromNoir(inputs.rollup_validation_requests), - mapCombinedAccumulatedDataFromNoir(inputs.end), - mapCombinedConstantDataFromNoir(inputs.constants), - mapPartialStateReferenceFromNoir(inputs.start_state), - mapRevertCodeFromNoir(inputs.revert_code), - mapGasFromNoir(inputs.gas_used), - mapAztecAddressFromNoir(inputs.fee_payer), - ); -} - -export function mapKernelCircuitPublicInputsToNoir(inputs: KernelCircuitPublicInputs): KernelCircuitPublicInputsNoir { - return { - rollup_validation_requests: mapRollupValidationRequestsToNoir(inputs.rollupValidationRequests), - constants: mapCombinedConstantDataToNoir(inputs.constants), - end: mapCombinedAccumulatedDataToNoir(inputs.end), - start_state: mapPartialStateReferenceToNoir(inputs.startState), - revert_code: mapRevertCodeToNoir(inputs.revertCode), - gas_used: mapGasToNoir(inputs.gasUsed), - fee_payer: mapAztecAddressToNoir(inputs.feePayer), - }; -} - -export function mapVerificationKeyToNoir( - key: VerificationKeyAsFields, - length: N, -): VerificationKeyNoir { - if (key.key.length !== length) { - throw new Error(`Expected ${length} fields, got ${key.key.length}`); - } - return { - key: key.key.map(mapFieldToNoir) as FixedLengthArray, - hash: mapFieldToNoir(key.hash), - }; -} - -function mapVkWitnessDataToNoir(vkData: VkWitnessData, length: N): VkDataNoir { - return { - vk: mapVerificationKeyToNoir(vkData.vk.keyAsFields, length), - vk_index: mapFieldToNoir(new Fr(vkData.vkIndex)), - vk_path: mapTuple(vkData.vkPath, mapFieldToNoir), - }; -} - -export function mapPrivateKernelCircuitPublicInputsFromNoir( - inputs: PrivateKernelCircuitPublicInputsNoir, -): PrivateKernelCircuitPublicInputs { - return new PrivateKernelCircuitPublicInputs( - mapTxConstantDataFromNoir(inputs.constants), - mapFieldFromNoir(inputs.min_revertible_side_effect_counter), - mapPrivateValidationRequestsFromNoir(inputs.validation_requests), - mapPrivateAccumulatedDataFromNoir(inputs.end), - mapPublicCallRequestFromNoir(inputs.public_teardown_call_request), - mapAztecAddressFromNoir(inputs.fee_payer), - inputs.is_private_only, - ); -} - -export function mapPrivateKernelCircuitPublicInputsToNoir( - inputs: PrivateKernelCircuitPublicInputs, -): PrivateKernelCircuitPublicInputsNoir { - return { - constants: mapTxConstantDataToNoir(inputs.constants), - validation_requests: mapPrivateValidationRequestsToNoir(inputs.validationRequests), - end: mapPrivateAccumulatedDataToNoir(inputs.end), - min_revertible_side_effect_counter: mapFieldToNoir(inputs.minRevertibleSideEffectCounter), - public_teardown_call_request: mapPublicCallRequestToNoir(inputs.publicTeardownCallRequest), - fee_payer: mapAztecAddressToNoir(inputs.feePayer), - is_private_only: inputs.isPrivateOnly, - }; -} - -/** - * Maps a private kernel inner data to a noir private kernel inner data. - * @param privateKernelInnerData - The private kernel inner data. - * @returns The noir private kernel inner data. - */ -export function mapPrivateKernelDataToNoir( - privateKernelInnerData: PrivateKernelData, -): PrivateKernelDataWithoutPublicInputsNoir { - return { - vk: mapVerificationKeyToNoir(privateKernelInnerData.vk, CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS), - vk_index: mapFieldToNoir(new Fr(privateKernelInnerData.vkIndex)), - vk_path: mapTuple(privateKernelInnerData.vkPath, mapFieldToNoir), - }; -} - -export function mapPrivateKernelTailCircuitPublicInputsForRollupFromNoir( - inputs: KernelCircuitPublicInputsNoir, -): PrivateKernelTailCircuitPublicInputs { - const forRollup = new PartialPrivateTailPublicInputsForRollup(mapCombinedAccumulatedDataFromNoir(inputs.end)); - return new PrivateKernelTailCircuitPublicInputs( - mapTxConstantDataFromNoir(inputs.constants), - mapRollupValidationRequestsFromNoir(inputs.rollup_validation_requests), - mapGasFromNoir(inputs.gas_used), - mapAztecAddressFromNoir(inputs.fee_payer), - undefined, - forRollup, - ); -} - -export function mapPrivateKernelTailCircuitPublicInputsForPublicFromNoir( - inputs: PrivateToPublicKernelCircuitPublicInputsNoir, -): PrivateKernelTailCircuitPublicInputs { - const forPublic = new PartialPrivateTailPublicInputsForPublic( - mapPrivateToPublicAccumulatedDataFromNoir(inputs.non_revertible_accumulated_data), - mapPrivateToPublicAccumulatedDataFromNoir(inputs.revertible_accumulated_data), - mapPublicCallRequestFromNoir(inputs.public_teardown_call_request), - ); - return new PrivateKernelTailCircuitPublicInputs( - mapTxConstantDataFromNoir(inputs.constants), - mapRollupValidationRequestsFromNoir(inputs.rollup_validation_requests), - mapGasFromNoir(inputs.gas_used), - mapAztecAddressFromNoir(inputs.fee_payer), - forPublic, - ); -} - -function mapTransientDataIndexHintToNoir(indexHint: TransientDataIndexHint): TransientDataIndexHintNoir { - return { - nullifier_index: mapNumberToNoir(indexHint.nullifierIndex), - note_hash_index: mapNumberToNoir(indexHint.noteHashIndex), - }; -} - -export function mapPrivateKernelResetHintsToNoir< - NH_RR_PENDING extends number, - NH_RR_SETTLED extends number, - NLL_RR_PENDING extends number, - NLL_RR_SETTLED extends number, - KEY_VALIDATION_REQUESTS extends number, - NUM_TRANSIENT_DATA_HINTS extends number, ->( - inputs: PrivateKernelResetHints< - NH_RR_PENDING, - NH_RR_SETTLED, - NLL_RR_PENDING, - NLL_RR_SETTLED, - KEY_VALIDATION_REQUESTS, - NUM_TRANSIENT_DATA_HINTS - >, -): PrivateKernelResetHintsNoir< - NH_RR_PENDING, - NH_RR_SETTLED, - NLL_RR_PENDING, - NLL_RR_SETTLED, - KEY_VALIDATION_REQUESTS, - NUM_TRANSIENT_DATA_HINTS -> { - return { - note_hash_read_request_hints: mapNoteHashReadRequestHintsToNoir(inputs.noteHashReadRequestHints), - nullifier_read_request_hints: mapNullifierReadRequestHintsToNoir(inputs.nullifierReadRequestHints), - key_validation_hints: inputs.keyValidationHints.map(mapKeyValidationHintToNoir) as FixedLengthArray< - KeyValidationHintNoir, - KEY_VALIDATION_REQUESTS - >, - transient_data_index_hints: inputs.transientDataIndexHints.map(mapTransientDataIndexHintToNoir) as FixedLengthArray< - TransientDataIndexHintNoir, - NUM_TRANSIENT_DATA_HINTS - >, - validation_requests_split_counter: mapNumberToNoir(inputs.validationRequestsSplitCounter), - }; -} - -/** - * Maps global variables to the noir type. - * @param globalVariables - The global variables. - * @returns The noir global variables. - */ -export function mapGlobalVariablesToNoir(globalVariables: GlobalVariables): GlobalVariablesNoir { - return { - chain_id: mapFieldToNoir(globalVariables.chainId), - version: mapFieldToNoir(globalVariables.version), - block_number: mapFieldToNoir(globalVariables.blockNumber), - slot_number: mapFieldToNoir(globalVariables.slotNumber), - timestamp: mapFieldToNoir(globalVariables.timestamp), - coinbase: mapEthAddressToNoir(globalVariables.coinbase), - fee_recipient: mapAztecAddressToNoir(globalVariables.feeRecipient), - gas_fees: mapGasFeesToNoir(globalVariables.gasFees), - }; -} - -/** - * Maps global variables from the noir type. - * @param globalVariables - The noir global variables. - * @returns The global variables. - */ -export function mapGlobalVariablesFromNoir(globalVariables: GlobalVariablesNoir): GlobalVariables { - return new GlobalVariables( - mapFieldFromNoir(globalVariables.chain_id), - mapFieldFromNoir(globalVariables.version), - mapFieldFromNoir(globalVariables.block_number), - mapFieldFromNoir(globalVariables.slot_number), - mapFieldFromNoir(globalVariables.timestamp), - mapEthAddressFromNoir(globalVariables.coinbase), - mapAztecAddressFromNoir(globalVariables.fee_recipient), - mapGasFeesFromNoir(globalVariables.gas_fees), - ); -} - -export function mapGasFeesToNoir(gasFees: GasFees): GasFeesNoir { - return { - fee_per_da_gas: mapFieldToNoir(gasFees.feePerDaGas), - fee_per_l2_gas: mapFieldToNoir(gasFees.feePerL2Gas), - }; -} - -export function mapGasFeesFromNoir(gasFees: GasFeesNoir): GasFees { - return new GasFees(mapFieldFromNoir(gasFees.fee_per_da_gas), mapFieldFromNoir(gasFees.fee_per_l2_gas)); -} - -export function mapFeeRecipientToNoir(feeRecipient: FeeRecipient): FeeRecipientNoir { - return { - recipient: mapEthAddressToNoir(feeRecipient.recipient), - value: mapFieldToNoir(feeRecipient.value), - }; -} - -export function mapFeeRecipientFromNoir(feeRecipient: FeeRecipientNoir): FeeRecipient { - return new FeeRecipient(mapEthAddressFromNoir(feeRecipient.recipient), mapFieldFromNoir(feeRecipient.value)); -} - -/** - * Maps poseidon sponge to noir. - * @param sponge - The circuits.js poseidon sponge. - * @returns The noir poseidon sponge. - */ -export function mapPoseidon2SpongeToNoir(sponge: Poseidon2Sponge): Poseidon2SpongeNoir { - return { - cache: mapTuple(sponge.cache, mapFieldToNoir), - state: mapTuple(sponge.state, mapFieldToNoir), - cache_size: mapNumberToNoir(sponge.cacheSize), - squeeze_mode: sponge.squeezeMode, - }; -} - -/** - * Maps poseidon sponge from noir. - * @param sponge - The noir poseidon sponge. - * @returns The circuits.js poseidon sponge. - */ -export function mapPoseidon2SpongeFromNoir(sponge: Poseidon2SpongeNoir): Poseidon2Sponge { - return new Poseidon2Sponge( - mapTupleFromNoir(sponge.cache, 3, mapFieldFromNoir), - mapTupleFromNoir(sponge.state, 4, mapFieldFromNoir), - mapNumberFromNoir(sponge.cache_size), - sponge.squeeze_mode, - ); -} - -/** - * Maps sponge blob to noir. - * @param spongeBlob - The circuits.js sponge blob. - * @returns The noir sponge blob. - */ -export function mapSpongeBlobToNoir(spongeBlob: SpongeBlob): SpongeBlobNoir { - return { - sponge: mapPoseidon2SpongeToNoir(spongeBlob.sponge), - fields: mapNumberToNoir(spongeBlob.fields), - expected_fields: mapNumberToNoir(spongeBlob.expectedFields), - }; -} - -/** - * Maps sponge blob from noir. - * @param spongeBlob - The noir sponge blob. - * @returns The circuits.js sponge blob. - */ -export function mapSpongeBlobFromNoir(spongeBlob: SpongeBlobNoir): SpongeBlob { - return new SpongeBlob( - mapPoseidon2SpongeFromNoir(spongeBlob.sponge), - mapNumberFromNoir(spongeBlob.fields), - mapNumberFromNoir(spongeBlob.expected_fields), - ); -} - -/** - * Maps blob commitment to noir. - * @param commitment - The circuits.js commitment. - * @returns The noir commitment. - */ -export function mapBlobCommitmentToNoir(commitment: [Fr, Fr]): BlobCommitmentNoir { - return { - inner: mapTuple(commitment, mapFieldToNoir), - }; -} - -/** - * Maps blob public inputs to noir. - * @param blobPublicInputs - The circuits.js blob public inputs. - * @returns The noir blob public inputs. - */ -export function mapBlobPublicInputsToNoir(blobPublicInputs: BlobPublicInputs): BlobPublicInputsNoir { - return { - z: mapFieldToNoir(blobPublicInputs.z), - y: mapBLS12BigNumToNoir(blobPublicInputs.y), - kzg_commitment: mapBlobCommitmentToNoir(blobPublicInputs.kzgCommitment), - }; -} - -/** - * Maps blob public inputs from noir. - * @param blobPublicInputs - The noir blob public inputs. - * @returns The circuits.js blob public inputs. - */ -export function mapBlobPublicInputsFromNoir(blobPublicInputs: BlobPublicInputsNoir): BlobPublicInputs { - return new BlobPublicInputs( - mapFieldFromNoir(blobPublicInputs.z), - mapBLS12BigNumFromNoir(blobPublicInputs.y), - mapTupleFromNoir(blobPublicInputs.kzg_commitment.inner, 2, mapFieldFromNoir), - ); -} - -/** - * Maps block blob public inputs to noir. - * @param blockBlobPublicInputs - The circuits.js block blob public inputs. - * @returns The noir block blob public inputs. - */ -export function mapBlockBlobPublicInputsToNoir( - blockBlobPublicInputs: BlockBlobPublicInputs, -): BlockBlobPublicInputsNoir { - return { - inner: mapTuple(blockBlobPublicInputs.inner, mapBlobPublicInputsToNoir), - }; -} - -/** - * Maps block blob public inputs from noir. - * @param blockBlobPublicInputs - The noir block blob public inputs. - * @returns The circuits.js block blob public inputs. - */ -export function mapBlockBlobPublicInputsFromNoir( - blockBlobPublicInputs: BlockBlobPublicInputsNoir, -): BlockBlobPublicInputs { - return new BlockBlobPublicInputs( - mapTupleFromNoir(blockBlobPublicInputs.inner, BLOBS_PER_BLOCK, mapBlobPublicInputsFromNoir), - ); -} - -/** - * Maps a constant rollup data to a noir constant rollup data. - * @param constantRollupData - The circuits.js constant rollup data. - * @returns The noir constant rollup data. - */ -export function mapConstantRollupDataToNoir(constantRollupData: ConstantRollupData): ConstantRollupDataNoir { - return { - last_archive: mapAppendOnlyTreeSnapshotToNoir(constantRollupData.lastArchive), - vk_tree_root: mapFieldToNoir(constantRollupData.vkTreeRoot), - protocol_contract_tree_root: mapFieldToNoir(constantRollupData.protocolContractTreeRoot), - global_variables: mapGlobalVariablesToNoir(constantRollupData.globalVariables), - }; -} - -/** - * Maps a constant rollup data from noir to the circuits.js type. - * @param constantRollupData - The noir constant rollup data. - * @returns The circuits.js constant rollup data. - */ -export function mapConstantRollupDataFromNoir(constantRollupData: ConstantRollupDataNoir): ConstantRollupData { - return new ConstantRollupData( - mapAppendOnlyTreeSnapshotFromNoir(constantRollupData.last_archive), - mapFieldFromNoir(constantRollupData.vk_tree_root), - mapFieldFromNoir(constantRollupData.protocol_contract_tree_root), - mapGlobalVariablesFromNoir(constantRollupData.global_variables), - ); -} - -/** - * Maps a base or merge rollup public inputs to a noir base or merge rollup public inputs. - * @param baseOrMergeRollupPublicInputs - The base or merge rollup public inputs. - * @returns The noir base or merge rollup public inputs. - */ -export function mapBaseOrMergeRollupPublicInputsToNoir( - baseOrMergeRollupPublicInputs: BaseOrMergeRollupPublicInputs, -): BaseOrMergeRollupPublicInputsNoir { - return { - rollup_type: mapFieldToNoir(new Fr(baseOrMergeRollupPublicInputs.rollupType)), - num_txs: mapFieldToNoir(new Fr(baseOrMergeRollupPublicInputs.numTxs)), - constants: mapConstantRollupDataToNoir(baseOrMergeRollupPublicInputs.constants), - start: mapPartialStateReferenceToNoir(baseOrMergeRollupPublicInputs.start), - end: mapPartialStateReferenceToNoir(baseOrMergeRollupPublicInputs.end), - start_sponge_blob: mapSpongeBlobToNoir(baseOrMergeRollupPublicInputs.startSpongeBlob), - end_sponge_blob: mapSpongeBlobToNoir(baseOrMergeRollupPublicInputs.endSpongeBlob), - out_hash: mapFieldToNoir(baseOrMergeRollupPublicInputs.outHash), - accumulated_fees: mapFieldToNoir(baseOrMergeRollupPublicInputs.accumulatedFees), - accumulated_mana_used: mapFieldToNoir(baseOrMergeRollupPublicInputs.accumulatedManaUsed), - }; -} - -/** - * Maps block root or block merge rollup public inputs to a noir block root or block merge rollup public inputs. - * @param blockRootOrBlockMergePublicInputs - The block root or block merge rollup public inputs. - * @returns The noir block root or block merge rollup public inputs. - */ -export function mapBlockRootOrBlockMergePublicInputsToNoir( - blockRootOrBlockMergePublicInputs: BlockRootOrBlockMergePublicInputs, -): BlockRootOrBlockMergePublicInputsNoir { - return { - previous_archive: mapAppendOnlyTreeSnapshotToNoir(blockRootOrBlockMergePublicInputs.previousArchive), - new_archive: mapAppendOnlyTreeSnapshotToNoir(blockRootOrBlockMergePublicInputs.newArchive), - previous_block_hash: mapFieldToNoir(blockRootOrBlockMergePublicInputs.previousBlockHash), - end_block_hash: mapFieldToNoir(blockRootOrBlockMergePublicInputs.endBlockHash), - start_global_variables: mapGlobalVariablesToNoir(blockRootOrBlockMergePublicInputs.startGlobalVariables), - end_global_variables: mapGlobalVariablesToNoir(blockRootOrBlockMergePublicInputs.endGlobalVariables), - out_hash: mapFieldToNoir(blockRootOrBlockMergePublicInputs.outHash), - fees: mapTuple(blockRootOrBlockMergePublicInputs.fees, mapFeeRecipientToNoir), - vk_tree_root: mapFieldToNoir(blockRootOrBlockMergePublicInputs.vkTreeRoot), - protocol_contract_tree_root: mapFieldToNoir(blockRootOrBlockMergePublicInputs.protocolContractTreeRoot), - prover_id: mapFieldToNoir(blockRootOrBlockMergePublicInputs.proverId), - blob_public_inputs: mapTuple(blockRootOrBlockMergePublicInputs.blobPublicInputs, mapBlockBlobPublicInputsToNoir), - }; -} - -function mapAvmCircuitPublicInputsToNoir(inputs: AvmCircuitPublicInputs): AvmCircuitPublicInputsNoir { - return { - global_variables: mapGlobalVariablesToNoir(inputs.globalVariables), - start_tree_snapshots: mapTreeSnapshotsToNoir(inputs.startTreeSnapshots), - start_gas_used: mapGasToNoir(inputs.startGasUsed), - gas_settings: mapGasSettingsToNoir(inputs.gasSettings), - fee_payer: mapAztecAddressToNoir(inputs.feePayer), - public_setup_call_requests: mapTuple(inputs.publicSetupCallRequests, mapPublicCallRequestToNoir), - public_app_logic_call_requests: mapTuple(inputs.publicAppLogicCallRequests, mapPublicCallRequestToNoir), - public_teardown_call_request: mapPublicCallRequestToNoir(inputs.publicTeardownCallRequest), - previous_non_revertible_accumulated_data_array_lengths: mapPrivateToAvmAccumulatedDataArrayLengthsToNoir( - inputs.previousNonRevertibleAccumulatedDataArrayLengths, - ), - previous_revertible_accumulated_data_array_lengths: mapPrivateToAvmAccumulatedDataArrayLengthsToNoir( - inputs.previousRevertibleAccumulatedDataArrayLengths, - ), - previous_non_revertible_accumulated_data: mapPrivateToAvmAccumulatedDataToNoir( - inputs.previousNonRevertibleAccumulatedData, - ), - previous_revertible_accumulated_data: mapPrivateToAvmAccumulatedDataToNoir( - inputs.previousRevertibleAccumulatedData, - ), - end_tree_snapshots: mapTreeSnapshotsToNoir(inputs.endTreeSnapshots), - end_gas_used: mapGasToNoir(inputs.endGasUsed), - accumulated_data: mapAvmAccumulatedDataToNoir(inputs.accumulatedData), - transaction_fee: mapFieldToNoir(inputs.transactionFee), - reverted: inputs.reverted, - }; -} - -/** - * Maps a base or merge rollup public inputs from noir to the circuits.js type. - * @param baseOrMergeRollupPublicInputs - The noir base or merge rollup public inputs. - * @returns The circuits.js base or merge rollup public inputs. - */ -export function mapBaseOrMergeRollupPublicInputsFromNoir( - baseOrMergeRollupPublicInputs: BaseOrMergeRollupPublicInputsNoir, -): BaseOrMergeRollupPublicInputs { - return new BaseOrMergeRollupPublicInputs( - mapNumberFromNoir(baseOrMergeRollupPublicInputs.rollup_type), - mapNumberFromNoir(baseOrMergeRollupPublicInputs.num_txs), - mapConstantRollupDataFromNoir(baseOrMergeRollupPublicInputs.constants), - mapPartialStateReferenceFromNoir(baseOrMergeRollupPublicInputs.start), - mapPartialStateReferenceFromNoir(baseOrMergeRollupPublicInputs.end), - mapSpongeBlobFromNoir(baseOrMergeRollupPublicInputs.start_sponge_blob), - mapSpongeBlobFromNoir(baseOrMergeRollupPublicInputs.end_sponge_blob), - mapFieldFromNoir(baseOrMergeRollupPublicInputs.out_hash), - mapFieldFromNoir(baseOrMergeRollupPublicInputs.accumulated_fees), - mapFieldFromNoir(baseOrMergeRollupPublicInputs.accumulated_mana_used), - ); -} - -/** - * Maps a block root or block merge rollup public inputs from noir to the circuits.js type. - * @param blockRootOrBlockMergePublicInputs - The noir lock root or block merge rollup public inputs. - * @returns The circuits.js block root or block merge rollup public inputs. - */ -export function mapBlockRootOrBlockMergePublicInputsFromNoir( - blockRootOrBlockMergePublicInputs: BlockRootOrBlockMergePublicInputsNoir, -): BlockRootOrBlockMergePublicInputs { - return new BlockRootOrBlockMergePublicInputs( - mapAppendOnlyTreeSnapshotFromNoir(blockRootOrBlockMergePublicInputs.previous_archive), - mapAppendOnlyTreeSnapshotFromNoir(blockRootOrBlockMergePublicInputs.new_archive), - mapFieldFromNoir(blockRootOrBlockMergePublicInputs.previous_block_hash), - mapFieldFromNoir(blockRootOrBlockMergePublicInputs.end_block_hash), - mapGlobalVariablesFromNoir(blockRootOrBlockMergePublicInputs.start_global_variables), - mapGlobalVariablesFromNoir(blockRootOrBlockMergePublicInputs.end_global_variables), - mapFieldFromNoir(blockRootOrBlockMergePublicInputs.out_hash), - mapTupleFromNoir(blockRootOrBlockMergePublicInputs.fees, AZTEC_MAX_EPOCH_DURATION, mapFeeRecipientFromNoir), - mapFieldFromNoir(blockRootOrBlockMergePublicInputs.vk_tree_root), - mapFieldFromNoir(blockRootOrBlockMergePublicInputs.protocol_contract_tree_root), - mapFieldFromNoir(blockRootOrBlockMergePublicInputs.prover_id), - mapTupleFromNoir( - blockRootOrBlockMergePublicInputs.blob_public_inputs, - AZTEC_MAX_EPOCH_DURATION, - mapBlockBlobPublicInputsFromNoir, - ), - ); -} - -/** - * Maps a previous rollup data from the circuits.js type to noir. - * @param previousRollupData - The circuits.js previous rollup data. - * @returns The noir previous rollup data. - */ -export function mapPreviousRollupDataToNoir(previousRollupData: PreviousRollupData): PreviousRollupDataNoir { - return { - base_or_merge_rollup_public_inputs: mapBaseOrMergeRollupPublicInputsToNoir( - previousRollupData.baseOrMergeRollupPublicInputs, - ), - proof: mapRecursiveProofToNoir(previousRollupData.proof), - vk: mapVerificationKeyToNoir(previousRollupData.vk, HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS), - vk_witness: { - leaf_index: mapFieldToNoir(new Fr(previousRollupData.vkWitness.leafIndex)), - sibling_path: mapTuple(previousRollupData.vkWitness.siblingPath, mapFieldToNoir), - }, - }; -} - -/** - * Maps a previous rollup data from the circuits.js type to noir. - * @param previousRollupData - The circuits.js previous rollup data. - * @returns The noir previous rollup data. - */ -export function mapPreviousRollupBlockDataToNoir( - previousRollupData: PreviousRollupBlockData, -): PreviousRollupBlockDataNoir { - return { - block_root_or_block_merge_public_inputs: mapBlockRootOrBlockMergePublicInputsToNoir( - previousRollupData.blockRootOrBlockMergePublicInputs, - ), - proof: mapRecursiveProofToNoir(previousRollupData.proof), - vk: mapVerificationKeyToNoir(previousRollupData.vk, HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS), - vk_witness: { - leaf_index: mapFieldToNoir(new Fr(previousRollupData.vkWitness.leafIndex)), - sibling_path: mapTuple(previousRollupData.vkWitness.siblingPath, mapFieldToNoir), - }, - }; -} - -/** - * Maps a AOT snapshot to noir. - * @param snapshot - The circuits.js AOT snapshot. - * @returns The noir AOT snapshot. - */ -export function mapAppendOnlyTreeSnapshotFromNoir(snapshot: AppendOnlyTreeSnapshotNoir): AppendOnlyTreeSnapshot { - return new AppendOnlyTreeSnapshot( - mapFieldFromNoir(snapshot.root), - mapNumberFromNoir(snapshot.next_available_leaf_index), - ); -} - -/** - * Maps a AOT snapshot from noir to the circuits.js type. - * @param snapshot - The noir AOT snapshot. - * @returns The circuits.js AOT snapshot. - */ -export function mapAppendOnlyTreeSnapshotToNoir(snapshot: AppendOnlyTreeSnapshot): AppendOnlyTreeSnapshotNoir { - return { - root: mapFieldToNoir(snapshot.root), - next_available_leaf_index: mapFieldToNoir(new Fr(snapshot.nextAvailableLeafIndex)), - }; -} - -export function mapRootRollupParityInputToNoir( - rootParityInput: RootParityInput, -): RootRollupParityInputNoir { - return { - proof: mapRecursiveProofToNoir(rootParityInput.proof), - verification_key: mapVerificationKeyToNoir(rootParityInput.verificationKey, HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS), - vk_path: mapTuple(rootParityInput.vkPath, mapFieldToNoir), - public_inputs: mapParityPublicInputsToNoir(rootParityInput.publicInputs), - }; -} - -/** - * Maps the block root rollup inputs to noir. - * @param rootRollupInputs - The circuits.js block root rollup inputs. - * @returns The noir block root rollup inputs. - */ -export function mapBlockRootRollupInputsToNoir(rootRollupInputs: BlockRootRollupInputs): BlockRootRollupInputsNoir { - return { - previous_rollup_data: mapTuple(rootRollupInputs.previousRollupData, mapPreviousRollupDataToNoir), - l1_to_l2_roots: mapRootRollupParityInputToNoir(rootRollupInputs.l1ToL2Roots), - l1_to_l2_messages: mapTuple(rootRollupInputs.newL1ToL2Messages, mapFieldToNoir), - l1_to_l2_message_subtree_sibling_path: mapTuple( - rootRollupInputs.newL1ToL2MessageTreeRootSiblingPath, - mapFieldToNoir, - ), - start_l1_to_l2_message_tree_snapshot: mapAppendOnlyTreeSnapshotToNoir( - rootRollupInputs.startL1ToL2MessageTreeSnapshot, - ), - start_archive_snapshot: mapAppendOnlyTreeSnapshotToNoir(rootRollupInputs.startArchiveSnapshot), - new_archive_sibling_path: mapTuple(rootRollupInputs.newArchiveSiblingPath, mapFieldToNoir), - previous_block_hash: mapFieldToNoir(rootRollupInputs.previousBlockHash), - prover_id: mapFieldToNoir(rootRollupInputs.proverId), - // @ts-expect-error - below line gives error 'Type instantiation is excessively deep and possibly infinite. ts(2589)' - blobs_fields: mapTuple(rootRollupInputs.blobFields, mapFieldToNoir), - blob_commitments: mapTuple(rootRollupInputs.blobCommitments, mapBlobCommitmentToNoir), - blobs_hash: mapFieldToNoir(rootRollupInputs.blobsHash), - }; -} - -/** - * Maps the empty block root rollup inputs to noir. - * @param rootRollupInputs - The circuits.js block root rollup inputs. - * @returns The noir block root rollup inputs. - */ -export function mapEmptyBlockRootRollupInputsToNoir( - rootRollupInputs: EmptyBlockRootRollupInputs, -): EmptyBlockRootRollupInputsNoir { - return { - archive: mapAppendOnlyTreeSnapshotToNoir(rootRollupInputs.archive), - block_hash: mapFieldToNoir(rootRollupInputs.blockHash), - global_variables: mapGlobalVariablesToNoir(rootRollupInputs.globalVariables), - vk_tree_root: mapFieldToNoir(rootRollupInputs.vkTreeRoot), - protocol_contract_tree_root: mapFieldToNoir(rootRollupInputs.protocolContractTreeRoot), - prover_id: mapFieldToNoir(rootRollupInputs.proverId), - }; -} - -/** - * Maps the root rollup inputs to noir. - * @param rootRollupInputs - The circuits.js root rollup inputs. - * @returns The noir root rollup inputs. - */ -export function mapRootRollupInputsToNoir(rootRollupInputs: RootRollupInputs): RootRollupInputsNoir { - return { - previous_rollup_data: mapTuple(rootRollupInputs.previousRollupData, mapPreviousRollupBlockDataToNoir), - prover_id: mapFieldToNoir(rootRollupInputs.proverId), - }; -} - -export function mapRecursiveProofToNoir(proof: RecursiveProof) { - return { - fields: mapTuple(proof.proof, mapFieldToNoir) as FixedLengthArray, - }; -} - -export function mapRootParityInputToNoir( - rootParityInput: RootParityInput, -): ParityRootParityInputNoir { - return { - proof: mapRecursiveProofToNoir(rootParityInput.proof), - verification_key: mapVerificationKeyToNoir(rootParityInput.verificationKey, HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS), - vk_path: mapTuple(rootParityInput.vkPath, mapFieldToNoir), - public_inputs: mapParityPublicInputsToNoir(rootParityInput.publicInputs), - }; -} - -export function mapParityPublicInputsToNoir(parityPublicInputs: ParityPublicInputs): ParityPublicInputsNoir { - return { - sha_root: mapFieldToNoir(parityPublicInputs.shaRoot), - converted_root: mapFieldToNoir(parityPublicInputs.convertedRoot), - vk_tree_root: mapFieldToNoir(parityPublicInputs.vkTreeRoot), - }; -} - -/** - * Maps a root rollup public inputs from noir. - * @param rootRollupPublicInputs - The noir root rollup public inputs. - * @returns The circuits.js root rollup public inputs. - */ -export function mapRootRollupPublicInputsFromNoir( - rootRollupPublicInputs: RootRollupPublicInputsNoir, -): RootRollupPublicInputs { - return new RootRollupPublicInputs( - mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.previous_archive), - mapAppendOnlyTreeSnapshotFromNoir(rootRollupPublicInputs.end_archive), - mapFieldFromNoir(rootRollupPublicInputs.previous_block_hash), - mapFieldFromNoir(rootRollupPublicInputs.end_block_hash), - mapFieldFromNoir(rootRollupPublicInputs.end_timestamp), - mapFieldFromNoir(rootRollupPublicInputs.end_block_number), - mapFieldFromNoir(rootRollupPublicInputs.out_hash), - mapTupleFromNoir(rootRollupPublicInputs.fees, AZTEC_MAX_EPOCH_DURATION, mapFeeRecipientFromNoir), - mapFieldFromNoir(rootRollupPublicInputs.vk_tree_root), - mapFieldFromNoir(rootRollupPublicInputs.protocol_contract_tree_root), - mapFieldFromNoir(rootRollupPublicInputs.prover_id), - mapTupleFromNoir( - rootRollupPublicInputs.blob_public_inputs, - AZTEC_MAX_EPOCH_DURATION, - mapBlockBlobPublicInputsFromNoir, - ), - ); -} - -/** - * Maps a parity public inputs from noir. - * @param parityPublicInputs - The noir parity public inputs. - * @returns The circuits.js parity public inputs. - */ -export function mapParityPublicInputsFromNoir(parityPublicInputs: ParityPublicInputsNoir): ParityPublicInputs { - return new ParityPublicInputs( - mapFieldFromNoir(parityPublicInputs.sha_root), - mapFieldFromNoir(parityPublicInputs.converted_root), - mapFieldFromNoir(parityPublicInputs.vk_tree_root), - ); -} - -/** - * Maps a block header to Noir - * @param header - The block header. - * @returns BlockHeader. - */ -export function mapHeaderToNoir(header: BlockHeader): BlockHeaderNoir { - return { - last_archive: mapAppendOnlyTreeSnapshotToNoir(header.lastArchive), - content_commitment: mapContentCommitmentToNoir(header.contentCommitment), - state: mapStateReferenceToNoir(header.state), - global_variables: mapGlobalVariablesToNoir(header.globalVariables), - total_fees: mapFieldToNoir(header.totalFees), - total_mana_used: mapFieldToNoir(header.totalManaUsed), - }; -} - -/** - * Maps a block header from Noir. - * @param header - The block header. - * @returns BlockHeader. - */ -export function mapHeaderFromNoir(header: BlockHeaderNoir): BlockHeader { - return new BlockHeader( - mapAppendOnlyTreeSnapshotFromNoir(header.last_archive), - mapContentCommitmentFromNoir(header.content_commitment), - mapStateReferenceFromNoir(header.state), - mapGlobalVariablesFromNoir(header.global_variables), - mapFieldFromNoir(header.total_fees), - mapFieldFromNoir(header.total_mana_used), - ); -} - -/** - * Maps a content commitment to Noir - * - */ -export function mapContentCommitmentToNoir(contentCommitment: ContentCommitment): ContentCommitmentNoir { - return { - num_txs: mapFieldToNoir(contentCommitment.numTxs), - blobs_hash: mapSha256HashToNoir(contentCommitment.blobsHash), - in_hash: mapSha256HashToNoir(contentCommitment.inHash), - out_hash: mapSha256HashToNoir(contentCommitment.outHash), - }; -} - -/** - * Maps a content commitment to Noir - * - */ -export function mapContentCommitmentFromNoir(contentCommitment: ContentCommitmentNoir): ContentCommitment { - return new ContentCommitment( - mapFieldFromNoir(contentCommitment.num_txs), - mapSha256HashFromNoir(contentCommitment.blobs_hash), - mapSha256HashFromNoir(contentCommitment.in_hash), - mapSha256HashFromNoir(contentCommitment.out_hash), - ); -} - -/** - * Maps state reference to Noir. - * @param stateReference - The state reference. - * @returns Noir representation of state reference. - */ -export function mapStateReferenceToNoir(stateReference: StateReference): StateReferenceNoir { - return { - l1_to_l2_message_tree: mapAppendOnlyTreeSnapshotToNoir(stateReference.l1ToL2MessageTree), - partial: mapPartialStateReferenceToNoir(stateReference.partial), - }; -} - -/** - * Maps state reference from Noir. - * @param stateReference - The state reference. - * @returns State reference - */ -export function mapStateReferenceFromNoir(stateReference: StateReferenceNoir): StateReference { - return new StateReference( - mapAppendOnlyTreeSnapshotFromNoir(stateReference.l1_to_l2_message_tree), - mapPartialStateReferenceFromNoir(stateReference.partial), - ); -} - -/** - * Maps partial state reference from Noir. - * @param partialStateReference - The state reference. - * @returns Partial state reference - */ -export function mapPartialStateReferenceFromNoir( - partialStateReference: PartialStateReferenceNoir, -): PartialStateReference { - return new PartialStateReference( - mapAppendOnlyTreeSnapshotFromNoir(partialStateReference.note_hash_tree), - mapAppendOnlyTreeSnapshotFromNoir(partialStateReference.nullifier_tree), - mapAppendOnlyTreeSnapshotFromNoir(partialStateReference.public_data_tree), - ); -} - -function mapTreeSnapshotsToNoir(snapshots: TreeSnapshots): TreeSnapshotsNoir { - return { - l1_to_l2_message_tree: mapAppendOnlyTreeSnapshotToNoir(snapshots.l1ToL2MessageTree), - note_hash_tree: mapAppendOnlyTreeSnapshotToNoir(snapshots.noteHashTree), - nullifier_tree: mapAppendOnlyTreeSnapshotToNoir(snapshots.nullifierTree), - public_data_tree: mapAppendOnlyTreeSnapshotToNoir(snapshots.publicDataTree), - }; -} - -// function mapTreeSnapshotsFromNoir(snapshots: TreeSnapshotsNoir) { -// return new TreeSnapshots( -// mapAppendOnlyTreeSnapshotFromNoir(snapshots.l1_to_l2_message_tree), -// mapAppendOnlyTreeSnapshotFromNoir(snapshots.note_hash_tree), -// mapAppendOnlyTreeSnapshotFromNoir(snapshots.nullifier_tree), -// mapAppendOnlyTreeSnapshotFromNoir(snapshots.public_data_tree), -// ); -// } - -/** - * Maps the merge rollup inputs to noir. - * @param mergeRollupInputs - The circuits.js merge rollup inputs. - * @returns The noir merge rollup inputs. - */ -export function mapMergeRollupInputsToNoir(mergeRollupInputs: MergeRollupInputs): MergeRollupInputsNoir { - return { - previous_rollup_data: mapTuple(mergeRollupInputs.previousRollupData, mapPreviousRollupDataToNoir), - }; -} - -/** - * Maps the block merge rollup inputs to noir. - * @param mergeRollupInputs - The circuits.js block merge rollup inputs. - * @returns The noir block merge rollup inputs. - */ -export function mapBlockMergeRollupInputsToNoir(mergeRollupInputs: BlockMergeRollupInputs): BlockMergeRollupInputsNoir { - return { - previous_rollup_data: mapTuple(mergeRollupInputs.previousRollupData, mapPreviousRollupBlockDataToNoir), - }; -} - -function mapNoteHashLeafPreimageToNoir(noteHashLeafValue: Fr): NoteHashLeafPreimageNoir { - return { - value: mapFieldToNoir(noteHashLeafValue), - }; -} - -/** - * Maps a nullifier leaf preimage to noir - * @param nullifierLeafPreimage - The nullifier leaf preimage. - * @returns The noir nullifier leaf preimage. - */ -export function mapNullifierLeafPreimageToNoir( - nullifierLeafPreimage: NullifierLeafPreimage, -): NullifierLeafPreimageNoir { - return { - nullifier: mapFieldToNoir(nullifierLeafPreimage.nullifier), - next_nullifier: mapFieldToNoir(nullifierLeafPreimage.nextNullifier), - next_index: mapNumberToNoir(Number(nullifierLeafPreimage.nextIndex)), - }; -} - -function mapMembershipWitnessToNoir(witness: MembershipWitness): MembershipWitnessNoir { - const siblingPath = mapTuple(witness.siblingPath, mapFieldToNoir) as FixedLengthArray; - return { - leaf_index: witness.leafIndex.toString(), - sibling_path: siblingPath, - }; -} - -/** - * Maps a leaf preimage of the public data tree to noir. - */ -export function mapPublicDataTreePreimageToNoir(preimage: PublicDataTreeLeafPreimage): PublicDataTreeLeafPreimageNoir { - return { - slot: mapFieldToNoir(preimage.slot), - value: mapFieldToNoir(preimage.value), - next_slot: mapFieldToNoir(preimage.nextSlot), - next_index: mapNumberToNoir(Number(preimage.nextIndex)), - }; -} - -/** - * Maps a partial state reference to a noir partial state reference. - * @param partialStateReference - The partial state reference. - * @returns The noir partial state reference. - */ -export function mapPartialStateReferenceToNoir( - partialStateReference: PartialStateReference, -): PartialStateReferenceNoir { - return { - note_hash_tree: mapAppendOnlyTreeSnapshotToNoir(partialStateReference.noteHashTree), - nullifier_tree: mapAppendOnlyTreeSnapshotToNoir(partialStateReference.nullifierTree), - public_data_tree: mapAppendOnlyTreeSnapshotToNoir(partialStateReference.publicDataTree), - }; -} - -/** - * Maps private base state diff hints to a noir state diff hints. - * @param hints - The state diff hints. - * @returns The noir state diff hints. - */ -export function mapPrivateBaseStateDiffHintsToNoir(hints: PrivateBaseStateDiffHints): PrivateBaseStateDiffHintsNoir { - return { - nullifier_predecessor_preimages: mapTuple(hints.nullifierPredecessorPreimages, mapNullifierLeafPreimageToNoir), - nullifier_predecessor_membership_witnesses: mapTuple( - hints.nullifierPredecessorMembershipWitnesses, - (witness: MembershipWitness) => mapMembershipWitnessToNoir(witness), - ), - sorted_nullifiers: mapTuple(hints.sortedNullifiers, mapFieldToNoir), - sorted_nullifier_indexes: mapTuple(hints.sortedNullifierIndexes, (index: number) => mapNumberToNoir(index)), - note_hash_subtree_sibling_path: mapTuple(hints.noteHashSubtreeSiblingPath, mapFieldToNoir), - nullifier_subtree_sibling_path: mapTuple(hints.nullifierSubtreeSiblingPath, mapFieldToNoir), - fee_write_low_leaf_preimage: mapPublicDataTreePreimageToNoir(hints.feeWriteLowLeafPreimage), - fee_write_low_leaf_membership_witness: mapMembershipWitnessToNoir(hints.feeWriteLowLeafMembershipWitness), - fee_write_sibling_path: mapTuple(hints.feeWriteSiblingPath, mapFieldToNoir), - }; -} - -/** - * Maps public base state diff hints to a noir state diff hints. - * @param hints - The state diff hints. - * @returns The noir state diff hints. - */ -export function mapPublicBaseStateDiffHintsToNoir(hints: PublicBaseStateDiffHints): PublicBaseStateDiffHintsNoir { - return { - nullifier_predecessor_preimages: mapTuple(hints.nullifierPredecessorPreimages, mapNullifierLeafPreimageToNoir), - nullifier_predecessor_membership_witnesses: mapTuple( - hints.nullifierPredecessorMembershipWitnesses, - (witness: MembershipWitness) => mapMembershipWitnessToNoir(witness), - ), - sorted_nullifiers: mapTuple(hints.sortedNullifiers, mapFieldToNoir), - sorted_nullifier_indexes: mapTuple(hints.sortedNullifierIndexes, (index: number) => mapNumberToNoir(index)), - note_hash_subtree_sibling_path: mapTuple(hints.noteHashSubtreeSiblingPath, mapFieldToNoir), - nullifier_subtree_sibling_path: mapTuple(hints.nullifierSubtreeSiblingPath, mapFieldToNoir), - low_public_data_writes_preimages: mapTuple(hints.lowPublicDataWritesPreimages, mapPublicDataTreePreimageToNoir), - low_public_data_writes_witnesses: mapTuple( - hints.lowPublicDataWritesMembershipWitnesses, - (witness: MembershipWitness) => mapMembershipWitnessToNoir(witness), - ), - public_data_tree_sibling_paths: mapTuple(hints.publicDataTreeSiblingPaths, path => mapTuple(path, mapFieldToNoir)), - }; -} - -/** - * Maps base parity inputs to noir. - * @param inputs - The circuits.js base parity inputs. - * @returns The noir base parity inputs. - */ -export function mapBaseParityInputsToNoir(inputs: BaseParityInputs): BaseParityInputsNoir { - return { - msgs: mapTuple(inputs.msgs, mapFieldToNoir), - vk_tree_root: mapFieldToNoir(inputs.vkTreeRoot), - }; -} - -/** - * Maps root parity inputs to noir. - * @param inputs - The circuits.js root parity inputs. - * @returns The noir root parity inputs. - */ -export function mapRootParityInputsToNoir(inputs: RootParityInputs): RootParityInputsNoir { - return { - children: mapTuple(inputs.children, mapRootParityInputToNoir), - }; -} - -function mapPrivateTubeDataToNoir(data: PrivateTubeData): PrivateTubeDataNoir { - return { - public_inputs: mapKernelCircuitPublicInputsToNoir(data.publicInputs), - proof: mapRecursiveProofToNoir(data.proof), - vk_data: mapVkWitnessDataToNoir(data.vkData, HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS), - }; -} - -/** - * Maps the inputs to the base rollup to noir. - * @param input - The circuits.js base rollup inputs. - * @returns The noir base rollup inputs. - */ -export function mapPrivateBaseRollupInputsToNoir(inputs: PrivateBaseRollupInputs): PrivateBaseRollupInputsNoir { - return { - tube_data: mapPrivateTubeDataToNoir(inputs.tubeData), - start: mapPartialStateReferenceToNoir(inputs.hints.start), - start_sponge_blob: mapSpongeBlobToNoir(inputs.hints.startSpongeBlob), - state_diff_hints: mapPrivateBaseStateDiffHintsToNoir(inputs.hints.stateDiffHints), - - archive_root_membership_witness: mapMembershipWitnessToNoir(inputs.hints.archiveRootMembershipWitness), - constants: mapConstantRollupDataToNoir(inputs.hints.constants), - fee_payer_fee_juice_balance_read_hint: mapPublicDataHintToNoir(inputs.hints.feePayerFeeJuiceBalanceReadHint), - }; -} - -function mapPublicTubeDataToNoir(data: PublicTubeData): PublicTubeDataNoir { - return { - public_inputs: mapPrivateToPublicKernelCircuitPublicInputsToNoir(data.publicInputs), - proof: mapRecursiveProofToNoir(data.proof), - vk_data: mapVkWitnessDataToNoir(data.vkData, HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS), - }; -} - -function mapAvmProofDataToNoir(data: AvmProofData): AvmProofDataNoir { - return { - public_inputs: mapAvmCircuitPublicInputsToNoir(data.publicInputs), - proof: mapRecursiveProofToNoir(data.proof), - vk_data: mapVkWitnessDataToNoir(data.vkData, AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS), - }; -} - -export function mapPublicBaseRollupInputsToNoir(inputs: PublicBaseRollupInputs): PublicBaseRollupInputsNoir { - return { - tube_data: mapPublicTubeDataToNoir(inputs.tubeData), - avm_proof_data: mapAvmProofDataToNoir(inputs.avmProofData), - start: mapPartialStateReferenceToNoir(inputs.hints.start), - start_sponge_blob: mapSpongeBlobToNoir(inputs.hints.startSpongeBlob), - state_diff_hints: mapPublicBaseStateDiffHintsToNoir(inputs.hints.stateDiffHints), - - archive_root_membership_witness: mapMembershipWitnessToNoir(inputs.hints.archiveRootMembershipWitness), - constants: mapConstantRollupDataToNoir(inputs.hints.constants), - }; -} - -export function mapEmptyKernelInputsToNoir(inputs: PrivateKernelEmptyInputs): PrivateKernelEmptyPrivateInputsNoir { - return { - empty_nested: mapEmptyNestedDataToNoir(inputs.emptyNested), - historical_header: mapHeaderToNoir(inputs.header), - chain_id: mapFieldToNoir(inputs.chainId), - version: mapFieldToNoir(inputs.version), - vk_tree_root: mapFieldToNoir(inputs.vkTreeRoot), - protocol_contract_tree_root: mapFieldToNoir(inputs.protocolContractTreeRoot), - }; -} - -function mapEmptyNestedDataToNoir(inputs: EmptyNestedData): EmptyNestedDataNoir { - return { - proof: mapRecursiveProofToNoir(inputs.proof), - vk: mapVerificationKeyToNoir(inputs.vk, HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS), - }; -} diff --git a/yarn-project/noir-protocol-circuits-types/src/utils/server/foreign_call_handler.ts b/yarn-project/noir-protocol-circuits-types/src/utils/server/foreign_call_handler.ts index 5cf86ef55eb..d95dec07a13 100644 --- a/yarn-project/noir-protocol-circuits-types/src/utils/server/foreign_call_handler.ts +++ b/yarn-project/noir-protocol-circuits-types/src/utils/server/foreign_call_handler.ts @@ -1,4 +1,5 @@ -import { BlockBlobPublicInputs, Fr, SpongeBlob } from '@aztec/circuits.js'; +import { Fr } from '@aztec/circuits.js'; +import { BlockBlobPublicInputs, SpongeBlob } from '@aztec/circuits.js/blobs'; import { Blob } from '@aztec/foundation/blob'; import { applyStringFormatting, createLogger } from '@aztec/foundation/log'; diff --git a/yarn-project/prover-client/src/block_builder/light.test.ts b/yarn-project/prover-client/src/block_builder/light.test.ts index c40b340da4e..32c52642db7 100644 --- a/yarn-project/prover-client/src/block_builder/light.test.ts +++ b/yarn-project/prover-client/src/block_builder/light.test.ts @@ -11,34 +11,36 @@ import { makeBloatedProcessedTx } from '@aztec/circuit-types/test'; import { type AppendOnlyTreeSnapshot, BLOBS_PER_BLOCK, - type BaseOrMergeRollupPublicInputs, BaseParityInputs, - BlockRootRollupInputs, FIELDS_PER_BLOB, Fr, type GlobalVariables, L1_TO_L2_MSG_SUBTREE_HEIGHT, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, MembershipWitness, - MergeRollupInputs, NESTED_RECURSIVE_PROOF_LENGTH, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, NUM_BASE_PARITY_PER_ROOT_PARITY, type ParityPublicInputs, - PreviousRollupData, - type PrivateBaseRollupHints, - PrivateBaseRollupInputs, - PrivateTubeData, type RecursiveProof, RootParityInput, RootParityInputs, - SpongeBlob, TUBE_VK_INDEX, VK_TREE_HEIGHT, type VerificationKeyAsFields, VkWitnessData, makeEmptyRecursiveProof, } from '@aztec/circuits.js'; +import { SpongeBlob } from '@aztec/circuits.js/blobs'; +import { + BaseOrMergeRollupPublicInputs, + BlockRootRollupInputs, + MergeRollupInputs, + PreviousRollupData, + PrivateBaseRollupHints, + PrivateBaseRollupInputs, + PrivateTubeData, +} from '@aztec/circuits.js/rollup'; import { makeGlobalVariables } from '@aztec/circuits.js/testing'; import { Blob } from '@aztec/foundation/blob'; import { padArrayEnd, times } from '@aztec/foundation/collection'; diff --git a/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts b/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts index c0271c4a56b..0ea04de9921 100644 --- a/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts +++ b/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts @@ -9,11 +9,7 @@ import { import { ARCHIVE_HEIGHT, AppendOnlyTreeSnapshot, - type BaseOrMergeRollupPublicInputs, BlockHeader, - BlockMergeRollupInputs, - type BlockRootOrBlockMergePublicInputs, - ConstantRollupData, ContentCommitment, Fr, type GlobalVariables, @@ -21,7 +17,6 @@ import { MAX_NULLIFIERS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MembershipWitness, - MergeRollupInputs, MerkleTreeCalculator, type NESTED_RECURSIVE_PROOF_LENGTH, NOTE_HASH_SUBTREE_HEIGHT, @@ -34,22 +29,29 @@ import { PUBLIC_DATA_TREE_HEIGHT, type ParityPublicInputs, PartialStateReference, - PreviousRollupBlockData, - PreviousRollupData, - PrivateBaseRollupHints, - PrivateBaseStateDiffHints, - PublicBaseRollupHints, - PublicBaseStateDiffHints, PublicDataHint, PublicDataTreeLeaf, PublicDataTreeLeafPreimage, type RecursiveProof, - RootRollupInputs, - type SpongeBlob, StateReference, VK_TREE_HEIGHT, type VerificationKeyAsFields, } from '@aztec/circuits.js'; +import { SpongeBlob } from '@aztec/circuits.js/blobs'; +import { + BaseOrMergeRollupPublicInputs, + BlockMergeRollupInputs, + BlockRootOrBlockMergePublicInputs, + ConstantRollupData, + MergeRollupInputs, + PreviousRollupBlockData, + PreviousRollupData, + PrivateBaseRollupHints, + PrivateBaseStateDiffHints, + PublicBaseRollupHints, + PublicBaseStateDiffHints, + RootRollupInputs, +} from '@aztec/circuits.js/rollup'; import { makeTuple } from '@aztec/foundation/array'; import { Blob } from '@aztec/foundation/blob'; import { padArrayEnd } from '@aztec/foundation/collection'; diff --git a/yarn-project/prover-client/src/orchestrator/block-proving-state.ts b/yarn-project/prover-client/src/orchestrator/block-proving-state.ts index 0c22fe718f5..214f41a8088 100644 --- a/yarn-project/prover-client/src/orchestrator/block-proving-state.ts +++ b/yarn-project/prover-client/src/orchestrator/block-proving-state.ts @@ -2,8 +2,6 @@ import { type L2Block, type MerkleTreeId } from '@aztec/circuit-types'; import { type ARCHIVE_HEIGHT, type AppendOnlyTreeSnapshot, - type BaseOrMergeRollupPublicInputs, - type BlockRootOrBlockMergePublicInputs, type Fr, type GlobalVariables, type L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, @@ -14,9 +12,10 @@ import { type RECURSIVE_PROOF_LENGTH, type RecursiveProof, type RootParityInput, - SpongeBlob, type VerificationKeyAsFields, } from '@aztec/circuits.js'; +import { SpongeBlob } from '@aztec/circuits.js/blobs'; +import { BaseOrMergeRollupPublicInputs, BlockRootOrBlockMergePublicInputs } from '@aztec/circuits.js/rollup'; import { type Tuple } from '@aztec/foundation/serialize'; import { type EpochProvingState } from './epoch-proving-state.js'; diff --git a/yarn-project/prover-client/src/orchestrator/epoch-proving-state.ts b/yarn-project/prover-client/src/orchestrator/epoch-proving-state.ts index b4005052c53..3c4fb1b7672 100644 --- a/yarn-project/prover-client/src/orchestrator/epoch-proving-state.ts +++ b/yarn-project/prover-client/src/orchestrator/epoch-proving-state.ts @@ -2,7 +2,6 @@ import { type MerkleTreeId } from '@aztec/circuit-types'; import { type ARCHIVE_HEIGHT, type AppendOnlyTreeSnapshot, - type BlockRootOrBlockMergePublicInputs, Fr, type GlobalVariables, type L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, @@ -10,9 +9,9 @@ import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, type Proof, type RecursiveProof, - type RootRollupPublicInputs, type VerificationKeyAsFields, } from '@aztec/circuits.js'; +import { BlockRootOrBlockMergePublicInputs, RootRollupPublicInputs } from '@aztec/circuits.js/rollup'; import { padArrayEnd } from '@aztec/foundation/collection'; import { type Tuple } from '@aztec/foundation/serialize'; diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator.ts b/yarn-project/prover-client/src/orchestrator/orchestrator.ts index 30a4312f97e..e4230003407 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator.ts @@ -18,14 +18,8 @@ import { AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS, type AppendOnlyTreeSnapshot, BLOBS_PER_BLOCK, - type BaseOrMergeRollupPublicInputs, BaseParityInputs, - type BaseRollupHints, - BlobPublicInputs, type BlockHeader, - type BlockRootOrBlockMergePublicInputs, - BlockRootRollupInputs, - EmptyBlockRootRollupInputs, FIELDS_PER_BLOB, Fr, type GlobalVariables, @@ -43,6 +37,14 @@ import { VerificationKeyData, makeEmptyRecursiveProof, } from '@aztec/circuits.js'; +import { BlobPublicInputs } from '@aztec/circuits.js/blobs'; +import { + BaseOrMergeRollupPublicInputs, + BaseRollupHints, + BlockRootOrBlockMergePublicInputs, + BlockRootRollupInputs, + EmptyBlockRootRollupInputs, +} from '@aztec/circuits.js/rollup'; import { makeTuple } from '@aztec/foundation/array'; import { Blob } from '@aztec/foundation/blob'; import { maxBy, padArrayEnd } from '@aztec/foundation/collection'; diff --git a/yarn-project/prover-client/src/orchestrator/tx-proving-state.ts b/yarn-project/prover-client/src/orchestrator/tx-proving-state.ts index 311b4aa75a0..a86bf51ca81 100644 --- a/yarn-project/prover-client/src/orchestrator/tx-proving-state.ts +++ b/yarn-project/prover-client/src/orchestrator/tx-proving-state.ts @@ -3,19 +3,21 @@ import { type AVM_PROOF_LENGTH_IN_FIELDS, AVM_VK_INDEX, type AppendOnlyTreeSnapshot, + type TUBE_PROOF_LENGTH, + TUBE_VK_INDEX, + VkWitnessData, +} from '@aztec/circuits.js'; +import { AvmProofData, - type BaseRollupHints, + BaseRollupHints, PrivateBaseRollupHints, PrivateBaseRollupInputs, PrivateTubeData, PublicBaseRollupHints, PublicBaseRollupInputs, PublicTubeData, - type TUBE_PROOF_LENGTH, - TUBE_VK_INDEX, TubeInputs, - VkWitnessData, -} from '@aztec/circuits.js'; +} from '@aztec/circuits.js/rollup'; import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types'; /** diff --git a/yarn-project/prover-client/src/prover-agent/agent-queue-rpc-integration.test.ts b/yarn-project/prover-client/src/prover-agent/agent-queue-rpc-integration.test.ts index fe22d723495..d6dda59fa3d 100644 --- a/yarn-project/prover-client/src/prover-agent/agent-queue-rpc-integration.test.ts +++ b/yarn-project/prover-client/src/prover-agent/agent-queue-rpc-integration.test.ts @@ -1,5 +1,6 @@ import { ProvingJobSourceSchema, type ServerCircuitProver } from '@aztec/circuit-types'; -import { ClientIvcProof, Fr, PrivateKernelEmptyInputData, TubeInputs } from '@aztec/circuits.js'; +import { ClientIvcProof, Fr, PrivateKernelEmptyInputData } from '@aztec/circuits.js'; +import { TubeInputs } from '@aztec/circuits.js/rollup'; import { makeAvmCircuitInputs, makeBaseParityInputs, diff --git a/yarn-project/prover-client/src/prover-agent/memory-proving-queue.ts b/yarn-project/prover-client/src/prover-agent/memory-proving-queue.ts index 19657111997..1e9b8d22333 100644 --- a/yarn-project/prover-client/src/prover-agent/memory-proving-queue.ts +++ b/yarn-project/prover-client/src/prover-agent/memory-proving-queue.ts @@ -11,25 +11,27 @@ import { import type { AVM_PROOF_LENGTH_IN_FIELDS, AvmCircuitInputs, - BaseOrMergeRollupPublicInputs, BaseParityInputs, + KernelCircuitPublicInputs, + NESTED_RECURSIVE_PROOF_LENGTH, + ParityPublicInputs, + PrivateKernelEmptyInputData, + RECURSIVE_PROOF_LENGTH, + RootParityInputs, +} from '@aztec/circuits.js'; +import { + BaseOrMergeRollupPublicInputs, BlockMergeRollupInputs, BlockRootOrBlockMergePublicInputs, BlockRootRollupInputs, EmptyBlockRootRollupInputs, - KernelCircuitPublicInputs, MergeRollupInputs, - NESTED_RECURSIVE_PROOF_LENGTH, - ParityPublicInputs, PrivateBaseRollupInputs, - PrivateKernelEmptyInputData, PublicBaseRollupInputs, - RECURSIVE_PROOF_LENGTH, - RootParityInputs, RootRollupInputs, RootRollupPublicInputs, TubeInputs, -} from '@aztec/circuits.js'; +} from '@aztec/circuits.js/rollup'; import { randomBytes } from '@aztec/foundation/crypto'; import { AbortError, TimeoutError } from '@aztec/foundation/error'; import { createLogger } from '@aztec/foundation/log'; diff --git a/yarn-project/prover-client/src/proving_broker/broker_prover_facade.ts b/yarn-project/prover-client/src/proving_broker/broker_prover_facade.ts index dc20621706d..f7dc9ab6a92 100644 --- a/yarn-project/prover-client/src/proving_broker/broker_prover_facade.ts +++ b/yarn-project/prover-client/src/proving_broker/broker_prover_facade.ts @@ -11,26 +11,28 @@ import { import { type AVM_PROOF_LENGTH_IN_FIELDS, type AvmCircuitInputs, - type BaseOrMergeRollupPublicInputs, type BaseParityInputs, - 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'; +import { + BaseOrMergeRollupPublicInputs, + BlockMergeRollupInputs, + BlockRootOrBlockMergePublicInputs, + BlockRootRollupInputs, + EmptyBlockRootRollupInputs, + MergeRollupInputs, + PrivateBaseRollupInputs, + PublicBaseRollupInputs, + RootRollupInputs, + RootRollupPublicInputs, + TubeInputs, +} from '@aztec/circuits.js/rollup'; import { sha256 } from '@aztec/foundation/crypto'; import { createLogger } from '@aztec/foundation/log'; import { retryUntil } from '@aztec/foundation/retry'; diff --git a/yarn-project/prover-client/src/test/bb_prover_base_rollup.test.ts b/yarn-project/prover-client/src/test/bb_prover_base_rollup.test.ts index 61b99669c8f..91be7ea037f 100644 --- a/yarn-project/prover-client/src/test/bb_prover_base_rollup.test.ts +++ b/yarn-project/prover-client/src/test/bb_prover_base_rollup.test.ts @@ -1,14 +1,8 @@ import { BBNativeRollupProver, type BBProverConfig } from '@aztec/bb-prover'; import { makeEmptyProcessedTx } from '@aztec/circuit-types'; -import { - PRIVATE_KERNEL_EMPTY_INDEX, - type PrivateBaseRollupHints, - PrivateBaseRollupInputs, - PrivateKernelEmptyInputData, - PrivateTubeData, - SpongeBlob, - VkWitnessData, -} from '@aztec/circuits.js'; +import { PRIVATE_KERNEL_EMPTY_INDEX, PrivateKernelEmptyInputData, VkWitnessData } from '@aztec/circuits.js'; +import { SpongeBlob } from '@aztec/circuits.js/blobs'; +import { PrivateBaseRollupHints, PrivateBaseRollupInputs, PrivateTubeData } from '@aztec/circuits.js/rollup'; import { createLogger } from '@aztec/foundation/log'; import { getVKSiblingPath, getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { protocolContractTreeRoot } from '@aztec/protocol-contracts'; diff --git a/yarn-project/prover-client/src/test/mock_prover.ts b/yarn-project/prover-client/src/test/mock_prover.ts index baf581d8f8e..ac09a602979 100644 --- a/yarn-project/prover-client/src/test/mock_prover.ts +++ b/yarn-project/prover-client/src/test/mock_prover.ts @@ -14,27 +14,29 @@ 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, type KernelCircuitPublicInputs, - type MergeRollupInputs, NESTED_RECURSIVE_PROOF_LENGTH, - type PrivateBaseRollupInputs, type PrivateKernelEmptyInputData, - type PublicBaseRollupInputs, RECURSIVE_PROOF_LENGTH, type RootParityInputs, - type RootRollupInputs, - type RootRollupPublicInputs, TUBE_PROOF_LENGTH, VerificationKeyData, makeEmptyRecursiveProof, makeRecursiveProof, } from '@aztec/circuits.js'; +import { + BaseOrMergeRollupPublicInputs, + BlockMergeRollupInputs, + BlockRootOrBlockMergePublicInputs, + BlockRootRollupInputs, + EmptyBlockRootRollupInputs, + MergeRollupInputs, + PrivateBaseRollupInputs, + PublicBaseRollupInputs, + RootRollupInputs, + RootRollupPublicInputs, +} from '@aztec/circuits.js/rollup'; import { makeBaseOrMergeRollupPublicInputs, makeBlockRootOrBlockMergeRollupPublicInputs, diff --git a/yarn-project/pxe/src/pxe_service/error_enriching.ts b/yarn-project/pxe/src/pxe_service/error_enriching.ts index 2c18f72b1e2..f8ff9663206 100644 --- a/yarn-project/pxe/src/pxe_service/error_enriching.ts +++ b/yarn-project/pxe/src/pxe_service/error_enriching.ts @@ -1,5 +1,8 @@ import { type SimulationError, isNoirCallStackUnresolved } from '@aztec/circuit-types'; -import { AztecAddress, Fr, FunctionSelector, PUBLIC_DISPATCH_SELECTOR } from '@aztec/circuits.js'; +import { PUBLIC_DISPATCH_SELECTOR } from '@aztec/circuits.js/constants'; +import { FunctionSelector } from '@aztec/foundation/abi'; +import { AztecAddress } from '@aztec/foundation/aztec-address'; +import { Fr } from '@aztec/foundation/fields'; import { type Logger } from '@aztec/foundation/log'; import { resolveAssertionMessageFromRevertData, resolveOpcodeLocations } from '@aztec/simulator/errors'; diff --git a/yarn-project/pxe/src/pxe_service/pxe_service.ts b/yarn-project/pxe/src/pxe_service/pxe_service.ts index 3a0e982c10d..74db147cf42 100644 --- a/yarn-project/pxe/src/pxe_service/pxe_service.ts +++ b/yarn-project/pxe/src/pxe_service/pxe_service.ts @@ -31,22 +31,23 @@ import { UniqueNote, getNonNullifiedL1ToL2MessageWitness, } from '@aztec/circuit-types'; +import type { + CompleteAddress, + ContractClassWithId, + ContractInstanceWithAddress, + GasFees, + L1_TO_L2_MSG_TREE_HEIGHT, + NodeInfo, + PartialAddress, + PrivateKernelTailCircuitPublicInputs, +} from '@aztec/circuits.js'; import { - type AztecAddress, - type CompleteAddress, - type ContractClassWithId, - type ContractInstanceWithAddress, - type GasFees, - type L1_TO_L2_MSG_TREE_HEIGHT, - type NodeInfo, - type PartialAddress, - type PrivateKernelTailCircuitPublicInputs, - computeAddressSecret, computeContractAddressFromInstance, computeContractClassId, getContractClassFromArtifact, -} from '@aztec/circuits.js'; +} from '@aztec/circuits.js/contract'; import { computeNoteHashNonce, siloNullifier } from '@aztec/circuits.js/hash'; +import { computeAddressSecret } from '@aztec/circuits.js/keys'; import { type AbiDecoded, type ContractArtifact, @@ -55,6 +56,7 @@ import { FunctionType, encodeArguments, } from '@aztec/foundation/abi'; +import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr, type Point } from '@aztec/foundation/fields'; import { type Logger, createLogger } from '@aztec/foundation/log'; import { Timer } from '@aztec/foundation/timer'; diff --git a/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts b/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts index d0dc0103bbf..5f333ecb0c4 100644 --- a/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts +++ b/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts @@ -1,6 +1,6 @@ import { type AztecNode, type PXE, TxEffect, mockTx, randomInBlock } from '@aztec/circuit-types'; import { INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js/constants'; -import { type L1ContractAddresses } from '@aztec/ethereum'; +import { type L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses'; import { EthAddress } from '@aztec/foundation/eth-address'; import { KeyStore } from '@aztec/key-store'; import { openTmpStore } from '@aztec/kv-store/lmdb'; From 08d651c8fdba0149f3a2dbe930c00ddd204a9886 Mon Sep 17 00:00:00 2001 From: thunkar Date: Thu, 19 Dec 2024 23:42:53 +0000 Subject: [PATCH 09/14] it builds --- .../end-to-end/src/composed/integration_l1_publisher.test.ts | 2 +- .../src/composed/integration_proof_verification.test.ts | 3 ++- yarn-project/prover-client/src/block_builder/light.ts | 3 ++- yarn-project/sequencer-client/src/publisher/l1-publisher.ts | 3 +-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts b/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts index f03231342b9..f1b14640aea 100644 --- a/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts +++ b/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts @@ -9,7 +9,6 @@ import { } from '@aztec/circuit-types'; import { makeBloatedProcessedTx } from '@aztec/circuit-types/test'; import { - BlockBlobPublicInputs, type BlockHeader, EthAddress, GENESIS_ARCHIVE_ROOT, @@ -18,6 +17,7 @@ import { MAX_NULLIFIERS_PER_TX, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, } from '@aztec/circuits.js'; +import { BlockBlobPublicInputs } from '@aztec/circuits.js/blobs'; import { fr } from '@aztec/circuits.js/testing'; import { type L1ContractAddresses, createEthereumChain } from '@aztec/ethereum'; import { EthCheatCodesWithState } from '@aztec/ethereum/test'; diff --git a/yarn-project/end-to-end/src/composed/integration_proof_verification.test.ts b/yarn-project/end-to-end/src/composed/integration_proof_verification.test.ts index 0d1066a7a4f..c910620d366 100644 --- a/yarn-project/end-to-end/src/composed/integration_proof_verification.test.ts +++ b/yarn-project/end-to-end/src/composed/integration_proof_verification.test.ts @@ -1,6 +1,7 @@ import { deployL1Contract, fileURLToPath } from '@aztec/aztec.js'; import { BBCircuitVerifier } from '@aztec/bb-prover'; -import { Proof, RootRollupPublicInputs } from '@aztec/circuits.js'; +import { Proof } from '@aztec/circuits.js'; +import { RootRollupPublicInputs } from '@aztec/circuits.js/rollup'; import { compileContract, createL1Clients } from '@aztec/ethereum'; import { type Logger } from '@aztec/foundation/log'; import { IVerifierAbi } from '@aztec/l1-artifacts'; diff --git a/yarn-project/prover-client/src/block_builder/light.ts b/yarn-project/prover-client/src/block_builder/light.ts index 9a95b6ef1ca..e56986b839a 100644 --- a/yarn-project/prover-client/src/block_builder/light.ts +++ b/yarn-project/prover-client/src/block_builder/light.ts @@ -7,7 +7,8 @@ import { makeEmptyProcessedTx, toNumBlobFields, } from '@aztec/circuit-types'; -import { Fr, type GlobalVariables, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, SpongeBlob } from '@aztec/circuits.js'; +import { Fr, type GlobalVariables, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/circuits.js'; +import { SpongeBlob } from '@aztec/circuits.js/blobs'; import { padArrayEnd } from '@aztec/foundation/collection'; import { createLogger } from '@aztec/foundation/log'; import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index a89969ede84..fb017cf71d7 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -13,10 +13,9 @@ import { AZTEC_MAX_EPOCH_DURATION, type BlockHeader, EthAddress, - type FeeRecipient, type Proof, - type RootRollupPublicInputs, } from '@aztec/circuits.js'; +import { FeeRecipient, RootRollupPublicInputs } from '@aztec/circuits.js/rollup'; import { type EthereumChain, type L1ContractsConfig, From edec316588f4a1fb7aedb066ca20097f4a7f3e67 Mon Sep 17 00:00:00 2001 From: thunkar Date: Thu, 19 Dec 2024 23:44:13 +0000 Subject: [PATCH 10/14] fmt --- .../bb-prover/src/prover/bb_prover.ts | 22 +++++++-------- .../bb-prover/src/test/test_circuit_prover.ts | 22 +++++++-------- .../src/interfaces/epoch-prover.ts | 2 +- .../src/interfaces/server_circuit_prover.ts | 22 +++++++-------- .../src/conversion/server.ts | 28 +++++++++---------- .../src/execution/server.ts | 20 ++++++------- .../src/block_builder/light.test.ts | 4 +-- .../orchestrator/block-building-helpers.ts | 6 ++-- .../src/orchestrator/block-proving-state.ts | 2 +- .../src/orchestrator/epoch-proving-state.ts | 2 +- .../src/orchestrator/orchestrator.ts | 6 ++-- .../src/orchestrator/tx-proving-state.ts | 2 +- .../src/prover-agent/memory-proving-queue.ts | 22 +++++++-------- .../proving_broker/broker_prover_facade.ts | 22 +++++++-------- .../src/test/bb_prover_base_rollup.test.ts | 2 +- .../prover-client/src/test/mock_prover.ts | 20 ++++++------- .../src/publisher/l1-publisher.ts | 2 +- 17 files changed, 103 insertions(+), 103 deletions(-) diff --git a/yarn-project/bb-prover/src/prover/bb_prover.ts b/yarn-project/bb-prover/src/prover/bb_prover.ts index 534d01395a3..7c5378cf677 100644 --- a/yarn-project/bb-prover/src/prover/bb_prover.ts +++ b/yarn-project/bb-prover/src/prover/bb_prover.ts @@ -31,17 +31,17 @@ import { makeRecursiveProofFromBinary, } from '@aztec/circuits.js'; import { - BaseOrMergeRollupPublicInputs, - BlockMergeRollupInputs, - BlockRootOrBlockMergePublicInputs, - BlockRootRollupInputs, - EmptyBlockRootRollupInputs, - MergeRollupInputs, - PrivateBaseRollupInputs, - PublicBaseRollupInputs, - RootRollupInputs, - RootRollupPublicInputs, - TubeInputs, + 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'; diff --git a/yarn-project/bb-prover/src/test/test_circuit_prover.ts b/yarn-project/bb-prover/src/test/test_circuit_prover.ts index b80cb16c1ad..73a5539e7e7 100644 --- a/yarn-project/bb-prover/src/test/test_circuit_prover.ts +++ b/yarn-project/bb-prover/src/test/test_circuit_prover.ts @@ -25,17 +25,17 @@ import { makeRecursiveProof, } from '@aztec/circuits.js'; import { - BaseOrMergeRollupPublicInputs, - BlockMergeRollupInputs, - BlockRootOrBlockMergePublicInputs, - BlockRootRollupInputs, - EmptyBlockRootRollupInputs, - MergeRollupInputs, - PrivateBaseRollupInputs, - PublicBaseRollupInputs, - RootRollupInputs, - RootRollupPublicInputs, - TubeInputs, + 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'; diff --git a/yarn-project/circuit-types/src/interfaces/epoch-prover.ts b/yarn-project/circuit-types/src/interfaces/epoch-prover.ts index 59d251739e2..e8faa020647 100644 --- a/yarn-project/circuit-types/src/interfaces/epoch-prover.ts +++ b/yarn-project/circuit-types/src/interfaces/epoch-prover.ts @@ -1,5 +1,5 @@ import { type BlockHeader, type Fr, type Proof } from '@aztec/circuits.js'; -import { RootRollupPublicInputs } from '@aztec/circuits.js/rollup'; +import { type RootRollupPublicInputs } from '@aztec/circuits.js/rollup'; import { type L2Block } from '../l2_block.js'; import { type BlockBuilder } from './block-builder.js'; diff --git a/yarn-project/circuit-types/src/interfaces/server_circuit_prover.ts b/yarn-project/circuit-types/src/interfaces/server_circuit_prover.ts index f60d9779db1..e9a63893f3e 100644 --- a/yarn-project/circuit-types/src/interfaces/server_circuit_prover.ts +++ b/yarn-project/circuit-types/src/interfaces/server_circuit_prover.ts @@ -11,17 +11,17 @@ import { type TUBE_PROOF_LENGTH, } from '@aztec/circuits.js'; import { - BaseOrMergeRollupPublicInputs, - BlockMergeRollupInputs, - BlockRootOrBlockMergePublicInputs, - BlockRootRollupInputs, - EmptyBlockRootRollupInputs, - MergeRollupInputs, - PrivateBaseRollupInputs, - PublicBaseRollupInputs, - RootRollupInputs, - RootRollupPublicInputs, - TubeInputs, + 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 type { Tx } from '../tx/tx.js'; diff --git a/yarn-project/noir-protocol-circuits-types/src/conversion/server.ts b/yarn-project/noir-protocol-circuits-types/src/conversion/server.ts index edbc99b17e9..e052b1cd044 100644 --- a/yarn-project/noir-protocol-circuits-types/src/conversion/server.ts +++ b/yarn-project/noir-protocol-circuits-types/src/conversion/server.ts @@ -36,24 +36,24 @@ import { } from '@aztec/circuits.js'; import { BlobPublicInputs, BlockBlobPublicInputs, Poseidon2Sponge, SpongeBlob } from '@aztec/circuits.js/blobs'; import { - AvmProofData, + type AvmProofData, BaseOrMergeRollupPublicInputs, - BlockMergeRollupInputs, + type BlockMergeRollupInputs, BlockRootOrBlockMergePublicInputs, - BlockRootRollupInputs, + type BlockRootRollupInputs, ConstantRollupData, - EmptyBlockRootRollupInputs, + type EmptyBlockRootRollupInputs, FeeRecipient, - MergeRollupInputs, - PreviousRollupBlockData, - PreviousRollupData, - PrivateBaseRollupInputs, - PrivateBaseStateDiffHints, - PrivateTubeData, - PublicBaseRollupInputs, - PublicBaseStateDiffHints, - PublicTubeData, - RootRollupInputs, + type MergeRollupInputs, + type PreviousRollupBlockData, + type PreviousRollupData, + type PrivateBaseRollupInputs, + type PrivateBaseStateDiffHints, + type PrivateTubeData, + type PublicBaseRollupInputs, + type PublicBaseStateDiffHints, + type PublicTubeData, + type RootRollupInputs, RootRollupPublicInputs, } from '@aztec/circuits.js/rollup'; import { toHex } from '@aztec/foundation/bigint-buffer'; diff --git a/yarn-project/noir-protocol-circuits-types/src/execution/server.ts b/yarn-project/noir-protocol-circuits-types/src/execution/server.ts index b9c198477e3..722172b9a1e 100644 --- a/yarn-project/noir-protocol-circuits-types/src/execution/server.ts +++ b/yarn-project/noir-protocol-circuits-types/src/execution/server.ts @@ -6,16 +6,16 @@ import { type RootParityInputs, } from '@aztec/circuits.js'; import { - BaseOrMergeRollupPublicInputs, - BlockMergeRollupInputs, - BlockRootOrBlockMergePublicInputs, - BlockRootRollupInputs, - EmptyBlockRootRollupInputs, - MergeRollupInputs, - PrivateBaseRollupInputs, - PublicBaseRollupInputs, - RootRollupInputs, - RootRollupPublicInputs, + type BaseOrMergeRollupPublicInputs, + type BlockMergeRollupInputs, + type BlockRootOrBlockMergePublicInputs, + type BlockRootRollupInputs, + type EmptyBlockRootRollupInputs, + type MergeRollupInputs, + type PrivateBaseRollupInputs, + type PublicBaseRollupInputs, + type RootRollupInputs, + type RootRollupPublicInputs, } from '@aztec/circuits.js/rollup'; import { pushTestData } from '@aztec/foundation/testing'; diff --git a/yarn-project/prover-client/src/block_builder/light.test.ts b/yarn-project/prover-client/src/block_builder/light.test.ts index 32c52642db7..26a5cfee69b 100644 --- a/yarn-project/prover-client/src/block_builder/light.test.ts +++ b/yarn-project/prover-client/src/block_builder/light.test.ts @@ -33,11 +33,11 @@ import { } from '@aztec/circuits.js'; import { SpongeBlob } from '@aztec/circuits.js/blobs'; import { - BaseOrMergeRollupPublicInputs, + type BaseOrMergeRollupPublicInputs, BlockRootRollupInputs, MergeRollupInputs, PreviousRollupData, - PrivateBaseRollupHints, + type PrivateBaseRollupHints, PrivateBaseRollupInputs, PrivateTubeData, } from '@aztec/circuits.js/rollup'; diff --git a/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts b/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts index 0ea04de9921..c8a0cc9f34f 100644 --- a/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts +++ b/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts @@ -37,11 +37,11 @@ import { VK_TREE_HEIGHT, type VerificationKeyAsFields, } from '@aztec/circuits.js'; -import { SpongeBlob } from '@aztec/circuits.js/blobs'; +import { type SpongeBlob } from '@aztec/circuits.js/blobs'; import { - BaseOrMergeRollupPublicInputs, + type BaseOrMergeRollupPublicInputs, BlockMergeRollupInputs, - BlockRootOrBlockMergePublicInputs, + type BlockRootOrBlockMergePublicInputs, ConstantRollupData, MergeRollupInputs, PreviousRollupBlockData, diff --git a/yarn-project/prover-client/src/orchestrator/block-proving-state.ts b/yarn-project/prover-client/src/orchestrator/block-proving-state.ts index 214f41a8088..6bc5efecacb 100644 --- a/yarn-project/prover-client/src/orchestrator/block-proving-state.ts +++ b/yarn-project/prover-client/src/orchestrator/block-proving-state.ts @@ -15,7 +15,7 @@ import { type VerificationKeyAsFields, } from '@aztec/circuits.js'; import { SpongeBlob } from '@aztec/circuits.js/blobs'; -import { BaseOrMergeRollupPublicInputs, BlockRootOrBlockMergePublicInputs } from '@aztec/circuits.js/rollup'; +import { type BaseOrMergeRollupPublicInputs, type BlockRootOrBlockMergePublicInputs } from '@aztec/circuits.js/rollup'; import { type Tuple } from '@aztec/foundation/serialize'; import { type EpochProvingState } from './epoch-proving-state.js'; diff --git a/yarn-project/prover-client/src/orchestrator/epoch-proving-state.ts b/yarn-project/prover-client/src/orchestrator/epoch-proving-state.ts index 3c4fb1b7672..3ea4db2228c 100644 --- a/yarn-project/prover-client/src/orchestrator/epoch-proving-state.ts +++ b/yarn-project/prover-client/src/orchestrator/epoch-proving-state.ts @@ -11,7 +11,7 @@ import { type RecursiveProof, type VerificationKeyAsFields, } from '@aztec/circuits.js'; -import { BlockRootOrBlockMergePublicInputs, RootRollupPublicInputs } from '@aztec/circuits.js/rollup'; +import { type BlockRootOrBlockMergePublicInputs, type RootRollupPublicInputs } from '@aztec/circuits.js/rollup'; import { padArrayEnd } from '@aztec/foundation/collection'; import { type Tuple } from '@aztec/foundation/serialize'; diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator.ts b/yarn-project/prover-client/src/orchestrator/orchestrator.ts index e4230003407..4095deeaac1 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator.ts @@ -39,9 +39,9 @@ import { } from '@aztec/circuits.js'; import { BlobPublicInputs } from '@aztec/circuits.js/blobs'; import { - BaseOrMergeRollupPublicInputs, - BaseRollupHints, - BlockRootOrBlockMergePublicInputs, + type BaseOrMergeRollupPublicInputs, + type BaseRollupHints, + type BlockRootOrBlockMergePublicInputs, BlockRootRollupInputs, EmptyBlockRootRollupInputs, } from '@aztec/circuits.js/rollup'; diff --git a/yarn-project/prover-client/src/orchestrator/tx-proving-state.ts b/yarn-project/prover-client/src/orchestrator/tx-proving-state.ts index a86bf51ca81..9bdd2eeda4d 100644 --- a/yarn-project/prover-client/src/orchestrator/tx-proving-state.ts +++ b/yarn-project/prover-client/src/orchestrator/tx-proving-state.ts @@ -9,7 +9,7 @@ import { } from '@aztec/circuits.js'; import { AvmProofData, - BaseRollupHints, + type BaseRollupHints, PrivateBaseRollupHints, PrivateBaseRollupInputs, PrivateTubeData, diff --git a/yarn-project/prover-client/src/prover-agent/memory-proving-queue.ts b/yarn-project/prover-client/src/prover-agent/memory-proving-queue.ts index 1e9b8d22333..863a702d1d3 100644 --- a/yarn-project/prover-client/src/prover-agent/memory-proving-queue.ts +++ b/yarn-project/prover-client/src/prover-agent/memory-proving-queue.ts @@ -20,17 +20,17 @@ import type { RootParityInputs, } from '@aztec/circuits.js'; import { - BaseOrMergeRollupPublicInputs, - BlockMergeRollupInputs, - BlockRootOrBlockMergePublicInputs, - BlockRootRollupInputs, - EmptyBlockRootRollupInputs, - MergeRollupInputs, - PrivateBaseRollupInputs, - PublicBaseRollupInputs, - RootRollupInputs, - RootRollupPublicInputs, - TubeInputs, + 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 { randomBytes } from '@aztec/foundation/crypto'; import { AbortError, TimeoutError } from '@aztec/foundation/error'; diff --git a/yarn-project/prover-client/src/proving_broker/broker_prover_facade.ts b/yarn-project/prover-client/src/proving_broker/broker_prover_facade.ts index f7dc9ab6a92..6dc3db0a933 100644 --- a/yarn-project/prover-client/src/proving_broker/broker_prover_facade.ts +++ b/yarn-project/prover-client/src/proving_broker/broker_prover_facade.ts @@ -21,17 +21,17 @@ import { type TUBE_PROOF_LENGTH, } from '@aztec/circuits.js'; import { - BaseOrMergeRollupPublicInputs, - BlockMergeRollupInputs, - BlockRootOrBlockMergePublicInputs, - BlockRootRollupInputs, - EmptyBlockRootRollupInputs, - MergeRollupInputs, - PrivateBaseRollupInputs, - PublicBaseRollupInputs, - RootRollupInputs, - RootRollupPublicInputs, - TubeInputs, + 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 { sha256 } from '@aztec/foundation/crypto'; import { createLogger } from '@aztec/foundation/log'; diff --git a/yarn-project/prover-client/src/test/bb_prover_base_rollup.test.ts b/yarn-project/prover-client/src/test/bb_prover_base_rollup.test.ts index 91be7ea037f..dc43748fcdd 100644 --- a/yarn-project/prover-client/src/test/bb_prover_base_rollup.test.ts +++ b/yarn-project/prover-client/src/test/bb_prover_base_rollup.test.ts @@ -2,7 +2,7 @@ import { BBNativeRollupProver, type BBProverConfig } from '@aztec/bb-prover'; import { makeEmptyProcessedTx } from '@aztec/circuit-types'; import { PRIVATE_KERNEL_EMPTY_INDEX, PrivateKernelEmptyInputData, VkWitnessData } from '@aztec/circuits.js'; import { SpongeBlob } from '@aztec/circuits.js/blobs'; -import { PrivateBaseRollupHints, PrivateBaseRollupInputs, PrivateTubeData } from '@aztec/circuits.js/rollup'; +import { type PrivateBaseRollupHints, PrivateBaseRollupInputs, PrivateTubeData } from '@aztec/circuits.js/rollup'; import { createLogger } from '@aztec/foundation/log'; import { getVKSiblingPath, getVKTreeRoot } from '@aztec/noir-protocol-circuits-types'; import { protocolContractTreeRoot } from '@aztec/protocol-contracts'; diff --git a/yarn-project/prover-client/src/test/mock_prover.ts b/yarn-project/prover-client/src/test/mock_prover.ts index ac09a602979..f67b3147830 100644 --- a/yarn-project/prover-client/src/test/mock_prover.ts +++ b/yarn-project/prover-client/src/test/mock_prover.ts @@ -26,16 +26,16 @@ import { makeRecursiveProof, } from '@aztec/circuits.js'; import { - BaseOrMergeRollupPublicInputs, - BlockMergeRollupInputs, - BlockRootOrBlockMergePublicInputs, - BlockRootRollupInputs, - EmptyBlockRootRollupInputs, - MergeRollupInputs, - PrivateBaseRollupInputs, - PublicBaseRollupInputs, - RootRollupInputs, - RootRollupPublicInputs, + type BaseOrMergeRollupPublicInputs, + type BlockMergeRollupInputs, + type BlockRootOrBlockMergePublicInputs, + type BlockRootRollupInputs, + type EmptyBlockRootRollupInputs, + type MergeRollupInputs, + type PrivateBaseRollupInputs, + type PublicBaseRollupInputs, + type RootRollupInputs, + type RootRollupPublicInputs, } from '@aztec/circuits.js/rollup'; import { makeBaseOrMergeRollupPublicInputs, diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index fb017cf71d7..463fcd3d864 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -15,7 +15,7 @@ import { EthAddress, type Proof, } from '@aztec/circuits.js'; -import { FeeRecipient, RootRollupPublicInputs } from '@aztec/circuits.js/rollup'; +import { type FeeRecipient, type RootRollupPublicInputs } from '@aztec/circuits.js/rollup'; import { type EthereumChain, type L1ContractsConfig, From cab692be2afff8c6a9f683c693223b4523418dd8 Mon Sep 17 00:00:00 2001 From: thunkar Date: Fri, 20 Dec 2024 00:08:29 +0000 Subject: [PATCH 11/14] finally --- boxes/boxes/vite/package.json | 4 +- boxes/boxes/vite/vite.config.ts | 4 -- boxes/yarn.lock | 45 +------------------ .../src/client.ts | 2 +- 4 files changed, 3 insertions(+), 52 deletions(-) diff --git a/boxes/boxes/vite/package.json b/boxes/boxes/vite/package.json index 5d127569aef..53e82474a8d 100644 --- a/boxes/boxes/vite/package.json +++ b/boxes/boxes/vite/package.json @@ -40,8 +40,6 @@ "typescript": "~5.6.2", "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" + "vite-plugin-node-polyfills": "^0.22.0" } } diff --git a/boxes/boxes/vite/vite.config.ts b/boxes/boxes/vite/vite.config.ts index ef09a7d9e67..30ba107a34a 100644 --- a/boxes/boxes/vite/vite.config.ts +++ b/boxes/boxes/vite/vite.config.ts @@ -1,8 +1,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 @@ -31,10 +29,8 @@ export default defineConfig({ }, }, plugins: [ - stripBlock({ start: "testing-only-start", end: "testing-only-end" }), react(), nodePolyfillsFix({ include: ["buffer", "process", "path"] }), - topLevelAwait(), ], optimizeDeps: { exclude: ["@noir-lang/acvm_js", "@noir-lang/noirc_abi", "@aztec/bb-prover"], diff --git a/boxes/yarn.lock b/boxes/yarn.lock index 6819882597c..889238e6bc6 100644 --- a/boxes/yarn.lock +++ b/boxes/yarn.lock @@ -1746,18 +1746,6 @@ __metadata: languageName: node linkType: hard -"@rollup/plugin-virtual@npm:^3.0.2": - version: 3.0.2 - resolution: "@rollup/plugin-virtual@npm:3.0.2" - peerDependencies: - rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 - peerDependenciesMeta: - rollup: - optional: true - checksum: 10c0/7115edb7989096d1ce334939fcf6e1ba365586b487bf61b2dd4f915386197f350db70904030342c0720fe58f5a52828975c645c4d415c1d432d9b1b6760a22ef - languageName: node - linkType: hard - "@rollup/pluginutils@npm:^5.0.1": version: 5.1.3 resolution: "@rollup/pluginutils@npm:5.1.3" @@ -2121,7 +2109,7 @@ __metadata: languageName: node linkType: hard -"@swc/core@npm:^1.7.0, @swc/core@npm:^1.7.26": +"@swc/core@npm:^1.7.26": version: 1.9.3 resolution: "@swc/core@npm:1.9.3" dependencies: @@ -11973,15 +11961,6 @@ __metadata: languageName: node linkType: hard -"uuid@npm:^10.0.0": - version: 10.0.0 - resolution: "uuid@npm:10.0.0" - bin: - uuid: dist/bin/uuid - checksum: 10c0/eab18c27fe4ab9fb9709a5d5f40119b45f2ec8314f8d4cf12ce27e4c6f4ffa4a6321dc7db6c515068fa373c075b49691ba969f0010bf37f44c37ca40cd6bf7fe - languageName: node - linkType: hard - "uuid@npm:^8.3.2": version: 8.3.2 resolution: "uuid@npm:8.3.2" @@ -12043,26 +12022,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" - dependencies: - "@rollup/plugin-virtual": "npm:^3.0.2" - "@swc/core": "npm:^1.7.0" - uuid: "npm:^10.0.0" - peerDependencies: - vite: ">=2.8" - checksum: 10c0/013e7b2e28632d93d04c4061187198e699064fc208a1657c100354b32da30921fa835879fc17779d5e0b074855237408da2fadd720fa0f4571137427a1efd5e3 - languageName: node - linkType: hard - "vite@npm:^5.0.0": version: 5.4.11 resolution: "vite@npm:5.4.11" @@ -12187,8 +12146,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 diff --git a/yarn-project/noir-protocol-circuits-types/src/client.ts b/yarn-project/noir-protocol-circuits-types/src/client.ts index 47ac9e9a9be..597e3be73ec 100644 --- a/yarn-project/noir-protocol-circuits-types/src/client.ts +++ b/yarn-project/noir-protocol-circuits-types/src/client.ts @@ -20,5 +20,5 @@ export { ClientCircuitArtifacts, type ClientProtocolArtifact } from './artifacts export { getPrivateKernelResetArtifactName } from './utils/private_kernel_reset.js'; export { maxPrivateKernelResetDimensions, privateKernelResetDimensionsConfig } from './private_kernel_reset_data.js'; -export { foreignCallHandler } from './utils/server/foreign_call_handler.js'; +export { foreignCallHandler } from './utils/client/foreign_call_handler.js'; export { ClientCircuitVks, getVKIndex, getVKTreeRoot, getVKSiblingPath } from './vks.js'; From 814590e5876ee8ec0cfbf0977f0403fba439ac25 Mon Sep 17 00:00:00 2001 From: thunkar Date: Fri, 20 Dec 2024 00:09:39 +0000 Subject: [PATCH 12/14] restore plugin --- boxes/boxes/vite/package.json | 3 +- boxes/boxes/vite/vite.config.ts | 2 + boxes/yarn.lock | 151 ++++++++++++++++++++++++++++++++ 3 files changed, 155 insertions(+), 1 deletion(-) diff --git a/boxes/boxes/vite/package.json b/boxes/boxes/vite/package.json index 53e82474a8d..c3301be3c0d 100644 --- a/boxes/boxes/vite/package.json +++ b/boxes/boxes/vite/package.json @@ -40,6 +40,7 @@ "typescript": "~5.6.2", "typescript-eslint": "^8.11.0", "vite": "^6.0.3", - "vite-plugin-node-polyfills": "^0.22.0" + "vite-plugin-node-polyfills": "^0.22.0", + "vite-plugin-top-level-await": "^1.4.4" } } diff --git a/boxes/boxes/vite/vite.config.ts b/boxes/boxes/vite/vite.config.ts index 30ba107a34a..94bade805b8 100644 --- a/boxes/boxes/vite/vite.config.ts +++ b/boxes/boxes/vite/vite.config.ts @@ -1,6 +1,7 @@ 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"; // 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 @@ -31,6 +32,7 @@ export default defineConfig({ plugins: [ react(), nodePolyfillsFix({ include: ["buffer", "process", "path"] }), + topLevelAwait(), ], optimizeDeps: { exclude: ["@noir-lang/acvm_js", "@noir-lang/noirc_abi", "@aztec/bb-prover"], diff --git a/boxes/yarn.lock b/boxes/yarn.lock index 889238e6bc6..76143078b44 100644 --- a/boxes/yarn.lock +++ b/boxes/yarn.lock @@ -1746,6 +1746,18 @@ __metadata: languageName: node linkType: hard +"@rollup/plugin-virtual@npm:^3.0.2": + version: 3.0.2 + resolution: "@rollup/plugin-virtual@npm:3.0.2" + peerDependencies: + rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 + peerDependenciesMeta: + rollup: + optional: true + checksum: 10c0/7115edb7989096d1ce334939fcf6e1ba365586b487bf61b2dd4f915386197f350db70904030342c0720fe58f5a52828975c645c4d415c1d432d9b1b6760a22ef + languageName: node + linkType: hard + "@rollup/pluginutils@npm:^5.0.1": version: 5.1.3 resolution: "@rollup/pluginutils@npm:5.1.3" @@ -2039,6 +2051,13 @@ __metadata: languageName: node linkType: hard +"@swc/core-darwin-arm64@npm:1.10.1": + version: 1.10.1 + resolution: "@swc/core-darwin-arm64@npm:1.10.1" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + "@swc/core-darwin-arm64@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-darwin-arm64@npm:1.9.3" @@ -2046,6 +2065,13 @@ __metadata: languageName: node linkType: hard +"@swc/core-darwin-x64@npm:1.10.1": + version: 1.10.1 + resolution: "@swc/core-darwin-x64@npm:1.10.1" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + "@swc/core-darwin-x64@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-darwin-x64@npm:1.9.3" @@ -2053,6 +2079,13 @@ __metadata: languageName: node linkType: hard +"@swc/core-linux-arm-gnueabihf@npm:1.10.1": + version: 1.10.1 + resolution: "@swc/core-linux-arm-gnueabihf@npm:1.10.1" + conditions: os=linux & cpu=arm + languageName: node + linkType: hard + "@swc/core-linux-arm-gnueabihf@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-linux-arm-gnueabihf@npm:1.9.3" @@ -2060,6 +2093,13 @@ __metadata: languageName: node linkType: hard +"@swc/core-linux-arm64-gnu@npm:1.10.1": + version: 1.10.1 + resolution: "@swc/core-linux-arm64-gnu@npm:1.10.1" + conditions: os=linux & cpu=arm64 & libc=glibc + languageName: node + linkType: hard + "@swc/core-linux-arm64-gnu@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-linux-arm64-gnu@npm:1.9.3" @@ -2067,6 +2107,13 @@ __metadata: languageName: node linkType: hard +"@swc/core-linux-arm64-musl@npm:1.10.1": + version: 1.10.1 + resolution: "@swc/core-linux-arm64-musl@npm:1.10.1" + conditions: os=linux & cpu=arm64 & libc=musl + languageName: node + linkType: hard + "@swc/core-linux-arm64-musl@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-linux-arm64-musl@npm:1.9.3" @@ -2074,6 +2121,13 @@ __metadata: languageName: node linkType: hard +"@swc/core-linux-x64-gnu@npm:1.10.1": + version: 1.10.1 + resolution: "@swc/core-linux-x64-gnu@npm:1.10.1" + conditions: os=linux & cpu=x64 & libc=glibc + languageName: node + linkType: hard + "@swc/core-linux-x64-gnu@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-linux-x64-gnu@npm:1.9.3" @@ -2081,6 +2135,13 @@ __metadata: languageName: node linkType: hard +"@swc/core-linux-x64-musl@npm:1.10.1": + version: 1.10.1 + resolution: "@swc/core-linux-x64-musl@npm:1.10.1" + conditions: os=linux & cpu=x64 & libc=musl + languageName: node + linkType: hard + "@swc/core-linux-x64-musl@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-linux-x64-musl@npm:1.9.3" @@ -2088,6 +2149,13 @@ __metadata: languageName: node linkType: hard +"@swc/core-win32-arm64-msvc@npm:1.10.1": + version: 1.10.1 + resolution: "@swc/core-win32-arm64-msvc@npm:1.10.1" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + "@swc/core-win32-arm64-msvc@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-win32-arm64-msvc@npm:1.9.3" @@ -2095,6 +2163,13 @@ __metadata: languageName: node linkType: hard +"@swc/core-win32-ia32-msvc@npm:1.10.1": + version: 1.10.1 + resolution: "@swc/core-win32-ia32-msvc@npm:1.10.1" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + "@swc/core-win32-ia32-msvc@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-win32-ia32-msvc@npm:1.9.3" @@ -2102,6 +2177,13 @@ __metadata: languageName: node linkType: hard +"@swc/core-win32-x64-msvc@npm:1.10.1": + version: 1.10.1 + resolution: "@swc/core-win32-x64-msvc@npm:1.10.1" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@swc/core-win32-x64-msvc@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-win32-x64-msvc@npm:1.9.3" @@ -2109,6 +2191,52 @@ __metadata: languageName: node linkType: hard +"@swc/core@npm:^1.7.0": + version: 1.10.1 + resolution: "@swc/core@npm:1.10.1" + dependencies: + "@swc/core-darwin-arm64": "npm:1.10.1" + "@swc/core-darwin-x64": "npm:1.10.1" + "@swc/core-linux-arm-gnueabihf": "npm:1.10.1" + "@swc/core-linux-arm64-gnu": "npm:1.10.1" + "@swc/core-linux-arm64-musl": "npm:1.10.1" + "@swc/core-linux-x64-gnu": "npm:1.10.1" + "@swc/core-linux-x64-musl": "npm:1.10.1" + "@swc/core-win32-arm64-msvc": "npm:1.10.1" + "@swc/core-win32-ia32-msvc": "npm:1.10.1" + "@swc/core-win32-x64-msvc": "npm:1.10.1" + "@swc/counter": "npm:^0.1.3" + "@swc/types": "npm:^0.1.17" + peerDependencies: + "@swc/helpers": "*" + dependenciesMeta: + "@swc/core-darwin-arm64": + optional: true + "@swc/core-darwin-x64": + optional: true + "@swc/core-linux-arm-gnueabihf": + optional: true + "@swc/core-linux-arm64-gnu": + optional: true + "@swc/core-linux-arm64-musl": + optional: true + "@swc/core-linux-x64-gnu": + optional: true + "@swc/core-linux-x64-musl": + optional: true + "@swc/core-win32-arm64-msvc": + optional: true + "@swc/core-win32-ia32-msvc": + optional: true + "@swc/core-win32-x64-msvc": + optional: true + peerDependenciesMeta: + "@swc/helpers": + optional: true + checksum: 10c0/a3d3b17c1abc8f32a7cc5dfaa006fc314e71cc0beb43e71b8b1c6c3d3841412a7e55d9e72009debd48159881e8a045ecd0ea56036e022f1bc87213fe29cd9015 + languageName: node + linkType: hard + "@swc/core@npm:^1.7.26": version: 1.9.3 resolution: "@swc/core@npm:1.9.3" @@ -11961,6 +12089,15 @@ __metadata: languageName: node linkType: hard +"uuid@npm:^10.0.0": + version: 10.0.0 + resolution: "uuid@npm:10.0.0" + bin: + uuid: dist/bin/uuid + checksum: 10c0/eab18c27fe4ab9fb9709a5d5f40119b45f2ec8314f8d4cf12ce27e4c6f4ffa4a6321dc7db6c515068fa373c075b49691ba969f0010bf37f44c37ca40cd6bf7fe + languageName: node + linkType: hard + "uuid@npm:^8.3.2": version: 8.3.2 resolution: "uuid@npm:8.3.2" @@ -12022,6 +12159,19 @@ __metadata: 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" + dependencies: + "@rollup/plugin-virtual": "npm:^3.0.2" + "@swc/core": "npm:^1.7.0" + uuid: "npm:^10.0.0" + peerDependencies: + vite: ">=2.8" + checksum: 10c0/013e7b2e28632d93d04c4061187198e699064fc208a1657c100354b32da30921fa835879fc17779d5e0b074855237408da2fadd720fa0f4571137427a1efd5e3 + languageName: node + linkType: hard + "vite@npm:^5.0.0": version: 5.4.11 resolution: "vite@npm:5.4.11" @@ -12146,6 +12296,7 @@ __metadata: typescript-eslint: "npm:^8.11.0" vite: "npm:^6.0.3" vite-plugin-node-polyfills: "npm:^0.22.0" + vite-plugin-top-level-await: "npm:^1.4.4" languageName: unknown linkType: soft From 9feec8ea7333d5145c707720aff938a568795cd7 Mon Sep 17 00:00:00 2001 From: thunkar Date: Fri, 20 Dec 2024 07:09:28 +0000 Subject: [PATCH 13/14] wasm simulator with blobs --- .../src/prover/bb_private_kernel_prover.ts | 4 +-- .../bb-prover/src/test/test_circuit_prover.ts | 4 +-- .../prover-client/src/mocks/fixtures.ts | 4 +-- .../prover-client/src/mocks/test_context.ts | 4 +-- .../orchestrator_failures.test.ts | 4 +-- .../simulator/src/providers/acvm_wasm.ts | 2 +- .../src/providers/acvm_wasm_with_blobs.ts | 25 +++++++++++++++++++ yarn-project/simulator/src/providers/index.ts | 1 + 8 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 yarn-project/simulator/src/providers/acvm_wasm_with_blobs.ts diff --git a/yarn-project/bb-prover/src/prover/bb_private_kernel_prover.ts b/yarn-project/bb-prover/src/prover/bb_private_kernel_prover.ts index eabd47a4803..5bdf4f6b9cb 100644 --- a/yarn-project/bb-prover/src/prover/bb_private_kernel_prover.ts +++ b/yarn-project/bb-prover/src/prover/bb_private_kernel_prover.ts @@ -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'; @@ -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> = new Map< ClientProtocolArtifact, diff --git a/yarn-project/bb-prover/src/test/test_circuit_prover.ts b/yarn-project/bb-prover/src/test/test_circuit_prover.ts index 73a5539e7e7..e8aff2e43cc 100644 --- a/yarn-project/bb-prover/src/test/test_circuit_prover.ts +++ b/yarn-project/bb-prover/src/test/test_circuit_prover.ts @@ -65,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'; @@ -78,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'); diff --git a/yarn-project/prover-client/src/mocks/fixtures.ts b/yarn-project/prover-client/src/mocks/fixtures.ts index 1aa223c57bb..a59340bd7d2 100644 --- a/yarn-project/prover-client/src/mocks/fixtures.ts +++ b/yarn-project/prover-client/src/mocks/fixtures.ts @@ -13,7 +13,7 @@ import { padArrayEnd } from '@aztec/foundation/collection'; import { randomBytes } from '@aztec/foundation/crypto'; import { type Logger } from '@aztec/foundation/log'; import { fileURLToPath } from '@aztec/foundation/url'; -import { NativeACVMSimulator, type SimulationProvider, WASMSimulator } from '@aztec/simulator'; +import { NativeACVMSimulator, type SimulationProvider, WASMSimulatorWithBlobs } from '@aztec/simulator'; import { promises as fs } from 'fs'; import path from 'path'; @@ -83,7 +83,7 @@ export async function getSimulationProvider( } } logger?.info('Using WASM ACVM simulation'); - return new WASMSimulator(); + return new WASMSimulatorWithBlobs(); } // Updates the expectedDb trees based on the new note hashes, contracts, and nullifiers from these txs diff --git a/yarn-project/prover-client/src/mocks/test_context.ts b/yarn-project/prover-client/src/mocks/test_context.ts index 803b8d8300e..cfb64f83be5 100644 --- a/yarn-project/prover-client/src/mocks/test_context.ts +++ b/yarn-project/prover-client/src/mocks/test_context.ts @@ -24,7 +24,7 @@ import { PublicProcessor, PublicTxSimulator, type SimulationProvider, - WASMSimulator, + WASMSimulatorWithBlobs, type WorldStateDB, } from '@aztec/simulator'; import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; @@ -69,7 +69,7 @@ export class TestContext { logger: Logger, proverCount = 4, createProver: (bbConfig: BBProverConfig) => Promise = _ => - Promise.resolve(new TestCircuitProver(new NoopTelemetryClient(), new WASMSimulator())), + Promise.resolve(new TestCircuitProver(new NoopTelemetryClient(), new WASMSimulatorWithBlobs())), blockNumber = 1, ) { const directoriesToCleanup: string[] = []; diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator_failures.test.ts b/yarn-project/prover-client/src/orchestrator/orchestrator_failures.test.ts index bf758abd286..c5c88dd8ed0 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator_failures.test.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator_failures.test.ts @@ -2,7 +2,7 @@ import { TestCircuitProver } from '@aztec/bb-prover'; import { type ServerCircuitProver } from '@aztec/circuit-types'; import { timesAsync } from '@aztec/foundation/collection'; import { createLogger } from '@aztec/foundation/log'; -import { WASMSimulator } from '@aztec/simulator'; +import { WASMSimulatorWithBlobs } from '@aztec/simulator'; import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; import { jest } from '@jest/globals'; @@ -28,7 +28,7 @@ describe('prover/orchestrator/failures', () => { let mockProver: ServerCircuitProver; beforeEach(() => { - mockProver = new TestCircuitProver(new NoopTelemetryClient(), new WASMSimulator()); + mockProver = new TestCircuitProver(new NoopTelemetryClient(), new WASMSimulatorWithBlobs()); orchestrator = new ProvingOrchestrator(context.worldState, mockProver, new NoopTelemetryClient()); }); diff --git a/yarn-project/simulator/src/providers/acvm_wasm.ts b/yarn-project/simulator/src/providers/acvm_wasm.ts index bed021be5be..244e6e168a0 100644 --- a/yarn-project/simulator/src/providers/acvm_wasm.ts +++ b/yarn-project/simulator/src/providers/acvm_wasm.ts @@ -17,7 +17,7 @@ export class WASMSimulator implements SimulationProvider { const _witnessMap = await executeCircuit( decodedBytecode, input, - foreignCallHandler, // handle calls to debug_log and evaluate_blobs mock + foreignCallHandler, // handle calls to debug_log ); return _witnessMap; diff --git a/yarn-project/simulator/src/providers/acvm_wasm_with_blobs.ts b/yarn-project/simulator/src/providers/acvm_wasm_with_blobs.ts new file mode 100644 index 00000000000..78d2f8992a2 --- /dev/null +++ b/yarn-project/simulator/src/providers/acvm_wasm_with_blobs.ts @@ -0,0 +1,25 @@ +import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types'; +import { type NoirCompiledCircuit } from '@aztec/types/noir'; + +import { executeCircuit } from '@noir-lang/acvm_js'; +import { type WitnessMap } from '@noir-lang/types'; + +import { type SimulationProvider } from './simulation_provider.js'; + +export class WASMSimulatorWithBlobs implements SimulationProvider { + async simulateCircuit(input: WitnessMap, compiledCircuit: NoirCompiledCircuit): Promise { + // Execute the circuit on those initial witness values + // + // Decode the bytecode from base64 since the acvm does not know about base64 encoding + const decodedBytecode = Buffer.from(compiledCircuit.bytecode, 'base64'); + // + // Execute the circuit + const _witnessMap = await executeCircuit( + decodedBytecode, + input, + foreignCallHandler, // handle calls to debug_log and evaluate_blobs mock + ); + + return _witnessMap; + } +} diff --git a/yarn-project/simulator/src/providers/index.ts b/yarn-project/simulator/src/providers/index.ts index 634f163865d..b4a832329bf 100644 --- a/yarn-project/simulator/src/providers/index.ts +++ b/yarn-project/simulator/src/providers/index.ts @@ -1,3 +1,4 @@ export * from './acvm_native.js'; +export * from './acvm_wasm_with_blobs.js'; export * from './simulation_provider.js'; export * from './factory.js'; From 4c1508877497cd03ced3b3a3a59d78048600dd91 Mon Sep 17 00:00:00 2001 From: thunkar Date: Fri, 20 Dec 2024 12:45:34 +0000 Subject: [PATCH 14/14] fix versions --- barretenberg/acir_tests/sol-test/package.json | 3 +- barretenberg/acir_tests/sol-test/yarn.lock | 274 +++++++++++------- boxes/yarn.lock | 118 +------- .../noir-protocol-circuits/package.json | 3 +- .../noir-protocol-circuits/yarn.lock | 25 +- .../src/conversion/common.ts | 9 - 6 files changed, 186 insertions(+), 246 deletions(-) diff --git a/barretenberg/acir_tests/sol-test/package.json b/barretenberg/acir_tests/sol-test/package.json index de1fdf8a961..a13cd369c14 100644 --- a/barretenberg/acir_tests/sol-test/package.json +++ b/barretenberg/acir_tests/sol-test/package.json @@ -10,6 +10,5 @@ "dependencies": { "ethers": "^6.8.1", "solc": "^0.8.27" - }, - "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" + } } diff --git a/barretenberg/acir_tests/sol-test/yarn.lock b/barretenberg/acir_tests/sol-test/yarn.lock index 9bc6faad6c9..293b9d13679 100644 --- a/barretenberg/acir_tests/sol-test/yarn.lock +++ b/barretenberg/acir_tests/sol-test/yarn.lock @@ -1,115 +1,169 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@adraffy/ens-normalize@1.10.1": - version "1.10.1" - resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz#63430d04bd8c5e74f8d7d049338f1cd9d4f02069" - integrity sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw== - -"@noble/curves@1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.2.0.tgz#92d7e12e4e49b23105a2555c6984d41733d65c35" - integrity sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw== +# This file is generated by running "yarn install" inside your project. +# Manual changes might be lost - proceed with caution! + +__metadata: + version: 8 + cacheKey: 10c0 + +"@adraffy/ens-normalize@npm:1.10.0": + version: 1.10.0 + resolution: "@adraffy/ens-normalize@npm:1.10.0" + checksum: 10c0/78ae700847a2516d5a0ae12c4e23d09392a40c67e73b137eb7189f51afb1601c8d18784aeda2ed288a278997824dc924d1f398852c21d41ee2c4c564f2fb4d26 + languageName: node + linkType: hard + +"@noble/curves@npm:1.2.0": + version: 1.2.0 + resolution: "@noble/curves@npm:1.2.0" dependencies: - "@noble/hashes" "1.3.2" - -"@noble/hashes@1.3.2": - version "1.3.2" - resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39" - integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== - -"@types/node@22.7.5": - version "22.7.5" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.5.tgz#cfde981727a7ab3611a481510b473ae54442b92b" - integrity sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ== + "@noble/hashes": "npm:1.3.2" + checksum: 10c0/0bac7d1bbfb3c2286910b02598addd33243cb97c3f36f987ecc927a4be8d7d88e0fcb12b0f0ef8a044e7307d1844dd5c49bb724bfa0a79c8ec50ba60768c97f6 + languageName: node + linkType: hard + +"@noble/hashes@npm:1.3.2": + version: 1.3.2 + resolution: "@noble/hashes@npm:1.3.2" + checksum: 10c0/2482cce3bce6a596626f94ca296e21378e7a5d4c09597cbc46e65ffacc3d64c8df73111f2265444e36a3168208628258bbbaccba2ef24f65f58b2417638a20e7 + languageName: node + linkType: hard + +"@types/node@npm:18.15.13": + version: 18.15.13 + resolution: "@types/node@npm:18.15.13" + checksum: 10c0/6e5f61c559e60670a7a8fb88e31226ecc18a21be103297ca4cf9848f0a99049dae77f04b7ae677205f2af494f3701b113ba8734f4b636b355477a6534dbb8ada + languageName: node + linkType: hard + +"aes-js@npm:4.0.0-beta.5": + version: 4.0.0-beta.5 + resolution: "aes-js@npm:4.0.0-beta.5" + checksum: 10c0/444f4eefa1e602cbc4f2a3c644bc990f93fd982b148425fee17634da510586fc09da940dcf8ace1b2d001453c07ff042e55f7a0482b3cc9372bf1ef75479090c + languageName: node + linkType: hard + +"command-exists@npm:^1.2.8": + version: 1.2.9 + resolution: "command-exists@npm:1.2.9" + checksum: 10c0/75040240062de46cd6cd43e6b3032a8b0494525c89d3962e280dde665103f8cc304a8b313a5aa541b91da2f5a9af75c5959dc3a77893a2726407a5e9a0234c16 + languageName: node + linkType: hard + +"commander@npm:^8.1.0": + version: 8.3.0 + resolution: "commander@npm:8.3.0" + checksum: 10c0/8b043bb8322ea1c39664a1598a95e0495bfe4ca2fad0d84a92d7d1d8d213e2a155b441d2470c8e08de7c4a28cf2bc6e169211c49e1b21d9f7edc6ae4d9356060 + languageName: node + linkType: hard + +"ethers@npm:^6.8.1": + version: 6.8.1 + resolution: "ethers@npm:6.8.1" dependencies: - undici-types "~6.19.2" - -aes-js@4.0.0-beta.5: - version "4.0.0-beta.5" - resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-4.0.0-beta.5.tgz#8d2452c52adedebc3a3e28465d858c11ca315873" - integrity sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q== - -command-exists@^1.2.8: - version "1.2.9" - resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.9.tgz#c50725af3808c8ab0260fd60b01fbfa25b954f69" - integrity sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w== - -commander@^8.1.0: - version "8.3.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66" - integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww== - -ethers@^6.8.1: - version "6.13.4" - resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.4.tgz#bd3e1c3dc1e7dc8ce10f9ffb4ee40967a651b53c" - integrity sha512-21YtnZVg4/zKkCQPjrDj38B1r4nQvTZLopUGMLQ1ePU2zV/joCfDC3t3iKQjWRzjjjbzR+mdAIoikeBRNkdllA== + "@adraffy/ens-normalize": "npm:1.10.0" + "@noble/curves": "npm:1.2.0" + "@noble/hashes": "npm:1.3.2" + "@types/node": "npm:18.15.13" + aes-js: "npm:4.0.0-beta.5" + tslib: "npm:2.4.0" + ws: "npm:8.5.0" + checksum: 10c0/2fb05a0377c7d251ef160ddb5ab8553311c81fd1b7931426d6492d2652704a6ac5c4ff277a5aa6b2e64fe8bbfeec0b0e98263049d2ce44bf2286a72cefc3204b + languageName: node + linkType: hard + +"follow-redirects@npm:^1.12.1": + version: 1.15.3 + resolution: "follow-redirects@npm:1.15.3" + peerDependenciesMeta: + debug: + optional: true + checksum: 10c0/915a2cf22e667bdf47b1a43cc6b7dce14d95039e9bbf9a24d0e739abfbdfa00077dd43c86d4a7a19efefcc7a99af144920a175eedc3888d268af5df67c272ee5 + languageName: node + linkType: hard + +"headless-test@workspace:.": + version: 0.0.0-use.local + resolution: "headless-test@workspace:." dependencies: - "@adraffy/ens-normalize" "1.10.1" - "@noble/curves" "1.2.0" - "@noble/hashes" "1.3.2" - "@types/node" "22.7.5" - aes-js "4.0.0-beta.5" - tslib "2.7.0" - ws "8.17.1" - -follow-redirects@^1.12.1: - version "1.15.9" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1" - integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ== - -js-sha3@0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" - integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== - -memorystream@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2" - integrity sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw== - -os-tmpdir@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - integrity sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g== - -semver@^5.5.0: - version "5.7.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" - integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== - -solc@^0.8.27: - version "0.8.28" - resolved "https://registry.yarnpkg.com/solc/-/solc-0.8.28.tgz#43f129ce31572625593677cc3ff53eb32100148c" - integrity sha512-AFCiJ+b4RosyyNhnfdVH4ZR1+TxiL91iluPjw0EJslIu4LXGM9NYqi2z5y8TqochC4tcH9QsHfwWhOIC9jPDKA== + ethers: "npm:^6.8.1" + solc: "npm:^0.8.27" + languageName: unknown + linkType: soft + +"js-sha3@npm:0.8.0": + version: 0.8.0 + resolution: "js-sha3@npm:0.8.0" + checksum: 10c0/43a21dc7967c871bd2c46cb1c2ae97441a97169f324e509f382d43330d8f75cf2c96dba7c806ab08a425765a9c847efdd4bffbac2d99c3a4f3de6c0218f40533 + languageName: node + linkType: hard + +"memorystream@npm:^0.3.1": + version: 0.3.1 + resolution: "memorystream@npm:0.3.1" + checksum: 10c0/4bd164657711d9747ff5edb0508b2944414da3464b7fe21ac5c67cf35bba975c4b446a0124bd0f9a8be54cfc18faf92e92bd77563a20328b1ccf2ff04e9f39b9 + languageName: node + linkType: hard + +"os-tmpdir@npm:~1.0.2": + version: 1.0.2 + resolution: "os-tmpdir@npm:1.0.2" + checksum: 10c0/f438450224f8e2687605a8dd318f0db694b6293c5d835ae509a69e97c8de38b6994645337e5577f5001115470414638978cc49da1cdcc25106dad8738dc69990 + languageName: node + linkType: hard + +"semver@npm:^5.5.0": + version: 5.7.2 + resolution: "semver@npm:5.7.2" + bin: + semver: bin/semver + checksum: 10c0/e4cf10f86f168db772ae95d86ba65b3fd6c5967c94d97c708ccb463b778c2ee53b914cd7167620950fc07faf5a564e6efe903836639e512a1aa15fbc9667fa25 + languageName: node + linkType: hard + +"solc@npm:^0.8.27": + version: 0.8.27 + resolution: "solc@npm:0.8.27" dependencies: - command-exists "^1.2.8" - commander "^8.1.0" - follow-redirects "^1.12.1" - js-sha3 "0.8.0" - memorystream "^0.3.1" - semver "^5.5.0" - tmp "0.0.33" - -tmp@0.0.33: - version "0.0.33" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" - integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== + command-exists: "npm:^1.2.8" + commander: "npm:^8.1.0" + follow-redirects: "npm:^1.12.1" + js-sha3: "npm:0.8.0" + memorystream: "npm:^0.3.1" + semver: "npm:^5.5.0" + tmp: "npm:0.0.33" + bin: + solcjs: solc.js + checksum: 10c0/6b7bed9531c6e1f1efcd30eb4ef4a741954bafb79b4d016faa728992990c8ca36a16d38118e3eeb39a205e834557c519e75cf4188a6212ac871e9755663c478d + languageName: node + linkType: hard + +"tmp@npm:0.0.33": + version: 0.0.33 + resolution: "tmp@npm:0.0.33" dependencies: - os-tmpdir "~1.0.2" - -tslib@2.7.0: - version "2.7.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.7.0.tgz#d9b40c5c40ab59e8738f297df3087bf1a2690c01" - integrity sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA== - -undici-types@~6.19.2: - version "6.19.8" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" - integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== - -ws@8.17.1: - version "8.17.1" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b" - integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ== + os-tmpdir: "npm:~1.0.2" + checksum: 10c0/69863947b8c29cabad43fe0ce65cec5bb4b481d15d4b4b21e036b060b3edbf3bc7a5541de1bacb437bb3f7c4538f669752627fdf9b4aaf034cebd172ba373408 + languageName: node + linkType: hard + +"tslib@npm:2.4.0": + version: 2.4.0 + resolution: "tslib@npm:2.4.0" + checksum: 10c0/eb19bda3ae545b03caea6a244b34593468e23d53b26bf8649fbc20fce43e9b21a71127fd6d2b9662c0fe48ee6ff668ead48fd00d3b88b2b716b1c12edae25b5d + languageName: node + linkType: hard + +"ws@npm:8.5.0": + version: 8.5.0 + resolution: "ws@npm:8.5.0" + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + checksum: 10c0/0baeee03e97865accda8fad51e8e5fa17d19b8e264529efdf662bbba2acc1c7f1de8316287e6df5cb639231a96009e6d5234b57e6ff36ee2d04e49a0995fec2f + languageName: node + linkType: hard diff --git a/boxes/yarn.lock b/boxes/yarn.lock index 76143078b44..3e2af4835f8 100644 --- a/boxes/yarn.lock +++ b/boxes/yarn.lock @@ -2051,13 +2051,6 @@ __metadata: languageName: node linkType: hard -"@swc/core-darwin-arm64@npm:1.10.1": - version: 1.10.1 - resolution: "@swc/core-darwin-arm64@npm:1.10.1" - conditions: os=darwin & cpu=arm64 - languageName: node - linkType: hard - "@swc/core-darwin-arm64@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-darwin-arm64@npm:1.9.3" @@ -2065,13 +2058,6 @@ __metadata: languageName: node linkType: hard -"@swc/core-darwin-x64@npm:1.10.1": - version: 1.10.1 - resolution: "@swc/core-darwin-x64@npm:1.10.1" - conditions: os=darwin & cpu=x64 - languageName: node - linkType: hard - "@swc/core-darwin-x64@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-darwin-x64@npm:1.9.3" @@ -2079,13 +2065,6 @@ __metadata: languageName: node linkType: hard -"@swc/core-linux-arm-gnueabihf@npm:1.10.1": - version: 1.10.1 - resolution: "@swc/core-linux-arm-gnueabihf@npm:1.10.1" - conditions: os=linux & cpu=arm - languageName: node - linkType: hard - "@swc/core-linux-arm-gnueabihf@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-linux-arm-gnueabihf@npm:1.9.3" @@ -2093,13 +2072,6 @@ __metadata: languageName: node linkType: hard -"@swc/core-linux-arm64-gnu@npm:1.10.1": - version: 1.10.1 - resolution: "@swc/core-linux-arm64-gnu@npm:1.10.1" - conditions: os=linux & cpu=arm64 & libc=glibc - languageName: node - linkType: hard - "@swc/core-linux-arm64-gnu@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-linux-arm64-gnu@npm:1.9.3" @@ -2107,13 +2079,6 @@ __metadata: languageName: node linkType: hard -"@swc/core-linux-arm64-musl@npm:1.10.1": - version: 1.10.1 - resolution: "@swc/core-linux-arm64-musl@npm:1.10.1" - conditions: os=linux & cpu=arm64 & libc=musl - languageName: node - linkType: hard - "@swc/core-linux-arm64-musl@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-linux-arm64-musl@npm:1.9.3" @@ -2121,13 +2086,6 @@ __metadata: languageName: node linkType: hard -"@swc/core-linux-x64-gnu@npm:1.10.1": - version: 1.10.1 - resolution: "@swc/core-linux-x64-gnu@npm:1.10.1" - conditions: os=linux & cpu=x64 & libc=glibc - languageName: node - linkType: hard - "@swc/core-linux-x64-gnu@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-linux-x64-gnu@npm:1.9.3" @@ -2135,13 +2093,6 @@ __metadata: languageName: node linkType: hard -"@swc/core-linux-x64-musl@npm:1.10.1": - version: 1.10.1 - resolution: "@swc/core-linux-x64-musl@npm:1.10.1" - conditions: os=linux & cpu=x64 & libc=musl - languageName: node - linkType: hard - "@swc/core-linux-x64-musl@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-linux-x64-musl@npm:1.9.3" @@ -2149,13 +2100,6 @@ __metadata: languageName: node linkType: hard -"@swc/core-win32-arm64-msvc@npm:1.10.1": - version: 1.10.1 - resolution: "@swc/core-win32-arm64-msvc@npm:1.10.1" - conditions: os=win32 & cpu=arm64 - languageName: node - linkType: hard - "@swc/core-win32-arm64-msvc@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-win32-arm64-msvc@npm:1.9.3" @@ -2163,13 +2107,6 @@ __metadata: languageName: node linkType: hard -"@swc/core-win32-ia32-msvc@npm:1.10.1": - version: 1.10.1 - resolution: "@swc/core-win32-ia32-msvc@npm:1.10.1" - conditions: os=win32 & cpu=ia32 - languageName: node - linkType: hard - "@swc/core-win32-ia32-msvc@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-win32-ia32-msvc@npm:1.9.3" @@ -2177,13 +2114,6 @@ __metadata: languageName: node linkType: hard -"@swc/core-win32-x64-msvc@npm:1.10.1": - version: 1.10.1 - resolution: "@swc/core-win32-x64-msvc@npm:1.10.1" - conditions: os=win32 & cpu=x64 - languageName: node - linkType: hard - "@swc/core-win32-x64-msvc@npm:1.9.3": version: 1.9.3 resolution: "@swc/core-win32-x64-msvc@npm:1.9.3" @@ -2191,53 +2121,7 @@ __metadata: languageName: node linkType: hard -"@swc/core@npm:^1.7.0": - version: 1.10.1 - resolution: "@swc/core@npm:1.10.1" - dependencies: - "@swc/core-darwin-arm64": "npm:1.10.1" - "@swc/core-darwin-x64": "npm:1.10.1" - "@swc/core-linux-arm-gnueabihf": "npm:1.10.1" - "@swc/core-linux-arm64-gnu": "npm:1.10.1" - "@swc/core-linux-arm64-musl": "npm:1.10.1" - "@swc/core-linux-x64-gnu": "npm:1.10.1" - "@swc/core-linux-x64-musl": "npm:1.10.1" - "@swc/core-win32-arm64-msvc": "npm:1.10.1" - "@swc/core-win32-ia32-msvc": "npm:1.10.1" - "@swc/core-win32-x64-msvc": "npm:1.10.1" - "@swc/counter": "npm:^0.1.3" - "@swc/types": "npm:^0.1.17" - peerDependencies: - "@swc/helpers": "*" - dependenciesMeta: - "@swc/core-darwin-arm64": - optional: true - "@swc/core-darwin-x64": - optional: true - "@swc/core-linux-arm-gnueabihf": - optional: true - "@swc/core-linux-arm64-gnu": - optional: true - "@swc/core-linux-arm64-musl": - optional: true - "@swc/core-linux-x64-gnu": - optional: true - "@swc/core-linux-x64-musl": - optional: true - "@swc/core-win32-arm64-msvc": - optional: true - "@swc/core-win32-ia32-msvc": - optional: true - "@swc/core-win32-x64-msvc": - optional: true - peerDependenciesMeta: - "@swc/helpers": - optional: true - checksum: 10c0/a3d3b17c1abc8f32a7cc5dfaa006fc314e71cc0beb43e71b8b1c6c3d3841412a7e55d9e72009debd48159881e8a045ecd0ea56036e022f1bc87213fe29cd9015 - languageName: node - linkType: hard - -"@swc/core@npm:^1.7.26": +"@swc/core@npm:^1.7.0, @swc/core@npm:^1.7.26": version: 1.9.3 resolution: "@swc/core@npm:1.9.3" dependencies: diff --git a/noir-projects/noir-protocol-circuits/package.json b/noir-projects/noir-protocol-circuits/package.json index 9979306ee73..2f5efb48850 100644 --- a/noir-projects/noir-protocol-circuits/package.json +++ b/noir-projects/noir-protocol-circuits/package.json @@ -4,6 +4,5 @@ "main": "index.js", "dependencies": { "@iarna/toml": "^2.2.5" - }, - "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" + } } diff --git a/noir-projects/noir-protocol-circuits/yarn.lock b/noir-projects/noir-protocol-circuits/yarn.lock index f411a21e2d6..54bdbaad9b2 100644 --- a/noir-projects/noir-protocol-circuits/yarn.lock +++ b/noir-projects/noir-protocol-circuits/yarn.lock @@ -1,8 +1,21 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 +# This file is generated by running "yarn install" inside your project. +# Manual changes might be lost - proceed with caution! +__metadata: + version: 8 + cacheKey: 10c0 -"@iarna/toml@^2.2.5": - version "2.2.5" - resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.5.tgz#b32366c89b43c6f8cefbdefac778b9c828e3ba8c" - integrity sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg== +"@iarna/toml@npm:^2.2.5": + version: 2.2.5 + resolution: "@iarna/toml@npm:2.2.5" + checksum: 10c0/d095381ad4554aca233b7cf5a91f243ef619e5e15efd3157bc640feac320545450d14b394aebbf6f02a2047437ced778ae598d5879a995441ab7b6c0b2c2f201 + languageName: node + linkType: hard + +"noir-protocol-circuits-generator@workspace:.": + version: 0.0.0-use.local + resolution: "noir-protocol-circuits-generator@workspace:." + dependencies: + "@iarna/toml": "npm:^2.2.5" + languageName: unknown + linkType: soft diff --git a/yarn-project/noir-protocol-circuits-types/src/conversion/common.ts b/yarn-project/noir-protocol-circuits-types/src/conversion/common.ts index ff90122d373..8434af0674a 100644 --- a/yarn-project/noir-protocol-circuits-types/src/conversion/common.ts +++ b/yarn-project/noir-protocol-circuits-types/src/conversion/common.ts @@ -575,15 +575,6 @@ export function mapPartialStateReferenceFromNoir( ); } -// function mapTreeSnapshotsFromNoir(snapshots: TreeSnapshotsNoir) { -// return new TreeSnapshots( -// mapAppendOnlyTreeSnapshotFromNoir(snapshots.l1_to_l2_message_tree), -// mapAppendOnlyTreeSnapshotFromNoir(snapshots.note_hash_tree), -// mapAppendOnlyTreeSnapshotFromNoir(snapshots.nullifier_tree), -// mapAppendOnlyTreeSnapshotFromNoir(snapshots.public_data_tree), -// ); -// } - export function mapMembershipWitnessToNoir(witness: MembershipWitness): MembershipWitnessNoir { const siblingPath = mapTuple(witness.siblingPath, mapFieldToNoir) as FixedLengthArray; return {