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

feat: update honk recursion constraint #6545

Merged
merged 15 commits into from
May 28, 2024

Conversation

lucasxia01
Copy link
Contributor

@lucasxia01 lucasxia01 commented May 20, 2024

Closes AztecProtocol/barretenberg#933.

Updates recursion constraint for honk so that it calls the ultra honk recursive verifier.
Removes key hash from the constraint. Also recursively aggregates the aggregation objects.

Ignores the case where we don't have the witness values and want to use dummy witnesses.

Please read contributing guidelines and remove this line.

@lucasxia01 lucasxia01 marked this pull request as draft May 20, 2024 21:09
@lucasxia01 lucasxia01 self-assigned this May 20, 2024
@AztecBot
Copy link
Collaborator

AztecBot commented May 20, 2024

Benchmark results

No metrics with a significant change found.

Detailed results

All benchmarks are run on txs on the Benchmarking contract on the repository. Each tx consists of a batch call to create_note and increment_balance, which guarantees that each tx has a private call, a nested private call, a public call, and a nested public call, as well as an emitted private note, an unencrypted log, and public storage read and write.

This benchmark source data is available in JSON format on S3 here.

Proof generation

Each column represents the number of threads used in proof generation.

Metric 1 threads 4 threads 16 threads 32 threads 64 threads
proof_construction_time_sha256 5,780 (-1%) 1,551 (-1%) 712 (-1%) 784 781 (+1%)

L2 block published to L1

Each column represents the number of txs on an L2 block published to L1.

Metric 8 txs 32 txs 64 txs
l1_rollup_calldata_size_in_bytes 1,412 1,412 1,412
l1_rollup_calldata_gas 9,464 9,464 9,464
l1_rollup_execution_gas 616,105 616,105 616,105
l2_block_processing_time_in_ms 1,278 (-1%) 4,787 (-1%) 9,489 (-2%)
l2_block_building_time_in_ms 44,826 177,900 355,421
l2_block_rollup_simulation_time_in_ms 44,657 177,272 354,082
l2_block_public_tx_process_time_in_ms 24,053 100,711 205,680

L2 chain processing

Each column represents the number of blocks on the L2 chain where each block has 16 txs.

Metric 3 blocks 5 blocks
node_history_sync_time_in_ms 9,488 14,444
node_database_size_in_bytes 14,499,920 21,348,432
pxe_database_size_in_bytes 18,071 29,868

Circuits stats

Stats on running time and I/O sizes collected for every kernel circuit run across all benchmarks.

Circuit simulation_time_in_ms witness_generation_time_in_ms proving_time_in_ms input_size_in_bytes output_size_in_bytes proof_size_in_bytes num_public_inputs size_in_gates
private-kernel-init 161 (+1%) 3,719 (-1%) 22,149 (+1%) 20,630 64,614 89,536 2,731 1,048,576
private-kernel-inner 621 4,284 (-1%) 46,309 92,318 64,614 89,536 2,731 2,097,152
private-kernel-tail 567 2,922 (-1%) 35,917 96,541 77,498 10,656 266 2,097,152
base-parity 6.56 1,233 (+8%) 2,915 128 64.0 2,208 2.00 131,072
root-parity 49.8 (-1%) 48.7 44,848 (+2%) 27,084 64.0 2,720 18.0 2,097,152
base-rollup 725 (-3%) 2,291 (+1%) 74,826 (+1%) 119,610 756 3,648 47.0 4,194,304
root-rollup 112 65.9 (+1%) 19,922 (+1%) 25,297 620 3,456 41.0 1,048,576
public-kernel-app-logic 521 2,986 47,067 (-2%) 104,941 86,302 114,784 3,520 2,097,152
public-kernel-tail 1,080 23,171 (+1%) 154,813 395,386 7,522 10,656 266 8,388,608
private-kernel-reset-small 591 2,108 (-3%) 45,501 (+1%) 120,733 64,614 89,536 2,731 2,097,152
merge-rollup 29.0 N/A N/A 16,534 756 N/A N/A N/A
public-kernel-setup 626 N/A N/A 104,941 86,302 N/A N/A N/A
public-kernel-teardown 529 N/A N/A 104,941 86,302 N/A N/A N/A
private-kernel-tail-to-public N/A 8,835 92,821 N/A N/A 114,784 3,520 4,194,304

Stats on running time collected for app circuits

Function input_size_in_bytes output_size_in_bytes witness_generation_time_in_ms proof_size_in_bytes proving_time_in_ms size_in_gates num_public_inputs
ContractClassRegisterer:register 1,344 9,944 472 (+1%) N/A N/A N/A N/A
ContractInstanceDeployer:deploy 1,408 9,944 42.3 (+1%) N/A N/A N/A N/A
MultiCallEntrypoint:entrypoint 1,920 9,944 1,446 N/A N/A N/A N/A
SchnorrAccount:constructor 1,312 9,944 1,005 (+1%) N/A N/A N/A N/A
SchnorrAccount:entrypoint 2,304 9,944 2,086 16,768 51,316 (+1%) 2,097,152 457
Token:privately_mint_private_note 1,280 9,944 1,146 N/A N/A N/A N/A
Token:transfer 1,376 9,944 4,071 16,768 53,630 (+1%) 2,097,152 457
Benchmarking:create_note 1,312 9,944 951 N/A N/A N/A N/A
FPC:fee_entrypoint_public 1,344 9,944 221 (+1%) N/A N/A N/A N/A
SchnorrAccount:spend_private_authwit 1,280 9,944 77.5 N/A N/A N/A N/A
Token:unshield 1,376 9,944 3,253 N/A N/A N/A N/A
FPC:fee_entrypoint_private 1,376 9,944 4,027 N/A N/A N/A N/A

