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: ClientIvc recursive verifier #6721

Merged
merged 19 commits into from
May 31, 2024
Merged

Conversation

ledwards2225
Copy link
Contributor

@ledwards2225 ledwards2225 commented May 28, 2024

Adds a ClientIvc recursive verifier which currently consists only of a PG rec verifier and Decider rec verifier. A goblin recursive verifier will be implemented in a separate PR then added to this work to complete the ClientIvc recursive verifier.

@ledwards2225 ledwards2225 self-assigned this May 28, 2024
@AztecBot
Copy link
Collaborator

AztecBot commented May 28, 2024

Benchmark results

Metrics with a significant change:

  • protocol_circuit_witness_generation_time_in_ms (base-parity): 894 (-17%)
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_ms 5,711 1,561 708 (-1%) 752 (-1%) 772 (-1%)
proof_construction_time_sha256_30_ms 11,393 (-1%) 3,066 (-1%) 1,373 (-2%) 1,406 (-1%) 1,464 (-1%)
proof_construction_time_sha256_100_ms 43,784 (-1%) 11,716 (-2%) 5,454 (-3%) 5,406 (-2%) 5,357 (-2%)
proof_construction_time_poseidon_hash_ms 78.0 34.0 34.0 57.0 (-2%) 88.0
proof_construction_time_poseidon_hash_30_ms 1,515 416 199 (-1%) 227 (-1%) 265 (-1%)
proof_construction_time_poseidon_hash_100_ms 5,738 1,556 (-2%) 724 (-1%) 786 790 (-2%)

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,281 4,810 9,538
l2_block_building_time_in_ms 44,025 (-1%) 174,233 (-1%) 349,305 (-1%)
l2_block_rollup_simulation_time_in_ms 43,828 (-1%) 173,491 (-1%) 347,841 (-1%)
l2_block_public_tx_process_time_in_ms 38,094 (-1%) 170,151 341,898 (-1%)

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,538 (+1%) 14,615 (+1%)
node_database_size_in_bytes 14,495,824 21,364,816
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 135 (-1%) 495 (-1%) 11,979 20,634 64,614 89,536 2,731 524,288
private-kernel-inner 407 1,003 (-1%) 45,239 92,326 64,614 89,536 2,731 2,097,152
private-kernel-tail 585 (-1%) 2,808 (-2%) 47,453 96,545 77,732 11,648 297 2,097,152
base-parity 6.62 (+2%) ⚠️ 894 (-17%) 2,810 (+1%) 128 64.0 2,208 2.00 131,072
root-parity 50.3 51.6 (+10%) 34,285 (+1%) 27,100 64.0 2,720 18.0 2,097,152
base-rollup 9,098 2,362 64,911 119,738 756 3,648 47.0 4,194,304
root-rollup 113 (+1%) 63.2 (-4%) 19,602 25,309 620 3,456 41.0 1,048,576
public-kernel-app-logic 570 (-1%) 3,555 38,769 108,073 86,550 116,768 3,582 2,097,152
public-kernel-tail 1,128 21,133 (-11%) 154,861 403,238 7,646 11,648 297 8,388,608
private-kernel-reset-small 589 (-1%) 2,120 40,718 120,737 64,614 89,536 2,731 2,097,152
public-kernel-setup 677 (+1%) 2,691 37,430 108,073 86,550 116,768 3,582 2,097,152
public-kernel-teardown 599 (+2%) 3,604 (+1%) 38,998 108,073 86,550 116,768 3,582 2,097,152
merge-rollup 31.2 (-3%) N/A N/A 16,542 756 N/A N/A N/A
private-kernel-tail-to-public N/A 8,864 (+1%) 87,044 (+1%) N/A N/A 116,768 3,582 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 467 (+1%) N/A N/A N/A N/A
ContractInstanceDeployer:deploy 1,408 9,944 42.1 N/A N/A N/A N/A
MultiCallEntrypoint:entrypoint 1,920 9,944 1,887 (+5%) N/A N/A N/A N/A
SchnorrAccount:constructor 1,312 9,944 1,589 (+9%) N/A N/A N/A N/A
SchnorrAccount:entrypoint 2,304 9,944 2,774 (+1%) 16,768 50,070 2,097,152 457
Token:privately_mint_private_note 1,280 9,944 1,659 N/A N/A N/A N/A
FPC:fee_entrypoint_public 1,344 9,944 1,130 16,768 10,026 524,288 457
Token:transfer 1,376 9,944 6,141 (+13%) 16,768 48,187 2,097,152 457
Benchmarking:create_note 1,344 9,944 1,394 N/A N/A N/A N/A
SchnorrAccount:spend_private_authwit 1,280 9,944 77.1 N/A N/A N/A N/A
Token:unshield 1,376 9,944 4,018 (+3%) N/A N/A N/A N/A
FPC:fee_entrypoint_private 1,376 9,944 4,899 (+2%) 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.5 (+1%) 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.609 (+1%) 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 49.2 (+1%) 76.5 247 479 (+1%) 928 1,838 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.502 (+1%) 0.471 0.448 0.447 (+1%) 0.440 0.439 N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 58.6 113 (+1%) 356 705 (+1%) 1,385 2,762 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.482 0.483 (+1%) 0.478 0.480 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 63.2 (+1%)
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.558

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 84,053 665,267

