Skip to content

Simplify MuxTableTarget, cheaper query hashes#528

Merged
robknight merged 2 commits into
mainfrom
simplify_mux_table_target
Jun 24, 2026
Merged

Simplify MuxTableTarget, cheaper query hashes#528
robknight merged 2 commits into
mainfrom
simplify_mux_table_target

Conversation

@robknight

@robknight robknight commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Closes #527

Two related changes to the operation aux-table machinery, building on #504:

  1. Cheaper query hashes. The custom-predicate and open-input-statement aux queries now hash over already-materialized component hashes instead of re-flattening wide statement structures. The custom query went from hashing a ~314-element flattening of (statement, op_type, op_args) to hashing statement_hash (4) + op_type (6) + op_arg_hashes (N*4), where those component hashes are reused from work the circuit already does (vec_ref_projected now returns the hash it computes; statement_hashes[i] is already available).

  2. Collapse the aux-table indirection. With every entry now a 4-element query hash, the table no longer needs the generic hash-and-unhash layer it inherited. MuxTableTarget stores query hashes directly, get returns a bare HashOutTarget, and TableEntryTarget is removed. This addresses issue Simplify MuxTableTarget #527.

Collapsing the indirection drops the per-row OperationAuxTableTag and the per-verify tag check. That is sound because domain separation now lives entirely in the query hash: every hash_*_query helper routes through operation_aux_query_hash, which prepends a unique OperationAuxQueryKind.

Removing this indirection reduces gate count by 2200 or so.

@robknight robknight requested a review from ed255 June 22, 2026 15:44

@ed255 ed255 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! It's a very nice optimization to reuse the hashed statements and operation arguments for the queries to the aux table.

I've left 2 minor requests, please take a look.

OpenInputStatement = 5,
PublicKeyOf = 6,
SignedBy = 7,
CustomPredVerify = 8,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a nitpick, but could you move this one to position 5 (and value 5), so that it matches the order in the table?
See

Self::OpenInputStatement(i) => Self::table_offset_open_input_statement(params) + *i,

}

fn hash_statement_query(builder: &mut CircuitBuilder, st: &StatementTarget) -> HashOutTarget {
fn hash_statement_query(builder: &mut CircuitBuilder, st_hash: &HashOutTarget) -> HashOutTarget {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

would you mind renaming this method to hash_open_input_statement_query? I realized this method uses the OperationAuxQueryKind::OpenInputStatement so it's more specific than just hashing a statement.

@robknight robknight merged commit 7a3f2c1 into main Jun 24, 2026
6 checks passed
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.

Simplify MuxTableTarget

2 participants