diff --git a/yarn-project/noir-compiler/package.json b/yarn-project/noir-compiler/package.json index 2232e05b0213..e03849b0de2e 100644 --- a/yarn-project/noir-compiler/package.json +++ b/yarn-project/noir-compiler/package.json @@ -45,6 +45,7 @@ } }, "dependencies": { + "@aztec/circuits.js": "workspace:^", "@aztec/foundation": "workspace:^", "@ltd/j-toml": "^1.38.0", "@noir-lang/noir_wasm": "portal:../../noir/packages/noir_wasm", diff --git a/yarn-project/noir-compiler/src/contract-interface-gen/abi.ts b/yarn-project/noir-compiler/src/contract-interface-gen/abi.ts index 61b47ea24d6c..df819ae65786 100644 --- a/yarn-project/noir-compiler/src/contract-interface-gen/abi.ts +++ b/yarn-project/noir-compiler/src/contract-interface-gen/abi.ts @@ -1,3 +1,4 @@ +import { FUNCTION_TREE_HEIGHT } from '@aztec/circuits.js'; import { ContractArtifact, DebugMetadata, FunctionArtifact, FunctionType } from '@aztec/foundation/abi'; import { deflate } from 'pako'; @@ -88,6 +89,9 @@ export function generateContractArtifact( { contract, debug }: NoirContractCompilationArtifacts, aztecNrVersion?: string, ): ContractArtifact { + if (contract.functions.length > 2 ** FUNCTION_TREE_HEIGHT) { + throw new Error(`Contract can only have a maximum of ${2 ** FUNCTION_TREE_HEIGHT} functions`); + } const originalFunctions = contract.functions; // TODO why sort? we should have idempotent compilation so this should not be needed. const sortedFunctions = [...contract.functions].sort((fnA, fnB) => fnA.name.localeCompare(fnB.name)); diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 4c4ad8d3a130..b0696b5e8aee 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -572,6 +572,7 @@ __metadata: version: 0.0.0-use.local resolution: "@aztec/noir-compiler@workspace:noir-compiler" dependencies: + "@aztec/circuits.js": "workspace:^" "@aztec/foundation": "workspace:^" "@jest/globals": ^29.5.0 "@ltd/j-toml": ^1.38.0