Transaction size based on fee payment method

| Metric | |
| - | |

@ledwards2225 ledwards2225 marked this pull request as ready for review May 29, 2024 19:59
@ledwards2225 ledwards2225 requested a review from maramihali May 29, 2024 20:00
Copy link
Collaborator

@AztecBot AztecBot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'C++ Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.05.

Benchmark suite Current: fd1ba5f Previous: 7b420cd Ratio
nativeconstruct_proof_ultrahonk_power_of_2/20 6036.137139999993 ms/iter 5497.058484000007 ms/iter 1.10

This comment was automatically generated by workflow using github-action-benchmark.

CC: @ludamad @codygunton

Copy link
Contributor

@maramihali maramihali left a comment

Choose a reason for hiding this comment

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

Looks good! just a couple of tiny comments :)


namespace bb::stdlib::recursion::honk {

void ClientIvcRecursiveVerifier_::verify(const ClientIVC::Proof& proof, VerifierInput& data)
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 we settle on either IVC or Ivc when it comes to naming

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated to IVC

// Perform recursive folding verification
FoldingVerifier folding_verifier{ builder, data };
auto recursive_verifier_accumulator = folding_verifier.verify_folding_proof(proof.folding_proof);
auto native_verifier_acc = std::make_shared<VerifierInput::Instance>(recursive_verifier_accumulator->get_value());
Copy link
Contributor

Choose a reason for hiding this comment

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

thinking out loud: if these two would share the same builder we wouldn't have to call get_value here. But probably not worth investing time atm, especially since we're not sure what's gonna happen when adding ZK

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah not a top priority but I agree, might make sense to have these two more integrated. Currently we might be duplicating the final accumulator in the witness doing it this way

#include "barretenberg/stdlib/honk_recursion/verifier/decider_recursive_verifier.hpp"

namespace bb::stdlib::recursion::honk {
class ClientIvcRecursiveVerifier_ {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder whether we should template this by builder.. unlikely we're going to use MegaCircuitBuilder but it's worth having the mechanism to quickly switch

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 don't think this is worth doing, at least not until we need it. Using mega requires using Goblin so it changes the whole dynamic of what this class does

// Generate the recursive verification circuit
verifier.verify(proof, verifier_input);

EXPECT_TRUE(CircuitChecker::check(builder));
Copy link
Contributor

Choose a reason for hiding this comment

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

can you also make sure we can do full proving and verification of the client ivc recursive verifier in this test

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 can but ideally we won't do full proof construction in these test since it'll be very time consuming. CheckCircuit should be nearly just as good and a couple orders of magnitude faster

@ledwards2225 ledwards2225 enabled auto-merge (squash) May 30, 2024 16:37
Copy link
Contributor

Changes to circuit sizes

Generated at commit: 4085551d5e20dd93c4bd789efdcc971ec4a21285, compared to commit: bd64cebcbb2d66a328cce2aebf9ea5b8fb1f8793

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
public_kernel_app_logic +30,688 ❌ +11.56% +152,884 ❌ +9.01%
public_kernel_teardown +30,688 ❌ +11.55% +152,884 ❌ +9.01%
public_kernel_setup +20,176 ❌ +8.97% +102,292 ❌ +6.60%
public_kernel_tail +3,338 ❌ +0.34% +6,110 ❌ +0.14%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
public_kernel_app_logic 296,133 (+30,688) +11.56% 1,849,160 (+152,884) +9.01%
public_kernel_teardown 296,490 (+30,688) +11.55% 1,849,558 (+152,884) +9.01%
public_kernel_setup 245,094 (+20,176) +8.97% 1,651,834 (+102,292) +6.60%
public_kernel_tail 983,135 (+3,338) +0.34% 4,475,643 (+6,110) +0.14%

@ledwards2225 ledwards2225 merged commit ceec7e2 into master May 31, 2024
33 checks passed
@ledwards2225 ledwards2225 deleted the lde/clientivc_rec_verifier branch May 31, 2024 13:46
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