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(avm): plumb execution hints from TS to AVM prover #6806

Merged
merged 2 commits into from
Jun 4, 2024

Conversation

dbanks12
Copy link
Contributor

No description provided.

Copy link
Contributor Author

dbanks12 commented May 31, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @dbanks12 and the rest of your teammates on Graphite Graphite

@dbanks12 dbanks12 force-pushed the db/avm-execution-hints-ts branch 2 times, most recently from 5993e34 to fab3145 Compare May 31, 2024 22:27
@AztecBot
Copy link
Collaborator

AztecBot commented May 31, 2024

Benchmark results

Metrics with a significant change:

  • proof_construction_time_sha256_30_ms (16): 1,752 (+22%)
  • protocol_circuit_witness_generation_time_in_ms (base-parity): 1,673 (+89%)
  • protocol_circuit_witness_generation_time_in_ms (root-parity): 60.9 (+31%)
  • protocol_circuit_proving_time_in_ms (private-kernel-tail): 56,374 (+22%)
  • protocol_circuit_proving_time_in_ms (private-kernel-tail-to-public): 102,924 (+21%)
  • protocol_circuit_proving_time_in_ms (base-rollup): 78,504 (+20%)
  • protocol_circuit_proving_time_in_ms (root-parity): 40,395 (+18%)
  • protocol_circuit_proving_time_in_ms (public-kernel-setup): 43,739 (+16%)
  • protocol_circuit_proving_time_in_ms (public-kernel-app-logic): 45,350 (+17%)
  • protocol_circuit_proving_time_in_ms (public-kernel-teardown): 45,657 (+17%)
  • protocol_circuit_proving_time_in_ms (root-rollup): 22,640 (+17%)
  • pxe_database_size_in_bytes (3): 7,774 (-16%)
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,717 (-3%) 1,547 (-3%) 710 (-1%) 747 (-3%) 776 (-2%)
proof_construction_time_sha256_30_ms 11,740 (-5%) 3,165 (-2%) ⚠️ 1,752 (+22%) 1,581 (+8%) 1,549 (+3%)
proof_construction_time_sha256_100_ms 44,810 (-4%) 11,755 (-3%) 5,422 (-2%) 5,411 (-2%) 5,345 (-2%)
proof_construction_time_poseidon_hash_ms 78.0 (-4%) 34.0 (-3%) 34.0 (-3%) 58.0 (-3%) 89.0 (-1%)
proof_construction_time_poseidon_hash_30_ms 1,518 (-4%) 419 (-3%) 201 (-1%) 228 272 (+1%)
proof_construction_time_poseidon_hash_100_ms 5,754 (-3%) 1,567 (-3%) 720 (-2%) 778 (-2%) 796 (-2%)

L2 block published to L1

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

Metric 4 txs 8 txs
l1_rollup_calldata_size_in_bytes 1,412 1,412
l1_rollup_calldata_gas 9,476 9,456
l1_rollup_execution_gas 608,012 607,992
l2_block_processing_time_in_ms 693 (-1%) 1,292
l2_block_building_time_in_ms 22,605 (+2%) 46,297 (+1%)
l2_block_rollup_simulation_time_in_ms 22,362 (+1%) 45,945 (+1%)
l2_block_public_tx_process_time_in_ms 19,177 (+1%) 42,500 (+1%)

L2 chain processing

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

