Giter VIP home page Giter VIP logo

cairo-vm-gs's People

Contributors

clementwalter avatar devswayam avatar jimmyfate avatar keneepatel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

cairo-vm-gs's Issues

Migrate to Typescript

Why

The project currently uses vanilla js. It would be better (easier to maintain, to understand) to use typescript.

What

Rewrite all the codebase in typescript

How

  1. Follow the doc to use ts in google app scripts
  2. Create a types.ts file gathering all the types
  3. Refactor codebase to use ts

feat: add a Run method

Why

In the current PoC, there is only a step method that generate the next step of the VM. We need a method to make the whole run directly as well

What

Create a run method, and a Run menu item, to end the run

How

See the while loop of the python vm
https://github.com/starkware-libs/cairo-lang/blob/efa9648f57568aad8f8a13fbf027d2de7c63c2c0/src/starkware/cairo/lang/vm/cairo_runner.py#L343

Logic is the same, where the final_pc has been put in the Execution column in the initialize step (see #3).

The function should at any stage of the run, ie. from the beginning (right after initialization) or after few steps have already been executed.

feat: add initializeSegments method logic

Why

The Cairo VM uses memory segments to track values. In short and almost true, a memory segment is just a list of values, ie. here a list of felt (felt is the only native type of cairo, think of felt as uint252).

A run of the VM actually consists in filling values in memory segments; allocating a segment just means creating an empty list at index i in the segments manager of the VM, much like

{
    0: [],
    1: [],
    42: [],
}

could be a memory with 3 initialized segments (with indexes 0, 1 and 42).

Segments can be allocated during the run (when the dev uses the alloc() function) or by the VM itself at the beginning of a run for given builtins. In cairo0, these builtins are declared at the tile level using the % builtin directive, and at the function level using corresponding implicit arguments.

The list of builtins actually available is:

[
  "output",
  "pedersen",
  "range_check",
  "ecdsa",
  "bitwise",
  "ec_op",
  "keccak",
  "poseidon",
]

Each builtin requires its own memory segment as these builtins actually enforces some rules over the segment. For example, the range_check segment will enforce that every values contained in this segment are actually no greater than 2**128.

Consequently, when initializing the VM for running a program, one needs to create as much memory segments as required.

What

The Cairo VM gs uses native sheet columns as memory segments.
The function should add the corresponding column with their header as names next to the Execution column

How

Follow the python VM https://github.com/starkware-libs/cairo-lang/blob/efa9648f57568aad8f8a13fbf027d2de7c63c2c0/src/starkware/cairo/lang/vm/cairo_runner.py#L216
Note that program_base is always the first segment, and Execution the second.

Add a menu in the UI to actually trigger the call

The CairoVM will for now only run the main entrypoint, so the final fp and pc segments should be added last, and their reference be added in the execution segment.

feat: add a Load Program menu

Why

Currently, the PoC showcase a small fibonacci program copy/pasted. We need to be able to load any compiled artifact instead.

What

Add a menu in the UI to load a program. This should open a file picker to upload a json file. Once uploaded and validated, the sheet should be updated as follows:

  • the Program tab is updated with the loaded program bytecode in column A
  • column B is filled with DECODE_INSTRUCTION(A) as as required
  • the Run tab is cleared with the loaded program bytecode in program, and the segments initialized

How

For the file picker, check the google doc
For the segment initialization, see #3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.