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

feat: Add imov instruction (WIP)

Open sirasistant opened this issue 1 year ago • 1 comments

Emitted size reductions
AppSubscription::assert_block_number with size 406 => 403
AppSubscription::assert_not_expired with size 399 => 396
AppSubscription::constructor with size 2476 => 2456
Auth::constructor with size 2012 => 1995
Auth::get_authorized with size 297 => 295
Auth::get_authorized_delay with size 359 => 357
Auth::get_scheduled_authorized with size 282 => 280
Auth::set_authorized with size 1882 => 1866
Auth::set_authorized_delay with size 1801 => 1786
AuthRegistry::_set_authorized with size 519 => 516
AuthRegistry::consume with size 2365 => 2346
AuthRegistry::is_consumable with size 519 => 516
AuthRegistry::is_reject_all with size 355 => 353
AuthRegistry::set_authorized with size 370 => 368
AuthRegistry::set_reject_all with size 206 => 205
AuthWitTest::consume_public with size 1638 => 1624
AvmInitializerTest::constructor with size 1952 => 1936
AvmInitializerTest::read_storage_immutable with size 100 => 99
AvmTest::add_args_return with size 14 => 14
AvmTest::add_storage_map with size 402 => 400
AvmTest::add_u128 with size 130 => 129
AvmTest::assert_nullifier_exists with size 107 => 106
AvmTest::assert_same with size 97 => 96
AvmTest::assert_timestamp with size 103 => 102
AvmTest::assertion_failure with size 111 => 110
AvmTest::check_selector with size 1464 => 1451
AvmTest::create_different_nullifier_in_nested_call with size 246 => 244
AvmTest::create_same_nullifier_in_nested_call with size 244 => 242
AvmTest::debug_logging with size 241 => 241
AvmTest::elliptic_curve_add_and_double with size 81 => 81
AvmTest::emit_nullifier_and_check with size 189 => 188
AvmTest::emit_unencrypted_log with size 640 => 635
AvmTest::get_address with size 12 => 12
AvmTest::get_args_hash with size 17 => 17
AvmTest::get_block_number with size 12 => 12
AvmTest::get_chain_id with size 12 => 12
AvmTest::get_da_gas_left with size 12 => 12
AvmTest::get_fee_per_da_gas with size 12 => 12
AvmTest::get_fee_per_l2_gas with size 12 => 12
AvmTest::get_function_selector with size 12 => 12
AvmTest::get_l2_gas_left with size 12 => 12
AvmTest::get_sender with size 12 => 12
AvmTest::get_storage_address with size 12 => 12
AvmTest::get_timestamp with size 12 => 12
AvmTest::get_transaction_fee with size 12 => 12
AvmTest::get_version with size 12 => 12
AvmTest::keccak_f1600 with size 61 => 60
AvmTest::keccak_hash with size 1220 => 1208
AvmTest::l1_to_l2_msg_exists with size 16 => 16
AvmTest::modulo2 with size 15 => 15
AvmTest::nested_call_to_add with size 363 => 360
AvmTest::nested_call_to_add_with_gas with size 477 => 474
AvmTest::nested_static_call_to_add with size 377 => 374
AvmTest::nested_static_call_to_set_storage with size 257 => 255
AvmTest::new_note_hash with size 10 => 10
AvmTest::new_nullifier with size 10 => 10
AvmTest::note_hash_exists with size 16 => 16
AvmTest::nullifier_collision with size 11 => 11
AvmTest::nullifier_exists with size 16 => 16
AvmTest::pedersen_commit with size 90 => 90
AvmTest::pedersen_hash with size 18 => 18
AvmTest::pedersen_hash_with_index with size 18 => 18
AvmTest::poseidon2_hash with size 1289 => 1277
AvmTest::read_storage_list with size 55 => 54
AvmTest::read_storage_map with size 213 => 212
AvmTest::read_storage_single with size 24 => 24
AvmTest::send_l2_to_l1_msg with size 11 => 11
AvmTest::set_opcode_big_field with size 18 => 18
AvmTest::set_opcode_small_field with size 12 => 12
AvmTest::set_opcode_u32 with size 12 => 12
AvmTest::set_opcode_u64 with size 12 => 12
AvmTest::set_opcode_u8 with size 12 => 12
AvmTest::set_read_storage_single with size 33 => 33
AvmTest::set_storage_list with size 21 => 21
AvmTest::set_storage_map with size 220 => 219
AvmTest::set_storage_single with size 18 => 18
AvmTest::sha256_hash with size 46 => 45
AvmTest::test_get_contract_instance with size 339 => 337
AvmTest::test_get_contract_instance_raw with size 82 => 82
AvmTest::to_radix_le with size 162 => 160
AvmTest::u128_addition_overflow with size 469 => 468
AvmTest::u128_from_integer_overflow with size 149 => 149
AvmTest::variable_base_msm with size 92 => 92
Benchmarking::broadcast with size 216 => 215
Benchmarking::increment_balance with size 613 => 609
CardGame::on_card_played with size 1735 => 1725
CardGame::on_cards_claimed with size 1471 => 1465
CardGame::on_game_joined with size 1374 => 1367
CardGame::start_game with size 1913 => 1898
Child::pub_get_value with size 21 => 21
Child::pub_inc_value with size 43 => 43
Child::pub_inc_value_internal with size 216 => 215
Child::pub_set_value with size 30 => 30
Child::set_value_twice_with_nested_first with size 262 => 260
Child::set_value_twice_with_nested_last with size 262 => 260
Child::set_value_with_two_nested_calls with size 226 => 224
Claim::constructor with size 2083 => 2066
Crowdfunding::_check_deadline with size 465 => 461
Crowdfunding::_publish_donation_receipts with size 1821 => 1804
Crowdfunding::init with size 2217 => 2199
DelegatedOn::public_set_value with size 21 => 21
Delegator::public_delegate_set_value with size 291 => 289
DocsExample::get_shared_immutable_constrained_public with size 247 => 246
DocsExample::get_shared_immutable_constrained_public_indirect with size 170 => 169
DocsExample::get_shared_immutable_constrained_public_multiple with size 75 => 74
DocsExample::initialize_public_immutable with size 165 => 164
DocsExample::initialize_shared_immutable with size 165 => 164
DocsExample::spend_public_authwit with size 13 => 13
DocsExample::update_leader with size 177 => 176
EasyPrivateVoting::add_to_tally_public with size 678 => 673
EasyPrivateVoting::constructor with size 1973 => 1957
EasyPrivateVoting::end_vote with size 192 => 190
FeeJuice::_increase_public_balance with size 663 => 659
FeeJuice::balance_of_public with size 372 => 370
FeeJuice::check_balance with size 502 => 499
FeeJuice::claim_public with size 4523 => 4474
FeeJuice::mint_public with size 499 => 496
FeeJuice::set_portal with size 185 => 184
FPC::constructor with size 1952 => 1936
FPC::pay_refund with size 1037 => 1029
FPC::pay_refund_with_shielded_rebate with size 1082 => 1074
FPC::prepare_fee with size 755 => 748
ImportTest::pub_call_public_fn with size 243 => 241
InclusionProofs::constructor with size 1826 => 1811
InclusionProofs::push_nullifier_public with size 86 => 85
InclusionProofs::test_nullifier_inclusion_from_public with size 90 => 89
KeyRegistry::register_npk_and_ivpk with size 10349 => 10264
KeyRegistry::register_ovpk_and_tpk with size 10351 => 10266
KeyRegistry::rotate_npk_m with size 6797 => 6740
Lending::_borrow with size 6430 => 6387
Lending::_deposit with size 530 => 526
Lending::_repay with size 4112 => 4085
Lending::_withdraw with size 6315 => 6272
Lending::borrow_public with size 515 => 510
Lending::deposit_public with size 1034 => 1024
Lending::get_asset with size 464 => 461
Lending::get_assets with size 274 => 271
Lending::get_position with size 2475 => 2460
Lending::init with size 409 => 407
Lending::repay_public with size 936 => 927
Lending::update_accumulator with size 6045 => 6009
Lending::withdraw_public with size 515 => 510
Parent::pub_entry_point with size 144 => 143
Parent::pub_entry_point_twice with size 250 => 248
Parent::public_nested_static_call with size 1588 => 1575
Parent::public_static_call with size 179 => 177
PriceFeed::get_price with size 355 => 353
PriceFeed::set_price with size 216 => 215
PrivateFPC::constructor with size 2083 => 2066
StatefulTest::get_public_value with size 360 => 358
StatefulTest::increment_public_value with size 285 => 283
StatefulTest::increment_public_value_no_init_check with size 217 => 216
StatefulTest::public_constructor with size 2142 => 2124
StaticChild::pub_get_value with size 176 => 175
StaticChild::pub_illegal_inc_value with size 214 => 213
StaticChild::pub_inc_value with size 43 => 43
StaticChild::pub_set_value with size 30 => 30
StaticParent::public_call with size 144 => 143
StaticParent::public_get_value_from_child with size 279 => 277
StaticParent::public_nested_static_call with size 486 => 482
StaticParent::public_static_call with size 179 => 177
Test::assert_public_global_vars with size 454 => 448
Test::consume_message_from_arbitrary_sender_public with size 3580 => 3542
Test::consume_mint_public_message with size 4025 => 3979
Test::create_l2_to_l1_message_arbitrary_recipient_public with size 11 => 11
Test::create_l2_to_l1_message_public with size 24 => 24
Test::dummy_public_call with size 171 => 170
Test::emit_nullifier_public with size 10 => 10
Test::emit_unencrypted with size 258 => 256
Test::is_time_equal with size 17 => 17
TestLog::emit_unencrypted_events with size 3149 => 3119
Token::_increase_public_balance with size 731 => 726
Token::_reduce_total_supply with size 401 => 398
Token::admin with size 227 => 225
Token::assert_minter_and_mint with size 651 => 646
Token::balance_of_public with size 440 => 437
Token::burn_public with size 3763 => 3731
Token::constructor with size 2674 => 2654
Token::is_minter with size 414 => 411
Token::mint_private with size 825 => 821
Token::mint_public with size 946 => 939
Token::public_get_decimals with size 262 => 260
Token::public_get_name with size 251 => 249
Token::public_get_symbol with size 255 => 253
Token::set_admin with size 180 => 178
Token::set_minter with size 357 => 354
Token::shield with size 3950 => 3919
Token::total_supply with size 255 => 253
Token::transfer_public with size 4077 => 4043
TokenBlacklist::_increase_public_balance with size 731 => 726
TokenBlacklist::_reduce_total_supply with size 401 => 398
TokenBlacklist::balance_of_public with size 440 => 437
TokenBlacklist::burn_public with size 4104 => 4070
TokenBlacklist::constructor with size 3844 => 3814
TokenBlacklist::get_roles with size 491 => 488
TokenBlacklist::mint_private with size 905 => 901
TokenBlacklist::mint_public with size 1387 => 1378
TokenBlacklist::shield with size 4291 => 4258
TokenBlacklist::total_supply with size 255 => 253
TokenBlacklist::transfer_public with size 4762 => 4724
TokenBlacklist::update_roles with size 2503 => 2485
TokenBridge::_assert_token_is_same with size 391 => 388
TokenBridge::_call_mint_on_token with size 586 => 581
TokenBridge::claim_public with size 4458 => 4408
TokenBridge::constructor with size 1962 => 1946
TokenBridge::exit_to_l1_public with size 1147 => 1136
TokenBridge::get_portal_address_public with size 112 => 111
TokenBridge::get_token with size 237 => 235
TokenWithRefunds::_increase_public_balance with size 731 => 726
TokenWithRefunds::_reduce_total_supply with size 401 => 398
TokenWithRefunds::admin with size 227 => 225
TokenWithRefunds::assert_minter_and_mint with size 651 => 646
TokenWithRefunds::balance_of_public with size 440 => 437
TokenWithRefunds::burn_public with size 3763 => 3731
TokenWithRefunds::complete_refund with size 774 => 770
TokenWithRefunds::constructor with size 2674 => 2654
TokenWithRefunds::is_minter with size 414 => 411
TokenWithRefunds::mint_private with size 825 => 821
TokenWithRefunds::mint_public with size 946 => 939
TokenWithRefunds::public_get_decimals with size 262 => 260
TokenWithRefunds::public_get_name with size 251 => 249
TokenWithRefunds::public_get_symbol with size 255 => 253
TokenWithRefunds::set_admin with size 180 => 178
TokenWithRefunds::set_minter with size 357 => 354
TokenWithRefunds::shield with size 3950 => 3919
TokenWithRefunds::total_supply with size 255 => 253
TokenWithRefunds::transfer_public with size 4077 => 4043
Uniswap::_approve_bridge_and_exit_input_asset_to_L1 with size 10596 => 10501
Uniswap::_assert_token_is_same with size 697 => 692
Uniswap::constructor with size 1952 => 1936
Uniswap::swap_public with size 6079 => 6022