Metric 3 blocks 5 blocks
node_history_sync_time_in_ms 5,998 (+2%) 8,500 (-1%)
node_database_size_in_bytes 9,490,512 12,746,832
pxe_database_size_in_bytes ⚠️ 7,774 (-16%) 15,127

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 137 (+1%) 465 (-7%) 12,855 (+5%) 20,634 64,614 89,536 2,731 524,288
private-kernel-inner 407 (-1%) 936 (-7%) 49,210 (+9%) 92,326 64,614 89,536 2,731 2,097,152
private-kernel-tail 583 2,596 (-8%) ⚠️ 56,374 (+22%) 96,545 68,261 11,648 297 2,097,152
base-parity 6.48 (-2%) ⚠️ 1,673 (+89%) 2,683 (-3%) 128 64.0 2,208 2.00 131,072
root-parity 49.5 (-2%) ⚠️ 60.9 (+31%) ⚠️ 40,395 (+18%) 27,100 64.0 2,720 18.0 2,097,152
base-rollup 6,058 (+2%) 2,362 ⚠️ 78,504 (+20%) 119,738 756 3,648 47.0 4,194,304
root-rollup 109 (-4%) 80.3 (+29%) ⚠️ 22,640 (+17%) 25,309 620 3,456 41.0 1,048,576
public-kernel-app-logic 573 3,426 (-3%) ⚠️ 45,350 (+17%) 108,073 86,550 116,768 3,582 2,097,152
public-kernel-tail 1,142 (-1%) 23,881 (+1%) 176,313 (+15%) 403,238 7,646 11,648 297 8,388,608
private-kernel-reset-small 589 1,922 (-11%) 45,297 (+11%) 120,737 64,614 89,536 2,731 2,097,152
public-kernel-setup 660 (-4%) 2,718 (+1%) ⚠️ 43,739 (+16%) 108,073 86,550 116,768 3,582 2,097,152
public-kernel-teardown 568 (-3%) 3,468 (-2%) ⚠️ 45,657 (+17%) 108,073 86,550 116,768 3,582 2,097,152
merge-rollup 33.4 (+11%) N/A N/A 16,542 756 N/A N/A N/A
private-kernel-tail-to-public N/A 8,274 (-7%) ⚠️ 102,924 (+21%) 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 456 (-3%) N/A N/A N/A N/A
ContractInstanceDeployer:deploy 1,408 9,944 41.3 (-2%) N/A N/A N/A N/A
MultiCallEntrypoint:entrypoint 1,920 9,944 1,767 (-2%) N/A N/A N/A N/A
SchnorrAccount:constructor 1,312 9,944 1,426 (-3%) N/A N/A N/A N/A
SchnorrAccount:entrypoint 2,304 9,944 2,809 (-1%) 16,768 53,285 (+6%) 2,097,152 457
Token:privately_mint_private_note 1,280 9,944 1,564 (-7%) N/A N/A N/A N/A
FPC:fee_entrypoint_public 1,344 9,944 1,016 (-11%) 16,768 10,975 (+9%) 524,288 457
Token:transfer 1,376 9,944 5,305 (-4%) 16,768 52,266 (+10%) 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.7 (-2%) N/A N/A N/A N/A
Token:unshield 1,376 9,944 3,911 (-2%) N/A N/A N/A N/A
FPC:fee_entrypoint_private 1,376 9,944 4,798 (-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 256 leaves 512 leaves 1024 leaves 32 leaves
batch_insert_into_append_only_tree_16_depth_ms 10.4 (-2%) 16.8 (-2%) 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.7 N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.601 (-2%) 0.516 (-2%) 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.4 (-2%) 75.9 (-1%) 131 (-2%) 247 472 (-2%) N/A
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 95.9 159 288 543 1,055 N/A
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.494 (-2%) 0.468 (-1%) 0.450 (-2%) 0.449 0.441 (-2%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 58.5 (-1%) 112 (-1%) 182 (-2%) 352 629 (-1%) N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 107 208 355 686 1,263 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.504 (-1%) 0.502 (-1%) 0.480 (-1%) 0.481 0.469 (-2%) N/A
batch_insert_into_indexed_tree_40_depth_ms N/A N/A N/A N/A N/A N/A N/A 58.8 (-1%)
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A N/A N/A N/A N/A N/A 101
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A N/A N/A N/A N/A N/A 0.549 (-1%)

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 79,470 665,267

Transaction size based on fee payment method

| Metric | |
| - | |

@dbanks12 dbanks12 force-pushed the db/avm-execution-hints-ts branch from fab3145 to 982f5b4 Compare June 1, 2024 01:30
@dbanks12 dbanks12 requested review from fcarreiro and Maddiaa0 June 1, 2024 03:16
@dbanks12 dbanks12 marked this pull request as ready for review June 1, 2024 03:16
@dbanks12
Copy link
Contributor Author

dbanks12 commented Jun 1, 2024

A few caveats with this PR that can be handled in follow-up PRs:

  1. This won't work for nested calls because the trace isn't properly separating hints per call
  2. The PublicCircuitPublicInputs in the test are empty. I guess we need a function to construct it from an AVM context.
  3. We are doing translation between AVM result and PubicExecutionResult in the proving test and that's very ugly

Copy link
Contributor

@fcarreiro fcarreiro left a comment

Choose a reason for hiding this comment

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

In general it looks ok, given the caveats you mention!

std::vector<uint8_t> const avm_public_inputs = read_file(public_inputs_path);
std::vector<uint8_t> avm_hints;
try {
avm_hints = read_file(hints_path);
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels like this PR should include the deserialization of the hints on the CPP side, to be sure that the serde works.

Copy link
Member

Choose a reason for hiding this comment

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

I can do this in a fast followup

@dbanks12 dbanks12 force-pushed the db/avm-execution-hints-ts branch from 982f5b4 to 11b6e5a Compare June 1, 2024 19:26
@dbanks12 dbanks12 force-pushed the db/avm-execution-hints-ts branch from c1c8278 to 2bacc0f Compare June 3, 2024 14:52
@dbanks12 dbanks12 enabled auto-merge (squash) June 3, 2024 15:01
@dbanks12 dbanks12 force-pushed the db/avm-execution-hints-ts branch 2 times, most recently from 4e8d866 to 7a194c4 Compare June 3, 2024 15:57
Copy link
Member

@Maddiaa0 Maddiaa0 left a comment

Choose a reason for hiding this comment

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

lgtm

@dbanks12 dbanks12 force-pushed the db/avm-execution-hints-ts branch 2 times, most recently from ebfda51 to 91f9172 Compare June 3, 2024 17:39
@dbanks12 dbanks12 force-pushed the db/avm-execution-hints-ts branch from 91f9172 to 1139a8d Compare June 4, 2024 10:41
@dbanks12 dbanks12 merged commit f3234f1 into master Jun 4, 2024
88 checks passed
@dbanks12 dbanks12 deleted the db/avm-execution-hints-ts branch June 4, 2024 11:24
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.

4 participants