aztec-packages icon indicating copy to clipboard operation
aztec-packages copied to clipboard

feat(avm): range check gadget

Open IlyasRidhuan opened this issue 1 year ago • 2 comments

This doesnt replace the existing range check - this just sets up the initial work for a range check gadget

IlyasRidhuan avatar Aug 14 '24 11:08 IlyasRidhuan

  • #8165 Graphite
  • #8164 Graphite
  • #7967 Graphite 👈
  • master

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

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

IlyasRidhuan avatar Aug 14 '24 11:08 IlyasRidhuan

Benchmark results

Metrics with a significant change:

  • avm_simulation_time_ms (Token:mint_public): 68.5 (+52%)
  • avm_simulation_time_ms (Token:assert_minter_and_mint): 40.2 (-39%)
  • avm_simulation_time_ms (Token:transfer_public): 31.2 (+53%)
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,764 1,564 714 783 (+3%) 781 (+1%)
proof_construction_time_sha256_30_ms 11,499 3,093 1,381 1,433 (+2%) 1,454
proof_construction_time_sha256_100_ms 44,283 11,790 5,442 5,629 (+2%) 5,748 (+1%)
proof_construction_time_poseidon_hash_ms 78.0 34.0 34.0 58.0 (-3%) 88.0 (-1%)
proof_construction_time_poseidon_hash_30_ms 1,529 422 202 (-1%) 223 (+1%) 279 (+4%)
proof_construction_time_poseidon_hash_100_ms 5,641 1,507 676 (-2%) 725 750 (+1%)

L2 block published to L1

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

Metric 4 txs 8 txs 16 txs
l1_rollup_calldata_size_in_bytes 4,356 7,876 14,884
l1_rollup_calldata_gas 50,148 93,018 178,228
l1_rollup_execution_gas 842,808 1,576,574 3,361,840
l2_block_processing_time_in_ms 252 (-4%) 454 827 (-1%)
l2_block_building_time_in_ms 11,362 22,212 44,538
l2_block_rollup_simulation_time_in_ms 11,362 22,212 44,537
l2_block_public_tx_process_time_in_ms 9,616 (-1%) 20,409 42,697

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 3,028 (-2%) 3,991 (+2%)
node_database_size_in_bytes 12,619,856 16,728,144
pxe_database_size_in_bytes 16,254 26,813

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 input_size_in_bytes output_size_in_bytes proving_time_in_ms
private-kernel-init 96.5 (+6%) 388 (-2%) 21,735 44,860 N/A
private-kernel-inner 176 (+3%) 683 (-2%) 72,544 45,007 N/A
private-kernel-reset-tiny 308 693 (-3%) 65,593 44,846 N/A
private-kernel-tail 167 (+1%) 132 (-5%) 50,644 52,257 N/A
base-parity 5.55 (-1%) N/A 160 96.0 N/A
root-parity 35.4 N/A 73,948 96.0 N/A
base-rollup 3,449 N/A 189,136 664 N/A
block-root-rollup 41.1 (-1%) N/A 58,205 2,448 N/A
public-kernel-setup 85.4 (+1%) N/A 105,085 71,222 N/A
public-kernel-app-logic 97.2 (+1%) N/A 104,911 71,222 N/A
public-kernel-tail 856 N/A 390,582 16,414 N/A
private-kernel-reset-small 309 (-1%) N/A 66,341 45,629 N/A
private-kernel-tail-to-public 1,370 598 (-3%) 455,400 1,825 N/A
public-kernel-teardown 83.6 (-1%) N/A 105,349 71,222 N/A
merge-rollup 20.3 (+1%) N/A 38,174 664 N/A
undefined N/A N/A N/A N/A 84,193 (+7%)

Stats on running time collected for app circuits

Function input_size_in_bytes output_size_in_bytes witness_generation_time_in_ms
ContractClassRegisterer:register 1,344 11,731 340 (-1%)
ContractInstanceDeployer:deploy 1,408 11,731 18.0 (-2%)
MultiCallEntrypoint:entrypoint 1,920 11,731 401 (-1%)
FeeJuice:deploy 1,376 11,731 384 (-2%)
SchnorrAccount:constructor 1,312 11,731 72.9 (-1%)
SchnorrAccount:entrypoint 2,304 11,731 392 (-1%)
Token:privately_mint_private_note 1,280 11,731 110 (+8%)
FPC:fee_entrypoint_public 1,344 11,731 26.6 (-11%)
Token:transfer 1,312 11,731 221 (-3%)
Benchmarking:create_note 1,344 11,731 85.7
SchnorrAccount:verify_private_authwit 1,280 11,731 27.7
Token:unshield 1,376 11,731 521 (-1%)
FPC:fee_entrypoint_private 1,376 11,731 697 (-2%)

AVM Simulation

Time to simulate various public functions in the AVM.

Function time_ms bytecode_size_in_bytes
FeeJuice:_increase_public_balance 59.5 (-9%) 7,101
FeeJuice:set_portal 11.9 (+19%) 2,128
Token:constructor 80.8 25,285
FPC:constructor 54.7 17,853
FeeJuice:mint_public 41.9 (+5%) 5,415
Token:mint_public :warning: 68.5 (+52%) 10,101
Token:assert_minter_and_mint :warning: 40.2 (-39%) 6,844
AuthRegistry:set_authorized 47.1 (+15%) 3,969
FPC:prepare_fee 228 (-2%) 6,747
Token:transfer_public :warning: 31.2 (+53%) 38,126
FPC:pay_refund 49.5 9,398
Benchmarking:increment_balance 1,197 6,179
Token:_increase_public_balance 42.4 (+6%) 7,705
FPC:pay_refund_with_shielded_rebate 62.2 (-3%) 9,881

Public DB Access

Time to access various public DBs.

Function time_ms
get-nullifier-index 0.161 (+1%)

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
batch_insert_into_append_only_tree_16_depth_ms 2.16 (-2%) 3.91 (-1%) N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_count 16.8 31.7 N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.112 (-2%) 0.111 (-2%) N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 11.1 (-3%) 17.6 (-3%) 31.5 (-2%) 58.8 (-1%) 114 (-2%)
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 95.9 159 287 543 1,055
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.107 (-3%) 0.103 (-2%) 0.102 (-2%) 0.101 (-1%) 0.102 (-2%)
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 14.1 (-2%) 25.6 (-2%) 44.5 (-1%) 82.5 (-1%) 162 (-2%)
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 109 207 355 691 1,363
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.107 (-2%) 0.103 (-1%) 0.108 (-1%) 0.102 0.103 (-1%)
batch_insert_into_indexed_tree_40_depth_ms N/A N/A 16.5 (-1%) N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A 132 N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A 0.106 (-2%) N/A N/A N/A N/A

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 64,779 668,997

Transaction size based on fee payment method

| Metric | | | - | |

AztecBot avatar Aug 14 '24 11:08 AztecBot

Merge activity

  • Aug 29, 1:34 PM EDT: @IlyasRidhuan started a stack merge that includes this pull request via Graphite.
  • Aug 29, 1:34 PM EDT: @IlyasRidhuan merged this pull request with Graphite.

IlyasRidhuan avatar Aug 29 '24 17:08 IlyasRidhuan