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: representation of a grumpkin verifier commitment key inside a bn254 circuit #6593

Merged
merged 7 commits into from
May 22, 2024

Conversation

maramihali
Copy link
Contributor

@maramihali maramihali commented May 22, 2024

This PR creates a representation of Grumpkin VerifierCommitmentKey inside a bn254 circuit and ensure consistency with native part. This is necessary to enable IPA verification in the recursive setting. I took a minimalist approach and excluded the pippenger_runtime_state as we will initially do MSMs in the IPA verifier via batch_mul. This is because pippenger needs to be rewritten to be usable in a recursive settings. I also restricted access to the VerifierSrs via member functions in the native VerifierCommitmentKey. This work is a step towards the ECCVM recursive verifier.

@maramihali maramihali self-assigned this May 22, 2024
@maramihali maramihali added the crypto cryptography label May 22, 2024
Copy link
Contributor

@ledwards2225 ledwards2225 left a comment

Choose a reason for hiding this comment

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

LG, just pointed out one typo

auto recursive_vk = std::make_shared<VK>(&builder, num_points, native_vk);
EXPECT_EQ(native_vk->get_first_g1(), recursive_vk->get_first_g1().get_value());
auto* native_monomial_points = native_vk->get_monomial_points();
auto recursive_monomial_ponts = recursive_vk->get_monomial_points();
Copy link
Contributor

Choose a reason for hiding this comment

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

points*

@AztecBot
Copy link
Collaborator

AztecBot commented May 22, 2024

Benchmark results

No base data found for comparison.

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,695 1,563 706 754 774

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 772 772 772
l1_rollup_calldata_gas 6,856 6,868 6,880
l1_rollup_execution_gas 587,396 587,408 587,420
l2_block_processing_time_in_ms 1,360 5,067 10,070
l2_block_building_time_in_ms 32,287 127,705 254,307
l2_block_rollup_simulation_time_in_ms 32,115 127,060 253,051
l2_block_public_tx_process_time_in_ms 16,676 69,522 141,748

L2 chain processing

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

Metric 5 blocks 10 blocks
node_history_sync_time_in_ms 15,398 28,540
node_database_size_in_bytes 21,258,320 37,896,272
pxe_database_size_in_bytes 29,868 12,535

Circuits stats

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

Circuit protocol_circuit_simulation_time_in_ms protocol_circuit_witness_generation_time_in_ms protocol_circuit_proving_time_in_ms protocol_circuit_input_size_in_bytes protocol_circuit_output_size_in_bytes protocol_circuit_proof_size_in_bytes protocol_circuit_num_public_inputs protocol_circuit_size_in_gates
private-kernel-init 161 3,639 21,278 19,985 61,999 86,720 2,643 1,048,576
private-kernel-inner 612 5,048 40,310 89,053 61,999 86,720 2,643 2,097,152
private-kernel-reset-small 579 2,655 23,707 117,961 61,999 86,720 2,643 1,048,576
private-kernel-tail 535 2,883 39,792 86,849 78,838 10,624 265 2,097,152
base-parity 6.58 1,567 3,768 128 64.0 2,208 2.00 131,072
root-parity 49.7 60.5 41,606 27,064 64.0 2,720 18.0 2,097,152
base-rollup 743 2,409 43,675 112,602 957 3,136 31.0 2,097,152
root-rollup 94.0 47.9 8,304 11,518 821 3,456 41.0 524,288
public-kernel-app-logic 244 178 933 96,850 84,967 116,320 3,568 4,096
public-kernel-tail 871 531 913 388,084 7,691 10,112 249 512
public-kernel-setup 223 149 950 143,141 84,967 116,320 3,568 4,096
public-kernel-teardown 226 214 1,032 143,141 84,967 116,320 3,568 4,096
merge-rollup 6.51 17.4 1,575 2,760 957 3,136 31.0 65,536
private-kernel-tail-to-public N/A 9,814 72,668 N/A N/A 116,832 3,584 4,194,304

Stats on running time collected for app circuits

