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

Trace sorting: Construct circuit as array<TraceBlock, N> #862

Closed
ledwards2225 opened this issue Feb 20, 2024 · 0 comments · Fixed by AztecProtocol/aztec-packages#4741
Closed
Assignees
Milestone

Comments

@ledwards2225
Copy link
Collaborator

ledwards2225 commented Feb 20, 2024

Instead of having a single {wires, selectors} "block" in the builders that holds all conventional gate data, we will have builder.trace_blocks which is an array<TraceBlock, NUM_BLOCKS>, where each TraceBlock contains {wires, selectors}. NUM_BLOCKS is the number of blocks for a given Flavor, determined by the number of gate types plus the number of special blocks like public inputs or a zero row. A "sorted" execution trace is achieved by iterating over the trace_blocks and populating the data in the trace polynomials, i.e. wire polys, selector polys, and permutation argument polys.

The TraceBlock and the logic for converting trace_blocks to polynomials is already in place. This work specifically involves restructuring the builder to populate trace_blocks and dealing with any issue that arise in that process. This has to work for all variants of Plonk/Honk.

Note: this work may also include some cleanup tasks left over from an earlier PR, such as moving more content into the trace generation method.

@ledwards2225 ledwards2225 self-assigned this Feb 20, 2024
ledwards2225 added a commit to AztecProtocol/aztec-packages that referenced this issue Feb 27, 2024
Introduces the pattern for constructing an execution trace sorted by
gate type. The single {`wires`, `selectors`} pair in the builders is
replaced by a `GateBlocks` type which has one {`wires`, `selectors`}
pair or "ExecutionTraceBlock" per gate type. The classes in
arithmetization.hpp have been updated to describe this structure.

This PR does not yet fully break the gates up by gate type. For example
the Goblin ultra builder still only has three blocks: ecc op gates,
public inputs, and "main" (everything else). This results in the exact
same execution trace that is currently constructed in master. In
principle, the full sorting amounts to simply adding gates to their
particular block instead of `main`. This will be done in a follow on.

This PR also makes modifications to the check_circuit functionality in
the Ultra builder. Previously, there was a fair bit of logic for storing
the pre-finalized state of the circuit so that it could be returned to
its original state after finalizing and checking. This has been replaced
by simply copying the circuit via its constructor, then ultimately
resetting it using this copy. This is a bit less efficient but
simplifies the logic substantially. (I have another follow on that will
further simplify, improve efficiency, and move the check circuit logic
to a separate class).

Closes AztecProtocol/barretenberg#862
AztecBot pushed a commit that referenced this issue Feb 28, 2024
Introduces the pattern for constructing an execution trace sorted by
gate type. The single {`wires`, `selectors`} pair in the builders is
replaced by a `GateBlocks` type which has one {`wires`, `selectors`}
pair or "ExecutionTraceBlock" per gate type. The classes in
arithmetization.hpp have been updated to describe this structure.

This PR does not yet fully break the gates up by gate type. For example
the Goblin ultra builder still only has three blocks: ecc op gates,
public inputs, and "main" (everything else). This results in the exact
same execution trace that is currently constructed in master. In
principle, the full sorting amounts to simply adding gates to their
particular block instead of `main`. This will be done in a follow on.

This PR also makes modifications to the check_circuit functionality in
the Ultra builder. Previously, there was a fair bit of logic for storing
the pre-finalized state of the circuit so that it could be returned to
its original state after finalizing and checking. This has been replaced
by simply copying the circuit via its constructor, then ultimately
resetting it using this copy. This is a bit less efficient but
simplifies the logic substantially. (I have another follow on that will
further simplify, improve efficiency, and move the check circuit logic
to a separate class).

Closes #862
@codygunton codygunton added this to the Trace Sorting milestone Feb 29, 2024
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 a pull request may close this issue.

2 participants