Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: throw compile time error if contract has too many fns #3536

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 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
3 changes: 3 additions & 0 deletions yarn-project/noir-compiler/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"tsBuildInfoFile": ".tsbuildinfo"
},
"references": [
{
"path": "../circuits.js"
},
{
"path": "../foundation"
}
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