Skip to content

Commit e1ff5ab

Browse files
Update the base runner constructor
1 parent 2a55cae commit e1ff5ab

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/zkregex_fuzzer/harness.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def harness(regex: str, primary_runner_cls: Type[Runner], secondary_runner_cls:
4646
regex = regex
4747
inp_num = len(inputs)
4848
try:
49-
primary_runner = primary_runner_cls(regex)
49+
primary_runner = primary_runner_cls(regex, {})
5050
except RegexCompileError as e:
5151
return HarnessResult(regex, inp_num, oracle, [], HarnessStatus.INVALID_SEED)
5252

src/zkregex_fuzzer/runner/base_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Runner(ABC):
3131
Abstract base class for regex runners.
3232
"""
3333

34-
def __init__(self, regex: str):
34+
def __init__(self, regex: str, kwargs: dict):
3535
self._regex = regex
3636
self._runner = "Abstract runner"
3737
self._regex_object = self.compile(regex)

src/zkregex_fuzzer/runner/circom.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ def __init__(self, regex: str, kwargs: dict):
239239
self._run_the_prover = kwargs.get("circom_prove", False)
240240
self._ptau_path = kwargs.get("circom_ptau", None)
241241
self._link_path = kwargs.get("circom_library", [])
242-
self._max_input_size = kwargs.get("max_input_size", 200)
242+
self._circom_max_input_size = kwargs.get("circom_max_input_size", 200)
243243
self._template_name = "TestRegex"
244-
super().__init__(regex)
244+
super().__init__(regex, kwargs)
245245
self._runner = "Circom"
246246

247247
def compile(self, regex: str) -> None:
@@ -269,7 +269,7 @@ def compile(self, regex: str) -> None:
269269
# Append the circom file to include the main function
270270
with open(circom_file_path, 'a') as f:
271271
f.write("\n\n")
272-
f.write("component main {public [msg]} = " + f"{self._template_name}({self._max_input_size});")
272+
f.write("component main {public [msg]} = " + f"{self._template_name}({self._circom_max_input_size});")
273273

274274
# Compile the circom code to wasm
275275
self._wasm_path, self._r1cs_path = CircomSubprocess.compile(circom_file_path, self._link_path)
@@ -284,15 +284,15 @@ def match(self, input: str) -> bool:
284284
Match the regex on an input.
285285
"""
286286
# Convert input to list of decimal ASCII values and pad input with zeroes
287-
numeric_input = [ord(c) for c in input] + [0] * (self._max_input_size - len(input))
287+
numeric_input = [ord(c) for c in input] + [0] * (self._circom_max_input_size - len(input))
288288

289289
# Write input to a temporary JSON file
290290
with tempfile.NamedTemporaryFile(suffix=".json", delete=False) as tmp_file:
291291
tmp_file.write(json.dumps({"msg": numeric_input}).encode())
292292
input_path = tmp_file.name
293293

294294
# Skip if input is larger than circuit max input size
295-
if len(numeric_input) > self._max_input_size:
295+
if len(numeric_input) > self._circom_max_input_size:
296296
logger.info(f"Input too large for input: {input}")
297297
raise RegexRunError(f"Input too large for input: {input}")
298298

src/zkregex_fuzzer/runner/python.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class PythonReRunner(Runner):
1111
Runner that uses the Python re module.
1212
"""
1313

14-
def __init__(self, regex: str):
15-
super().__init__(regex)
14+
def __init__(self, regex: str, kwargs: dict):
15+
super().__init__(regex, kwargs)
1616
self._runner = "Python re module"
1717

1818
def compile(self, regex: str) -> None:

0 commit comments

Comments
 (0)