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

Add logic to ignore unsupported contexts #44

Merged
merged 11 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions src/core/dependencies/parser/CircomTemplateInputsVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ import {
VarDefinitionContext,
RhsValueContext,
TemplateStmtContext,
BlockInstantiationExpressionContext,
DotExpressionContext,
} from "@distributedlab/circom-parser";

import { InputData } from "../../../types/core";
import { HardhatZKitError } from "../../../errors";
import { Reporter } from "../../../reporter";

/**
* Visitor class for the {@link https://www.npmjs.com/package/@distributedlab/circom-parser | @distributedlab/circom-parser} package.
Expand Down Expand Up @@ -134,6 +137,15 @@ export class CircomTemplateInputsVisitor extends CircomVisitor<void> {
const expressionVisitor = new CircomExpressionVisitor(true, this.vars);

if (ctx.expression()) {
if (
ctx.expression() instanceof BlockInstantiationExpressionContext ||
ctx.expression() instanceof DotExpressionContext
) {
Reporter?.reportUnsupportedExpression(ctx.expression().getText());

return [0n];
}

const expressionResult = expressionVisitor.visitExpression(ctx.expression());

if (Array.isArray(expressionResult)) {
Expand Down
7 changes: 7 additions & 0 deletions src/reporter/ReporterFacade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
VerifiersGenerationReporter,
VKeyFilesGenerationReporter,
ZKeyFilesGenerationReporter,
WarningsReporter,
} from "./reporters";

import { createProgressBarProcessor } from "./ProgressBarProcessor";
Expand All @@ -31,6 +32,7 @@ class ReporterFacade {
private _setupReporter!: SetupReporter;
private _progressReporter!: ProgressReporter;
private _ptauFileReporter!: PtauFileReporter;
private _warningsReporter!: WarningsReporter;
private _circomCompilerReporter!: CircomCompilerReporter;
private _circuitCompilationReporter!: CircuitCompilationReporter;
private _verifiersGenerationReporter!: VerifiersGenerationReporter;
Expand All @@ -55,6 +57,7 @@ class ReporterFacade {
this._vKeyFilesGenerationReporter = new VKeyFilesGenerationReporter(quiet);
this._zKeyFilesGenerationReporter = new ZKeyFilesGenerationReporter(quiet);
this._circuitFilesResolvingReporter = new CircuitFilesResolvingReporter(quiet);
this._warningsReporter = new WarningsReporter(quiet);
}

public setQuiet(newValue: boolean) {
Expand Down Expand Up @@ -219,6 +222,10 @@ class ReporterFacade {
this._progressReporter.updateProgressBarValue(valueToAdd);
}

public reportUnsupportedExpression(contextText: string) {
this._warningsReporter.reportUnsupportedExpression(contextText);
}

public verboseLog(namespace: string, formatterStr: string, logArgs: any[] = []) {
debug(`hardhat-zkit:${namespace}`)(formatterStr, ...logArgs);
}
Expand Down
11 changes: 11 additions & 0 deletions src/reporter/reporters/WarningsReporter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { BaseReporter } from "@src/reporter/reporters/BaseReporter";
KyrylR marked this conversation as resolved.
Show resolved Hide resolved

export class WarningsReporter extends BaseReporter {
public reportUnsupportedExpression(contextText: string) {
if (this.isQuiet()) return;

console.warn(
`Expression structure: ${contextText} not supported if the expression is used to determine the dimension of input signal!`,
KyrylR marked this conversation as resolved.
Show resolved Hide resolved
);
}
}
1 change: 1 addition & 0 deletions src/reporter/reporters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from "./BaseReporter";
export * from "./SetupReporter";
export * from "./ProgressReporter";
export * from "./PtauFileReporter";
export * from "./WarningsReporter";
export * from "./CircomCompilerReporter";
export * from "./CircuitCompilationReporter";
export * from "./CircuitFilesResolvingReporter";
Expand Down
Loading