sirasistant avatar Aug 13 '24 16:08 sirasistant

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_ms 5,761 1,557 699 (-1%) 773 (+3%) 777 (+1%)
proof_construction_time_sha256_30_ms 11,876 3,192 (+1%) 1,420 (+1%) 1,449 (+1%) 1,474 (+1%)
proof_construction_time_sha256_100_ms 44,336 (+1%) 12,339 (+1%) 6,164 (-5%) 5,631 5,541 (-1%)
proof_construction_time_poseidon_hash_ms 78.0 34.0 34.0 57.0 (-3%) 88.0
proof_construction_time_poseidon_hash_30_ms 1,529 418 201 (+1%) 225 (-2%) 268 (+2%)
proof_construction_time_poseidon_hash_100_ms 5,660 1,532 684 (+1%) 740 752

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,324 7,844 14,852
l1_rollup_calldata_gas 49,684 92,484 177,428
l1_rollup_execution_gas 1,294,347 2,042,115 3,869,098
l2_block_processing_time_in_ms 254 (-1%) 447 803 (-3%)
l2_block_building_time_in_ms 9,177 (-2%) 18,075 (-1%) 35,866 (-2%)
l2_block_rollup_simulation_time_in_ms 9,177 (-2%) 18,074 (-1%) 35,866 (-2%)
l2_block_public_tx_process_time_in_ms 7,732 (-2%) 16,529 (-1%) 34,296 (-2%)

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,026 (+2%) 3,886
node_database_size_in_bytes 12,722,256 16,805,968
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 100 (-1%) 392 (-4%) 21,842 44,858 N/A
private-kernel-inner 168 (-1%) 692 (-2%) 72,543 45,005 N/A
private-kernel-reset-tiny 508 (-2%) 1,198 (-1%) 69,603 44,844 N/A
private-kernel-tail 269 (-3%) 194 (-3%) 50,758 52,256 N/A
base-parity 5.58 N/A 160 96.0 N/A
root-parity 33.3 N/A 69,084 96.0 N/A
base-rollup 2,854 N/A 187,817 664 N/A
root-rollup 38.7 N/A 54,525 716 N/A
public-kernel-setup 99.1 (-2%) N/A 103,760 71,222 N/A
public-kernel-app-logic 106 N/A 103,599 71,222 N/A
public-kernel-tail 562 (-2%) N/A 409,190 16,414 N/A
private-kernel-reset-small 485 (-1%) N/A 66,533 45,629 N/A
private-kernel-tail-to-public 1,506 (+1%) 706 (-1%) 507,270 1,697 N/A
public-kernel-teardown 93.5 (-3%) N/A 104,005 71,222 N/A
merge-rollup 19.0 N/A 35,742 664 N/A
undefined N/A N/A N/A N/A 68,266 (+1%)

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 344 (-1%)
ContractInstanceDeployer:deploy 1,408 11,731 18.2
MultiCallEntrypoint:entrypoint 1,920 11,731 460
FeeJuice:deploy 1,376 11,731 392
SchnorrAccount:constructor 1,312 11,731 171 (-1%)
SchnorrAccount:entrypoint 2,304 11,731 507
Token:privately_mint_private_note 1,280 11,731 220
FPC:fee_entrypoint_public 1,344 11,731 25.2 (-1%)
Token:transfer 1,312 11,731 405 (-2%)
Benchmarking:create_note 1,344 11,731 164 (-1%)
SchnorrAccount:verify_private_authwit 1,280 11,731 27.8 (+1%)
Token:unshield 1,376 11,731 641 (+2%)
FPC:fee_entrypoint_private 1,376 11,731 854

