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

docs: cairo execution trace #214

Merged
merged 21 commits into from
Aug 23, 2023
Merged

Conversation

entropidelic
Copy link
Collaborator

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Aug 14, 2023

Codecov Report

Merging #214 (5f7f45c) into main (6976f9d) will not change coverage.
Report is 4 commits behind head on main.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #214   +/-   ##
=======================================
  Coverage   94.87%   94.87%           
=======================================
  Files          33       33           
  Lines        7069     7069           
=======================================
  Hits         6707     6707           
  Misses        362      362           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@MauroToscano MauroToscano marked this pull request as ready for review August 15, 2023 19:44

But there's a trick. If the last executed instruction is any instruction, and it's copied, the transition constraints won't be satisfied. To be able to do this, we need to use something called "proof mode". In proof mode, the main function of the program is wrapped in another one, which calls it and returns to an infinite loop. This loop is a jump relative 0.

Since this loop can be executed many times without changing the validity of the trace, it can be copied as many times as
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it seems like the sentence is incomplete at the end


The first is critical for the verifier to not only know that something was executed correctly but to know what was executed.

To make this check, we need to add dummy accesses on the memory cells with address 0 and value 0, which helps us prove it was used by changing the final value of the constraints that ensure that the memory is continuous and read-only.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would add that the (0, 0) dummy accesses are added to the unsorted memory accesses, and that before sorting when making the permutation argument, the dummy accesses are overwritten by the public memory ones. So at the end, for the permutation argument to work, we have two columns:

  • the unsorted original memory accesses + holes + (0, 0) dummy acceseses
  • the sorted full memory column

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The details of the calculation may be dispatched to the paper, but the (0, 0) accesses in the unsorted column is the reason why the final cumulative product is not 1

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've added a more detailed explanation on how that works

@entropidelic
Copy link
Collaborator Author

entropidelic commented Aug 17, 2023

@MauroToscano nice one, just a little comment on the whole holes filling/padding part.
It may be useful to specify exactly how are we filling these holes and dummy accesses. Since the enforce selector removing PR, we are adding one column for the whole memory additions (dummy + holes) and one for the rc holes. We wanted to do this in this way so that the added memory cells and rc values don't have to satisfy constraints other than the ones imposed by them being memory addresses or range checked values.

@MauroToscano
Copy link
Collaborator

MauroToscano commented Aug 22, 2023

@MauroToscano nice one, just a little comment on the whole holes filling/padding part. It may be useful to specify exactly how are we filling these holes and dummy accesses. Since the enforce selector removing PR, we are adding one column for the whole memory additions (dummy + holes) and one for the rc holes. We wanted to do this in this way so that the added memory cells and rc values don't have to satisfy constraints other than the ones imposed by them being memory addresses or range checked values.

I'd do it more generic since we may change that. With sub columns we may change that layout. But, i'll mention how it can be done.


#### Trace extension / Padding

The last step is padding the trace to a power of two for efficiency. We may also need to pad the trace if for some reason some unbalance is given by the layout.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The last step is padding the trace to a power of two for efficiency. We may also need to pad the trace if for some reason some unbalance is given by the layout.
The last step is padding the trace to a power of two for efficiency. We may also need to pad the trace to balance the layout.

Comment on lines +48 to +49
building components of the instruction interact to change the VM state, refer to the Cairo
whitepaper, sections 4.4 and 4.5.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add a link to the paper here

@MauroToscano MauroToscano added this pull request to the merge queue Aug 23, 2023
Merged via the queue into main with commit 1bb1a5f Aug 23, 2023
6 checks passed
@MauroToscano MauroToscano deleted the add-cairo-execution-trace-docs branch August 23, 2023 13:59
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.

5 participants