NethermindEth / cairo-vm-go

A virtual machine for Cairo written in Go
MIT License
82 stars 50 forks source link

Build hint map for Cairo 1 #621

Closed cicr99 closed 3 months ago

cicr99 commented 4 months ago

Currently the hintrunner package handles the building of map for the hints for Cairo zero. In the case of Cairo 1, the hints are a lot easier to parse from the compiled output. Let's take this one as an example:

[
      834,
      [
        {
          "TestLessThanOrEqual": {
            "lhs": {
              "Immediate": "0x102c"
            },
            "rhs": {
              "Deref": {
                "register": "AP",
                "offset": -12
              }
            },
            "dst": {
              "register": "AP",
              "offset": 0
            }
          }
        }
      ]
    ],

Notice they are already named, so there's no need to match the hint against the code string as in previous version. The input parameters for the hint execution already match the hint structures we have implemented for this version (see TestLessThanOrEquals structure for reference) and the types of the parameters already comply with the current implementation for operanders.

Task: Create a method similar to GetZeroHints to produce the map[uint64][]hinter.Hinter on account of the program version being used.

In the main pipeline, it would be a good idea to replace the call to GetZeroHints by a general method like GetHints (or something like that) that decides, according to the program version, which hint constructor to call

danielcdz commented 4 months ago

Hello @cicr99! Hope you are doing well! I can help with this issue if it is possible

onlydustapp[bot] commented 4 months ago

Hey @danielcdz! Thanks for showing interest. We've created an application for you to contribute to Cairo VM in Go. Go check it out on OnlyDust!