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

feat: Dynamic Address for Out-of-Domain Row in TASM AIR Evaluation #314

Merged
merged 26 commits into from
Aug 14, 2024

Conversation

aszepieniec
Copy link
Collaborator

The current TASM AIR evaluation code is very efficient but has a major drawback: the location of the inputs to the circuit (i.e., the {current, next} {main, aux} out-of-domain (OOD) rows) are statically defined and hence must be known at compile time. As a result, one runs into complications when verifying multiple STARK proofs in a single TASM program; and verifying a dynamic number of them is all but impossible. Moreover, the static location of the OOD rows are baked into the computer program, meaning that even if you do compile a TASM program that verifies multiple proofs, you get different programs (and different digests!) depending on how many proofs you actually need to verify.

This PR adds a second function for evaluating the AIR in tasm. It is a dynamic counterpart to the static one that's already there.

The new function does take a memory layout object, just like the old function does. But the difference is that this new memory layout object only specifies where to find the challenges and where to find free memory. The locations of the OOD rows is given as arguments on the stack. The method then stores these locations in the first few words of the free memory region. Whenever an input needs to be read, the relevant pointer-pointer is read and dereferenced twice -- the second time with the appropriate offset. (In contrast, the static code derefences a regular pointer once.)

In more detail, here are the changes introduced by this PR:

  • Update spec and spec-verifying tests.
  • Rename current tasm code to reflect static nature.
  • Add dynamic tasm code emitter.
  • Integrate dynamic tasm evaluator into existing tests.
  • Restructure: file air.rs and directory air contain logic related to evaluating AIR.

Base automatically changed from asz/addi to master August 12, 2024 12:27
Copy link
Member

@jan-ferdinand jan-ferdinand left a comment

Choose a reason for hiding this comment

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

It seems like there is a huge amount of copied code in the new dynamic generator. This does not feel necessary. Looks fine other than that.

constraint-evaluation-generator/src/codegen/static_tasm.rs Outdated Show resolved Hide resolved
constraint-evaluation-generator/src/main.rs Show resolved Hide resolved
triton-vm/src/air.rs Outdated Show resolved Hide resolved
triton-vm/src/air/memory_layout.rs Outdated Show resolved Hide resolved
triton-vm/src/table.rs Outdated Show resolved Hide resolved
@jan-ferdinand jan-ferdinand force-pushed the asz/dynamic-ood-location-2 branch 2 times, most recently from e2541de to dab8af8 Compare August 14, 2024 10:42
Copy and paste is a root of evil.

Also, repair the broken abstraction of the `Codegen` trait.

changelog: ignore
If the constraints are not in place, the corresponding error message is
well suited to figure out what is going on. Since this is a test, not a
piece of production code, that's all that's needed. Adding special
error handling logic, especially with the to-be-avoided “catch_unwind”,
is overkill.

changelog: ignore
- introduce `const`s to remove random magic numbers
- replace copy-pasted code with closures
- use canonical methods of ad-hoc interpretation
- reduce nesting level on happy path through early returns
- etc.

changelog: ignore
@jan-ferdinand jan-ferdinand merged commit 33bc62c into master Aug 14, 2024
5 checks passed
@jan-ferdinand jan-ferdinand deleted the asz/dynamic-ood-location-2 branch August 14, 2024 12:42
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