AVM Simulation

Time to simulate various public functions in the AVM.

Function time_ms bytecode_size_in_bytes
FeeJuice:_increase_public_balance 56.3 (+2%) 8,099
FeeJuice:set_portal 9.63 2,352
Token:constructor 91.8 (+3%) 30,907 (-1%)
FPC:constructor 56.6 (+4%) 22,220 (-1%)
FeeJuice:mint_public 37.5 (-1%) 6,120
Token:mint_public 71.7 (+1%) 11,650 (-1%)
Token:assert_minter_and_mint 39.3 (-2%) 7,978 (-1%)
AuthRegistry:set_authorized 35.7 (-6%) 4,517
FPC:prepare_fee 235 (-6%) 8,742 (-1%)
Token:transfer_public 22.5 (+9%) 47,034 (-1%)
FPC:pay_refund 53.4 (-8%) 12,034 (-1%)
Benchmarking:increment_balance 965 (-1%) 7,410 (-1%)
Token:_increase_public_balance 39.2 (-1%) 8,910 (-1%)
FPC:pay_refund_with_shielded_rebate 66.9 (-2%) 12,583 (-1%)

Public DB Access

Time to access various public DBs.

Function time_ms
get-nullifier-index 0.166 (+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.21 3.87 (-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.115 0.109 (-1%) N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 11.6 (+2%) 17.9 (-4%) 31.0 (-1%) 59.2 (-2%) 112 (-3%)
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.111 (+2%) 0.104 (-4%) 0.100 (-1%) 0.102 (-2%) 0.101 (-2%)
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 14.5 26.0 (+1%) 43.6 (-2%) 84.2 (+1%) 163
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.110 0.104 0.105 (-2%) 0.104 (+1%) 0.103 (+1%)
batch_insert_into_indexed_tree_40_depth_ms N/A N/A 16.5 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 (+1%) 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 13 '24 17:08 AztecBot