Tree insertion stats

The duration to insert a fixed batch of leaves into each tree type.

Metric 1 leaves 16 leaves 64 leaves 128 leaves 512 leaves 1024 leaves 2048 leaves 4096 leaves 32 leaves
batch_insert_into_append_only_tree_16_depth_ms 10.4 (-2%) 17.0 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_count 16.7 31.8 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.606 (-2%) 0.521 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 48.5 75.7 (-1%) 247 474 927 (-1%) 1,829 (-1%) N/A
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 95.9 159 543 1,055 2,079 4,127 N/A
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.496 0.467 (-1%) 0.448 0.443 0.439 (-1%) 0.438 (-1%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 58.5 113 (+1%) 355 699 1,385 2,756 (-1%) N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 106 208 692 1,363 2,707 5,395 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.507 0.505 0.481 0.480 0.479 0.478 (-1%) N/A
batch_insert_into_indexed_tree_40_depth_ms N/A N/A N/A N/A N/A N/A N/A N/A 62.4
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A N/A N/A N/A N/A N/A N/A 107
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A N/A N/A N/A N/A N/A N/A 0.553

Miscellaneous

Transaction sizes based on how many contract classes are registered in the tx.

Metric 0 registered classes 1 registered classes
tx_size_in_bytes 83,794 665,117

Transaction size based on fee payment method

| Metric | |
| - | |

std::array<uint32_t, HonkRecursionConstraint::AGGREGATION_OBJECT_SIZE> nested_aggregation_object = {};
// If the proof has public inputs attached to it, we should handle setting the nested aggregation object
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure how to replace this check that the aggregation object is there. Maybe impossible given proof sizes are variable.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is not possible given the proof sizes are variable. If we add some way to attach constant metadata to the opcode we should be able to determine this as well as other information about the proof (like which verifier we want to use)

@lucasxia01 lucasxia01 marked this pull request as ready for review May 23, 2024 21:10
@@ -26,7 +26,7 @@ template <typename Flavor> class UltraVerifier_ {
bool verify_proof(const HonkProof& proof);

std::shared_ptr<VerificationKey> key;
std::shared_ptr<Transcript> transcript;
std::shared_ptr<Transcript> transcript; // this seems useless
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll leave a todo here I guess


// TODO(luke): Eventually this will return something like aggregation_state but I'm simplifying for now until we
// determine the exact interface. Simply returns the two pairing points.
PairingPoints verify_proof(const HonkProof& proof);
PairingPoints verify_proof(const StdlibProof<Builder>& proof);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

just a new function that allows you directly pass in a stdlib proof

@lucasxia01 lucasxia01 requested a review from vezenovm May 23, 2024 22:34
Copy link
Contributor

@vezenovm vezenovm left a comment

Choose a reason for hiding this comment

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

I like the use of one aggregation object in the constraint, simplifies the mental model. Mostly nits

@lucasxia01 lucasxia01 requested a review from vezenovm May 24, 2024 18:55
Copy link
Contributor

@vezenovm vezenovm left a comment

Choose a reason for hiding this comment

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

LGTM. Just noting that we will need to test this against prove THEN verify rather than just prove AND verify to test we pass in the case of invalid witness assignments

std::array<uint32_t, HonkRecursionConstraint::AGGREGATION_OBJECT_SIZE> nested_aggregation_object = {};
// If the proof has public inputs attached to it, we should handle setting the nested aggregation object
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is not possible given the proof sizes are variable. If we add some way to attach constant metadata to the opcode we should be able to determine this as well as other information about the proof (like which verifier we want to use)

@lucasxia01 lucasxia01 merged commit 6f86352 into master May 28, 2024
85 checks passed
@lucasxia01 lucasxia01 deleted the lx/honk-recursion-constraint-2 branch May 28, 2024 22:04
TomAFrench added a commit that referenced this pull request May 29, 2024
* master:
  feat: prepare circuit output for validation (#6678)
  chore: stop building/publishing `acvm_backend.wasm` (#6584)
  chore: add bench programs (#6566)
  chore: make public data update requests, note hashes, and unencrypted logs readonly in TS (#6658)
  git subrepo push --branch=master noir-projects/aztec-nr
  git_subrepo.sh: Fix parent in .gitrepo file. [skip ci]
  chore: replace relative paths to noir-protocol-circuits
  git subrepo push --branch=master barretenberg
  feat: update honk recursion constraint (#6545)
  feat: Add code-workspace and update build dirs (#6723)
  feat: Sync from noir (#6717)
  feat: folding acir programs (#6685)
  feat: sumcheck part of ECCVM recursive verifier instantiated as an UltraCircuit (#6413)
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.

Update recursion_constraint.hpp/cpp for Honk
3 participants