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

epic: investigate and design a tracing API for the cairo vm ts #41

Open
Eikix opened this issue Nov 28, 2023 · 3 comments
Open

epic: investigate and design a tracing API for the cairo vm ts #41

Eikix opened this issue Nov 28, 2023 · 3 comments
Labels
epic Macro-task - Usually a collection of sub-issues

Comments

@Eikix
Copy link
Member

Eikix commented Nov 28, 2023

  • look at VMs, i.e. EVMs,
  • NPM packages for tracing and error tracing

This is not linked to the VM trace (prover mode)

@Eikix Eikix assigned Eikix and unassigned Eikix Dec 1, 2023
@ClementWalter
Copy link
Member

@Eikix can you give more context ? or we close this?

@Eikix
Copy link
Member Author

Eikix commented Jun 9, 2024

Ah yes, I wonder how we can replicate the concept of Cairo trace for Cairo VM TS

The fact that you get a precise error trace when hitting a CairoVM error in Python. Moreover, I wonder if it can come directly decoded

@zmalatrax
Copy link
Collaborator

Ah yes, I wonder how we can replicate the concept of Cairo trace for Cairo VM TS

The fact that you get a precise error trace when hitting a CairoVM error in Python. Moreover, I wonder if it can come directly decoded

Are you talking about what the --show_trace flag outputs in the python VM cli? If so, the JS error already display the call stack leading to the error

But if we're talking about where it failed on the Cairo program, such as

cairo_programs/cairo_0/bad_programs/bad_range_check_builtin.cairo:4:5: Error at pc=0:2:
Value 3618502788666131213697322783095070105623107215331596699973092056135872020480, in range check builtin 0, is out of range [0, 340282366920938463463374607431768211456).
    assert [range_check_ptr] = -1;
    ^****************************^
  • For Error at pc=0:2, we can add a try catch clause in the vm step() to log at which PC it failed and then throw
  • A meaningful error message is doable by adding an error message to the super('') constructor of each error class (e.g. error: Value ${value} in range_check builtin is out of range [0, ${bound}])
  • For the link to the Cairo program, is it done through the debug_info of the compilation artifacts, instruction_locations maps the (relative) PC (0:2 => "2") to the instruction location. The inst field gives the path to the cairo program + start/end lines and columns of the instruction.

Assuming the Cairo file is available in the context of execution, adding a debug attribute to the VM (optional in the config ?) would allow to show which Cairo statement induced the error. Don't know if something changes with more complex cases (w/ hints, nested call to imported libraries) but as is, it can be implemented without too much hassle imo

"2": {
  "accessible_scopes": [
    "__main__",
    "__main__.main"
  ],
  "flow_tracking_data": {
    "ap_tracking": {
      "group": 0,
      "offset": 1
    },
    "reference_ids": {
      "__main__.main.__temp0": 1,
      "__main__.main.range_check_ptr": 0
    }
  },
  "hints": [],
  "inst": {
    "end_col": 35,
    "end_line": 4,
    "input_file": {
      "filename": "cairo_programs/cairo_0/bad_programs/bad_range_check_builtin.cairo"
    },
    "start_col": 5,
    "start_line": 4
  }
},

@zmalatrax zmalatrax added the epic Macro-task - Usually a collection of sub-issues label Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic Macro-task - Usually a collection of sub-issues
Projects
Status: 🆕 Backlog
Development

No branches or pull requests

3 participants