Function app_circuit_proof_size_in_bytes app_circuit_proving_time_in_ms app_circuit_size_in_gates app_circuit_num_public_inputs
SchnorrAccount:entrypoint 16,128 48,992 2,097,152 437
Test:emit_nullifier 16,128 2,236 65,536 437
FPC:fee_entrypoint_public 16,128 8,325 524,288 437
FPC:fee_entrypoint_private 16,128 9,011 524,288 437
Token:unshield 16,128 50,614 2,097,152 437
SchnorrAccount:spend_private_authwit 16,128 2,641 131,072 437
Token:transfer 16,128 34,843 2,097,152 437

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 11.3 18.3 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.658 0.563 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 52.1 81.5 263 506 993 1,967 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.534 0.503 0.479 0.473 0.471 0.470 N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 62.8 120 377 744 1,469 2,928 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.547 0.540 0.513 0.511 0.510 0.509 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 67.7
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 108
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.594

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,613 664,966

Transaction size based on fee payment method

| Metric | |
| - | |

Transaction processing duration by data writes.

Metric 0 new note hashes 1 new note hashes 2 new note hashes
tx_pxe_processing_time_ms 27,402 4,305 122,546
Metric 0 public data writes 1 public data writes 2 public data writes 3 public data writes 4 public data writes 8 public data writes
tx_sequencer_processing_time_ms 1,350 2,233 1,514 4,164 1,687 1,991

@maramihali maramihali enabled auto-merge (squash) May 22, 2024 13:35
Copy link
Contributor

github-actions bot commented May 22, 2024

Changes to circuit sizes

Generated at commit: cea5afbe15dbf08055ca60ef43cbcd0635785f9b, compared to commit: bd0ae422e9f1b7e955c9b68b4a5238b248e128d4

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
rollup_base +9,914 ❌ +5.47% +29,611 ❌ +1.67%
private_kernel_tail -2 ✅ -0.00% -4 ✅ -0.00%
private_kernel_tail_to_public -4 ✅ -0.00% -8 ✅ -0.00%
public_kernel_teardown -160 ✅ -0.07% -300 ✅ -0.04%
public_kernel_setup -160 ✅ -0.07% -300 ✅ -0.04%
public_kernel_app_logic -200 ✅ -0.08% -360 ✅ -0.05%
private_kernel_tail_to_public_simulated 0 ➖ 0.00% -4 ✅ -0.11%
public_kernel_app_logic_simulated 0 ➖ 0.00% -4 ✅ -0.11%
public_kernel_setup_simulated 0 ➖ 0.00% -4 ✅ -0.11%
public_kernel_teardown_simulated 0 ➖ 0.00% -4 ✅ -0.11%
public_kernel_tail -2,126 ✅ -0.21% -4,928 ✅ -0.13%
private_kernel_tail_simulated 0 ➖ 0.00% -2 ✅ -0.75%
public_kernel_tail_simulated 0 ➖ 0.00% -2 ✅ -0.75%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
rollup_base 191,041 (+9,914) +5.47% 1,806,511 (+29,611) +1.67%
private_kernel_tail 195,031 (-2) -0.00% 1,316,885 (-4) -0.00%
private_kernel_tail_to_public 621,552 (-4) -0.00% 2,147,286 (-8) -0.00%
public_kernel_teardown 223,363 (-160) -0.07% 667,581 (-300) -0.04%
public_kernel_setup 223,157 (-160) -0.07% 667,288 (-300) -0.04%
public_kernel_app_logic 251,697 (-200) -0.08% 796,596 (-360) -0.05%
private_kernel_tail_to_public_simulated 1 (0) 0.00% 3,584 (-4) -0.11%
public_kernel_app_logic_simulated 1 (0) 0.00% 3,584 (-4) -0.11%
public_kernel_setup_simulated 1 (0) 0.00% 3,584 (-4) -0.11%
public_kernel_teardown_simulated 1 (0) 0.00% 3,584 (-4) -0.11%
public_kernel_tail 1,027,305 (-2,126) -0.21% 3,704,913 (-4,928) -0.13%
private_kernel_tail_simulated 1 (0) 0.00% 265 (-2) -0.75%
public_kernel_tail_simulated 1 (0) 0.00% 265 (-2) -0.75%

@maramihali maramihali disabled auto-merge May 22, 2024 13:50
@maramihali maramihali enabled auto-merge (squash) May 22, 2024 13:55
@maramihali maramihali merged commit 1d84975 into master May 22, 2024
73 checks passed
@maramihali maramihali deleted the mm/stdlib-verifier-commitment-key branch May 22, 2024 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto cryptography
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants