Skip to content

Commit

Permalink
cairo-run: make tracer host:port configurable
Browse files Browse the repository at this point in the history
We make the --tracer flag take an optional argument, letting us
configure the host:port to serve on at startup.

We default to localhost:8100 if the optional argument is not set, and as
previously don't start the tracer in case the --tracer flag is not set
at all.
  • Loading branch information
halseth committed Apr 28, 2023
1 parent c638236 commit d0b9cc6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/starkware/cairo/lang/vm/cairo_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ def main():
default="plain",
help="The layout of the Cairo AIR.",
)
parser.add_argument("--tracer", action="store_true", help="Run the tracer.")
parser.add_argument(
"--tracer",
nargs='?',
const="localhost:8100",
help="Run the tracer at the given host and port (default: localhost:8100.")
parser.add_argument(
"--profile_output",
type=str,
Expand Down Expand Up @@ -432,7 +436,12 @@ def cairo_run(args):
debug_info_file=debug_info_file, debug_info=runner.get_relocated_debug_info()
)

if args.tracer:
if args.tracer is not None:
# Tracer set, split host and port.
splits = args.tracer.split(':')
host = splits[0]
port = int(splits[1])

CAIRO_TRACER = "starkware.cairo.lang.tracer.tracer"
subprocess.call(
list(
Expand All @@ -444,6 +453,8 @@ def cairo_run(args):
CAIRO_TRACER,
f"--program={args.program.name}",
f"--trace={trace_file.name}",
f"--host={host}",
f"--port={port}",
f"--memory={memory_file.name}",
f"--air_public_input={args.air_public_input.name}"
if args.air_public_input
Expand Down

0 comments on commit d0b9cc6

Please sign in to comment.