Skip to content

feat(avm2): avm redesign init#10906

Merged
fcarreiro merged 6 commits into
masterfrom
fc/vm2-prototype
Jan 11, 2025
Merged

feat(avm2): avm redesign init#10906
fcarreiro merged 6 commits into
masterfrom
fc/vm2-prototype

Conversation

@fcarreiro

@fcarreiro fcarreiro commented Dec 20, 2024

Copy link
Copy Markdown
Contributor

This is a redesign of the witgen/proving part of the AVM. There's still a lot of work to be done, but I have to merge at some point to let others contribute :). Most of the content is PoC, not supposed to be real.

We'll eventually have a doc explaining everything, but for now, some highlights:

Architecture

The proving process is now divided in 3 parts:

  • Simulation (aka event generation): Intrinsically sequential. Executes bytecode and generates packed information (events) that summarize what happened. Examples would be a bytecode decomposition event, memory access event, etc. This part has no dependencies on BB or PIL beyond FF. It also has, in principle, no knowledge of the circuit or columns.
  • Trace generation: This part is parallelizable. The meat of it is translating events into columns in a (sparse!) trace. It is the glue between events and the circuit. It has knowledge of the columns, but not really about any relation or constrain (**) or PIL.
  • Constraining: This is parallelizable. It's the actual constraining/proving/check circuit. It's dependent on BB and the (currently) autogenerated relations from PIL. We convert the sparse trace to polynomials.

Possible future standalone simulation

Hints and DB accesses: The simulation/witgen process has no knowledge of hints (so far). We define a DB interface which the simulation process uses. This DB is then "seeded" with hints. This means that in the future it should be possible to switch the DB to a real DB and things should "just work™️".

I think we should try to follow this philosophy as much as possible and not rely on TS hints that we can compute ourselves.

Configurability: Other aspects of simulation are configurable. E.g., we can configure a fast simulation only variant that does no event generation and no bytecode hashing whereas for full proving you would do that (incurring in at least 25ms for a single bytecode hashing).

Philosophy

Dependency injection is used everywhere (without framework). You'll see references stored in classes and may not like it, but it's actually working well. See https://www.youtube.com/watch?v=kCYo2gJ3Y38 as well.

There are lots of interfaces for mocking. Blame C++ 🤷 .

I'm making it a priority to have the right separation of concerns and engineering practices. There's zero tolerance on hacks. If we need a hack, we trigger a refactor.

Testing

Whereas before our tests required setting up everything and basically do full proving or check circuit, now everything can be tested separately. We use a mockist approach (common in C++). Our old tests would take ~0.5s each, now they take microseconds. Simulation, tracegen, and constraining can be tested separate from each other. In particular, you can create tests for constraints at the relation or subrelation level.

Lookups/permutations

Not really supported yet. But you don't need to keep counts for lookups.

TS/C++ communication

AVM inputs are now (de)serialized with messagepack.

(**) It does require lookup/permutation settings.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-avm Component: AVM related tickets (aka public VM)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants