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

Improve ReadME #37

Closed
wants to merge 4 commits into from
Closed

Improve ReadME #37

wants to merge 4 commits into from

Conversation

danilowhk
Copy link

Added more description and graphs about the Cairo VM and specifically Cairo VM TS.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you also need to update the existing part

@@ -34,3 +34,205 @@ Read so far up to
- Install [bun](https://bun.sh/)
- Run `bun install` to install all dependencies
- Run `bun test` to run all tests

## Introduction to Cairo VM
Cairo VM is an advanced virtual CPU architecture designed for blockchain technology and cryptographic operations. It's Turing-complete and STARK-friendly, efficiently handling complex program statements as polynomial equations over a finite field. This feature is crucial for secure and effective cryptographic proof management in blockchain applications, making Cairo VM a key player in the realm of decentralized computing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

advanced? what does it mean?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm more like innovative as for Zk is something new/advanced, but will change the wording

@@ -34,3 +34,205 @@ Read so far up to
- Install [bun](https://bun.sh/)
- Run `bun install` to install all dependencies
- Run `bun test` to run all tests

## Introduction to Cairo VM
Cairo VM is an advanced virtual CPU architecture designed for blockchain technology and cryptographic operations. It's Turing-complete and STARK-friendly, efficiently handling complex program statements as polynomial equations over a finite field. This feature is crucial for secure and effective cryptographic proof management in blockchain applications, making Cairo VM a key player in the realm of decentralized computing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it "designed for blockchain technology and cryptographic operation" really?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was designed for efficient proof generation with the goal of scaling Ethereum

@@ -34,3 +34,205 @@ Read so far up to
- Install [bun](https://bun.sh/)
- Run `bun install` to install all dependencies
- Run `bun test` to run all tests

## Introduction to Cairo VM
Cairo VM is an advanced virtual CPU architecture designed for blockchain technology and cryptographic operations. It's Turing-complete and STARK-friendly, efficiently handling complex program statements as polynomial equations over a finite field. This feature is crucial for secure and effective cryptographic proof management in blockchain applications, making Cairo VM a key player in the realm of decentralized computing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This feature is crucial for secure and effective cryptographic proof management in blockchain applications, making Cairo VM a key player in the realm of decentralized computing." bla bla bla

though you can give more context about the relevance of proving systems in general, be more precise about the Cairo VM itself VS proving systems

Cairo VM is an advanced virtual CPU architecture designed for blockchain technology and cryptographic operations. It's Turing-complete and STARK-friendly, efficiently handling complex program statements as polynomial equations over a finite field. This feature is crucial for secure and effective cryptographic proof management in blockchain applications, making Cairo VM a key player in the realm of decentralized computing.

## Register-Based VM
Cairo VM's register-based architecture allows for quicker data access compared to stack based interaction, enhancing computational efficiency and performance in cryptographic operations.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where did you get this from?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The choice for register based instead of stack based is because its easier to generate traces that can generate proofs / that are polynomial friendly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that the file is lined. You can add trunk to the cairo vm ts CI, like in other kkrt repo

Cairo VM's register-based architecture allows for quicker data access compared to stack based interaction, enhancing computational efficiency and performance in cryptographic operations.

## Detailed Architecture Overview
- **Finite Field Operations**: Core to Cairo VM's computational power for cryptographic aspects of STARKs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unclear

- **Three-Register System**: The Cairo VM employs a three-register system, consisting of:

- **Program Counter (PC)**: Manages the sequence of program execution by holding the memory address of the next instruction.
- **Allocation Pointer (AP)**: Crucial for memory management, it points to the first unused memory cell, dynamically adjusting as the program runs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz avoid words like "crucial" and in general, words that don't give a precise and concise info

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"dynamically adjusting" ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That it changes not linearly but "dynamically" as the program runs

## Detailed Architecture Overview
- **Finite Field Operations**: Core to Cairo VM's computational power for cryptographic aspects of STARKs.

- **Three-Register System**: The Cairo VM employs a three-register system, consisting of:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refers to 4.1 The registers
https://eprint.iacr.org/2021/1063.pdf

Comment on lines +53 to +56
## Advanced Functionality and Impact
- **Scalability and Efficiency**: Integration with STARKs for efficient verification of computational claims.
- **Security Enhancements**: Read-only memory model and finite field operations fortify Cairo VM against common vulnerabilities.
- **Flexibility and Turing Completeness**: Suitable for a variety of applications, from simple smart contracts to complex decentralized applications.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

- **Flexibility and Turing Completeness**: Suitable for a variety of applications, from simple smart contracts to complex decentralized applications.


## Overall Cairo VM TS Flow
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this automatically generated? not sure it's accurate anymore, and most probably subject to change.

Also not a fan of big graph that don't really bring any value to me as they are hard to read

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't automatically generated, but if this is validated than could work on automatic generation. First did by hand to test

end

```
- **Overview**: The Cairo VM TS Flow diagram illustrates the interconnectivity and operational dynamics of the various classes within the Cairo VM TypeScript implementation. It showcases how each class contributes to the overall functioning of the VM, detailing the interactions between the VirtualMachine, RunContext, MemorySegmentManager, Memory, and CairoRunner classes. This flowchart is a tool for understanding the architecture and inner workings of the Cairo VM, highlighting the orchestration of instruction execution, memory management, and execution control within this sophisticated virtual environment.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this chatGPT powered?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used Gpt to generate the initial wordings and then I rewrote/changed it myself

fn_runUntilPc -->|call_fn_step in VM| VM
end
```
- **Overview**: CairoRunner is pivotal in the initial setup and execution flow of the Cairo VM in the TypeScript environment. It meticulously handles the initialization of memory segments, setting up the main entry point, and defining the initial state of the VM, laying down the foundational elements necessary for program execution.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"pivotal" => don't, cf previous comment about succintness

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"meticulously" => don't

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"foundational" => don't

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by cf?

Comment on lines +135 to +148
- **Main Functions**:
- `initialize`: Sets up the Cairo VM by initializing the necessary segments and the main entry point. This function lays the groundwork for the VM's operational environment.

- `runUntilPc`: Controls the execution of the VM until a specified program counter (PC) is reached. It repeatedly invokes the VM's step function, progressing through the program instructions until the end condition is met.

- `initializeSegments`: Responsible for creating the program and execution segments in the VM's memory. This function allocates the necessary memory space for the program's execution, setting the stage for the instructions to be loaded and executed.

- `initializeMainEntrypoint`: Initializes the main function entry point of the program. This includes setting up the initial registers and determining the final PC for the main function.

- `initializeFunctionEntrypoint`: Sets up a function entry point in the VM. This involves preparing the registers for the function call and calculating the final PC for the function.

- `initializeState`: Configures the initial state of the VM, including setting the initial PC, AP, and FP, and loading the program data into the VM's memory.

- `initializeVm`: Finalizes the VM's initialization by setting the run context's AP, FP, and PC to their initial values, ensuring the VM is ready to execute the program.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like doc that should be generated from the docstring

Copy link
Member

@ClementWalter ClementWalter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz review succinctness, skim, are focus more about few key components required to grasp the VM flow. Also even if you can outline the why of this VM with considerations regarding the proving system, the how of the VM should be more underlined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants