Simplify MuxTableTarget, cheaper query hashes#528
Merged
Conversation
ed255
approved these changes
Jun 23, 2026
ed255
left a comment
Collaborator
There was a problem hiding this comment.
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, |
Collaborator
There was a problem hiding this comment.
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
| } | ||
|
|
||
| fn hash_statement_query(builder: &mut CircuitBuilder, st: &StatementTarget) -> HashOutTarget { | ||
| fn hash_statement_query(builder: &mut CircuitBuilder, st_hash: &HashOutTarget) -> HashOutTarget { |
Collaborator
There was a problem hiding this comment.
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.
ed255
approved these changes
Jun 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #527
Two related changes to the operation aux-table machinery, building on #504:
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 hashingstatement_hash (4) + op_type (6) + op_arg_hashes (N*4), where those component hashes are reused from work the circuit already does (vec_ref_projectednow returns the hash it computes;statement_hashes[i]is already available).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.
MuxTableTargetstores query hashes directly,getreturns a bareHashOutTarget, andTableEntryTargetis removed. This addresses issue Simplify MuxTableTarget #527.Collapsing the indirection drops the per-row
OperationAuxTableTagand the per-verify tag check. That is sound because domain separation now lives entirely in the query hash: everyhash_*_queryhelper routes throughoperation_aux_query_hash, which prepends a uniqueOperationAuxQueryKind.Removing this indirection reduces gate count by 2200 or so.