Skip to content

Split aux tables based on size#504

Open
robknight wants to merge 3 commits into
mainfrom
split-aux-tables
Open

Split aux tables based on size#504
robknight wants to merge 3 commits into
mainfrom
split-aux-tables

Conversation

@robknight
Copy link
Copy Markdown
Collaborator

The aux table holds supporting data for certain operations, including Merkle container and state transition ops, SignedBy, PublicKeyOf, and custom predicate operations. It has a fixed row size, based on the largest possible value. Most aux table entries are quite small - MerkleTreeStateTransitionClaimTarget is 18 field elements, and all others are smaller. However, CustomPredicateVerifyQueryTarget is 314 field elements. Because of this outlier, the table rows are much larger than is needed for typical cases, making lookups more expensive than they need to be.

This change splits CustomPredicateVerifyQueryTarget out:

  • General aux table now only carries Merkle / pubkey / signature / state-transition entries — narrower rows, fewer Poseidon constraints per lookup.
  • A second table (custom_pred_verify_hashes) stores just the query hash for each CustomPredVerify entry, indexed by the same aux_index.
  • verify_custom_circuit looks up the stored hash and compares it to a freshly-computed hash of (statement, op_type, op_args), instead of unhashing a wide row and doing flattened equality.

Both tables are identical in length (every push to one is paired with a None padding push to the other), enforced via helpers on a new OperationAuxTables struct.

This reduces measured gate count by 3445.

@robknight robknight requested a review from ax0 April 29, 2026 09:36
@ed255
Copy link
Copy Markdown
Collaborator

ed255 commented May 20, 2026

If I understand this correctly, the saving comes from replacing:

  • an is_equal_flattenable over 314 elements (CustomPredicateVerifyQueryTarget)
    by
  • an is_equal_flattenable over 4 elements (HashOutTarget) + an extra lookup over a table of hashes

I wonder if we can apply this change for all cases, and we can move back to a single table.

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.

3 participants