Skip to content

Commit

Permalink
throw compile time error if contract has too many fns
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-kothari committed Dec 4, 2023
1 parent ed1501a commit d9f4d17
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions yarn-project/noir-compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions yarn-project/noir-compiler/src/contract-interface-gen/abi.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions yarn-project/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d9f4d17

Please sign in to comment.